@openchambery/web 2.1.8-beta.3 → 2.1.8-beta.4

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 (113) hide show
  1. package/dist/assets/{AgentAvatar-DTgZob6V.js → AgentAvatar-qSjSZvIG.js} +1 -1
  2. package/dist/assets/{AssistantView-CzNcYiVL.js → AssistantView-Dx-mzVKK.js} +3 -3
  3. package/dist/assets/{DiagramView-Cmdi3PAV.js → DiagramView-CDmixuZQ.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-Dcu_ZfKa.js → FadeInOnReveal-CD5d1k_u.js} +1 -1
  5. package/dist/assets/{Icon-BKVaYkO0.js → Icon-QASb6r3F.js} +1 -1
  6. package/dist/assets/{ImageLoadingPlaceholder-CICdqe37.js → ImageLoadingPlaceholder-BuGiEI7w.js} +1 -1
  7. package/dist/assets/{LoadingImage-DC63uLZK.js → LoadingImage-FRySi1BM.js} +1 -1
  8. package/dist/assets/{MarkdownRenderer-CIapvMEi.js → MarkdownRenderer-CggK1I6D.js} +2 -2
  9. package/dist/assets/{MarkdownRendererImpl-CuovZBls.js → MarkdownRendererImpl-Cms-VuSl.js} +1 -1
  10. package/dist/assets/{MarkstreamRendererImpl-DtQlVw4f.js → MarkstreamRendererImpl-CrC7_3Y7.js} +1 -1
  11. package/dist/assets/{MobileDetailNavigation-BcQ1gCG1.js → MobileDetailNavigation-CunQ1OIb.js} +1 -1
  12. package/dist/assets/{MobileShareBridge-CZbknYvz.js → MobileShareBridge-CoRbF_fc.js} +1 -1
  13. package/dist/assets/MobileTabPageHeader-Bj_Lu8tt.js +2 -0
  14. package/dist/assets/{MultiRunWindow-CsDXEsR_.js → MultiRunWindow-BgNee8Nh.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-B8R06QbP.js → OnboardingScreen-CHa767GT.js} +1 -1
  16. package/dist/assets/{OverlayScrollbar-BrYVChrM.js → OverlayScrollbar-C7Ls30Hy.js} +1 -1
  17. package/dist/assets/{SettingsView-bWUvVuP2.js → SettingsView-D0Rk6ERT.js} +10 -10
  18. package/dist/assets/{SettingsWindow-Cs1Z7BAg.js → SettingsWindow-8i92GNln.js} +1 -1
  19. package/dist/assets/{TerminalView-Cfa5bIj1.js → TerminalView-mLwQ0UU9.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-ChVqyMGX.js → ToolOutputDialog-DH6ASkUk.js} +1 -1
  21. package/dist/assets/{appThemeRegistry-CuS2weCQ.js → appThemeRegistry-CHeMJdPY.js} +1 -1
  22. package/dist/assets/{button-NnBwy1et.js → button-DOrwfkre.js} +1 -1
  23. package/dist/assets/{collapsible-Divs2HzS.js → collapsible-BJwPZMpo.js} +1 -1
  24. package/dist/assets/{diagram-Dw2fVTEr.js → diagram-BFevUcKu.js} +1 -1
  25. package/dist/assets/{dialog-thtcgEoi.js → dialog-FSXwOR2i.js} +1 -1
  26. package/dist/assets/{dropdown-menu.styles-DG86fojG.js → dropdown-menu.styles-CfTQwJHe.js} +1 -1
  27. package/dist/assets/{es-CyvQWK39.js → es-VbQQdCdi.js} +1 -1
  28. package/dist/assets/{fileMentionTouchSelection-D9YYbFDF.js → fileMentionTouchSelection-CSelAE3Z.js} +1 -1
  29. package/dist/assets/{fr-BgKUUIer.js → fr-BotRbS9t.js} +1 -1
  30. package/dist/assets/{gitApi-q2aVvcM1.js → gitApi-B123oHQk.js} +1 -1
  31. package/dist/assets/{input-BFFtmAyl.js → input-Ctgb06ot.js} +1 -1
  32. package/dist/assets/{insertionBoundaries-B2M9QiEF.js → insertionBoundaries-cfka-ff_.js} +1 -1
  33. package/dist/assets/{ja-vAsqZ3i2.js → ja-l_gq6Coh.js} +1 -1
  34. package/dist/assets/{ko-CjgHIGr_.js → ko-yhU5rfe5.js} +1 -1
  35. package/dist/assets/{main-4h6m9pZ0.js → main-DJhLxkOQ.js} +10 -10
  36. package/dist/assets/{main-B3grbXe8.js → main-IO37JIWf.js} +2 -2
  37. package/dist/assets/{markdownHeightCache-qy-s2Sd8.js → markdownHeightCache-B6drDnVO.js} +1 -1
  38. package/dist/assets/{mcpQueries-BD28dy9B.js → mcpQueries-Digedyij.js} +1 -1
  39. package/dist/assets/miniChat-mE8pRELI.js +2 -0
  40. package/dist/assets/mobile-Cia2889g.js +2 -0
  41. package/dist/assets/{multirun-Dhq8Cx1W.js → multirun-C1I9Attc.js} +1 -1
  42. package/dist/assets/{pl-CNRmHctC.js → pl-BkynZgOJ.js} +1 -1
  43. package/dist/assets/{projectMeta-2J4Ull4h.js → projectMeta-C2WeOasQ.js} +1 -1
  44. package/dist/assets/{pt-BR-B4NRHMT2.js → pt-BR-Dw_Dokez.js} +1 -1
  45. package/dist/assets/renderElectronMiniChatApp-FpoAJUKI.js +2 -0
  46. package/dist/assets/{renderMobileApp-Zl-L5gSE.js → renderMobileApp-DrT0ZwHw.js} +6 -6
  47. package/dist/assets/{runtimeConfig-GAVzvQGc.js → runtimeConfig-yW48patn.js} +1 -1
  48. package/dist/assets/{runtimeEndpointReset-DdNzM2Ae.js → runtimeEndpointReset-CMmN7tH1.js} +5 -5
  49. package/dist/assets/{scheduledTaskNavigation-DqwoOss-.js → scheduledTaskNavigation-DEMPeoot.js} +1 -1
  50. package/dist/assets/sessionChangeSummary-D1YrkHbB.js +1 -0
  51. package/dist/assets/{sessionLookup-BPCTTSdg.js → sessionLookup-DrKLmlMv.js} +1 -1
  52. package/dist/assets/{sortable-tabs-strip-BLrK5Ln9.js → sortable-tabs-strip-BVnwfMAa.js} +1 -1
  53. package/dist/assets/speechSettingsQueries-BNPsqHp5.js +4 -0
  54. package/dist/assets/{store-_hKtW1V3.js → store-COtDAfPx.js} +2 -2
  55. package/dist/assets/{textarea-CN-vZS5F.js → textarea-DJ52TDJj.js} +1 -1
  56. package/dist/assets/{tooltip-uzT2SsYJ.js → tooltip-JgW0lJaV.js} +1 -1
  57. package/dist/assets/{uk-CXna2F44.js → uk-DSl09YqU.js} +1 -1
  58. package/dist/assets/{useAppFontEffects-BlstuBSz.js → useAppFontEffects-BUJapti0.js} +51 -53
  59. package/dist/assets/{useDesktopWindowControlsLayout-BhS1NmBt.js → useDesktopWindowControlsLayout-Dlh9xNoE.js} +1 -1
  60. package/dist/assets/{useEffectiveDirectory-CiR2SqiL.js → useEffectiveDirectory-2dkaAaxr.js} +1 -1
  61. package/dist/assets/{useMobileNavigationStore-BRqifj9r.js → useMobileNavigationStore-BRQBoMI1.js} +6 -6
  62. package/dist/assets/{useWorkerHighlightedLines-Jea_E56b.js → useWorkerHighlightedLines-BRAfFOVn.js} +1 -1
  63. package/dist/assets/vendor-codemirror-autocomplete-7c2L_4dM.js +12 -0
  64. package/dist/assets/vendor-codemirror-commands-B8KrBQ9B.js +1 -0
  65. package/dist/assets/vendor-codemirror-lang-angular-DXOgWEVj.js +23 -0
  66. package/dist/assets/{vendor-codemirror-lang-cpp-C3UKgJaQ.js → vendor-codemirror-lang-cpp-Dh8C3xqP.js} +1 -1
  67. package/dist/assets/{vendor-codemirror-lang-go-Cv5NYdGm.js → vendor-codemirror-lang-go-BXAJ1_dh.js} +5 -5
  68. package/dist/assets/{vendor-codemirror-lang-java-D6hBTIgD.js → vendor-codemirror-lang-java-DAyCHRhk.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-jinja-ehGXhAov.js → vendor-codemirror-lang-jinja-0TICrMfO.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-json-tHviF6YN.js → vendor-codemirror-lang-json-mLulNbwB.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-less-B-yDfSDo.js → vendor-codemirror-lang-less-CNvptX3P.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-liquid-BdoLH4KN.js → vendor-codemirror-lang-liquid-8g5seytq.js} +1 -1
  73. package/dist/assets/vendor-codemirror-lang-markdown-CV1IO6Qs.js +6 -0
  74. package/dist/assets/{vendor-codemirror-lang-php-Ch8GW4Xz.js → vendor-codemirror-lang-php-xP7rf28_.js} +1 -1
  75. package/dist/assets/vendor-codemirror-lang-python-YM2WVLHF.js +9 -0
  76. package/dist/assets/{vendor-codemirror-lang-rust-BEUlElU6.js → vendor-codemirror-lang-rust-CtafR0gt.js} +1 -1
  77. package/dist/assets/vendor-codemirror-lang-sass-B4iav_Ps.js +1 -0
  78. package/dist/assets/{vendor-codemirror-lang-sql-BnZql454.js → vendor-codemirror-lang-sql-C6q09UUZ.js} +2 -2
  79. package/dist/assets/{vendor-codemirror-lang-vue-BCwQBvLR.js → vendor-codemirror-lang-vue-DIB78UsR.js} +1 -1
  80. package/dist/assets/{vendor-codemirror-lang-wast-mrtA2eML.js → vendor-codemirror-lang-wast-C_JVdOCF.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-lang-xml-ClAh-G2D.js → vendor-codemirror-lang-xml-DIuzY_d4.js} +1 -1
  82. package/dist/assets/{vendor-codemirror-lang-yaml-CjL8XEf2.js → vendor-codemirror-lang-yaml-BO0hIfQM.js} +1 -1
  83. package/dist/assets/{vendor-codemirror-language-data-DGDYune4.js → vendor-codemirror-language-data-Ctd4WxgW.js} +2 -2
  84. package/dist/assets/vendor-codemirror-search-ZqtrPLjU.js +2 -0
  85. package/dist/assets/{vendor-replit-codemirror-vim-CEibx3EP.js → vendor-replit-codemirror-vim-DDj0dSVY.js} +6 -6
  86. package/dist/assets/{zh-CN-C0S7hK8T.js → zh-CN-NtO1bA00.js} +1 -1
  87. package/dist/assets/{zh-TW-CVG-Rqd-.js → zh-TW-CF0z_L0k.js} +1 -1
  88. package/dist/index.html +2 -2
  89. package/dist/mini-chat.html +2 -2
  90. package/dist/mobile.html +2 -2
  91. package/package.json +1 -1
  92. package/server/lib/config-sync/DOCUMENTATION.md +10 -5
  93. package/server/lib/config-sync/engine.js +1 -1
  94. package/server/lib/config-sync/magpie-auth.js +111 -0
  95. package/server/lib/config-sync/magpie-auth.test.js +79 -0
  96. package/server/lib/config-sync/magpie.js +76 -7
  97. package/server/lib/config-sync/magpie.test.js +102 -2
  98. package/server/lib/opencode/DOCUMENTATION.md +1 -0
  99. package/server/lib/opencode/lifecycle.js +4 -0
  100. package/server/lib/opencode/lifecycle.test.js +7 -2
  101. package/dist/assets/MobileTabPageHeader-DjbyneLy.js +0 -2
  102. package/dist/assets/miniChat-ChSEmnwp.js +0 -2
  103. package/dist/assets/mobile-CrKlS4SH.js +0 -2
  104. package/dist/assets/renderElectronMiniChatApp-DsPg8kQs.js +0 -2
  105. package/dist/assets/sessionChangeSummary-CFlwf4sL.js +0 -2
  106. package/dist/assets/speechSettingsQueries-D4rx8jJk.js +0 -4
  107. package/dist/assets/vendor-codemirror-autocomplete-DHomsvW7.js +0 -12
  108. package/dist/assets/vendor-codemirror-commands-C9DCaJ0C.js +0 -1
  109. package/dist/assets/vendor-codemirror-lang-angular-BDXnzWgq.js +0 -23
  110. package/dist/assets/vendor-codemirror-lang-markdown-Bt-vLz9k.js +0 -6
  111. package/dist/assets/vendor-codemirror-lang-python-B4naLXMo.js +0 -9
  112. package/dist/assets/vendor-codemirror-lang-sass-ibtp2iUB.js +0 -1
  113. package/dist/assets/vendor-codemirror-search-D2SOgzph.js +0 -2
@@ -27,6 +27,7 @@ This module provides OpenCode server integration utilities for the web server ru
27
27
  - `packages/web/server/lib/opencode/cli-entry-runtime.js`: CLI entrypoint runtime that detects direct execution, forces `OPENCHAMBER_RUNTIME=web` unless already `ssh-remote` (so `dev:server` cannot inherit a leftover desktop env and host a relay, while SSH-managed remotes may), parses CLI options, and starts server bootstrap.
28
28
  - `packages/web/server/lib/opencode/routes.js`: OpenCode/provider settings and auth-related route registration.
29
29
  - `packages/web/server/lib/opencode/lifecycle.js`: OpenCode process lifecycle runtime (startup, restart, readiness, health monitoring). Managed child env inherits the user shell environment unchanged; experimental flags such as `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS` follow the user's own environment and are never injected by OpenChamber.
30
+ - Before shared-service/private startup, config-sync's Magpie adapter repairs the discoverable command entry for an existing OpenChamber-managed Magpie CLI. No download occurs at startup. Errors remain explicit rather than starting OpenCode with an undiscoverable managed dependency. External services are not modified.
30
31
  - `packages/web/server/lib/opencode/v1-migration-gate.js`: pure V1→v2 migration admission gate (`GET /api/experimental/migration/v1` → whether transcript may be fetched).
31
32
  - `packages/web/server/lib/opencode/managed-capabilities-runtime.js`: managed-child scheduled-task resources, config injection, rotating bridge identity, and bridge authorization.
32
33
  - `packages/web/server/lib/opencode/env-runtime.js`: OpenCode CLI/binary resolution and shell environment runtime.
@@ -6,6 +6,7 @@ import { readOpenCode2BinaryVersion } from './ensure-cli.js';
6
6
  import { createRevokedRuntimeContract, evaluateRuntimeContract } from './runtime-contract.js';
7
7
  import { OPENCODE_V1_MIGRATION_PATH, fetchV1MigrationGate } from './v1-migration-gate.js';
8
8
  import { isProcessAlive } from './shared-service.js';
9
+ import { createMagpieSync } from '../config-sync/magpie.js';
9
10
 
10
11
  const parsePositiveInt = (value, fallback) => {
11
12
  const parsed = Number.parseInt(String(value ?? ''), 10);
@@ -71,6 +72,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
71
72
  buildAugmentedPath,
72
73
  buildManagedOpenCodePath,
73
74
  getManagedOpenCodeShellEnvSnapshot,
75
+ prepareMagpieInstallation = () => createMagpieSync().repairInstallation(),
74
76
  managedCapabilitiesRuntime = null,
75
77
  getActiveSessionCount = () => 0,
76
78
  // Official background service (shared-service.js). null keeps the private
@@ -691,6 +693,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
691
693
  * or the registration is missing/malformed; the caller decides rollback.
692
694
  */
693
695
  const connectSharedOpenCodeService = async ({ binaryPath } = {}) => {
696
+ await prepareMagpieInstallation();
694
697
  if (!binaryPath) {
695
698
  await applyOpencodeBinaryFromSettings({ strict: true });
696
699
  if (typeof ensurePinnedOpenCode2CliEnv === 'function') {
@@ -793,6 +796,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
793
796
  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
794
797
 
795
798
  const startOpenCodeOnce = async () => {
799
+ await prepareMagpieInstallation();
796
800
  // New managed instance — drop any prior permit before spawn/probes.
797
801
  const generationAtStart = revokeRuntimeExecutionPermit('managed-start');
798
802
  const requestedPort = env.ENV_CONFIGURED_OPENCODE_PORT;
@@ -101,6 +101,7 @@ const createRuntime = (overrides = {}, stateRef = null) => {
101
101
  normalizeApiPrefix: vi.fn(() => ''),
102
102
  applyOpencodeBinaryFromSettings: vi.fn(async () => null),
103
103
  ensureOpencodeCliEnv: vi.fn(),
104
+ prepareMagpieInstallation: vi.fn(async () => {}),
104
105
  ensureLocalOpenCodeServerPassword: vi.fn(async () => 'password'),
105
106
  resolveManagedOpenCodeLaunchSpec: vi.fn((binary) => ({ binary, args: [], wrapperType: null })),
106
107
  setOpenCodePort: vi.fn((port) => {
@@ -195,14 +196,16 @@ describe('OpenCode lifecycle', () => {
195
196
  it('launches managed OpenCode with the managed PATH', async () => {
196
197
  delete process.env.OPENCODE_BINARY;
197
198
  const child = createMockChild();
199
+ const prepareMagpieInstallation = vi.fn(async () => {});
198
200
  spawnMock.mockImplementationOnce(() => {
201
+ expect(prepareMagpieInstallation).toHaveBeenCalledTimes(1);
199
202
  queueMicrotask(() => {
200
203
  child.stdout.emit('data', 'opencode server listening on http://127.0.0.1:45678\n');
201
204
  });
202
205
  return child;
203
206
  });
204
207
 
205
- const runtime = createRuntime();
208
+ const runtime = createRuntime({ prepareMagpieInstallation });
206
209
  const server = await runtime.startOpenCode();
207
210
  const [binary, args, options] = spawnMock.mock.calls[0];
208
211
 
@@ -1100,13 +1103,15 @@ describe('shared official OpenCode service', () => {
1100
1103
  const sharedService = createSharedService();
1101
1104
  const adoptOpenCodeServerPassword = vi.fn();
1102
1105
  const stateRef = {};
1103
- const runtime = createRuntime({ env: UNCONFIGURED_ENV, sharedService, adoptOpenCodeServerPassword }, stateRef);
1106
+ const prepareMagpieInstallation = vi.fn(async () => {});
1107
+ const runtime = createRuntime({ env: UNCONFIGURED_ENV, sharedService, adoptOpenCodeServerPassword, prepareMagpieInstallation }, stateRef);
1104
1108
  const fetchMock = stubSharedFetch();
1105
1109
 
1106
1110
  await runtime.bootstrapOpenCodeAtStartup();
1107
1111
 
1108
1112
  expect(spawnMock).not.toHaveBeenCalled();
1109
1113
  expect(sharedService.start).toHaveBeenCalledTimes(1);
1114
+ expect(prepareMagpieInstallation.mock.invocationCallOrder[0]).toBeLessThan(sharedService.start.mock.invocationCallOrder[0]);
1110
1115
  const startInput = sharedService.start.mock.calls[0][0];
1111
1116
  expect(startInput.binary).toBe('/mock/opencode');
1112
1117
  expect(startInput.env.OPENCODE_SERVER_PASSWORD).toBeUndefined();
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,o as r}from"./runtime-switch-3ad3yzM7.js";import{n as i}from"./runtime-fetch-QCWYlAx0.js";import{Gt as a,Kt as o,Mn as s,Sn as c,_ as l,an as u,dn as d,f,fn as p,h as m,i as h,ln as g,m as _,on as v,ot as y,sn as b,st as x,u as S,un as C}from"./persistence-B7ORJ371.js";import{a as w,i as T,r as E}from"./vendor-zustand-o69pgTEK.js";import{it as D,nt as O,rt as k}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as A,Nt as j,Vt as M,n as N,t as P}from"./platform-CiBU2bCp.js";import{b as F,n as I}from"./useUIStore-CDMI_Yzu.js";import{n as L}from"./vendor-react-BP2cRVqX.js";import{o as R}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{o as ee}from"./vendor-tanstack-react-query-CdqCAt40.js";import{t as te}from"./types-BuiqMmh_.js";import{A as ne,G as re,H as z,K as ie,L as ae,P as B,Q as oe,T as se,V,W as H,X as ce,Z as le,a as ue,g as de,ht as fe,lt as pe,mt as me,pt as he,q as ge,st as U,tt as _e}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{n as W}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as ve,d as ye,f as G,p as be,r as K,t as q}from"./button-NnBwy1et.js";import{Ar as xe,Dr as Se,Pr as J,Qn as Ce,ar as we,br as Te,co as Y,d as Ee,di as De,er as Oe,gi as ke,ir as Ae,nr as je,ro as Me,tr as Ne,yn as Pe}from"./useMobileNavigationStore-BRqifj9r.js";import{n as Fe}from"./useThemeSystem-8jhE4Zyk.js";import{n as X}from"./Icon-BKVaYkO0.js";import{a as Ie,n as Le,o as Re,r as ze,t as Be}from"./dialog-thtcgEoi.js";import{L as Ve,_ as He,b as Ue,c as We,n as Ge,s as Ke,u as qe}from"./gitApi-q2aVvcM1.js";import{A as Je,_ as Ye,a as Xe,b as Ze,c as Qe,h as $e,m as et,n as tt,r as nt,t as rt,x as it}from"./projectMeta-2J4Ull4h.js";import{t as at}from"./input-BFFtmAyl.js";import{i as ot,n as st,t as ct}from"./tooltip-uzT2SsYJ.js";import{$t as lt,A as ut,F as dt,I as ft,J as pt,N as mt,Q as ht,Qt as gt,Xt as _t,Y as vt,Yt as yt,Z as bt,Zt as xt,cn as St,ct as Ct,en as wt,mt as Tt,o as Et,q as Dt,rn as Ot,st as kt,y as At}from"./speechSettingsQueries-D4rx8jJk.js";import{i as jt,n as Mt}from"./OverlayScrollbar-BrYVChrM.js";import{n as Nt,t as Pt}from"./textarea-CN-vZS5F.js";import{n as Ft}from"./MarkdownRenderer-CIapvMEi.js";import{a as It}from"./url-nbXEti6c.js";import{r as Lt}from"./markdown-worker-DFNZ3KJ_.js";import{i as Rt,n as zt,o as Bt}from"./mcpQueries-BD28dy9B.js";import{n as Vt,r as Ht,t as Ut}from"./collapsible-Divs2HzS.js";import{a as Wt,d as Gt,o as Kt,s as qt}from"./vendor-codemirror-commands-C9DCaJ0C.js";import{a as Jt,c as Yt,i as Xt,o as Zt,r as Qt,s as $t}from"./vendor-codemirror-search-D2SOgzph.js";import{n as en,t as tn}from"./vendor-replit-codemirror-vim-CEibx3EP.js";import{i as nn,n as rn,r as an,t as on}from"./projectActions-CWvNGKfA.js";var sn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],cn=e=>[...sn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],Z=L(),Q=k();function ln(e){let t=(0,Z.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Q.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var un={},dn=(e,t=n())=>JSON.stringify([t,zt(e)]),fn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},pn=e=>{let t=zt(e);return t?j.getScopedApiClient(t):j.getApiClient()},mn=e=>e?{location:{directory:e}}:void 0,hn=e=>zt(e===void 0?A.getState().currentDirectory:e),gn=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=dn(hn(e));return t().diagnosticsByDirectory[n]??un},clearDiagnostic:(t,n,r)=>{let i=dn(hn(n),r);e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=hn(r),a=n(),o=dn(i,a),s=pn(i);try{await s.mcp.connect({server:t,...mn(i)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await Bt(_,i,a),e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=hn(r),a=n(),o=dn(i,a);await pn(i).mcp.disconnect({server:t,...mn(i)}),await Bt(_,i,a),e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{throw M(`mcp.auth`)},completeAuth:async(e,t,n)=>{throw M(`mcp.auth`)},clearAuth:async(e,t)=>{throw M(`mcp.auth`)},testConnection:async(t,r)=>{let i=hn(r),a=n(),o=dn(i,a),s=pn(i),c=Rt(_,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...mn(i)})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let d=(await Bt(_,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...mn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await Bt(_,i,a)}return l||e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,o,t)})),{status:f??Rt(_,i,a)[t],error:l,warning:u}}}))),$=e(D(),1),_n=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,vn=()=>_n(`2.1.8-beta.3`),yn=(e,t)=>_n(t)||_n(e),bn=(e,t)=>{let n=_n(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},xn=async()=>{let e=vn();if(!N())return e;try{let{App:t}=await R(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return yn((await t.getInfo()).version,e)}catch{return e}},Sn=async()=>{if(!N())return null;try{let{App:e}=await R(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.getInfo(),n=typeof t.build==`string`?t.build.trim():``;if(n.length===0)return null;let r=Number.parseInt(n,10);return Number.isFinite(r)?r:null}catch{return null}},Cn=`https://openchamber.xiaobe.top/v1/update/check`,wn=`https://openchamber-update.vercel.app/v1/update/check`,Tn=`https://github.com/yee94/openchamber/releases/latest`,En=`https://github.com/yee94/openchamber/releases`,Dn=`https://testflight.apple.com/join/ZCENBHtm`,On=1e4;function kn(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function An(e,t){let n=kn(e),r=kn(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function jn(){return[Cn,wn]}function Mn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Nn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Pn(e,t,n,r){try{if(N())try{let{CapacitorHttp:r}=await R(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function Fn(e,t){return e===`ios`?Dn:`${En}/download/v${t}/app-release.apk`}function In(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=An(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${En}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():Fn(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Ln(e,t,n,r){let i=await Pn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Nn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return In(a,t.currentVersion,t.platform)}async function Rn(e,t,n,r){let i=await Pn(Tn,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:Tn,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=An(s,e),l=`${En}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Fn(t,s)}}async function zn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=jn(),a=r()+On;for(let[t,o]of i.entries()){let s=Mn(a,i.length-t+1,r);if(s===null)break;let c=await Ln(o,e,s,n);if(c)return c}let o=Mn(a,1,r);if(o!==null){let r=await Rn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Bn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Mt();return e}catch{return`unknown`}}function Vn(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function Hn(){let e=P();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function Un(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Bn()),n.set(`arch`,Vn()),n.set(`platform`,Hn()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,u()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function Wn(e,t){let n=t??`unknown`;try{let r=Un(e),a=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&a&&r.set(`currentVersion`,a);let o=await i(`/api/openchamber/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function Gn(){return N()?`mobile`:b()?`desktop`:g()?`vscode`:C()?`web`:null}var Kn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function qn(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};return e.primaryAction===`apply_ota`&&e.ota.bundle?e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:e.primaryAction===`install_native_required`?{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var Jn=0,Yn=w()((e,t)=>({...Kn,checkForUpdates:async()=>{let n=Gn();if(!n)return null;let r=++Jn;e({checking:!0,error:null,runtimeType:n});try{let i=null,o=null;if(n===`desktop`){let n=I.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await a(n);if(r!==Jn||I.getState().otaChannelOverride!==n)return null;let o=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:o,...o?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:o?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await Wn(`web`),o=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)o=(await Wn(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await xn()??`unknown`,r=N()?s()?.mobileUpdates:void 0,a=I.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==a;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let o=await r.checkForOtaUpdate(a===`beta`||a===`stable`?{channelOverride:a}:void 0),s=qn(o,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==o.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:o.nextCheckInSec,otaDecision:o,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:a,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),o.nextCheckInSec}catch(t){if(!(t instanceof te)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:a}),null}}return i=await zn({currentVersion:n,platform:Hn()===`ios`?`ios`:`android`,deviceClass:Bn(),arch:Vn(),reportUsage:I.getState().reportUsage}),o=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:o,otaDecision:null,otaPhase:`idle`}),o}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(i){return r===Jn&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:c,downloaded:l}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(c||l)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=I.getState().otaChannelOverride,r=await a(n);if(n!==I.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await o(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!b())return()=>{};let n=[],r=await d(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await p(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await c())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(Kn)}})),Xn=`https://github.com/yee94/openchamber/releases`;function Zn(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(be(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Qn(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function $n(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function er(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function tr(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.length===0?[]:n.map((t,r)=>{let i=n[r+1]?.start??e.length,a=e.slice(t.start,i).trim();return{version:t.version,date:t.date,start:t.start,end:i,raw:a}})}var nr=2e3,rr=6e5;async function ir(){try{let e=await i(`/api/openchamber/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function ar(){try{return(await i(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function or(e,t=Math.ceil(rr/nr),n=nr){for(let r=0;r<t;r++){try{let t=await i(`/api/openchamber/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await ar())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var sr=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=G(),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(`idle`),[h,g]=(0,$.useState)(null),_=Yn(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${Xn}/tag/v${n.version}`:Xn),y=n?.downloadUrl,b=a?.total?Math.round(a.downloaded/a.total*100):0,x=l===`web`,S=l===`mobile`,C=S&&n?.manualUpdate===!0&&!!y,w=S&&n?.inAppApply===!0,T=l===`desktop`&&n?.manualUpdate===!0,E=n?.updateCommand||`openchamber update`,D=W(e=>{!e&&w&&i&&Yn.getState().dismiss(),t(e)}),O=W(()=>{Yn.getState().dismiss(),t(!1)});(0,$.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await ye(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,$.useCallback)(async e=>{await It(e)},[]),j=(0,$.useCallback)(async()=>{m(`updating`),g(null);let e=await ir();if(!e.success){m(`error`),g(e.error||u(`updateDialog.error.updateFailed`));return}e.autoRestart&&(m(`restarting`),await new Promise(e=>setTimeout(e,2e3))),m(`reconnecting`),await or(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),M=(0,$.useCallback)(()=>{y&&A(y)},[A,y]),N=p!==`idle`&&p!==`error`,P=(0,$.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=tr(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:$n(e)};let r=[...t].sort((e,t)=>er(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:Zn(t.date),content:$n(Qn(t.raw)||e)}))}},[n?.body,u]);return(0,Q.jsx)(Be,{open:e,onOpenChange:N?void 0:D,children:(0,Q.jsxs)(Le,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Q.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Q.jsxs)(Re,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Q.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Q.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Q.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Q.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Q.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Q.jsx)(Nt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Q.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Q.jsx)(Ft,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Q.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Q.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Q.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Q.jsx)(Ft,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Q.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Q.jsx)(X,{name:`terminal`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Q.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Q.jsx)(`button`,{onClick:k,className:K(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Q.jsx)(X,{name:`check`,className:`h-4 w-4`}):(0,Q.jsx)(X,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Q.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Q.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Q.jsx)(X,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Q.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Q.jsx)(`span`,{}),(0,Q.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Q.jsxs)(q,{onClick:s,size:`default`,children:[(0,Q.jsx)(X,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Q.jsxs)(q,{onClick:()=>void A(v),size:`default`,children:[(0,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Q.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Q.jsx)(q,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Q.jsxs)(q,{onClick:c,size:`default`,children:[(0,Q.jsx)(X,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Q.jsxs)(q,{onClick:M,size:`default`,children:[(0,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Q.jsxs)(q,{onClick:j,size:`default`,children:[(0,Q.jsx)(X,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Q.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},cr=e(O(),1);function lr(e){let t=(0,Z.c)(20),{label:n,children:r,description:i,itemId:a,ariaLabel:o,className:s,cardClassName:c,cardId:l}=e,u=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,d;t[0]===s?d=t[1]:(d=K(`oc-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Q.jsx)(`div`,{className:`oc-settings-group-label`,"data-settings-label-script":u,children:n}):null,t[2]=n,t[3]=u,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=K(`oc-settings-group-card`,c),t[5]=c,t[6]=p);let m;t[7]!==l||t[8]!==r||t[9]!==a||t[10]!==p?(m=(0,Q.jsx)(`div`,{id:l,"data-settings-item":a,className:p,children:r}),t[7]=l,t[8]=r,t[9]=a,t[10]=p,t[11]=m):m=t[11];let h;t[12]===i?h=t[13]:(h=i?(0,Q.jsx)(`p`,{className:`oc-settings-group-description text-muted-foreground`,children:i}):null,t[12]=i,t[13]=h);let g;return t[14]!==o||t[15]!==d||t[16]!==f||t[17]!==m||t[18]!==h?(g=(0,Q.jsxs)(`section`,{className:d,"aria-label":o,children:[f,m,h]}),t[14]=o,t[15]=d,t[16]=f,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function ur(e){let t=(0,Z.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Q.jsx)(dr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Q.jsx)(lr,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function dr(e){let t=(0,Z.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=K(`oc-settings-group-row oc-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=K(`oc-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Q.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Q.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=K(`oc-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Q.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Q.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function fr(e){let t=(0,Z.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=pr,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=K(`oc-settings-group-row oc-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Q.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Q.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,Q.jsx)(Je,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Q.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function pr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var mr=`/mcp/oauth/callback`,hr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},gr=e=>{let t=vr(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},_r=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},vr=e=>{if(typeof e!=`string`||!e.trim())return null;let t=hr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},yr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,br=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=tn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return yr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function xr(e){return e?[en(),_e.of(br),ge()]:[]}var Sr={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Cr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function wr(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Sr)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Cr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var Tr=new WeakMap;function Er(e,t){let n=Xt(e.state);if(!n.valid)return Tr.delete(e),0;let r=Tr.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return Tr.set(e,{query:n,doc:e.state.doc,total:a}),a}function Dr(e){let t=Xt(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function Or(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=Er(t,n),o=a===0?0:Dr(t);i.textContent=a===0?``:`${o}/${a}`}var kr=new U,Ar=new U,jr=new U,Mr=new U,Nr=new U,Pr=new U,Fr=new U,Ir=e=>e,Lr=se,Rr=Jt,zr=Qt,Br=class extends ie{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`oc-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},Vr=(e,t)=>!e||e.length===0?[]:fe.define({create(n){let r=new he,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,z.widget({widget:new Br(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>H.decorations.from(e)}),Hr=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return re.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new he;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,z.line({class:`oc-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function Ur({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=$.useRef(null),h=$.useRef(null),g=$.useRef(e),_=$.useRef(t),v=$.useRef(s),y=$.useRef(c),b=$.useRef(f),x=$.useRef(l),S=$.useRef(p),C=$.useRef(new Map),[w,T]=$.useState([]),E=$.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=$.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--oc-editor-gutter-width`,`${i}px`)},[]);return $.useEffect(()=>{g.current=e},[e]),$.useEffect(()=>{_.current=t},[t]),$.useEffect(()=>{v.current=s,y.current=c},[s,c]),$.useEffect(()=>{b.current=f},[f]),$.useEffect(()=>{x.current=l,E(l)},[l,E]),$.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__OPENCHAMBER_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=pe.create({doc:g.current,extensions:[...e?[H.cspNonce.of(e)]:[],ce({fixed:!0}),kr.of(oe(a)),Kt(),ne.of(` `),Fr.of(xr(p)),le.of([Gt,...Wt,...qt]),H.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=Yt(e.startState),n=Yt(e.state);t!==n&&b.current?.(n);let r=!Xt(e.startState).eq(Xt(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Or(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),Ar.of(H.editable.of(!i)),jr.of(n??[]),Mr.of(Hr(o)),Nr.of(Vr(l,C.current)),Pr.of(u?[Zt({top:!0}),le.of(Ir($t))]:[])]});return h.current=new H({state:t,parent:m.current}),Lr(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),$.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[kr.reconfigure(oe(a)),Ar.reconfigure(H.editable.of(!i)),jr.reconfigure(n??[]),Mr.reconfigure(Hr(o)),Nr.reconfigure(Vr(l,C.current)),Pr.reconfigure(u?[Zt({top:!0}),le.of(Ir($t))]:[])]}),Lr(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),$.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:Fr.reconfigure(xr(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Rr(e),requestAnimationFrame(()=>{wr(e.dom),Or(e.dom,e,!0)})):zr(e))},[d,u]),$.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),Lr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:K(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,cr.createPortal)(e.content,e.container,e.id))]})}function Wr(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=H.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=ue.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],class:`cm-comment`},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],class:`cm-keyword`},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],class:`cm-operator`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],class:`cm-punctuation`},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],class:`cm-string`},{tag:V.escape,class:`cm-string-2`},{tag:[V.number,V.bool,V.atom,V.null,V.self],class:`cm-number`},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],class:`cm-builtin`},{tag:V.definition(V.variableName),class:`cm-def`},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],class:`cm-variable`},{tag:V.propertyName,class:`cm-property`},{tag:V.attributeName,class:`cm-attribute`},{tag:[V.className,V.typeName,V.namespace],class:`cm-variable-3`},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],class:`cm-tag`},{tag:V.link,class:`cm-link`},{tag:[V.heading,V.heading1,V.heading2,V.heading3,V.heading4,V.heading5,V.heading6],class:`cm-keyword`}]),l=ue.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],color:e.colors.syntax.base.comment},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],color:e.colors.syntax.base.keyword},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],color:e.colors.syntax.base.operator},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],color:e.colors.syntax.base.string},{tag:V.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[V.number,V.bool,V.atom,V.null,V.self],color:e.colors.syntax.base.number},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],color:e.colors.syntax.base.function},{tag:V.definition(V.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],color:e.colors.syntax.base.variable},{tag:V.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:V.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[V.className,V.typeName,V.namespace],color:e.colors.syntax.base.type},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:V.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,B(de,{fallback:!0}),B(ae),B(c),B(l)]}var Gr=180,Kr=me.define(),qr=1,Jr=2,Yr=4,Xr=new Map,Zr=(e,t)=>{let n=`${e}|${t}`,r=Xr.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&qr&&(i+=`font-style:italic;`),t&Jr&&(i+=`font-weight:bold;`),t&Yr&&(i+=`text-decoration:underline;`);let a=z.mark({attributes:{style:i}});return Xr.set(n,a),a},Qr=(e,t)=>{let n=new he,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,Zr(t,r)))}}return n.finish()},$r=fe.define({create(){return z.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Kr)&&(n=e.value);return n},provide:e=>H.decorations.from(e)}),ei=e=>re.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},Gr)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Lt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:Kr.of(Qr(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),ti=e=>[$r,ei(e)],ni=e=>{let t=(0,Z.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Q.jsx)(X,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(X,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Q.jsx)(st,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(ct,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},ri=w()(E(T((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await He(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await Ue();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await qe()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=s()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await i(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await h({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await Ke(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await Ve(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await We(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:F(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=ri);var ii=`w-full max-w-[30rem]`,ai=e=>{let t=(0,Z.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Q.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Q.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=K(`oc-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Q.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Q.jsx)(lr,{className:`oc-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Q.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},oi=450,si=({projectRef:e=null})=>{let{t}=G(),{isMobile:n,isTablet:r}=jt(),i=n||r,a=Y(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ee(e=>e.getWorktreeMetadata),c=Pe(),l=A(e=>e.homeDirectory),[u,d]=$.useState([]),[f,p]=$.useState(!1),[m,h]=$.useState(!1),[g,_]=$.useState(null),[v,y]=$.useState(null),[b,x]=$.useState([]),[S,C]=$.useState(!1),w=$.useRef(!1),T=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=$.useCallback(async()=>{if(!(!T||v===!1))try{let e=await Qe(T);x(e)}catch{}},[T,v]);$.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await Ge(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),$.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await Qe(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),$.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([Oe(T),Ne(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=$.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Ae(T,n)?(_(JSON.stringify(e)),!0):(J.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1)}catch{return J.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=$.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);$.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},oi);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=$.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=$.useCallback(()=>{d(e=>[...e,``])},[]),M=$.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=$.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),P=$.useCallback(e=>{p(e),T&&we(T,e)},[T]),F=$.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...xe.getState().activeSessions,...xe.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));ke.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=$.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);$.useEffect(()=>{v&&o&&E()},[I,v,o,E]);let L=(0,Q.jsxs)(ct,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsxs)(st,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.openchamber.worktrees.setup.tooltipPrefix`),` `,(0,Q.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.openchamber.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Q.jsxs)(ct,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(st,{sideOffset:8,className:`max-w-xs`,children:t(`settings.openchamber.worktrees.list.tooltip`)})]});return o?v===!1?(0,Q.jsx)(ai,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.gitOnly`)})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ai,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.setup.loading`)}):(0,Q.jsxs)(`div`,{className:K(`flex flex-col gap-2`,ii),children:[u.map((e,n)=>(0,Q.jsxs)(`div`,{className:`oc-settings-group-row flex w-full items-center gap-2`,children:[(0,Q.jsx)(at,{value:e,onChange:e=>k(n,e.target.value),onBlur:N,placeholder:t(`settings.openchamber.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.openchamber.worktrees.setup.removeCommandAria`),children:(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.openchamber.worktrees.setup.addCommand`)]}),(0,Q.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Q.jsx)(Je,{checked:f,onChange:P,ariaLabel:t(`settings.openchamber.worktrees.setup.waitForCommandsAria`)}),(0,Q.jsx)(`span`,{className:K(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.openchamber.worktrees.setup.waitForCommands`)})]})]})}),(0,Q.jsx)(ai,{title:t(`settings.openchamber.worktrees.list.title`),titleAccessory:R,children:S?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.list.loading`)}):b.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.openchamber.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:K(`space-y-1`,ii),children:b.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.openchamber.worktrees.list.detachedHead`)}),(0,Q.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:ve(e.path,l)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:K(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.openchamber.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Q.jsx)(ai,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.selectProject`)})})},ci=(e,t)=>t.updatedAtMs-e.updatedAtMs,li=w((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([lt(),Ot()]),i={};for(let e of r.sort(ci))i[e.id]=e;t().listenerReady||await St(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await gt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await Ot(),n={};for(let e of t.sort(ci))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await wt({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=yt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await xt(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await _t(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await xt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),ui=450,di=()=>x(),fi=()=>({id:di(),name:``,command:``,icon:`play`}),pi=({projectRef:e})=>{let{t}=G(),n=$.useMemo(()=>v(),[]),r=li(e=>e.instances),i=li(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[l,u]=$.useState(null),[d,f]=$.useState({}),p=$.useRef(!1),m=$.useRef(null);$.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),$.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Ce(e);if(t)return;o(n.actions),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let h=$.useMemo(()=>n?nn(r):[],[r,n]),g=$.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),_=$.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=$.useCallback(async n=>await je(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(on,{detail:{projectId:e.id}})),!0):(J.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!_||s||g||p.current)return;let e=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await y(a)}finally{p.current=!1}})())},ui);return()=>{window.clearTimeout(e)}},[a,_,s,y,g]),$.useEffect(()=>{if(!_||!g||s){g||(m.current=null);return}let e=window.setTimeout(()=>{m.current!==g&&(m.current=g,J.error(g))},1e3);return()=>{window.clearTimeout(e)}},[_,s,g]);let b=$.useCallback(()=>{let e=fi();o(t=>[...t,e]),f(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),f(t=>{let n={...t};return delete n[e],n})},[]),S=$.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Q.jsxs)(ai,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Q.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Q.jsx)(`div`,{className:K(`space-y-0`,ii),children:a.map(e=>{let r=e.icon||`play`,i=an[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Q.jsxs)(Ut,{open:a,onOpenChange:t=>{f(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(Ht,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(X,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(Vt,{className:`pt-1.5`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Q.jsxs)(kt,{children:[(0,Q.jsx)(Tt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Q.jsx)(X,{name:i,className:`h-4 w-4`})})}),(0,Q.jsx)(Ct,{align:`start`,className:`w-56 p-2`,children:(0,Q.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:rn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Q.jsx)(X,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Q.jsx)(at,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Q.jsx)(Pt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Q.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Q.jsx)(Je,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Q.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Q.jsxs)(`div`,{className:`mt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(at,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Q.jsxs)(ct,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(st,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),h.length>0?(0,Q.jsxs)(et,{value:e.desktopOpenSshForward&&h.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Q.jsx)(Ze,{className:`h-7 w-full`,children:(0,Q.jsx)(it,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Q.jsxs)($e,{children:[(0,Q.jsx)(Ye,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),h.map(e=>(0,Q.jsx)(Ye,{value:e.id,children:e.label},e.id))]})]}):(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),g&&a.length>0?(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:g}):null]})},mi=e=>{let t=(0,Z.c)(123),{form:n}=e,{t:r}=G(),{currentTheme:i}=Fe(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?tt[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Q.jsx)(at,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Q.jsx)(ur,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let ee;t[13]===r?ee=t[14]:(ee=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=ee);let te;t[15]===r?te=t[16]:(te=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=te);let ne;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(ne=(0,Q.jsx)(ht,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`oc-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=ne):ne=t[20];let re;t[21]!==ee||t[22]!==te||t[23]!==ne?(re=(0,Q.jsx)(ur,{label:ee,description:te,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:ne}),t[21]=ee,t[22]=te,t[23]=ne,t[24]=re):re=t[24];let z;t[25]===r?z=t[26]:(z=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=z);let ie;t[27]===u?ie=t[28]:(ie=()=>u(null),t[27]=u,t[28]=ie);let ae=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,B;t[29]===ae?B=t[30]:(B=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,ae),t[29]=ae,t[30]=B);let oe;t[31]===r?oe=t[32]:(oe=r(`settings.projects.page.field.none`),t[31]=r,t[32]=oe);let se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=se):se=t[33];let V;t[34]!==ie||t[35]!==B||t[36]!==oe?(V=(0,Q.jsx)(`button`,{type:`button`,onClick:ie,className:B,title:oe,children:se}),t[34]=ie,t[35]=B,t[36]=oe,t[37]=V):V=t[37];let H;t[38]!==l||t[39]!==u?(H=rt.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:K(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=H):H=t[40];let ce;t[41]!==V||t[42]!==H?(ce=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[V,H]}),t[41]=V,t[42]=H,t[43]=ce):ce=t[43];let le;t[44]!==z||t[45]!==ce?(le=(0,Q.jsx)(ur,{label:z,itemId:`projects.accent-color`,children:ce}),t[44]=z,t[45]=ce,t[46]=le):le=t[46];let ue;t[47]===r?ue=t[48]:(ue=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=ue);let de;t[49]===O?de=t[50]:(de=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=de);let fe;t[51]!==D||t[52]!==de?(fe=(0,Q.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:de}),t[51]=D,t[52]=de,t[53]=fe):fe=t[53];let pe;t[54]===c?pe=t[55]:(pe=()=>c(null),t[54]=c,t[55]=pe);let me=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,he;t[56]===me?he=t[57]:(he=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,me),t[56]=me,t[57]=he);let ge;t[58]===r?ge=t[59]:(ge=r(`settings.projects.page.field.none`),t[58]=r,t[59]=ge);let U;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=U):U=t[60];let _e;t[61]!==pe||t[62]!==he||t[63]!==ge?(_e=(0,Q.jsx)(`button`,{type:`button`,onClick:pe,className:he,title:ge,children:U}),t[61]=pe,t[62]=he,t[63]=ge,t[64]=_e):_e=t[64];let W;t[65]!==N||t[66]!==s||t[67]!==c?(W=nt.map(e=>{let t=e.Icon;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Q.jsx)(X,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=W):W=t[68];let ve;t[69]!==_e||t[70]!==W?(ve=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[_e,W]}),t[69]=_e,t[70]=W,t[71]=ve):ve=t[71];let ye;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(ye=w&&E&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(Xe,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=ye):ye=t[82];let be;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(be=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Q.jsx)(at,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(q,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Q.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=be):be=t[87];let xe;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(xe=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Q.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=xe):xe=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Q.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Se):Se=t[99];let J;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(J=v&&(0,Q.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=J):J=t[104];let Ce;t[105]!==xe||t[106]!==Se||t[107]!==J?(Ce=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[xe,Se,J]}),t[105]=xe,t[106]=Se,t[107]=J,t[108]=Ce):Ce=t[108];let we;t[109]!==fe||t[110]!==ve||t[111]!==ye||t[112]!==be||t[113]!==Ce?(we=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[fe,ve,ye,be,Ce]}),t[109]=fe,t[110]=ve,t[111]=ye,t[112]=be,t[113]=Ce,t[114]=we):we=t[114];let Te;t[115]!==ue||t[116]!==we?(Te=(0,Q.jsx)(ur,{label:ue,itemId:`projects.icon`,children:we}),t[115]=ue,t[116]=we,t[117]=Te):Te=t[117];let Y;return t[118]!==le||t[119]!==Te||t[120]!==R||t[121]!==re?(Y=(0,Q.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[R,re,le,Te]}),t[118]=le,t[119]=Te,t[120]=R,t[121]=re,t[122]=Y):Y=t[122],Y},hi=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,gi=e=>{if(!e)return null;let t=e.trim();return t&&hi.test(t)?t.toLowerCase():null},_i=e=>{let{t}=G(),n=Y(e=>e.uploadProjectIcon),r=Y(e=>e.removeProjectIcon),i=Y(e=>e.discoverProjectIcon),a=Y(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=$.useState(``),[c,l]=$.useState(null),[u,d]=$.useState(null),[f,p]=$.useState(null),[m,h]=$.useState(void 0),[g,_]=$.useState(!1),[v,y]=$.useState(!1),[b,x]=$.useState(!1),[S,C]=$.useState(!1),[w,T]=$.useState(null),[E,D]=$.useState(null),[O,k]=$.useState(!1),A=$.useRef(null),j=$.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;$.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),$.useEffect(()=>()=>{j()},[j]);let N=$.useMemo(()=>Me(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,ee=!!(e&&P&&!S),te=!O&&(F||ee),ne=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),re=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),z=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ie=$.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),ae=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){J.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){J.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}J.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),B=$.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return J.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return J.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:gi(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:re,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:ee,showImagePreview:te,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:z,handleRemoveImageIcon:ie,handleDiscoverIcon:ae,hasChanges:ne,prepareSaveData:B,currentIconImage:a,project:e}},vi=450,yi=(e,t)=>{let{t:n}=G(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=$.useRef(!1);$.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{J.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},vi);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},bi=e=>{let t=(0,Z.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=G(),a=_i(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),yi(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Q.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Q.jsx)(mi,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Q.jsx)(pi,{projectRef:s}),g=(0,Q.jsx)(si,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function xi(e,t,n){return Math.min(n,Math.max(t,e))}function Si(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function Ci(e,t){let n=Si(t);return n<=0?e:Number(e.toFixed(n))}var wi=$.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=G(),[h,g]=$.useState(()=>e===void 0?``:String(e)),{isMobile:_}=jt(),v=$.useRef(!1),y=$.useRef(null),b=$.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);$.useEffect(()=>()=>{y.current?.()},[]),$.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=$.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=$.useRef(x);$.useEffect(()=>{S.current=x},[x]);let C=$.useCallback(e=>{let a=Ci(xi(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=$.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=$.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=Ci(xi(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Q.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Q.jsx)(X,{name:`subtract`,className:`block h-4 w-4`})}),(0,Q.jsx)(`div`,{"data-slot":`number-input-value`,className:K(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Q.jsx)(X,{name:`add`,className:`block h-4 w-4`})})]}):(0,Q.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Q.jsx)(X,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Q.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:K(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Q.jsx)(X,{name:`add`,className:`block h-3.5 w-3.5`})})]})});wi.displayName=`NumberInput`;function Ti(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var Ei={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function Di(e,t){let n=Ei[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Oi(e){return Ei[e]??[]}function ki(e){return[...e].sort((e,t)=>e.order-t.order)}function Ai(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Di(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function ji(e,t,n){let r=new Map;for(let i of e){let e=Di(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Mi(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var Ni=(e,t=``,n=!1)=>ee({queryKey:m.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await i(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let a=await r.json();if(!a||!Array.isArray(a.sources)||!a.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>f(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return a}}),Pi=6e4,Fi=0,Ii=0,Li,Ri=0,zi=0,Bi=0,Vi=new Map,Hi=e=>{let t=sn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):Pi,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||t.includes(e))):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},Ui=async()=>{let e=s()?.settings;if(e)try{let t=(await e.load())?.settings;return Hi(t??null)}catch{}if(!g()){let e=await i(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return Hi(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:Pi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:sn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Wi=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return f(n)&&r.push(n),r},Gi=async(e,t)=>{let n=Ii;Vi.set(e,(Vi.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await _.fetchQuery({queryKey:m.quota(e),queryFn:({signal:t})=>S(e,t),staleTime:0,retry:!1});if(n!==Ii)return{providerId:e,stale:!0};if(!f(r))throw Error(`Invalid quota response`);return t(t=>({results:Wi(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===Ii?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===Ii){let n=(Vi.get(e)??1)-1;n>0?Vi.set(e,n):Vi.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},Ki=()=>{Li=void 0,Ri+=1,Ii+=1,Fi+=1,Vi.clear(),qi.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},qi=w()(E((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Pi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:sn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=Ii;try{let n=await Ui();if(t!==Ii)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++Fi;e({isLoading:!0,error:null});let r=sn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>Gi(t,e))),t().fetchMagpieQuotas(!0)]);if(n===Fi){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await Gi(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=Ii,i=A.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);Li!==o&&(Li=o,Ri+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=Ri,c=++zi;try{let{sources:o,incomplete:l}=await _.fetchQuery(Ni(i,a,n));if(r!==Ii||s!==Ri||c<Bi||i!==A.getState().currentDirectory||a!==t().magpieUsageUrl)return;Bi=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==Ii||s!==Ri||c<Bi||i!==A.getState().currentDirectory||a!==t().magpieUsageUrl)return;Bi=c,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),h({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),h({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Mi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),h({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),Ji=()=>{let e=(0,Z.c)(11),t=A(Yi),n=qi(Xi),r=qi(Zi),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],$.useEffect(i,a);let o=qi(Qi),s=qi($i),c=qi(ea),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),$.useEffect(l,u)};function Yi(e){return e.currentDirectory}function Xi(e){return e.magpieUsageUrl}function Zi(e){return e.fetchMagpieQuotas}function Qi(e){return e.autoRefresh}function $i(e){return e.refreshIntervalMs}function ea(e){return e.fetchAllQuotas}var ta=e=>{let t=(0,Z.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=ut(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=ft(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=K(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Q.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Q.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},na=e=>{let t=(0,Z.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=G(),s;t[0]===n.status?s=t[1]:(s=dt(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=K(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:mt(n.remainingSeconds)})}):(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Q.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=K(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:mt(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},ra=e=>e instanceof Error&&e.name===`CancelledError`,ia=w(()=>({setStatus:e=>vt(_,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await _.cancelQueries({queryKey:m.github.auth(r),exact:!0});try{return await pt(_,e,r)}catch(e){if(ra(e))return Dt(_,r);throw e}}})),aa={displayMode:`browser`,installed:!1,browserTab:!0},oa=new Set,sa=aa,ca=!1,la,ua=()=>{let e=Et();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},da=()=>(!ca&&typeof window<`u`&&(sa=ua(),ca=!0),sa),fa=()=>{let e=ua();ca=!0,e.displayMode!==sa.displayMode&&(sa=e,oa.forEach(e=>e()))},pa=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,fa):typeof t.addListener==`function`&&t.addListener(fa);return window.addEventListener(`appinstalled`,fa),window.addEventListener(`focus`,fa),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,fa):typeof t.removeListener==`function`&&t.removeListener(fa);window.removeEventListener(`appinstalled`,fa),window.removeEventListener(`focus`,fa)}},ma=e=>(oa.add(e),la??=pa(),fa(),()=>{oa.delete(e),oa.size===0&&(la?.(),la=void 0)}),ha=()=>$.useSyncExternalStore(ma,da,ga);function ga(){return aa}var _a=`OPEN CHAMBER`,va=w()(T(e=>({sidebarBrandName:_a,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:l(),version:2,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n=e;return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=_a),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=_a),n}}));typeof window<`u`&&t(e=>{r(e)&&va.persist.rehydrate()});var ya=(e,t)=>e?t.kind===e.kind?t.projectRoot.length===e.projectRoot.length?t.projectId.localeCompare(e.projectId)<0:t.projectRoot.length>e.projectRoot.length:t.kind===`project`:!0,ba=(e,t,n)=>{ya(e.get(t),n)&&e.set(t,n)},xa=e=>{let t=e;return y(t.directory)??y(t.project?.worktree)},Sa=e=>{if(e===`/`||/^[A-Z]:$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:t===0?`/`:t===2&&/^[A-Z]:\//.test(e)?e.slice(0,2):e.slice(0,t)},Ca=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=y(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),ba(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=y(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=y(e.path);t&&ba(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=Sa(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(xa(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return p(e,l,d),p(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},wa=`__other__`;function Ta(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Ea({mode:e=`dialog`}){let{t}=G(),{isMobile:n,isTablet:r,hasTouchInput:i}=jt(),a=n||r||i,o=e===`page`,s=I(e=>e.isArchivedSessionsDialogOpen),c=I(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=Y(e=>e.projects),d=xe(e=>e.archivedSessions),f=Ee(e=>e.setCurrentSession),p=I(e=>e.setSettingsDialogOpen),[m,h]=$.useState(!1),[_,v]=$.useState(null),[y,b]=$.useState(null);$.useEffect(()=>{if(!l){v(null),b(null);return}let e=!1;return h(!0),Te().catch(()=>{e||J.error(t(`settings.openchamber.archivedSessions.toast.loadFailed`))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,t]);let x=$.useMemo(()=>{let e=Ca([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,g(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>Ta(t)-Ta(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=d.filter(e=>!r.has(e.id)).sort((e,t)=>Ta(t)-Ta(e));i.length>0&&n.set(wa,i);let a=[];for(let e of u){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(wa);return o&&o.length>0&&a.push({projectId:wa,label:t(`settings.openchamber.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=_?x.find(e=>e.projectId===_)??null:null,w=$.useCallback(async e=>{b(e.id);try{await De(e.id)?J.success(t(`settings.openchamber.archivedSessions.toast.restored`)):J.error(t(`settings.openchamber.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=$.useCallback(e=>{let t=Se(e);f(e.id,t),c(!1),p(!1)},[f,c,p]),E=C?C.label:t(`settings.openchamber.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.openchamber.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.description`),O=(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>v(null),children:[(0,Q.jsx)(X,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.openchamber.archivedSessions.dialog.backToProjects`)]}):null,m?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.openchamber.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Se(e),r=Ta(e),i=y===e.id;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?At(r):null,r>0&&n?` · `:null,n?ve(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.openchamber.archivedSessions.actions.preview`)}),(0,Q.jsxs)(q,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Q.jsx)(X,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(X,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.openchamber.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>v(e.projectId),className:K(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(X,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:ve(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.openchamber.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!m&&S>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.openchamber.archivedSessions.summarySingle`:`settings.openchamber.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`oc-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.description`)}),O]}):a?(0,Q.jsx)(bt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Q.jsx)(Be,{open:s,onOpenChange:c,children:(0,Q.jsxs)(Le,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Q.jsxs)(Ie,{children:[(0,Q.jsx)(Re,{children:E}),(0,Q.jsx)(ze,{children:D})]}),O]})})}function Da(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Ea,{mode:`dialog`}),e[0]=t):t=e[0],t}var Oa=48;function ka({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(null),s=(0,$.useRef)(null),c=(0,$.useRef)(null),l=W(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/Oa)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--oc-mobile-title-collapse`,r.toFixed(4)))}),u=W(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,$.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.oc-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`header`,{ref:i,className:K(`oc-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Q.jsxs)(`div`,{className:`oc-mobile-collapsing-header-inner`,children:[(0,Q.jsxs)(`div`,{className:`oc-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Q.jsx)(`p`,{className:`oc-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Q.jsx)(`h1`,{className:`oc-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Q.jsx)(`div`,{className:`oc-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Q.jsx)(`div`,{className:`oc-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{lr as A,sn as B,ti as C,gr as D,mr as E,bn as F,Sn as I,xn as L,fr as M,sr as N,_r as O,Yn as P,gn as R,ni as S,Ur as T,cn as V,ki as _,va as a,li as b,na as c,Ji as d,qi as f,ji as g,Ai as h,Ca as i,dr as j,ur as k,ta as l,Ti as m,Da as n,ha as o,Oi as p,Ea as r,ia as s,ka as t,Ki as u,wi as v,Wr as w,ri as x,bi as y,ln as z};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-DsPg8kQs.js","assets/rolldown-runtime-hePW80VL.js","assets/persistence-B7ORJ371.js","assets/runtime-auth-C8w0nlKy.js","assets/runtime-switch-3ad3yzM7.js","assets/runtime-fetch-QCWYlAx0.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-CDMI_Yzu.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-CiBU2bCp.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-NnBwy1et.js","assets/store-_hKtW1V3.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useMobileNavigationStore-BRqifj9r.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-Dlvb7P0q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/Icon-BKVaYkO0.js","assets/useAppFontEffects-BlstuBSz.js","assets/desktopHosts-DSBZ-9-L.js","assets/desktopRelayRestore-DK8TzHRx.js","assets/vendor-codemirror-autocomplete-DHomsvW7.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/rasterizePng-CpK-xCkB.js","assets/dualLimitLru-D8Sphgua.js","assets/AgentAvatar-DTgZob6V.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-7lEG-JsF.js","assets/useThemeSystem-8jhE4Zyk.js","assets/dialog-thtcgEoi.js","assets/gitApi-q2aVvcM1.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-2J4Ull4h.js","assets/input-BFFtmAyl.js","assets/tooltip-uzT2SsYJ.js","assets/OverlayScrollbar-BrYVChrM.js","assets/textarea-CN-vZS5F.js","assets/vendor-framer-motion-D-oiwsxL.js","assets/vendor-dnd-kit-core-5pNnzVdw.js","assets/vendor-dnd-kit-accessibility-COSwgjFs.js","assets/vendor-dnd-kit-sortable-Dm50I0m7.js","assets/speechSettingsQueries-D4rx8jJk.js","assets/vendor-codemirror-lang-angular-BDXnzWgq.js","assets/vendor-codemirror-lang-json-tHviF6YN.js","assets/vendor-codemirror-lang-markdown-Bt-vLz9k.js","assets/vendor-codemirror-lang-python-B4naLXMo.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/dropdown-menu.styles-DG86fojG.js","assets/vendor-codemirror-language-data-DGDYune4.js","assets/image-loading-qNtUCy69.js","assets/fileQueries-BGE5l3Jd.js","assets/useRuntimeAPIs-Cx8S1HLz.js","assets/relay-image-stream-qI2NTXbG.js","assets/image-loading-CObM4tcX.css","assets/sessionChangeSummary-CFlwf4sL.js","assets/LoadingImage-DC63uLZK.js","assets/ImageLoadingPlaceholder-CICdqe37.js","assets/sessionChangeSummary-vC84qM3v.css","assets/insertionBoundaries-B2M9QiEF.js","assets/fileMentionTouchSelection-D9YYbFDF.js","assets/appThemeRegistry-CuS2weCQ.js","assets/MarkdownRenderer-CIapvMEi.js","assets/markdownHeightCache-qy-s2Sd8.js","assets/url-nbXEti6c.js","assets/markdown-worker-DFNZ3KJ_.js","assets/useEffectiveDirectory-CiR2SqiL.js","assets/FadeInOnReveal-Dcu_ZfKa.js","assets/markdownTheme-CV7_0QAL.js","assets/useWorkerHighlightedLines-Jea_E56b.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/vendor-cmdk-RDxC-9Iz.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-BLrK5Ln9.js","assets/vendor-motion-88WXBOBf.js","assets/vendor-legendapp-list-CNxU_ALy.js","assets/useFontPreferences-6LD7d7hP.js","assets/terminalApi-bN5IYQau.js","assets/useDesktopWindowControlsLayout-BhS1NmBt.js","assets/src-C9BNQK0O.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./runtimeConfig-GAVzvQGc.js";import{o as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */window.__OPENCHAMBER_RUNTIME_APIS__=e(),t(async()=>{let{renderElectronMiniChatApp:e}=await import(`./renderElectronMiniChatApp-DsPg8kQs.js`);return{renderElectronMiniChatApp:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(({renderElectronMiniChatApp:t})=>{t(window.__OPENCHAMBER_RUNTIME_APIS__??e())});
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-Zl-L5gSE.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-C8w0nlKy.js","assets/runtime-switch-3ad3yzM7.js","assets/runtime-fetch-QCWYlAx0.js","assets/persistence-B7ORJ371.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-CDMI_Yzu.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-CiBU2bCp.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/capgoAdapter-KNLHDj7G.js","assets/types-BuiqMmh_.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-sonner-ZS8XIOVl.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-NnBwy1et.js","assets/store-_hKtW1V3.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/MobileShareBridge-CZbknYvz.js","assets/MobileDetailNavigation-BcQ1gCG1.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/useMobileNavigationStore-BRqifj9r.js","assets/useAssistantUIStore-Dlvb7P0q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/Icon-BKVaYkO0.js","assets/rasterizePng-CpK-xCkB.js","assets/AgentAvatar-DTgZob6V.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-7lEG-JsF.js","assets/dualLimitLru-D8Sphgua.js","assets/useThemeSystem-8jhE4Zyk.js","assets/dialog-thtcgEoi.js","assets/gitApi-q2aVvcM1.js","assets/useAppFontEffects-BlstuBSz.js","assets/desktopHosts-DSBZ-9-L.js","assets/desktopRelayRestore-DK8TzHRx.js","assets/vendor-codemirror-autocomplete-DHomsvW7.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-2J4Ull4h.js","assets/input-BFFtmAyl.js","assets/tooltip-uzT2SsYJ.js","assets/OverlayScrollbar-BrYVChrM.js","assets/textarea-CN-vZS5F.js","assets/vendor-framer-motion-D-oiwsxL.js","assets/vendor-dnd-kit-core-5pNnzVdw.js","assets/vendor-dnd-kit-accessibility-COSwgjFs.js","assets/vendor-dnd-kit-sortable-Dm50I0m7.js","assets/speechSettingsQueries-D4rx8jJk.js","assets/vendor-codemirror-lang-angular-BDXnzWgq.js","assets/vendor-codemirror-lang-json-tHviF6YN.js","assets/vendor-codemirror-lang-markdown-Bt-vLz9k.js","assets/vendor-codemirror-lang-python-B4naLXMo.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/dropdown-menu.styles-DG86fojG.js","assets/vendor-codemirror-language-data-DGDYune4.js","assets/image-loading-qNtUCy69.js","assets/fileQueries-BGE5l3Jd.js","assets/useRuntimeAPIs-Cx8S1HLz.js","assets/relay-image-stream-qI2NTXbG.js","assets/image-loading-CObM4tcX.css","assets/sessionChangeSummary-CFlwf4sL.js","assets/LoadingImage-DC63uLZK.js","assets/ImageLoadingPlaceholder-CICdqe37.js","assets/sessionChangeSummary-vC84qM3v.css","assets/insertionBoundaries-B2M9QiEF.js","assets/fileMentionTouchSelection-D9YYbFDF.js","assets/appThemeRegistry-CuS2weCQ.js","assets/MarkdownRenderer-CIapvMEi.js","assets/markdownHeightCache-qy-s2Sd8.js","assets/url-nbXEti6c.js","assets/markdown-worker-DFNZ3KJ_.js","assets/useEffectiveDirectory-CiR2SqiL.js","assets/FadeInOnReveal-Dcu_ZfKa.js","assets/markdownTheme-CV7_0QAL.js","assets/useWorkerHighlightedLines-Jea_E56b.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/vendor-cmdk-RDxC-9Iz.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-BLrK5Ln9.js","assets/vendor-motion-88WXBOBf.js","assets/vendor-legendapp-list-CNxU_ALy.js","assets/useFontPreferences-6LD7d7hP.js","assets/terminalApi-bN5IYQau.js","assets/MobileTabPageHeader-DjbyneLy.js","assets/mcpQueries-BD28dy9B.js","assets/collapsible-Divs2HzS.js","assets/vendor-codemirror-commands-C9DCaJ0C.js","assets/vendor-codemirror-search-D2SOgzph.js","assets/vendor-replit-codemirror-vim-CEibx3EP.js","assets/projectActions-CWvNGKfA.js","assets/runtimeEndpointReset-DdNzM2Ae.js","assets/scheduledTaskNavigation-DqwoOss-.js","assets/sessionLookup-BPCTTSdg.js","assets/vendor-cron-parser-BmO80h0C.js","assets/runtimeEndpointReset-ByXtaeWD.css","assets/SettingsView-bWUvVuP2.js","assets/vendor-yaml-C9KlJAlj.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/AssistantView-CzNcYiVL.js","assets/assistant-attachment-cache-Bzewqov4.js","assets/src-C9BNQK0O.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./runtimeConfig-GAVzvQGc.js";import{o as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */window.__OPENCHAMBER_RUNTIME_APIS__=e(),t(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-Zl-L5gSE.js`);return{renderMobileApp:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119])).then(({renderMobileApp:t})=>{t(window.__OPENCHAMBER_RUNTIME_APIS__??e())});
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/gitApi-q2aVvcM1.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-3ad3yzM7.js","assets/runtime-auth-C8w0nlKy.js","assets/runtime-fetch-QCWYlAx0.js","assets/persistence-B7ORJ371.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-CDMI_Yzu.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-CiBU2bCp.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/useMobileNavigationStore-BRqifj9r.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-sonner-ZS8XIOVl.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-NnBwy1et.js","assets/store-_hKtW1V3.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useAssistantUIStore-Dlvb7P0q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Nn as t,Wt as n,r,rn as i,sn as a,t as o}from"./persistence-B7ORJ371.js";import{it as s,rt as c}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as l,Nt as u}from"./platform-CiBU2bCp.js";import{n as d}from"./useUIStore-CDMI_Yzu.js";import{n as f,t as p}from"./vendor-react-BP2cRVqX.js";import{o as m}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */import{n as h,s as g}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as _,m as v,r as y,t as b}from"./button-NnBwy1et.js";import{n as x}from"./store-_hKtW1V3.js";import{Ea as ee,Nt as te,S as ne,ba as S,co as re,d as C,ln as ie,nn as ae,yn as oe}from"./useMobileNavigationStore-BRqifj9r.js";import{n as se}from"./Icon-BKVaYkO0.js";import{At as ce,Bt as le,Dt as ue,E as w,Et as de,Ft as T,Mt as fe,Nt as pe,Ot as me,Pt as E,T as he,Tt as ge,a as _e,ft as D,jt as O,kt as ve,t as ye,w as be,wt as xe}from"./useAppFontEffects-BlstuBSz.js";import{s as Se}from"./projectMeta-2J4Ull4h.js";import{r as Ce}from"./tooltip-uzT2SsYJ.js";import{Dt as we,bt as Te,gt as k}from"./speechSettingsQueries-D4rx8jJk.js";import{n as Ee}from"./useRuntimeAPIs-Cx8S1HLz.js";import{d as De,y as Oe}from"./insertionBoundaries-B2M9QiEF.js";import{i as ke,n as Ae,r as je,t as Me}from"./useDesktopWindowControlsLayout-BhS1NmBt.js";var Ne=p(),A=f(),j=e(s(),1),M=c(),Pe=e=>{let t=(0,A.c)(3),{mode:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,M.jsx)(D.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i},Fe=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=typeof window<`u`?window.__OPENCHAMBER_HOME__:``;if(n&&t===n)return`~`;if(n&&t.startsWith(`${n}/`))return`~/${t.slice(n.length+1)}`;let r=t.split(`/`).filter(Boolean);return r.length<=3?t:`.../${r.slice(-3).join(`/`)}`},N=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=t.replace(/\\/g,`/`);return n===`/`?`/`:n.replace(/\/+$/,``)},P=e=>{let t=(0,A.c)(117),{mode:n}=e,{t:r}=_(),o=C(Le),s=C(Re),c=C(ze),u=l(Be),d=re(Ve),f=re(He),p=S(Ue),m=S(We),h=oe(),g=ie(o??``),v=Ee(),x=Oe(Ge),ee;t[0]===o?ee=t[1]:(ee=e=>o?e.worktreeMetadata.get(o)?.path??``:``,t[0]=o,t[1]=ee);let te=C(ee),ce;t[2]===o?ce=t[3]:(ce=e=>o?e.worktreeMetadata.get(o)?.branch?.trim()??null:null,t[2]=o,t[3]=ce);let le=C(ce),ue;t[4]===o?ue=t[5]:(ue=e=>o?e.getAttachment(o):void 0,t[4]=o,t[5]=ue);let w=ne(ue),de=C(Ke),[T,fe]=j.useState(!1),pe=typeof window<`u`?window.__OPENCHAMBER_MACOS_MAJOR__??0:0,me=Number.isFinite(pe)&&pe>0,{usesFramelessChrome:E,side:he}=Me(),ge=me?pe>=26?`h-12`:pe<=15?`h-14`:``:``,_e;t[6]!==o||t[7]!==h?(_e=o?h.find(e=>e.id===o)??null:null,t[6]=o,t[7]=h,t[8]=_e):_e=t[8];let D=_e,O=D?.worktreeMetadata??null,ve,ye;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(ve=()=>{a()&&i(`desktop_get_window_pinned`).then(e=>{typeof e?.pinned==`boolean`&&fe(e.pinned)})},ye=[],t[9]=ve,t[10]=ye):(ve=t[9],ye=t[10]),j.useEffect(ve,ye);let be;t[11]!==s||t[12]!==n||t[13]!==D?.title||t[14]!==r?(be=D?.title?.trim()||r(s||n===`draft`?`miniChat.header.newSession`:`miniChat.header.session`),t[11]=s,t[12]=n,t[13]=D?.title,t[14]=r,t[15]=be):be=t[15];let xe=be,Se=D?.directory??null,Ce;t[16]===Se?Ce=t[17]:(Ce=N(Se),t[16]=Se,t[17]=Ce);let we=Ce,Te=te||O?.path||w?.cwd||w?.worktreeRoot||``,k;t[18]===Te?k=t[19]:(k=N(Te),t[18]=Te,t[19]=k);let Ne=k,Pe;t[20]===u?Pe=t[21]:(Pe=N(u),t[20]=u,t[21]=Pe);let P=Ne||we||de||Pe,Ie;t[22]===P?Ie=t[23]:(Ie=Fe(P),t[22]=P,t[23]=Ie);let $e=Ie,et;t[24]!==we||t[25]!==Ne?(et=e=>{let t=N(Ne||we||``);if(!t)return null;for(let n of e.availableWorktreesByProject.values()){let e=n.find(e=>N(e.path)===t)?.branch?.trim();if(e)return e}return null},t[24]=we,t[25]=Ne,t[26]=et):et=t[26];let tt=C(et),nt,rt;t[27]!==x||t[28]!==P||t[29]!==v.git?(nt=()=>{P&&x(P,v.git).catch(qe)},rt=[x,P,v.git],t[27]=x,t[28]=P,t[29]=v.git,t[30]=nt,t[31]=rt):(nt=t[30],rt=t[31]),j.useEffect(nt,rt),O?.projectDirectory,w?.worktreeRoot;let it;bb0:{let e=O?.projectDirectory??w?.worktreeRoot??null,n;t[32]===e?n=t[33]:(n=N(e),t[32]=e,t[33]=n);let r=n||P;if(!r){it=null;break bb0}let i;t[34]!==r||t[35]!==d?(i=d.map(Je).filter(e=>e.normalizedPath&&(e.normalizedPath===r||r.startsWith(`${e.normalizedPath}/`))).sort(Ye)[0]??null,t[34]=r,t[35]=d,t[36]=i):i=t[36],it=i}let at=it,ot;bb1:{let e=at??f;if(!e){ot=$e||`OpenChamberY`;break bb1}let n;t[37]===e.path?n=t[38]:(n=e.path.split(/[\\/]/).filter(Boolean).at(-1)??e.path,t[37]=e.path,t[38]=n),ot=n}let st=ot,ct=De(P||null),lt;t[39]!==tt||t[40]!==ct||t[41]!==O?.branch||t[42]!==w?.branch||t[43]!==le?(lt=ct||le||O?.branch?.trim()||w?.branch?.trim()||tt,t[39]=tt,t[40]=ct,t[41]=O?.branch,t[42]=w?.branch,t[43]=le,t[44]=lt):lt=t[44];let ut=lt,dt=ut&&ut!==`HEAD`?ut:null,ft;t[45]===p?ft=t[46]:(ft=p(),t[45]=p,t[46]=ft);let pt=ft,mt;bb2:{for(let e=g.length-1;e>=0;--e){let t=g[e];if(t.role!==`assistant`||typeof t.providerID!=`string`||typeof t.modelID!=`string`)continue;let n=m.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.modelID);if(n){mt=n;break bb2}}mt=void 0}let ht=mt,gt=pt?.limit?pt:ht,F=gt&&typeof gt.limit==`object`&&gt.limit!==null?gt.limit:null,_t=F&&typeof F.context==`number`?F.context:0,vt=F&&typeof F.output==`number`?F.output:0,I=ae(o??``,_t,vt),[L,yt]=j.useState(null),bt;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(bt={WebkitAppRegion:`drag`},t[47]=bt):bt=t[47];let xt=bt,St;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(St={WebkitAppRegion:`no-drag`},t[48]=St):St=t[48];let Ct=St,wt,Tt;t[49]!==I||t[50]!==o?(wt=()=>{if(!o){yt(Xe);return}if(I){yt(e=>e&&e.pending===I.pending&&e.totalTokens===I.totalTokens&&e.percentage===I.percentage&&e.contextLimit===I.contextLimit&&(e.outputLimit??0)===(I.outputLimit??0)&&(e.normalizedOutput??0)===(I.normalizedOutput??0)&&e.thresholdLimit===I.thresholdLimit&&e.lastMessageId===I.lastMessageId?e:I);return}yt(Ze)},Tt=[I,o],t[49]=I,t[50]=o,t[51]=wt,t[52]=Tt):(wt=t[51],Tt=t[52]),j.useEffect(wt,Tt);let Et=L&&L.contextLimit>0?Math.min(999,L.totalTokens/L.contextLimit*100):0,Dt;t[53]===T?Dt=t[54]:(Dt=()=>{let e=!T;fe(e),i(`desktop_set_window_pinned`,{pinned:e}).catch(()=>{fe(!e)})},t[53]=T,t[54]=Dt);let Ot=Dt,kt;t[55]!==u||t[56]!==o||t[57]!==c||t[58]!==P||t[59]!==D?(kt=()=>{let e=o?{sessionId:o,directory:D?.directory??u??``}:{mode:`draft`,directory:P||u||``,projectId:c};i(`desktop_focus_main_window`,e).then(Qe)},t[55]=u,t[56]=o,t[57]=c,t[58]=P,t[59]=D,t[60]=kt):kt=t[60];let At=kt,jt=E?`h-12`:ge||`min-h-14`,R;t[61]===jt?R=t[62]:(R=y(`flex items-center gap-3 bg-background pr-3`,me?`pl-[5.5rem]`:`pl-3`,jt),t[61]=jt,t[62]=R);let z;t[63]!==E||t[64]!==he?(z=E&&he===`left`?(0,M.jsx)(je,{visible:!0,position:`left`}):null,t[63]=E,t[64]=he,t[65]=z):z=t[65];let B;t[66]===r?B=t[67]:(B=r(`sessions.switcher.openAria`),t[66]=r,t[67]=B);let V;t[68]===xe?V=t[69]:(V=(0,M.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full`,children:xe}),t[68]=xe,t[69]=V);let H;t[70]===st?H=t[71]:(H=(0,M.jsx)(`span`,{className:`truncate`,children:st}),t[70]=st,t[71]=H);let U;t[72]===dt?U=t[73]:(U=dt?(0,M.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,M.jsx)(se,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,M.jsx)(`span`,{className:`truncate`,children:dt})]}):null,t[72]=dt,t[73]=U);let W;t[74]!==H||t[75]!==U?(W=(0,M.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75`,children:[H,U]}),t[74]=H,t[75]=U,t[76]=W):W=t[76];let G;t[77]!==B||t[78]!==V||t[79]!==W?(G=(0,M.jsx)(Ae,{children:(0,M.jsxs)(`button`,{type:`button`,"aria-label":B,style:Ct,className:`flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60`,children:[V,W]})}),t[77]=B,t[78]=V,t[79]=W,t[80]=G):G=t[80];let Mt;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=(0,M.jsx)(`div`,{className:`min-w-0 flex-1`}),t[81]=Mt):Mt=t[81];let K;t[82]!==Et||t[83]!==L?(K=L?(0,M.jsx)(ke,{pending:L.pending,totalTokens:L.totalTokens,percentage:Et,colorPercentage:L.percentage,contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,className:`h-9 shrink-0 pl-1 pr-1 typography-ui-label`,valueClassName:`font-semibold leading-none`,hideIcon:!0,showPercentIcon:!0,percentIconClassName:`h-4.5 w-4.5`}):null,t[82]=Et,t[83]=L,t[84]=K):K=t[84];let q;t[85]!==T||t[86]!==r?(q=r(T?`miniChat.actions.unpinAria`:`miniChat.actions.pinAria`),t[85]=T,t[86]=r,t[87]=q):q=t[87];let J;t[88]!==T||t[89]!==r?(J=r(T?`miniChat.actions.unpin`:`miniChat.actions.pin`),t[88]=T,t[89]=r,t[90]=J):J=t[90];let Y;t[91]===T?Y=t[92]:(Y=T?(0,M.jsx)(se,{name:`pushpin-2-fill`,className:`h-4 w-4`}):(0,M.jsx)(se,{name:`pushpin-2`,className:`h-4 w-4`}),t[91]=T,t[92]=Y);let X;t[93]!==Ot||t[94]!==q||t[95]!==J||t[96]!==Y?(X=(0,M.jsx)(b,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ot,"aria-label":q,title:J,style:Ct,children:Y}),t[93]=Ot,t[94]=q,t[95]=J,t[96]=Y,t[97]=X):X=t[97];let Z;t[98]===r?Z=t[99]:(Z=r(`miniChat.actions.openMainAria`),t[98]=r,t[99]=Z);let Q;t[100]===r?Q=t[101]:(Q=r(`miniChat.actions.openMain`),t[100]=r,t[101]=Q);let Nt;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Nt=(0,M.jsx)(se,{name:`external-link`,className:`h-4 w-4`}),t[102]=Nt):Nt=t[102];let $;t[103]!==At||t[104]!==Z||t[105]!==Q?($=(0,M.jsx)(b,{type:`button`,variant:`ghost`,size:`icon`,onClick:At,"aria-label":Z,title:Q,style:Ct,children:Nt}),t[103]=At,t[104]=Z,t[105]=Q,t[106]=$):$=t[106];let Pt=E&&he===`right`,Ft;t[107]===Pt?Ft=t[108]:(Ft=(0,M.jsx)(je,{visible:Pt,position:`right`}),t[107]=Pt,t[108]=Ft);let It;return t[109]!==R||t[110]!==z||t[111]!==G||t[112]!==K||t[113]!==X||t[114]!==$||t[115]!==Ft?(It=(0,M.jsxs)(`header`,{className:R,style:xt,children:[z,G,Mt,K,X,$,Ft]}),t[109]=R,t[110]=z,t[111]=G,t[112]=K,t[113]=X,t[114]=$,t[115]=Ft,t[116]=It):It=t[116],It},Ie=e=>{let t=(0,A.c)(9),{mode:n,autoOpenDraft:r,unavailable:i}=e,a=r!==void 0&&r,o=i!==void 0&&i,{t:s}=_(),c;t[0]===n?c=t[1]:(c=(0,M.jsx)(P,{mode:n}),t[0]=n,t[1]=c);let l;t[2]!==a||t[3]!==s||t[4]!==o?(l=(0,M.jsx)(`main`,{className:`min-h-0 flex-1`,children:o?(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground`,children:(0,M.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`font-medium text-foreground`,children:s(`miniChat.unavailable.title`)}),(0,M.jsx)(`div`,{className:`mt-1 typography-small text-muted-foreground`,children:s(`miniChat.unavailable.description`)})]})}):(0,M.jsx)(Pe,{mode:`mini-chat`,children:(0,M.jsx)(w,{autoOpenDraft:a})})}),t[2]=a,t[3]=s,t[4]=o,t[5]=l):l=t[5];let u;return t[6]!==c||t[7]!==l?(u=(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u};function Le(e){return e.currentSessionId}function Re(e){return!!e.newSessionDraft?.open}function ze(e){return e.newSessionDraft?.selectedProjectId??null}function Be(e){return e.currentDirectory}function Ve(e){return e.projects}function He(e){return e.getActiveProject()}function Ue(e){return e.getCurrentModel}function We(e){return e.providers}function Ge(e){return e.ensureStatus}function Ke(e){return e.newSessionDraft?.open?N(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``}function qe(){}function Je(e){return{...e,normalizedPath:N(e.path)}}function Ye(e,t){return t.path.length-e.path.length}function Xe(e){return e===null?e:null}function Ze(e){return e===null?e:null}function Qe(e){return e?.focused===!0?i(`desktop_close_current_window`):null}var $e=()=>{document.querySelector(`textarea[data-chat-input="true"]`)?.focus()},et=()=>{let e=d(e=>e.shortcutOverrides),t=l(e=>e.currentDirectory),r=re(e=>e.getActiveProject()),a=C(e=>e.openNewSessionDraft);j.useEffect(()=>{let o=t=>Te(t,e),s=e=>{if(k(e,o(`focus_input`))){e.preventDefault(),$e();return}if(n()&&k(e,o(`close_context_panel_tab`))){e.preventDefault(),i(`desktop_close_current_window`).catch(e=>{console.warn(`[mini-chat-shortcuts] failed to close current window`,e)});return}if(n()&&k(e,o(`new_mini_chat`))){e.preventDefault(),i(`desktop_open_draft_mini_chat_window`,{directory:t||r?.path||``,projectId:r?.id??null})?.catch(e=>{console.warn(`[mini-chat-shortcuts] failed to open draft mini chat window`,e)});return}if(k(e,o(`new_chat`))){e.preventDefault(),a({selectedProjectId:r?.id??null,directoryOverride:t||r?.path||null,preserveDirectoryOverride:!!(t||r?.path)}),$e();return}if(k(e,o(`open_model_selector`))){e.preventDefault();let{isModelSelectorOpen:t,setModelSelectorOpen:n}=d.getState();n(!t,{instant:!0});return}if(k(e,o(`cycle_thinking_variant`))){let t=S.getState();if(t.getCurrentModelVariants().length===0)return;e.preventDefault(),t.cycleCurrentVariant();let n=S.getState().currentVariant,r=C.getState().currentSessionId,i=S.getState().currentAgentName,a=S.getState().currentProviderId,o=S.getState().currentModelId;r&&i&&a&&o&&ee.getState().saveAgentModelVariantForSession(r,i,a,o,n),i&&a&&o&&S.getState().saveAgentModelSelection(i,a,o,n);return}let s=k(e,o(`cycle_favorite_model_forward`)),c=k(e,o(`cycle_favorite_model_backward`));if(s||c){let{favoriteModels:t,addRecentModel:n}=d.getState();if(t.length===0)return;e.preventDefault();let{currentProviderId:r,currentModelId:i,providers:a,setProvider:o,setModel:c,setCurrentVariant:l}=S.getState(),u=t[(t.findIndex(e=>e.providerID===r&&e.modelID===i)+(s?1:-1)+t.length)%t.length];o(u.providerID),c(u.modelID);let f=a.find(e=>e.id===u.providerID)?.models?.find(e=>e.id===u.modelID),p=f?.variants?Object.keys(f.variants):[],m=u.variant!==void 0&&p.includes(u.variant)?u.variant:void 0;l(m),n(u.providerID,u.modelID,m)}};return window.addEventListener(`keydown`,s),()=>window.removeEventListener(`keydown`,s)},[r?.id,r?.path,t,a,e])},tt=`openchamber:mini-chat-presence`,nt=()=>{let e=typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams;return{mode:e.get(`mode`)===`session`?`session`:`draft`,sessionId:e.get(`sessionId`)?.trim()||null,directory:e.get(`directory`)?.trim()||null,projectId:e.get(`projectId`)?.trim()||null}},rt=({config:e})=>{let t=oe(),n=l(e=>e.currentDirectory),r=l(e=>e.setDirectory),i=re(e=>e.projects),a=C(e=>e.currentSessionId),o=C(e=>!!e.newSessionDraft?.open),s=C(e=>e.newSessionDraft?.open?e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``:``),c=C(e=>e.setCurrentSession),u=C(e=>e.openNewSessionDraft),d=S(e=>e.initializeApp),f=S(e=>e.isInitialized),p=xe();j.useEffect(()=>{d()},[d]),j.useEffect(()=>{if(f)return;let e=!0,t=0,n=window.setInterval(()=>{if(e){if(t+=1,t>10){window.clearInterval(n);return}S.getState().isInitialized||S.getState().initializeApp()}},1e3);return()=>{e=!1,window.clearInterval(n)}},[f]);let _=j.useRef(!1);j.useEffect(()=>{if(!_.current&&e.mode===`session`&&e.directory){if(n===e.directory){_.current=!0;return}r(e.directory,{showOverlay:!1}),_.current=!0}},[e.directory,e.mode,n,r]),j.useEffect(()=>{e.mode!==`draft`||!o||a||!s||n===s||r(s,{showOverlay:!1})},[e.mode,n,a,s,o,r]),ue({enabled:!0,source:`electronMiniChat:recovery`});let v=j.useRef(!1);j.useEffect(()=>{if(v.current||e.mode!==`session`||!e.sessionId)return;if(a===e.sessionId){v.current=!0;return}if(a){v.current=!0;return}let n=t.find(t=>t.id===e.sessionId);if(!n){p.ensureSessionRenderable(e.sessionId);return}let r=n.directory??e.directory;c(e.sessionId,r),v.current=!0},[e,a,t,c,p]);let y=g(t),b=h(e=>{let t=e.detail,n=typeof t?.sessionId==`string`?t.sessionId.trim():``;if(!n||C.getState().currentSessionId===n)return;let r=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():y.current.find(e=>e.id===n)?.directory??null;p.ensureSessionRenderable(n),c(n,r),v.current=!0});j.useEffect(()=>(window.addEventListener(`openchamber:open-session`,b),()=>window.removeEventListener(`openchamber:open-session`,b)),[b]),j.useEffect(()=>{e.mode!==`draft`||o||a||u({selectedProjectId:e.projectId,directoryOverride:e.directory,preserveDirectoryOverride:!!e.directory})},[e,a,o,u]),j.useEffect(()=>{if(i.length===0)return;let e=!1;return(async()=>{await Promise.all(i.map(async t=>{let n=t.path.replace(/\\/g,`/`).replace(/\/+$/,``);if(n)try{if(!(Oe.getState().directories.get(n)?.isGitRepo??await m(()=>import(`./gitApi-q2aVvcM1.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])))||e)return;await Se({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i]);let x=j.useRef(!1);return j.useEffect(()=>{if(x.current||!f)return;let t=()=>{if(x.current)return;x.current=!0;let e=typeof document<`u`?document.getElementById(`initial-loading`):null;e&&(e.classList.add(`fade-out`),window.setTimeout(()=>e.remove(),300))},n=e.mode===`session`?a===e.sessionId:o,r=window.setTimeout(t,n?100:1500);return()=>window.clearTimeout(r)},[f,e.mode,e.sessionId,a,o]),null},it=()=>{let e=(0,A.c)(4),t=C(ft),n=l(pt),r,i;return e[0]!==n||e[1]!==t?(r=()=>{if(!t||!n||typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(tt),r=r=>{e.postMessage({type:`mini-chat-session-presence`,sessionId:t,directory:n,viewed:r})};r(!0);let i=window.setInterval(()=>r(!0),5e3),a=()=>r(!1);return window.addEventListener(`beforeunload`,a),()=>{window.clearInterval(i),window.removeEventListener(`beforeunload`,a),r(!1),e.close()}},i=[n,t],e[0]=n,e[1]=t,e[2]=r,e[3]=i):(r=e[2],i=e[3]),j.useEffect(r,i),null},at=e=>{let t=(0,A.c)(6),n=oe(),r=C(mt),[i,a]=j.useState(!1),o,s;return t[0]!==e.mode||t[1]!==e.sessionId||t[2]!==r||t[3]!==n?(o=()=>{if(e.mode!==`session`||!e.sessionId||r===e.sessionId){a(!1);return}if(n.some(t=>t.id===e.sessionId)){a(!1);return}let t=window.setTimeout(()=>a(!0),5e3);return()=>window.clearTimeout(t)},s=[e.mode,e.sessionId,r,n],t[0]=e.mode,t[1]=e.sessionId,t[2]=r,t[3]=n,t[4]=o,t[5]=s):(o=t[4],s=t[5]),j.useEffect(o,s),i};function ot(e){let n=(0,A.c)(16),{apis:r}=e,i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=nt(),n[0]=i):i=n[0];let a=i,o=l(ut),s=C(lt),c=C(ct),d,f;n[1]===o?(d=n[2],f=n[3]):(d=()=>{u.setDirectory(o||a.directory||void 0)},f=[a.directory,o],n[1]=o,n[2]=d,n[3]=f),j.useEffect(d,f);let p,m;n[4]===r?(p=n[5],m=n[6]):(p=()=>(t(r),st),m=[r],n[4]=r,n[5]=p,n[6]=m),j.useEffect(p,m),ye(),et();let h;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={enabled:!0},n[7]=h):h=n[7],he(h),be();let g;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=u.getSdkClient(),n[8]=g):g=n[8];let _=o||a.directory||``,v=!(c&&s===null),y;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,M.jsx)(Ce,{delayDuration:300,skipDelayDuration:150,children:(0,M.jsxs)(`div`,{className:`h-full text-foreground bg-background`,children:[(0,M.jsx)(dt,{config:a}),(0,M.jsx)(ge,{})]})}),n[9]=y):y=n[9];let b;n[10]===r?b=n[11]:(b=(0,M.jsx)(de,{apis:r,children:y}),n[10]=r,n[11]=b);let x;return n[12]!==b||n[13]!==_||n[14]!==v?(x=(0,M.jsx)(we,{children:(0,M.jsx)(te,{sdk:g,directory:_,bootstrapDirectory:v,children:b})}),n[12]=b,n[13]=_,n[14]=v,n[15]=x):x=n[15],x}function st(){return t(null)}function ct(e){return!!e.newSessionDraft?.open}function lt(e){return e.currentSessionId}function ut(e){return e.currentDirectory}var dt=e=>{let t=(0,A.c)(11),{config:n}=e,r=at(n),i;t[0]===n?i=t[1]:(i=(0,M.jsx)(rt,{config:n}),t[0]=n,t[1]=i);let a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(it,{}),o=(0,M.jsx)(_e,{embeddedBackgroundWorkEnabled:!0}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=n.mode===`draft`,c;t[4]!==n.mode||t[5]!==r||t[6]!==s?(c=(0,M.jsx)(Ie,{mode:n.mode,autoOpenDraft:s,unavailable:r}),t[4]=n.mode,t[5]=r,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==c?(l=(0,M.jsxs)(M.Fragment,{children:[i,a,o,c]}),t[8]=i,t[9]=c,t[10]=l):l=t[10],l};function ft(e){return e.currentSessionId}function pt(e){return e.currentDirectory}function mt(e){return e.currentSessionId}var ht=()=>{x(),o().then(()=>{Promise.all([r(),le()]).catch(e=>{console.error(`[mini-chat-main] settings init failed:`,e)}),O(),ce(),ve()}).catch(e=>{console.error(`[mini-chat-main] appearance init failed:`,e)})};function gt(e){ht();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);(0,Ne.createRoot)(t).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(me,{children:(0,M.jsx)(v,{children:(0,M.jsx)(fe,{children:(0,M.jsx)(pe,{children:(0,M.jsx)(E,{children:(0,M.jsx)(T,{children:(0,M.jsx)(ot,{apis:e})})})})})})})}))}export{gt as renderElectronMiniChatApp};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_t as t,dt as n,ft as r,gt as i,ln as a,yt as o}from"./persistence-B7ORJ371.js";import{it as s,nt as c,rt as l}from"./vendor-base-ui-CdzJ6My_.js";import{n as u,t as d}from"./platform-CiBU2bCp.js";import{n as f}from"./vendor-react-BP2cRVqX.js";import{a as p,n as m}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{f as h,n as g,r as _}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as v,r as y,t as b}from"./button-NnBwy1et.js";import{Pr as x,ba as S}from"./useMobileNavigationStore-BRqifj9r.js";import{n as C}from"./Icon-BKVaYkO0.js";import{v as w}from"./image-loading-qNtUCy69.js";import{a as T,o as E}from"./dropdown-menu.styles-DG86fojG.js";import{i as ee,t as D}from"./textarea-CN-vZS5F.js";import{t as O}from"./LoadingImage-DC63uLZK.js";var k=e(s(),1),A=f(),j=l(),te=e(c(),1),M=p(`OpenChamberMedia`);function N(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function P(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return N({platform:d(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function ne(){return u()&&m.getPlatform()===`android`&&m.isPluginAvailable(`OpenChamberMedia`)}async function F(e){if(!ne())return null;let t=await M.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(m.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var I=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,re=e=>{let t=(0,A.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=v(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,j.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let u;t[4]===s?u=t[5]:(u=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===s?f=t[9]:(f=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,j.jsx)(C,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=p):p=t[10];let m;t[11]===s?m=t[12]:(m=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=m);let h;t[13]===m?h=t[14]:(h=(0,j.jsx)(`span`,{className:`truncate`,children:m}),t[13]=m,t[14]=h);let g;t[15]!==a||t[16]!==h?(g=(0,j.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:I,"data-mobile-press-feedback":`none`,onClick:a,children:[p,h]}),t[15]=a,t[16]=h,t[17]=g):g=t[17];let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,j.jsx)(C,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=_):_=t[18];let y;t[19]===s?y=t[20]:(y=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=y);let x;t[21]===y?x=t[22]:(x=(0,j.jsx)(`span`,{className:`truncate`,children:y}),t[21]=y,t[22]=x);let S;t[23]!==o||t[24]!==x?(S=(0,j.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:I,"data-mobile-press-feedback":`none`,onClick:o,children:[_,x]}),t[23]=o,t[24]=x,t[25]=S):S=t[25];let w;t[26]!==S||t[27]!==g?(w=(0,j.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,j.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[g,S]})}),t[26]=S,t[27]=g,t[28]=w):w=t[28];let T;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==w||t[33]!==l||t[34]!==u||t[35]!==d||t[36]!==f?(T=(0,j.jsx)(ee,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:u,closeAriaLabel:d,resizeAriaLabel:f,fitContent:!0,children:w}),t[29]=n,t[30]=i,t[31]=r,t[32]=w,t[33]=l,t[34]=u,t[35]=d,t[36]=f,t[37]=T):T=t[37],T},L={glyph:`_glyph_1xs2e_1`,lens:`_lens_1xs2e_12`,shape:`_shape_1xs2e_21`,revolve:`_revolve_1xs2e_1`};function ie(e){let t=(0,A.c)(18),{decorative:n,size:r}=e,i=n!==void 0&&n,a=r===void 0?20:r,{t:o}=v(),s;t[0]===a?s=t[1]:(s={width:a,height:a},t[0]=a,t[1]=s);let c=i||void 0,l=i?void 0:`img`,u;t[2]!==i||t[3]!==o?(u=i?void 0:o(`common.loading`),t[2]=i,t[3]=o,t[4]=u):u=t[4];let d=`scale(${a/28})`,f;t[5]===d?f=t[6]:(f={transform:d},t[5]=d,t[6]=f);let p,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,j.jsx)(`span`,{className:L.shape}),p=(0,j.jsx)(`span`,{className:L.shape}),m=(0,j.jsx)(`span`,{className:L.shape}),t[7]=p,t[8]=m,t[9]=h):(p=t[7],m=t[8],h=t[9]);let g;t[10]===f?g=t[11]:(g=(0,j.jsxs)(`span`,{className:L.lens,style:f,children:[h,p,m]}),t[10]=f,t[11]=g);let _;return t[12]!==g||t[13]!==s||t[14]!==c||t[15]!==l||t[16]!==u?(_=(0,j.jsx)(`span`,{"data-dictation-loading":!0,className:L.glyph,style:s,"aria-hidden":c,role:l,"aria-label":u,children:g}),t[12]=g,t[13]=s,t[14]=c,t[15]=l,t[16]=u,t[17]=_):_=t[17],_}var R=w(!1).colors,ae=`M-50 74.564 A600 600 0 0 1 147.707 22.283 A38 38 0 0 1 154.330 97.994 A524 524 0 0 0 -18.333 143.653 Z`,oe=`M450 74.564 A600 600 0 0 0 252.293 22.283 A38 38 0 0 0 245.670 97.994 A524 524 0 0 1 418.333 143.653 Z`,se={colorScheme:`light`,"--surface-background":R.surface.background,"--surface-foreground":R.surface.foreground,"--primary-base":R.primary.base,"--foreground":R.surface.background,"--interactive-hover":`color-mix(in srgb, var(--surface-background) 12%, transparent)`,"--interactive-active":`color-mix(in srgb, var(--surface-background) 20%, transparent)`,"--ring":R.interactive.focusRing,"--status-error":R.status.error};function z(e){let t=(0,A.c)(85),{containerRef:n,disabled:r,onInsert:i,onSend:a,onRelease:o,onError:s,onHintChange:c}=e,{t:l}=v(),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(!1),[m,h]=(0,k.useState)(`edit`),_=(0,k.useRef)(null),y=(0,k.useRef)(null),b=(0,k.useRef)(`insert`),x=(0,k.useRef)(null),S=(0,k.useId)(),C=(0,k.useId)(),w=(0,k.useId)(),E;t[0]!==i||t[1]!==a?(E=e=>b.current===`send`?a(e):i(e),t[0]=i,t[1]=a,t[2]=E):E=t[2];let ee;t[3]!==s||t[4]!==E?(ee={onTranscript:E,onError:s},t[3]=s,t[4]=E,t[5]=ee):ee=t[5];let D=T(ee),{status:O,isStarting:M,partialTranscript:N,error:P,volume:ne}=D,F=g(c),I=u?m===`cancel`?`cancelling`:m===`edit`?`editing`:`recording`:f?`processing`:null,re,L;t[6]!==I||t[7]!==F?(re=()=>{F(I)},L=[I,F],t[6]=I,t[7]=F,t[8]=re,t[9]=L):(re=t[8],L=t[9]),(0,k.useEffect)(re,L);let R,z;t[10]===F?(R=t[11],z=t[12]):(R=()=>()=>F(null),z=[F],t[10]=F,t[11]=R,t[12]=z),(0,k.useEffect)(R,z);let le;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{y.current&&clearTimeout(y.current),y.current=null},t[13]=le):le=t[13];let B=g(le),ue;t[14]!==n||t[15]!==r?(ue=e=>{if(r||!(e instanceof HTMLElement))return null;let t=n.current?.querySelector(`textarea`);return!t||t.value!==``||t.disabled||t.readOnly||e!==t&&!e.closest(`[data-oc-composer-compact-surface]`)||e.closest(`button, [data-composer-action]`)?null:t},t[14]=n,t[15]=r,t[16]=ue):ue=t[16];let V=g(ue),de;t[17]!==B||t[18]!==D||t[19]!==P||t[20]!==f||t[21]!==O?(de=()=>{f||(B(),_.current=null,d(!1),h(`edit`),O===`failed`||O===`idle`&&P?D.discardFailedDictation():D.cancelDictation())},t[17]=B,t[18]=D,t[19]=P,t[20]=f,t[21]=O,t[22]=de):de=t[22];let H=g(de),U;t[23]!==D||t[24]!==r||t[25]!==V||t[26]!==f||t[27]!==O?(U=e=>{let t=e.target;r||f||O!==`idle`||_.current||!e.isPrimary||e.button!==0||!(t instanceof HTMLElement)||V(t)&&(e.preventDefault(),e.stopPropagation(),_.current={pointer:e.pointerId,x:e.clientX,y:e.clientY,intent:`edit`,started:!1},y.current=setTimeout(()=>{if(y.current=null,!_.current)return;let e=V(t);if(!e){_.current=null;return}e.blur(),_.current.started=!0,b.current=`insert`,d(!0),h(`edit`),D.startDictation()},300))},t[23]=D,t[24]=r,t[25]=V,t[26]=f,t[27]=O,t[28]=U):U=t[28];let W=g(U),fe;t[29]===B?fe=t[30]:(fe=e=>{let t=_.current;if(!t||t.pointer!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let n=e.clientX-t.x,r=x.current?.getBoundingClientRect(),i=r&&r.width>0&&e.clientY>=r.top&&e.clientY<=r.bottom?e.clientX<r.left+r.width/2?`cancel`:`send`:n<=-64?`cancel`:n>=64?`send`:`edit`;if(!t.started&&Math.hypot(n,t.y-e.clientY)>12){B(),_.current=null;return}t.started&&i!==t.intent&&(t.intent=i,h(i))},t[29]=B,t[30]=fe);let pe=g(fe),me;t[31]!==H||t[32]!==B||t[33]!==n||t[34]!==D||t[35]!==P||t[36]!==o||t[37]!==N||t[38]!==O?(me=e=>{let t=_.current;if(!(!t||t.pointer!==e.pointerId)){if(e.preventDefault(),e.stopPropagation(),B(),P||O===`failed`){H();return}_.current=null,d(!1),t.started?t.intent===`cancel`?D.cancelDictation():(b.current=t.intent===`edit`?`insert`:`send`,o(N),p(!0),Promise.resolve(D.confirmDictation()).finally(()=>{p(!1),D.discardFailedDictation(),t.intent===`edit`&&n.current?.querySelector(`textarea`)?.focus()})):n.current?.querySelector(`textarea`)?.focus()}},t[31]=H,t[32]=B,t[33]=n,t[34]=D,t[35]=P,t[36]=o,t[37]=N,t[38]=O,t[39]=me):me=t[39];let he=g(me),ge;t[40]===H?ge=t[41]:(ge=e=>{_.current?.pointer===e.pointerId&&H()},t[40]=H,t[41]=ge);let G=g(ge),_e;t[42]===V?_e=t[43]:(_e=e=>{V(e.target)&&e.preventDefault()},t[42]=V,t[43]=_e);let K=g(_e),ve,q;t[44]!==H||t[45]!==B||t[46]!==n||t[47]!==W||t[48]!==G||t[49]!==pe||t[50]!==K||t[51]!==he?(ve=()=>{let e=n.current;if(!e)return;let t=()=>{document.visibilityState===`hidden`&&H()};return e.addEventListener(`pointerdown`,W,!0),e.addEventListener(`touchstart`,K,{capture:!0,passive:!1}),window.addEventListener(`pointermove`,pe,{capture:!0,passive:!1}),window.addEventListener(`pointerup`,he,!0),window.addEventListener(`pointercancel`,G,!0),e.addEventListener(`contextmenu`,K,!0),e.addEventListener(`selectstart`,K,!0),window.addEventListener(`blur`,H),document.addEventListener(`visibilitychange`,t),()=>{B(),e.removeEventListener(`pointerdown`,W,!0),e.removeEventListener(`touchstart`,K,!0),window.removeEventListener(`pointermove`,pe,!0),window.removeEventListener(`pointerup`,he,!0),window.removeEventListener(`pointercancel`,G,!0),e.removeEventListener(`contextmenu`,K,!0),e.removeEventListener(`selectstart`,K,!0),window.removeEventListener(`blur`,H),document.removeEventListener(`visibilitychange`,t)}},q=[n,W,pe,he,G,H,B,K],t[44]=H,t[45]=B,t[46]=n,t[47]=W,t[48]=G,t[49]=pe,t[50]=K,t[51]=he,t[52]=ve,t[53]=q):(ve=t[52],q=t[53]),(0,k.useEffect)(ve,q);let J,ye;if(t[54]!==H||t[55]!==r?(J=()=>{r&&H()},ye=[r,H],t[54]=H,t[55]=r,t[56]=J,t[57]=ye):(J=t[56],ye=t[57]),(0,k.useEffect)(J,ye),!u&&!f)return null;let Y=Math.min(1,Math.max(0,ne))**.6,be=!!P,xe=P?H:void 0,Se;t[58]===Y?Se=t[59]:(Se={...se,"--speech-energy":Y},t[58]=Y,t[59]=Se);let Ce=Se,we;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,j.jsx)(`div`,{className:`oc-speech-light-field`,"aria-hidden":`true`,children:[`ice`,`lilac`,`mint`,`blush`,`mid`,`core`].map(ce)}),t[60]=we):we=t[60];let Te=M||f,X;t[61]!==P||t[62]!==M||t[63]!==N||t[64]!==f||t[65]!==O||t[66]!==l?(X=P&&!f?(0,j.jsx)(`p`,{role:`alert`,className:`oc-speech-caption oc-speech-error`,children:P}):(0,j.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`oc-speech-caption`,children:M||f?(0,j.jsx)(ie,{size:72}):N?(0,j.jsx)(`span`,{className:`oc-speech-interim`,children:N}):l(O===`uploading`?`chat.dictation.processing`:`chat.dictation.listening`)}),t[61]=P,t[62]=M,t[63]=N,t[64]=f,t[65]=O,t[66]=l,t[67]=X):X=t[67];let Z;t[68]!==Te||t[69]!==X?(Z=(0,j.jsx)(`div`,{className:`oc-speech-content`,"data-starting":Te,children:X}),t[68]=Te,t[69]=X,t[70]=Z):Z=t[70];let Q;t[71]!==S||t[72]!==C||t[73]!==w||t[74]!==u||t[75]!==m||t[76]!==l?(Q=u&&(0,j.jsx)(`div`,{className:`oc-speech-gesture-stage`,"aria-hidden":`true`,children:(0,j.jsxs)(`div`,{className:`oc-speech-gesture-surfaces`,children:[(0,j.jsx)(`div`,{className:`oc-speech-target-glass`,style:{clipPath:`url(#${C})`}}),(0,j.jsx)(`div`,{className:`oc-speech-target-glass`,style:{clipPath:`url(#${w})`}}),(0,j.jsxs)(`svg`,{className:`oc-speech-geometry`,viewBox:`0 0 400 226`,focusable:`false`,children:[(0,j.jsxs)(`defs`,{children:[(0,j.jsx)(`clipPath`,{id:C,clipPathUnits:`objectBoundingBox`,children:(0,j.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:ae})}),(0,j.jsx)(`clipPath`,{id:w,clipPathUnits:`objectBoundingBox`,children:(0,j.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:oe})}),(0,j.jsxs)(`linearGradient`,{id:S,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,j.jsx)(`stop`,{offset:`0%`,className:`oc-speech-arc-top`}),(0,j.jsx)(`stop`,{offset:`100%`,className:`oc-speech-arc-bottom`})]})]}),(0,j.jsxs)(`g`,{className:`oc-speech-targets`,ref:x,children:[(0,j.jsxs)(`g`,{className:`oc-speech-target oc-speech-target--cancel`,"data-active":m===`cancel`,children:[(0,j.jsx)(`path`,{d:ae}),(0,j.jsx)(`text`,{x:`95`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(-11 95 68)`,children:l(`chat.dictation.cancelGesture`)})]}),(0,j.jsxs)(`g`,{className:`oc-speech-target oc-speech-target--send`,"data-active":m===`send`,children:[(0,j.jsx)(`path`,{d:oe}),(0,j.jsx)(`text`,{x:`305`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(11 305 68)`,children:l(`chat.dictation.send`)})]})]}),(0,j.jsx)(`path`,{className:`oc-speech-hold-arc`,fill:`url(#${S})`,d:`M-50 186.987 A500 500 0 0 1 450 186.987 L450 300 H-50 Z`})]})]})}),t[71]=S,t[72]=C,t[73]=w,t[74]=u,t[75]=m,t[76]=l,t[77]=Q):Q=t[77];let $;return t[78]!==m||t[79]!==be||t[80]!==xe||t[81]!==Ce||t[82]!==Z||t[83]!==Q?($=(0,te.createPortal)((0,j.jsxs)(`div`,{className:`oc-speech-overlay`,"data-intent":m,"data-error":be,onClick:xe,style:Ce,children:[we,Z,Q]}),document.body),t[78]=m,t[79]=be,t[80]=xe,t[81]=Ce,t[82]=Z,t[83]=Q,t[84]=$):$=t[84],$}function ce(e){return(0,j.jsx)(`div`,{className:`oc-speech-reactor oc-speech-reactor--${e}`,children:(0,j.jsx)(`div`,{className:`oc-speech-light`})},e)}function le(e){let t=(0,A.c)(7),{available:n}=e,r=S(B),[i,o]=(0,k.useState)(null),s;t[0]!==n||t[1]!==r?(s=n&&r&&!a()&&E(),t[0]=n,t[1]=r,t[2]=s):s=t[2];let c=s,l=c?i:null,u;return t[3]!==c||t[4]!==r||t[5]!==l?(u={globallyEnabled:r,enabled:c,hint:l,onHintChange:o},t[3]=c,t[4]=r,t[5]=l,t[6]=u):u=t[6],u}function B(e){return e.dictationEnabled}var ue=k.createContext(null),V=e=>{let t=(0,A.c)(3),{actions:n,children:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,j.jsx)(ue.Provider,{value:n,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},de=()=>k.useContext(ue),H=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function U(e){let t=(0,A.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,j.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function W(e){let t=(0,A.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,j.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,j.jsx)(U,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function fe(e){let t=(0,A.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=y(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,j.jsx)(C,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,j.jsx)(U,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var pe=k.forwardRef((e,t)=>{let n=(0,A.c)(19),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({children:r,className:i,expanded:s,focusedTone:c,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=s!==void 0&&s,u=c===void 0?`primary`:c,d=l&&`min-h-0 flex-1`,f=u===`info`?`focus-within:ring-[var(--status-info)]`:`focus-within:ring-primary/50`,p;n[7]!==i||n[8]!==d||n[9]!==f?(p=y(`relative flex flex-col overflow-visible border border-border/80 focus-within:ring-1`,d,f,i),n[7]=i,n[8]=d,n[9]=f,n[10]=p):p=n[10];let m;n[11]===o?m=n[12]:(m={borderRadius:`var(--radius-xl)`,backgroundColor:`var(--surface-subtle)`,...o},n[11]=o,n[12]=m);let h;return n[13]!==r||n[14]!==a||n[15]!==t||n[16]!==p||n[17]!==m?(h=(0,j.jsx)(`div`,{ref:t,className:p,style:m,...a,children:r}),n[13]=r,n[14]=a,n[15]=t,n[16]=p,n[17]=m,n[18]=h):h=n[18],h});pe.displayName=`ChatComposerSurface`;var me=k.forwardRef((e,t)=>{let n=(0,A.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,j.jsx)(D,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});me.displayName=`ChatPromptTextarea`;var he=e=>{let t=(0,A.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,j.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},ge=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},G=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:o,onSubmit:s,onStop:c,onAddFiles:l,onRemoveAttachment:u,addFilesLabel:d,removeAttachmentLabel:f,fileAccept:p=`image/*`,sendLabel:m,stopLabel:_,hint:b,leftControls:S,rightControls:w,footerContent:T,inputHeader:E,attachmentContent:ee,highlightedContent:D,highlightRef:A,inputRef:te,textareaProps:M,textLayoutClassName:N,inputClassName:I,inputOuterClassName:L,inputStyle:ie,footerClassName:R,footerStyle:ae,contentClassName:oe,inputSectionClassName:se,autoResize:z=!0,disableInputWhilePending:ce=!0,layout:le=`stacked`,children:B,className:ue,expanded:V=!1,...de})=>{let{t:U}=v(),G=le===`inline`,[_e,K]=k.useState(!1),[ve,q]=k.useState(!1),J=P(),ye=t.length>0||_e,Y=k.useRef(null),be=k.useRef(null),xe=k.useRef(null),Se=k.useId().replace(/:/g,``),Ce=g(()=>{if(!z||V||M?.fillContainer){G&&K(!1);return}let e=Y.current;if(!e)return;e.style.height=G?`0px`:`auto`;let t=Number.parseFloat(window.getComputedStyle(e).maxHeight),n=G?Math.max(e.scrollHeight,48):e.scrollHeight,r=Number.isFinite(t)?Math.min(n,t):n;e.style.height=`${r}px`,e.style.overflowY=Number.isFinite(t)&&n>t?`auto`:`hidden`;let i=r>48;G&&K(e=>e===i?e:i)});k.useLayoutEffect(()=>{Ce()},[z,V,G,M?.fillContainer,e]),h(G&&z&&!V&&!M?.fillContainer?Y:null,Ce);let we=e=>{M?.onKeyDown?.(e),!(e.defaultPrevented||H(e))&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),!n&&(!r||!ce)&&s())},Te=e=>{l?.(e.target.files),e.target.value=``},X=g(()=>{Y.current?.blur(),q(!0)}),Z=g(e=>{q(!1),requestAnimationFrame(()=>e?.click())}),Q=g(()=>{q(!1),requestAnimationFrame(()=>{(async()=>{if(!ne()){xe.current?.click();return}try{let e=await F(20);if(e===null){xe.current?.click();return}e.length>0&&l?.(e)}catch(e){console.error(`Native photo pick failed`,e),x.error(U(`chat.chatInput.toast.attachFileFailed`))}})()})}),$=e.trim().length>0||t.length>0,Ee=t.filter(e=>e.mime.startsWith(`image/`)),De=t.filter(e=>!e.mime.startsWith(`image/`)),Oe=l?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`input`,{ref:be,type:`file`,accept:p,multiple:!0,className:`hidden`,onChange:Te}),J?(0,j.jsx)(`input`,{ref:xe,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:Te}):null,(0,j.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>J?X():be.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":d,children:(0,j.jsx)(C,{name:`attachment-2`,className:`size-[18px]`})})]}):null,ke=!n&&!r&&$,Ae=a?`size-6`:`size-full`,je=r&&c?(0,j.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":_,children:(0,j.jsx)(W,{className:Ae})}):(0,j.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":ke?`true`:void 0,className:y(`flex size-8 shrink-0 items-center justify-center outline-none`,ke?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!$,"aria-label":m,children:ke?(0,j.jsx)(fe,{className:Ae}):(0,j.jsx)(C,{name:r?`loader-4`:`send-plane-2`,className:y(`size-4`,r&&`animate-spin`)})}),Me=r&&c?(0,j.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":_,children:(0,j.jsx)(W,{className:Ae})}):(0,j.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:y(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,ke?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!$,"aria-busy":r||void 0,"aria-label":m,children:(0,j.jsx)(fe,{className:Ae,spinning:r})}),Ne=G?Me:je,Pe=S===void 0?Oe:S;return(0,j.jsxs)(pe,{className:ue,expanded:V,...de,children:[B,(0,j.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":le,className:y(`relative flex min-h-0`,G?y(`min-h-12 flex-row`,ye?`items-end`:`items-center`):`flex-col`,V&&`flex-1`,oe),children:[G&&Pe?(0,j.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:Pe}):null,(0,j.jsxs)(`div`,{className:y(`overflow-hidden`,G&&`min-w-0 flex-1`,V&&`flex min-h-0 flex-1 flex-col`,se),children:[E,ee,Ee.length>0?(0,j.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:Ee.map(e=>(0,j.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,j.jsx)(`span`,{className:`block size-16`,children:(0,j.jsx)(O,{fill:!0,src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`})}),u?(0,j.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,j.jsx)(C,{name:`close`,className:`size-3`})}):null]},e.id))}):null,De.length>0?(0,j.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:De.map(e=>(0,j.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,j.jsx)(C,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),u?(0,j.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,j.jsx)(C,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,j.jsxs)(`div`,{className:y(`relative overflow-hidden`,G&&y(`flex min-h-12`,_e?`items-end`:`items-center`),V&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[D?(0,j.jsx)(`div`,{ref:A,"aria-hidden":!0,"data-composer-highlight":`true`,className:y(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,N,I),children:D}):null,(0,j.jsx)(me,{...M,simple:!0,fillContainer:!G&&M?.fillContainer,ref:e=>{Y.current=e,ge(te,e)},"data-chat-input":`true`,value:e,onChange:e=>o(e.target.value,e),onKeyDown:we,disabled:n||r&&ce,placeholder:i,enterKeyHint:a?`send`:M?.enterKeyHint,outerClassName:y(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,G&&`flex-none`,V&&`min-h-0 flex-1`,L),className:y(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,G?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,N,I,D&&`text-transparent caret-[var(--surface-foreground)]`),style:ie,rows:M?.rows??1})]})]}),G?(0,j.jsx)(`div`,{className:y(`flex h-12 shrink-0 items-center pr-1.5`,R),style:ae,"data-composer-inline-send":`true`,children:w??Ne}):(0,j.jsx)(he,{className:R,style:ae,children:T??(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`flex items-center gap-1.5`,children:S??Oe}),b?(0,j.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:b}):(0,j.jsx)(`div`,{className:`flex-1`}),(0,j.jsx)(`div`,{className:`flex items-center gap-1.5`,children:w??Ne})]})})]}),J&&l?(0,j.jsx)(re,{id:`mobile-attach-pick-${Se}`,open:ve,onOpenChange:e=>{e||q(!1)},onPickPhotos:Q,onPickFiles:()=>Z(be.current)}):null]})},_e={dictation:102,mentionFile:100,mentionAgent:100,mentionSession:100,mentionCommand:100,mentionPaste:100,code:90,codeFence:90,link:80,linkUrl:78,heading:70,blockquote:40,listMarker:35,marker:10},K={dictation:`text-foreground underline decoration-current underline-offset-4`,mentionFile:`text-[var(--primary)]`,mentionAgent:`text-[var(--primary)]`,mentionSession:`text-[var(--primary)]`,mentionCommand:`text-[var(--primary)]`,mentionPaste:`text-[var(--primary)]`,code:`rounded-[3px] bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,codeFence:`bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,link:`text-[var(--status-info)] underline`,linkUrl:`text-muted-foreground`,heading:`text-[var(--syntax-keyword)]`,blockquote:`text-muted-foreground`,listMarker:`text-[var(--syntax-keyword)]`,marker:`text-muted-foreground`},ve=`text-foreground`;function q(e,t,n){let r=0,i=e.length;for(;r<i;){let i=e[r];if(i==="`"){let i=/^`+/.exec(e.slice(r))?.[0]??``,a=e.indexOf(i,r+i.length);if(a!==-1){let e=a+i.length;n.push({start:t+r,end:t+e,style:`code`}),r=e;continue}}if(i===`[`){let i=/^\[([^\]\n]*)\]\(([^)\n]*)\)/.exec(e.slice(r));if(i){let e=t+r,a=i[1].length,o=i[2].length,s=e+1,c=s+a,l=c+2,u=l+o,d=u+1;n.push({start:e,end:s,style:`marker`}),a>0&&n.push({start:s,end:c,style:`link`}),n.push({start:c,end:l,style:`marker`}),o>0&&n.push({start:l,end:u,style:`linkUrl`}),n.push({start:u,end:d,style:`marker`}),r+=i[0].length;continue}}r+=1}}var J=/^(\s*)(`{3,}|~{3,})\s*(\S*)/;function ye(e){let t=J.exec(e);return t?{marker:t[2],lang:t[3]||``}:null}function Y(e,t){return RegExp(`^\\s*\\${t[0]}{${t.length},}\\s*$`).test(e)}function be(e){let t=[];if(!e)return t;let n=0,r=!1,i=``,a=e.split(`
2
- `);for(let e=0;e<a.length;e+=1){let o=a[e],s=n,c=s+o.length;if(n=c+1,r){t.push({start:s,end:c,style:`codeFence`}),Y(o,i)&&(r=!1);continue}let l=ye(o);if(l){r=!0,i=l.marker,t.push({start:s,end:c,style:`codeFence`});continue}let u=/^(\s*)(#{1,6})(\s+)/.exec(o);if(u){let e=s+u[1].length,n=e+u[2].length;t.push({start:e,end:n,style:`marker`});let r=n+u[3].length;c>r&&(t.push({start:r,end:c,style:`heading`}),q(o.slice(r-s),r,t));continue}let d=/^(\s*)(>+)(\s?)/.exec(o);if(d){let e=s+d[1].length,n=e+d[2].length;t.push({start:e,end:n,style:`marker`});let r=n+d[3].length;c>r&&(t.push({start:r,end:c,style:`blockquote`}),q(o.slice(r-s),r,t));continue}let f=/^(\s*)([-*+]|\d{1,9}[.)])(\s+)/.exec(o);if(f){let e=s+f[1].length,n=e+f[2].length;t.push({start:e,end:n,style:`listMarker`});let r=n+f[3].length;q(o.slice(r-s),r,t);continue}q(o,s,t)}return t}function xe(e,t){if(!e||t.length===0)return null;let n=e.length,r=new Set([0,n]);for(let e of t)e.start>0&&e.start<n&&r.add(e.start),e.end>0&&e.end<n&&r.add(e.end);let i=[...r].sort((e,t)=>e-t),a=t.map((e,t)=>({range:e,index:t})).filter(e=>e.range.end>e.range.start).sort((e,t)=>e.range.start-t.range.start),s=[],c=[],l=0;for(let t=0;t<i.length-1;t+=1){let n=i[t],r=i[t+1];if(r<=n)continue;for(;l<a.length&&a[l].range.start<=n;)c.push(a[l]),l+=1;for(let e=c.length-1;e>=0;--e)c[e].range.end<=n&&c.splice(e,1);let u=null,d=-1,f=1/0;for(let{range:e,index:t}of c){let n=e.priority??_e[e.style];(n>d||n===d&&t<f)&&(d=n,f=t,u=e)}let p=u?u.className??K[u.style]:ve,m=e.slice(n,r),h=u?.visual,g=u?.skillName,_=s[s.length-1];_&&_.className===p&&o(_.visual,h)&&_.skillName===g?_.text+=m:s.push({text:m,className:p,visual:h,skillName:g})}return s.length>0?s:null}function Se(e,t){let n=new Set(Array.from(t,e=>e.toLowerCase())),r=[];for(let t of[/(^|\s)\/(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)/gi,/(^|\s)@(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)(?=$|\s|[),.;:!?])/gi]){let i;for(;(i=t.exec(e))!==null;){let e=i[2]??``,t=i[3]||``;if(!n.has(t.toLowerCase()))continue;let a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+e.length+t.length,name:t})}}return r}function Ce(e,t,n){if(e===t){let t=n.find(t=>e>t.start&&e<t.end);return t?{start:t.start,end:t.end}:null}let r=n.filter(n=>n.start<t&&n.end>e);return r.length===0?null:{start:Math.min(e,...r.map(e=>e.start)),end:Math.max(t,...r.map(e=>e.end))}}function we(e,t,n){let r=Se(e,t),i=Math.max(0,Math.min(n.selectionStart,e.length)),a=Math.max(i,Math.min(n.selectionEnd,e.length)),o=i,s=a;if(i===a)if(n.altKey)if(n.key===`Backspace`){for(;o>0&&/\s/.test(e[o-1]);)--o;for(;o>0&&!/\s/.test(e[o-1]);)--o}else{for(;s<e.length&&/\s/.test(e[s]);)s+=1;for(;s<e.length&&!/\s/.test(e[s]);)s+=1}else n.key===`Backspace`?o=Math.max(0,i-1):s=Math.min(e.length,i+1);if(o===s)return null;let c=r.filter(e=>e.start<s&&e.end>o);if(c.length===0)return null;let l=Math.min(o,...c.map(e=>e.start)),u=Math.max(s,...c.map(e=>e.end));return u<e.length&&/\s/.test(e[u])&&(l===0||/\s/.test(e[l-1]))?u+=1:u===e.length&&l>0&&/\s/.test(e[l-1])&&--l,{text:`${e.slice(0,l)}${e.slice(u)}`,caret:l,removedSkillNames:c.map(e=>e.name)}}function Te(e){return e.map(e=>({start:e.start,end:e.end,style:e.kind===`file`?`mentionFile`:e.kind===`session`?`mentionSession`:`mentionAgent`,visual:e.kind===`session`&&e.label?t({trigger:`@`,icon:`chat-thread`,label:e.label},i({trigger:`@`,icon:`chat-thread`,label:e.label})):void 0}))}function X(e){let t=(0,A.c)(28),{visual:i,text:a}=e,o=i.trigger.length,s=o+i.label.length,c=s+(i.suffix?.length??0),l;t[0]!==s||t[1]!==o||t[2]!==a?(l=a.slice(o,Math.min(s,a.length)),t[0]=s,t[1]=o,t[2]=a,t[3]=l):l=t[3];let u=l,d;t[4]!==s||t[5]!==c||t[6]!==a?(d=a.slice(s,Math.min(c,a.length)),t[4]=s,t[5]=c,t[6]=a,t[7]=d):d=t[7];let f=d,p;t[8]!==c||t[9]!==a?(p=a.slice(Math.min(c,a.length)),t[8]=c,t[9]=a,t[10]=p):p=t[10];let m=p,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h={left:n,right:n},t[11]=h):h=t[11];let g=i.icon,_;t[12]===g?_=t[13]:(_=(0,j.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 inline-flex items-center justify-center`,style:h,children:(0,j.jsx)(C,{name:g,className:`${r} shrink-0 text-[var(--primary)]`,"aria-hidden":`true`})}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==i.trigger?(v=(0,j.jsxs)(`span`,{className:`relative inline-block align-baseline text-transparent leading-none`,children:[i.trigger,_]}),t[14]=_,t[15]=i.trigger,t[16]=v):v=t[16];let y;t[17]===u?y=t[18]:(y=(0,j.jsx)(`span`,{children:u}),t[17]=u,t[18]=y);let b;t[19]===f?b=t[20]:(b=f?(0,j.jsx)(`span`,{className:`text-transparent`,children:f}):null,t[19]=f,t[20]=b);let x;t[21]===m?x=t[22]:(x=m?(0,j.jsx)(`span`,{className:`text-transparent`,children:m}):null,t[21]=m,t[22]=x);let S;return t[23]!==x||t[24]!==v||t[25]!==y||t[26]!==b?(S=(0,j.jsxs)(j.Fragment,{children:[v,y,b,x]}),t[23]=x,t[24]=v,t[25]=y,t[26]=b,t[27]=S):S=t[27],S}var Z=e=>({text:e.text,references:e.references.map(e=>({...e}))}),Q=e=>e.map(e=>({...e,range:{...e.range}})),$=(e,t)=>e.text===t.text&&JSON.stringify(e.references)===JSON.stringify(t.references),Ee=(e,t,n)=>({document:Z(e),mentions:Q(t),selection:{...n}}),De=()=>({undo:[],redo:[]}),Oe=(e,t)=>({undo:[...e.undo,t].slice(-100),redo:[]}),ke=(e,t)=>{let n=e.undo.at(-1);return!n||!$(n.after.document,t)?null:{history:{undo:e.undo.slice(0,-1),redo:[...e.redo,n]},snapshot:Ee(n.before.document,n.before.mentions,n.before.selection)}},Ae=(e,t)=>{let n=e.redo.at(-1);return!n||!$(n.before.document,t)?null:{history:{undo:[...e.undo,n],redo:e.redo.slice(0,-1)},snapshot:Ee(n.after.document,n.after.mentions,n.after.selection)}},je=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case`ArrowUp`:case`PageUp`:case`Home`:return!0;default:return!1}},Me=(e,t,n)=>{let r=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;r&&r!==e;){if(r instanceof HTMLElement){let e=r.scrollHeight-r.clientHeight;if(e>1&&(n===`up`?r.scrollTop>0:r.scrollTop<e-1))return!0}r=r.parentElement}return!1},Ne=(e,t)=>Me(e,t,`up`),Pe=(e,t)=>Me(e,t,`down`),Fe=e=>{let t=(0,A.c)(15),{scrollRef:n,enabled:r,onUpwardIntent:i}=e,a=r===void 0||r,o=k.useRef(null),s;t[0]===i?s=t[1]:(s=()=>{i()},t[0]=i,t[1]=s);let c=g(s),l;t[2]!==c||t[3]!==n?(l=e=>{let t=n.current;t&&(e.deltaY>=0||t instanceof HTMLElement&&(Ne(t,e.target)||c()))},t[2]=c,t[3]=n,t[4]=l):l=t[4];let u=g(l),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{let t=e.touches.item(0);o.current=t?t.clientY:null},t[5]=d):d=t[5];let f=g(d),p;t[6]!==c||t[7]!==n?(p=e=>{let t=n.current,r=e.touches.item(0);if(!r){o.current=null;return}let i=o.current;o.current=r.clientY,i!==null&&(r.clientY-i<=2||!t||!(t instanceof HTMLElement)||Ne(t,e.target)||c())},t[6]=c,t[7]=n,t[8]=p):p=t[8];let m=g(p),h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{o.current=null},t[9]=h):h=t[9];let v=g(h),y;t[10]===c?y=t[11]:(y=e=>{je(e)&&c()},t[10]=c,t[11]=y);let b=g(y),[x,S]=k.useState(null),C;t[12]===n?C=t[13]:(C=()=>{let e=n.current??null;S(t=>t===e?t:e)},t[12]=n,t[13]=C),k.useEffect(C);let w=a&&x?x:Ie,T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T={passive:!0},t[14]=T):T=t[14];let E=T;_(`wheel`,u,w,E),_(`touchstart`,f,w,E),_(`touchmove`,m,w,E),_(`touchend`,v,w,E),_(`touchcancel`,v,w,E),_(`keydown`,b,w)};function Ie(){}var Le=e=>{if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.trunc(e);return t>=0?t:void 0},Re=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.summary;return!t||typeof t!=`object`||Array.isArray(t)?null:t},ze=e=>{let t=Le(e);return t!==void 0&&t>0?t:void 0};function Be(e){let t=Re(e);if(!t)return null;let n=ze(t.additions),r=ze(t.deletions),i=ze(t.files)??ze(t.diffCount);return n===void 0&&r===void 0&&i===void 0?null:{...n===void 0?{}:{additions:n},...r===void 0?{}:{deletions:r},...i===void 0?{}:{files:i}}}function Ve(e){if(!e)return null;let t=[];return e.additions!==void 0&&e.additions>0&&t.push(`+${e.additions}`),e.deletions!==void 0&&e.deletions>0&&t.push(`−${e.deletions}`),t.length>0?t.join(` `):null}function He(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.providerID==`string`?t.providerID.trim():``,r=typeof t.modelID==`string`?t.modelID.trim():``;if(n&&r)return`${n}/${r}`;let i=t.model;if(typeof i==`string`&&i.trim())return i.trim();if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i,t=typeof e.providerID==`string`?e.providerID.trim():typeof e.provider==`string`?e.provider.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():typeof e.id==`string`?e.id.trim():``;if(t&&n)return`${t}/${n}`}return null}function Ue(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(typeof t.branch==`string`&&t.branch.trim())return t.branch.trim();let n=t.project;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.branch;if(typeof e==`string`&&e.trim())return e.trim()}return null}export{z as A,G as C,V as D,H as E,P as F,re as M,ne as N,de as O,F as P,be as S,W as T,Y as _,je as a,Ce as b,Fe as c,Oe as d,Ae as f,Se as g,xe as h,He as i,ie as j,le as k,Ee as l,X as m,Ue as n,Pe as o,ke as p,Be as r,Ne as s,Ve as t,De as u,ye as v,fe as w,we as x,Te as y};