@xopcai/xopc 0.0.121 → 0.0.123

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 (309) hide show
  1. package/README.md +23 -3
  2. package/README.zh-CN.md +23 -3
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-4AW4JgSU.js → agent-avatar-dicebear-Bicr3ZBg.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-CxDSFHGx.js +2 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CE6GkGU2.js → app-management-settings-panel-CbEy9sR1.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BmaUjghw.js → appearance-settings-CTHja6n9.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-CyZdgqvm.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-CX4_KWut.js → archive-plugin-Bpy64GjU.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-jf-PIIUU.js → attachment-load-DMkp4xSb.js} +1 -1
  12. package/dist/gateway/static/root/assets/automation-suggestion-card-KnYaP7NT.js +1 -0
  13. package/dist/gateway/static/root/assets/automations-page-8VLKM4au.js +1 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-DG9XQikd.js → binary-plugins-DA9C5mCw.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Up_VIxLJ.js → block-editor-CiSXk_YC.js} +6 -6
  16. package/dist/gateway/static/root/assets/browser-settings-page-5tPg0DcP.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-CGM4OyMw.js → capability-presets-api-CEJ44WCU.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CzWt0LBb.js → capability-presets-settings-panel-BJW3aVST.js} +1 -1
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-BEByL4_o.js → channel-recipient-api-CDhrhfhN.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-CorUCTrs.js +1 -0
  21. package/dist/gateway/static/root/assets/connectors-page-VKstC3sP.js +2 -0
  22. package/dist/gateway/static/root/assets/directory-picker-path-field-7jKfbH0J.js +1 -0
  23. package/dist/gateway/static/root/assets/dreaming-settings-m1-wmz4o.js +1 -0
  24. package/dist/gateway/static/root/assets/{extension-debug-page-DZxa_j7-.js → extension-debug-page-C9qQQrBS.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-page-CseziW53.js → extension-page-DcBBMEGl.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-settings-page-B_9J-xyo.js → extension-settings-page-BQ-jMMP9.js} +1 -1
  27. package/dist/gateway/static/root/assets/{fetch-Cs4ck8zA.js → fetch-Dtpbbe0s.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-Dl223a7r.js → gateway-config-api-BN6pyX2c.js} +1 -1
  29. package/dist/gateway/static/root/assets/gateway-settings-hQtgVmSR.js +1 -0
  30. package/dist/gateway/static/root/assets/{gateway-startup-retry-IvePwjFE.js → gateway-startup-retry-BIET2x3y.js} +1 -1
  31. package/dist/gateway/static/root/assets/goal-create-dialog-BuIMDx6C.js +1 -0
  32. package/dist/gateway/static/root/assets/goal-detail-page-FEypCq74.js +1 -0
  33. package/dist/gateway/static/root/assets/{goals-config-api-CUCP6yCl.js → goals-config-api-CQm2r1Ty.js} +1 -1
  34. package/dist/gateway/static/root/assets/goals-page-C4-2_MLG.js +2 -0
  35. package/dist/gateway/static/root/assets/{goals-settings-Dj87qPxv.js → goals-settings-DDrdRMxB.js} +1 -1
  36. package/dist/gateway/static/root/assets/heartbeat-settings-BJVok3Sl.js +1 -0
  37. package/dist/gateway/static/root/assets/index-CBDr5xjB.css +1 -0
  38. package/dist/gateway/static/root/assets/index-T0SaNd5a.js +191 -0
  39. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DJgYw0nB.js → keyboard-shortcuts-settings-C2TuQppb.js} +1 -1
  40. package/dist/gateway/static/root/assets/logs-page-DwkwPgid.js +2 -0
  41. package/dist/gateway/static/root/assets/{markdown-split-gnQ_EiGo.js → markdown-split-DhONQ81k.js} +1 -1
  42. package/dist/gateway/static/root/assets/{media-plugins-CQV-mgJn.js → media-plugins-DS44pJzr.js} +1 -1
  43. package/dist/gateway/static/root/assets/messages-avfvyZuQ.js +3 -0
  44. package/dist/gateway/static/root/assets/models-hub-panel-huNY4A1G.js +2 -0
  45. package/dist/gateway/static/root/assets/notes-page-DdfGuEZ1.js +1 -0
  46. package/dist/gateway/static/root/assets/notes-workbench-B0bT9Hqa.js +2 -0
  47. package/dist/gateway/static/root/assets/{preview-open-alternatives-BPMXC-2u.js → preview-open-alternatives-Dej6zHnr.js} +1 -1
  48. package/dist/gateway/static/root/assets/project-detail-page-CjxhPorG.js +1 -0
  49. package/dist/gateway/static/root/assets/projects-page-C4Z5OJMF.js +1 -0
  50. package/dist/gateway/static/root/assets/remote-access-hub-CVCOPUVd.js +1 -0
  51. package/dist/gateway/static/root/assets/{save-bar-controls-BEHqwZjz.js → save-bar-controls-Zu1FzH6z.js} +1 -1
  52. package/dist/gateway/static/root/assets/{schedule-field-CMY25m97.js → schedule-field-BW78mKc0.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schema-form-CxjxsFfg.js → schema-form-Cc-IOydE.js} +1 -1
  54. package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +1 -0
  55. package/dist/gateway/static/root/assets/sessions-page-B4qExXHC.js +1 -0
  56. package/dist/gateway/static/root/assets/settings-advanced-gate-Ce8yLTBi.js +1 -0
  57. package/dist/gateway/static/root/assets/{settings-collapsible-section-s-kiLAxP.js → settings-collapsible-section-DIpIYht_.js} +1 -1
  58. package/dist/gateway/static/root/assets/{settings-form-section-CIxIEYxU.js → settings-form-section-BFxBNxOG.js} +1 -1
  59. package/dist/gateway/static/root/assets/settings-page-C4fivemT.js +1 -0
  60. package/dist/gateway/static/root/assets/settings-page-layout-CLx4o2PN.js +1 -0
  61. package/dist/gateway/static/root/assets/setup-status-panel-Kyc4eUf0.js +1 -0
  62. package/dist/gateway/static/root/assets/share-preview-page-ZswWCrDu.js +2 -0
  63. package/dist/gateway/static/root/assets/shares-settings-Bu76CMiC.js +1 -0
  64. package/dist/gateway/static/root/assets/skill-reload-api-D-CFg86j.js +1 -0
  65. package/dist/gateway/static/root/assets/skills-page-CUU4f6Ss.js +2 -0
  66. package/dist/gateway/static/root/assets/{system-settings-panel-Czjf0kLJ.js → system-settings-panel-3ZNcGRhS.js} +1 -1
  67. package/dist/gateway/static/root/assets/{typed-models-lib-Cmt8SYdI.js → typed-models-lib-bpzZjiVF.js} +1 -1
  68. package/dist/gateway/static/root/assets/{use-channel-catalog-DyM-ckEQ.js → use-channel-catalog-BCjZLZ3O.js} +1 -1
  69. package/dist/gateway/static/root/assets/{user-profile-settings-panel-BygLv8vm.js → user-profile-settings-panel-CIXafITi.js} +1 -1
  70. package/dist/gateway/static/root/assets/{utils-CloW8coB.js → utils-DXMtz5j_.js} +1 -1
  71. package/dist/gateway/static/root/assets/voice-api-key-field-C1MrQD8R.js +1 -0
  72. package/dist/gateway/static/root/assets/workflow-run-setup-panel-DqizIcY5.js +3 -0
  73. package/dist/gateway/static/root/assets/workflow-start-dialog-B4sZpTDQ.js +1 -0
  74. package/dist/gateway/static/root/assets/workflows-page-B3sVNPFk.js +18 -0
  75. package/dist/gateway/static/root/index.html +5 -5
  76. package/dist/package.js +1 -1
  77. package/dist/src/agent/agent-manager.d.ts +2 -0
  78. package/dist/src/agent/agent-manager.js +47 -7
  79. package/dist/src/agent/agent-manager.js.map +1 -1
  80. package/dist/src/agent/context/project-context.d.ts +19 -0
  81. package/dist/src/agent/context/project-context.js +90 -0
  82. package/dist/src/agent/context/project-context.js.map +1 -0
  83. package/dist/src/agent/goals/goal-locale.js +2 -2
  84. package/dist/src/agent/memory/types.d.ts +1 -0
  85. package/dist/src/agent/prompt/service-prompt-builder.d.ts +1 -0
  86. package/dist/src/agent/prompt/service-prompt-builder.js +2 -0
  87. package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
  88. package/dist/src/agent/prompt/system-prompt-params.d.ts +2 -0
  89. package/dist/src/agent/prompt/system-prompt-params.js +1 -0
  90. package/dist/src/agent/prompt/system-prompt-params.js.map +1 -1
  91. package/dist/src/agent/prompt/system-prompt.d.ts +1 -0
  92. package/dist/src/agent/prompt/system-prompt.js +2 -1
  93. package/dist/src/agent/prompt/system-prompt.js.map +1 -1
  94. package/dist/src/agent/service.js +4 -3
  95. package/dist/src/agent/service.js.map +1 -1
  96. package/dist/src/agent/session/session-config-service.js +6 -1
  97. package/dist/src/agent/session/session-config-service.js.map +1 -1
  98. package/dist/src/agent/session/session-hydrator.js +7 -3
  99. package/dist/src/agent/session/session-hydrator.js.map +1 -1
  100. package/dist/src/agent/session/session-inspector.js +9 -5
  101. package/dist/src/agent/session/session-inspector.js.map +1 -1
  102. package/dist/src/agent/starter-agents.js +5 -34
  103. package/dist/src/agent/starter-agents.js.map +1 -1
  104. package/dist/src/agent/tools/factory.js +1 -1
  105. package/dist/src/agent/tools/factory.js.map +1 -1
  106. package/dist/src/agent/tools/goal-tool.d.ts +5 -1
  107. package/dist/src/agent/tools/goal-tool.js +8 -2
  108. package/dist/src/agent/tools/goal-tool.js.map +1 -1
  109. package/dist/src/agent/tools/index.d.ts +1 -1
  110. package/dist/src/agent/workflow/index.js +2 -2
  111. package/dist/src/agent/workflow/runtime.js +1 -1
  112. package/dist/src/automations/api/routes.js +13 -2
  113. package/dist/src/automations/api/routes.js.map +1 -1
  114. package/dist/src/automations/domain/types.d.ts +2 -0
  115. package/dist/src/automations/domain/validation.d.ts +3 -0
  116. package/dist/src/automations/domain/validation.js +1 -0
  117. package/dist/src/automations/domain/validation.js.map +1 -1
  118. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -0
  119. package/dist/src/automations/service/action-executor.js +3 -1
  120. package/dist/src/automations/service/action-executor.js.map +1 -1
  121. package/dist/src/automations/service/automation-service.d.ts +4 -1
  122. package/dist/src/automations/service/automation-service.js +2 -2
  123. package/dist/src/automations/service/automation-service.js.map +1 -1
  124. package/dist/src/automations/storage/automation-repository.d.ts +3 -1
  125. package/dist/src/automations/storage/automation-repository.js +7 -5
  126. package/dist/src/automations/storage/automation-repository.js.map +1 -1
  127. package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
  128. package/dist/src/automations/storage/automation-run-repository.js +12 -1
  129. package/dist/src/automations/storage/automation-run-repository.js.map +1 -1
  130. package/dist/src/chat-commands/builtins/goal.js +4 -1
  131. package/dist/src/chat-commands/builtins/goal.js.map +1 -1
  132. package/dist/src/chat-commands/context.js +2 -1
  133. package/dist/src/chat-commands/context.js.map +1 -1
  134. package/dist/src/cli/command-loaders.js +1 -0
  135. package/dist/src/cli/command-loaders.js.map +1 -1
  136. package/dist/src/cli/command-manifest.js +4 -0
  137. package/dist/src/cli/command-manifest.js.map +1 -1
  138. package/dist/src/cli/commands/agent.js +2 -2
  139. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  140. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  141. package/dist/src/cli/commands/goal.js +27 -4
  142. package/dist/src/cli/commands/goal.js.map +1 -1
  143. package/dist/src/cli/commands/models.js +1 -1
  144. package/dist/src/cli/commands/onboard.js +1 -1
  145. package/dist/src/cli/commands/profile.js +1 -1
  146. package/dist/src/cli/commands/project.d.ts +4 -0
  147. package/dist/src/cli/commands/project.js +239 -0
  148. package/dist/src/cli/commands/project.js.map +1 -0
  149. package/dist/src/cli/commands/tunnel.js +1 -1
  150. package/dist/src/cli/commands/update.js +1 -1
  151. package/dist/src/cli/extension-cli-register.js +1 -1
  152. package/dist/src/config/index.js +1 -1
  153. package/dist/src/gateway/hono/routes/goals.js +51 -4
  154. package/dist/src/gateway/hono/routes/goals.js.map +1 -1
  155. package/dist/src/gateway/hono/routes/index.js +2 -0
  156. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  157. package/dist/src/gateway/hono/routes/memory.js +5 -1
  158. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  159. package/dist/src/gateway/hono/routes/notes.js +5 -0
  160. package/dist/src/gateway/hono/routes/notes.js.map +1 -1
  161. package/dist/src/gateway/hono/routes/projects.d.ts +3 -0
  162. package/dist/src/gateway/hono/routes/projects.js +662 -0
  163. package/dist/src/gateway/hono/routes/projects.js.map +1 -0
  164. package/dist/src/gateway/hono/routes/sessions.js +47 -7
  165. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  166. package/dist/src/gateway/hono/routes/workflows.js +27 -4
  167. package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
  168. package/dist/src/gateway/run-loop.js +1 -1
  169. package/dist/src/gateway/service.d.ts +3 -0
  170. package/dist/src/gateway/service.js +10 -3
  171. package/dist/src/gateway/service.js.map +1 -1
  172. package/dist/src/goals/goal-service.d.ts +1 -1
  173. package/dist/src/goals/goal-service.js +2 -1
  174. package/dist/src/goals/goal-service.js.map +1 -1
  175. package/dist/src/goals/goal-store.d.ts +1 -1
  176. package/dist/src/goals/goal-store.js +12 -6
  177. package/dist/src/goals/goal-store.js.map +1 -1
  178. package/dist/src/goals/goal-workflow-judge.js +1 -1
  179. package/dist/src/goals/types.d.ts +3 -0
  180. package/dist/src/i18n/goals-bundle.js +1 -1
  181. package/dist/src/i18n/index.js +1 -1
  182. package/dist/src/i18n/share-tool-bundle.js +2 -2
  183. package/dist/src/notes/agent-context.js +2 -2
  184. package/dist/src/projects/automation-bind.d.ts +1 -0
  185. package/dist/src/projects/automation-bind.js +16 -0
  186. package/dist/src/projects/automation-bind.js.map +1 -0
  187. package/dist/src/projects/goal-bind.d.ts +4 -0
  188. package/dist/src/projects/goal-bind.js +40 -0
  189. package/dist/src/projects/goal-bind.js.map +1 -0
  190. package/dist/src/projects/index.d.ts +12 -0
  191. package/dist/src/projects/index.js +12 -0
  192. package/dist/src/projects/memory-bind.d.ts +1 -0
  193. package/dist/src/projects/memory-bind.js +16 -0
  194. package/dist/src/projects/memory-bind.js.map +1 -0
  195. package/dist/src/projects/project-agent.d.ts +10 -0
  196. package/dist/src/projects/project-agent.js +27 -0
  197. package/dist/src/projects/project-agent.js.map +1 -0
  198. package/dist/src/projects/project-loop.d.ts +58 -0
  199. package/dist/src/projects/project-loop.js +118 -0
  200. package/dist/src/projects/project-loop.js.map +1 -0
  201. package/dist/src/projects/project-service.d.ts +40 -0
  202. package/dist/src/projects/project-service.js +187 -0
  203. package/dist/src/projects/project-service.js.map +1 -0
  204. package/dist/src/projects/project-store.d.ts +31 -0
  205. package/dist/src/projects/project-store.js +193 -0
  206. package/dist/src/projects/project-store.js.map +1 -0
  207. package/dist/src/projects/session-bind.d.ts +5 -0
  208. package/dist/src/projects/session-bind.js +46 -0
  209. package/dist/src/projects/session-bind.js.map +1 -0
  210. package/dist/src/projects/types.d.ts +62 -0
  211. package/dist/src/projects/types.js +1 -0
  212. package/dist/src/projects/workflow-bind.d.ts +1 -0
  213. package/dist/src/projects/workflow-bind.js +16 -0
  214. package/dist/src/projects/workflow-bind.js.map +1 -0
  215. package/dist/src/projects/workspace-project.d.ts +22 -0
  216. package/dist/src/projects/workspace-project.js +143 -0
  217. package/dist/src/projects/workspace-project.js.map +1 -0
  218. package/dist/src/projects/workspace.d.ts +5 -0
  219. package/dist/src/projects/workspace.js +25 -0
  220. package/dist/src/projects/workspace.js.map +1 -0
  221. package/dist/src/session/index.d.ts +1 -1
  222. package/dist/src/session/index.js +3 -3
  223. package/dist/src/session/session-workspace.d.ts +4 -2
  224. package/dist/src/session/session-workspace.js +10 -3
  225. package/dist/src/session/session-workspace.js.map +1 -1
  226. package/dist/src/session/types.d.ts +3 -0
  227. package/dist/src/session/types.js.map +1 -1
  228. package/dist/src/storage/sqlite/memory-records-repository.d.ts +3 -0
  229. package/dist/src/storage/sqlite/memory-records-repository.js +16 -5
  230. package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
  231. package/dist/src/storage/sqlite/migrations/019_projects.sql +40 -0
  232. package/dist/src/storage/sqlite/migrations/020_project_default_agent.sql +1 -0
  233. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  234. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  235. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  236. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  237. package/dist/src/storage/sqlite/notes-repository.js +20 -4
  238. package/dist/src/storage/sqlite/notes-repository.js.map +1 -1
  239. package/dist/src/storage/sqlite/row-mappers.d.ts +2 -0
  240. package/dist/src/storage/sqlite/row-mappers.js +2 -0
  241. package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
  242. package/dist/src/storage/sqlite/schema.js +1 -1
  243. package/dist/src/storage/sqlite/session-repository.js +10 -5
  244. package/dist/src/storage/sqlite/session-repository.js.map +1 -1
  245. package/dist/src/storage/sqlite/transcript-repository.js +8 -0
  246. package/dist/src/storage/sqlite/transcript-repository.js.map +1 -1
  247. package/dist/src/tui/backends/embedded-backend.d.ts +7 -1
  248. package/dist/src/tui/backends/embedded-backend.js +41 -2
  249. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  250. package/dist/src/tui/backends/gateway-sse-backend.d.ts +7 -1
  251. package/dist/src/tui/backends/gateway-sse-backend.js +22 -0
  252. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  253. package/dist/src/tui/tui-backend.d.ts +16 -0
  254. package/dist/src/tui/tui-commands.js +145 -0
  255. package/dist/src/tui/tui-commands.js.map +1 -1
  256. package/dist/src/tui/tui.js +21 -0
  257. package/dist/src/tui/tui.js.map +1 -1
  258. package/dist/src/workflows/domain/run.d.ts +1 -0
  259. package/dist/src/workflows/domain/run.js.map +1 -1
  260. package/dist/src/workflows/index.js +1 -1
  261. package/dist/src/workflows/service/workflow-run-service.d.ts +1 -0
  262. package/dist/src/workflows/service/workflow-run-service.js +18 -4
  263. package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
  264. package/dist/src/workflows/service/workflow-run-service.types.d.ts +2 -0
  265. package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
  266. package/dist/src/workflows/service/workflow-session-bridge.js +3 -0
  267. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
  268. package/dist/src/workflows/store/run-index-store.d.ts +1 -0
  269. package/dist/src/workflows/store/run-index-store.js +13 -3
  270. package/dist/src/workflows/store/run-index-store.js.map +1 -1
  271. package/dist/src/workflows/store/run-store.d.ts +3 -1
  272. package/dist/src/workflows/store/run-store.js +5 -2
  273. package/dist/src/workflows/store/run-store.js.map +1 -1
  274. package/package.json +10 -1
  275. package/dist/gateway/static/root/assets/agents-2SVUUPlp.js +0 -2
  276. package/dist/gateway/static/root/assets/apps-page-BWeQ1I49.js +0 -1
  277. package/dist/gateway/static/root/assets/automation-suggestion-card-BHk5rtJz.js +0 -1
  278. package/dist/gateway/static/root/assets/automations-page-QHotl53D.js +0 -1
  279. package/dist/gateway/static/root/assets/browser-settings-page-Cmwi6IIQ.js +0 -8
  280. package/dist/gateway/static/root/assets/channels-settings-BOMCUe2J.js +0 -1
  281. package/dist/gateway/static/root/assets/connectors-page-C-Dexk_F.js +0 -2
  282. package/dist/gateway/static/root/assets/dreaming-settings-WPEj8pir.js +0 -1
  283. package/dist/gateway/static/root/assets/gateway-settings-DdzbtW9R.js +0 -1
  284. package/dist/gateway/static/root/assets/goal-detail-page-Dxldogms.js +0 -1
  285. package/dist/gateway/static/root/assets/goals-page-DU5Nd6Xp.js +0 -2
  286. package/dist/gateway/static/root/assets/heartbeat-settings-Cgm5JmwH.js +0 -1
  287. package/dist/gateway/static/root/assets/index-BU1pvxmS.js +0 -191
  288. package/dist/gateway/static/root/assets/index-l54WfSqe.css +0 -1
  289. package/dist/gateway/static/root/assets/logs-page-C10aS4XO.js +0 -2
  290. package/dist/gateway/static/root/assets/messages-C6Kc4Jhf.js +0 -3
  291. package/dist/gateway/static/root/assets/models-hub-panel-B35CAfg6.js +0 -2
  292. package/dist/gateway/static/root/assets/note-detail-page-Brlwse8x.js +0 -2
  293. package/dist/gateway/static/root/assets/note-image-lightbox-BthwKjLA.js +0 -1
  294. package/dist/gateway/static/root/assets/note-time-hm6JO_Wi.js +0 -1
  295. package/dist/gateway/static/root/assets/notes-page-CoAwRc7L.js +0 -1
  296. package/dist/gateway/static/root/assets/remote-access-hub-B36RQ05h.js +0 -1
  297. package/dist/gateway/static/root/assets/sessions-page-73THChnj.js +0 -1
  298. package/dist/gateway/static/root/assets/settings-advanced-gate-CR9VsY-R.js +0 -1
  299. package/dist/gateway/static/root/assets/settings-page-BJ1AhfKI.js +0 -1
  300. package/dist/gateway/static/root/assets/settings-page-layout--6qT7ZJa.js +0 -1
  301. package/dist/gateway/static/root/assets/setup-status-panel-C1TtS1vJ.js +0 -1
  302. package/dist/gateway/static/root/assets/share-preview-page-BZADSbS1.js +0 -2
  303. package/dist/gateway/static/root/assets/shares-settings-gqC8Rmhy.js +0 -1
  304. package/dist/gateway/static/root/assets/skill-reload-api-C9P-WYvS.js +0 -1
  305. package/dist/gateway/static/root/assets/skills-page-CEpSvOhF.js +0 -2
  306. package/dist/gateway/static/root/assets/voice-api-key-field-BsoqJba6.js +0 -1
  307. package/dist/gateway/static/root/assets/voice-player-store-DduWlJYV.js +0 -1
  308. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CcQeX6l5.js +0 -3
  309. package/dist/gateway/static/root/assets/workflows-page-CeA8A9Ef.js +0 -18
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-C6Kc4Jhf.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-Cs4ck8zA.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{$i as p,$t as m,Aa as h,At as g,Bt as _,Ci as v,Co as y,Da as b,Dt as x,Ea as S,Et as C,Ft as w,Gi as T,Gs as E,Gt as D,Hi as O,Ht as k,It as A,Ji as j,Js as M,Jt as N,Ki as P,Lo as F,Lt as I,Mt as L,Na as R,Nt as z,Oa as B,Oo as V,Ot as ee,Pt as te,Qt as ne,Rt as re,Sa as H,So as U,Ss as W,Ta as G,Tt as ie,Ui as ae,Uo as K,Ut as oe,Va as q,Vo as se,Vt as ce,Wt as le,Xt as ue,Yt as de,Za as fe,Zt as pe,_a as me,ca as he,co as ge,ct as _e,en as ve,f as ye,fs as be,gi as xe,ha as Se,hi as Ce,ia as J,is as we,jt as Te,kt as Ee,ma as De,mc as Oe,oa as Y,oc as ke,ot as Ae,qi as je,qt as Me,ra as Ne,sa as Pe,so as Fe,st as Ie,tn as Le,uo as Re,wo as ze,xa as Be,yc as Ve,zt as He}from"./index-BU1pvxmS.js";import{a as Ue,c as We,d as Ge,f as Ke,l as qe,n as Je,o as Ye,r as Xe,s as Ze,t as Qe,u as $e}from"./voice-api-key-field-BsoqJba6.js";import{t as et}from"./settings-advanced-gate-CR9VsY-R.js";import{t as tt}from"./settings-collapsible-section-s-kiLAxP.js";import{n as nt,t as rt}from"./settings-form-section-CIxIEYxU.js";import{i as it,n as at,t as ot}from"./settings-page-layout--6qT7ZJa.js";import{n as st,t as ct}from"./save-bar-controls-BEHqwZjz.js";var X=n(),Z=e(t(),1),Q=r(),lt=()=>c(Ke),ut=()=>c(`/api/image/capabilities`),dt=()=>c(`/api/global-defaults`),ft={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function pt(){let e=await l(ut());if(!e.payload)throw Error(`Invalid image capabilities response`);return e.payload}function mt(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function ht(e){return e.map(e=>e.trim()).filter(Boolean)}function gt(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=ht(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=ht(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function _t(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function vt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var yt={saving:!1,savedFlash:!1,error:void 0};function bt(e){let t=(0,X.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let g=h,_;t[7]!==c||t[8]!==g||t[9]!==f?(_=()=>{g&&f([...c,g])},t[7]=c,t[8]=g,t[9]=f,t[10]=_):_=t[10];let v=_,y;t[11]!==c||t[12]!==f?(y=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=y):y=t[13];let b=y,x;t[14]!==c||t[15]!==f?(x=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=x):x=t[16];let S=x,C;t[17]===n?C=t[18]:(C=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=C);let w;t[19]===r?w=t[20]:(w=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=w);let T;t[21]!==C||t[22]!==w?(T=(0,Q.jsxs)(`div`,{className:`mb-3`,children:[C,w]}),t[21]=C,t[22]=w,t[23]=T):T=t[23];let E;t[24]===c?E=t[25]:(E=new Set(c),t[24]=c,t[25]=E);let D;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==E||t[30]!==s?(D=(0,Q.jsx)(Ne,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:E,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=E,t[30]=s,t[31]=D):D=t[31];let O;t[32]!==i||t[33]!==D?(O=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,D]}),t[32]=i,t[33]=D,t[34]=O):O=t[34];let k;t[35]===a?k=t[36]:(k=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=k);let A;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==S||t[43]!==m||t[44]!==b?(A=c.length===0?(0,Q.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg border border-dashed border-edge bg-surface-subtle px-3 text-sm font-normal text-fg-subtle`,children:o}):c.map((e,t)=>(0,Q.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,Q.jsx)(Ne,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>b(t,e)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,Q.jsx)(q,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=S,t[43]=m,t[44]=b,t[45]=A):A=t[45];let j=!g,M;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(U,{className:`size-4`,"aria-hidden":`true`}),t[46]=M):M=t[46];let N;t[47]!==v||t[48]!==a||t[49]!==j?(N=(0,Q.jsxs)(`button`,{type:`button`,onClick:v,disabled:j,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[M,a]}),t[47]=v,t[48]=a,t[49]=j,t[50]=N):N=t[50];let P;t[51]!==A||t[52]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[A,N]}),t[51]=A,t[52]=N,t[53]=P):P=t[53];let F;t[54]!==k||t[55]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,P]}),t[54]=k,t[55]=P,t[56]=F):F=t[56];let I;t[57]!==O||t[58]!==F?(I=(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[O,F]}),t[57]=O,t[58]=F,t[59]=I):I=t[59];let L;return t[60]!==I||t[61]!==T?(L=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[T,I]}),t[60]=I,t[61]=T,t[62]=L):L=t[62],L}function xt(){let e=o(e=>e.language),t=a(e),n=t.imageModelsSettings,r=!!s(e=>e.token),[i,c]=(0,Z.useReducer)(_e,yt),{saving:l,error:u}=i,p=v(),m=(0,Z.useMemo)(()=>new Set(p.map(e=>e.id)),[p]),{data:h=[],isLoading:g}=f(r?lt():null,Ge,{revalidateOnFocus:!1}),{data:_,isLoading:y,mutate:b}=f(r?ut():null,pt,{revalidateOnFocus:!1}),{data:x,isLoading:S,mutate:w}=f(r?dt():null,ie,{revalidateOnFocus:!1}),T=h.some(e=>e.configured),E=qe(h),[D,O]=(0,Z.useState)(ft),[k,A]=(0,Z.useState)(ft);(0,Z.useEffect)(()=>{if(!x?.models)return;let e=mt(x.models);O(e),A(e)},[x?.models]);let j=JSON.stringify(D)!==JSON.stringify(k),M=E.credDirty||j;(0,Z.useEffect)(()=>{if(!M)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[M]),st({id:`image-models`,dirty:M,saving:l,save:(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{saving:!0,error:void 0}});try{if(j){if(!x?.models)throw Error(n.loadError);let e=await C(gt(x.models,D));await w(e,!1),await b();let t=mt(e.models);O(t),A(t)}E.credDirty&&(await E.saveCredentials(n.credentialsSaveError),await b()),c({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:n.saved})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{saving:!1}})}},[E,x?.models,j,D,w,b,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,Z.useCallback)(()=>{E.credDirty&&E.onDiscardCredentials(),j&&O(k),c({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[E,k,j])});let N=(0,Z.useMemo)(()=>vt(n),[n]),P=(0,Z.useMemo)(()=>_t(_?.imageUnderstanding.providers??[]),[_?.imageUnderstanding.providers]),F=(0,Z.useMemo)(()=>_t(_?.imageGeneration.providers??[]),[_?.imageGeneration.providers]),I=(0,Z.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]);return r?g||y||S?(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(K,{className:`size-4 animate-spin`}),` Loading…`]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u?(0,Q.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:u}):null,(0,Q.jsx)(bt,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:D.imageModel,fallbackValues:D.imageModelFallbacks,options:P,emptyLabel:n.noModelSelected,onValueChange:e=>O(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>O(t=>({...t,imageModelFallbacks:e}))}),(0,Q.jsx)(bt,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:D.imageGenerationModel,fallbackValues:D.imageGenerationModelFallbacks,options:F,emptyLabel:n.noModelSelected,onValueChange:e=>O(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>O(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,Q.jsx)(`input`,{type:`number`,min:1,value:D.imageGenerationModelTimeoutMs,onChange:e=>O(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:D.imageGenerationModelAutoProviderFallback,onChange:e=>O(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,Q.jsx)(tt,{icon:ge,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:T,children:h.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Q.jsx)($e,{summaries:h,credDraft:E.credDraft,credBaseline:E.credBaseline,credDirty:E.credDirty,credSaving:E.credSaving,credError:E.credError,credSavedFlash:E.credSavedFlash,credNoopFlash:E.credNoopFlash,updateCredRow:E.updateCredRow,onDiscardCredentials:E.onDiscardCredentials,onSaveCredentials:()=>void E.saveCredentials(n.credentialsSaveError),extensionIds:m,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:I,messages:N})})]}):(0,Q.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var St=G;function Ct(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function wt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Tt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function Et(){return i(S,G)}function Dt(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ot(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var kt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],At=[{id:`whisper-1`,name:`Whisper-1`}],jt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Mt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Nt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Pt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Ft=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],It=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Lt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Rt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],zt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Bt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Vt(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Ht(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Ut(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Wt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Gt(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function Kt(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function qt(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function Jt(){let e=a(o(e=>e.language)).voiceSettings,t=!!s(e=>e.token),[n,r]=(0,Z.useReducer)(qt,{form:null,baseline:null}),i=n.form,l=n.baseline,[u,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v=(0,Z.useRef)(!1),y=(0,Z.useRef)({parsed:null,models:void 0}),{data:b,error:x,isLoading:S,mutate:C}=xe(t),{data:w,error:T,isLoading:E,mutate:D}=f(t?c(`/api/voice/models`):null,Je,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=f(t?c(`/api/voice/providers`):null,Xe,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=f(t?c(`/api/voice/stt-providers`):null,Ue,{revalidateOnFocus:!1}),P=(0,Z.useMemo)(()=>O?.providers??[],[O]),F=(0,Z.useMemo)(()=>j?.providers??[],[j]),I=(0,Z.useMemo)(()=>b?.payload?.config===void 0?null:Ye(b.payload.config),[b]),L=(0,Z.useMemo)(()=>!i||!l?!1:JSON.stringify(i)!==JSON.stringify(l),[i,l]);t?I!==null&&w!==void 0&&!v.current&&(y.current.parsed!==I||y.current.models!==w)&&(y.current={parsed:I,models:w},r({type:`sync`,value:I}),p(w)):(y.current.parsed!==null||y.current.models!==void 0)&&(y.current={parsed:null,models:void 0},r({type:`reset`}),p(null),v.current=!1);let R=!!(t&&(I===null||w===void 0||O===void 0||j===void 0)&&(S||E||A||N)),z=x instanceof Error?x.message:x?String(x):T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):M instanceof Error?M.message:M?String(M):null,V=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),ee=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),te=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),ne=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),re=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),H=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),U=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),W=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),G=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ie=(0,Z.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(st({id:`voice`,dirty:L,saving:m,save:(0,Z.useCallback)(async()=>{if(!(!i||m)){h(!0),_(null);try{await Ze(i),r({type:`saved`,value:i}),v.current=!1,d({type:`success`,title:e.saved})}catch(t){_(t instanceof Error?t.message:e.saveError)}finally{h(!1)}}},[i,m,e.saveError]),discard:(0,Z.useCallback)(()=>{l&&(v.current=!1,r({type:`discard`}),_(null))},[l])}),!t)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.needToken})});if(R)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(K,{className:`size-4 animate-spin`}),e.loading]})});if(!i||u===null)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??z??e.loadError}),(0,Q.jsx)(B,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:e.retry})]});let ae=i.stt,oe=i.tts,q=Wt(e);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(Yt,{v:e,stt:ae,tts:oe}),(0,Q.jsx)(Zt,{v:e,apiKeyLabels:q,stt:ae,models:u,sttProviders:F,updateStt:V,updateSttAlibaba:ee,updateSttOpenai:te,updateSttFallback:ne}),(0,Q.jsx)(nn,{v:e,apiKeyLabels:q,tts:oe,models:u,ttsProviders:P,updateTts:re,updateTtsAlibaba:H,updateTtsOpenai:U,updateTtsEdge:W,updateTtsMinimax:G,updateTtsLocalCli:ie})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Q.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Q.jsx)(`strong`,{className:`text-accent`,children:e.notes.title}),` `,e.notes.duration]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.notes.envVars})]})]})}function Yt(e){let t=(0,X.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Bt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Q.jsx)(Xt,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Ht(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Q.jsx)(Xt,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Vt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Q.jsx)(Xt,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Q.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function Xt(e){let t=(0,X.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s=a?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=i(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Q.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function Zt(e){let t=(0,X.c)(46),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:kt,p=o?.stt?.openai?.length?o.stt.openai:At,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==a||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter(tn),C;t[17]!==a.provider||t[18]!==a.providers||t[19]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[17]=a.provider,t[18]=a.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(F,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==a.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,Q.jsx)(rn,{checked:a.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=a.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=a.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:n.stt.provider}),(0,Q.jsx)(J,{className:Et(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Q.jsxs)(Y,{value:e.id,children:[Bt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,Q.jsx)(J,{className:Et(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(en)}):a.provider===`openai`?(0,Q.jsx)(J,{className:Et(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map($t)}):a.provider===`groq`?(0,Q.jsx)(J,{className:Et(),value:m||jt[0].id,onChange:e=>w({model:e.target.value}),children:jt.map(Qt)}):(0,Q.jsx)(`input`,{className:Tt(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:n.stt.apiKey}),(0,Q.jsx)(Qe,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Ct(a.provider)?` ${Ct(a.provider)}`:``]})]})]}),S.length>0?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Q.jsx)(an,{field:e,value:Gt(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:St},e.key))}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,Q.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,Q.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function Qt(e){return(0,Q.jsx)(Y,{value:e.id,children:e.name},e.id)}function $t(e){return(0,Q.jsx)(Y,{value:e.id,children:e.name},e.id)}function en(e){return(0,Q.jsx)(Y,{value:e.id,children:e.name},e.id)}function tn(e){return e.key!==`apiKey`&&e.key!==`model`}function nn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:a,updateTts:o,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Mt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Nt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Pt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Ft,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:It,_=r?.tts?.minimax?.length?r.tts.minimax:Lt,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Rt,[y,b]=(0,Z.useState)(e.tts.test.sampleText),[x,S]=(0,Z.useState)({status:`idle`}),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=(0,Z.useCallback)(()=>{C.current?.pause(),C.current=null,w.current&&=(URL.revokeObjectURL(w.current),null)},[]),E=(0,Z.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.id)||(e.add(n.id),t.push(n));return t},[a]),D=E.find(e=>e.id===n.provider),O=n.providers?.[n.provider],k={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...O??{}},A=(D?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),j=!!D?.diagnostics.requiresApiKey,M=!!D?.configured||!j,N=n.enabled?M?`ready`:`action`:`muted`,P=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,F=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,Z.useEffect)(()=>()=>T(),[T]);let I=(0,Z.useCallback)(e=>{o({provider:e}),S({status:`idle`})},[o]),L=(0,Z.useCallback)(async()=>{let t=y.trim();if(!t){S({status:`error`,message:e.tts.test.emptyText});return}T(),S({status:`loading`});try{let r=await We({text:t,provider:n.provider,providerConfig:k,...P?{model:P}:{},...F?{voice:F}:{}}),i=Ot(r.audio,r.mimeType);w.current=i;let a=new Audio(i);C.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Dt(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>S({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>S({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),S({status:`playing`,summary:o})}catch(e){T(),S({status:`error`,message:e instanceof Error?e.message:String(e)})}},[P,F,k,T,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),z=(0,Z.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),V=(0,Z.useCallback)((e,t)=>{let r={[e.key]:t};z(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,z,l,u,c]);return(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(R,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(rn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>o({enabled:e})}),(0,Q.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,N===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:N===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Q.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?M?`${e.tts.statusReady} ${Vt(n.provider,e)}${F?` · ${F}`:``}`:`${e.tts.statusNeedsSetup} ${Vt(n.provider,e)} · ${D?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:e.tts.trigger}),(0,Q.jsxs)(J,{className:Et(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,Q.jsx)(Y,{value:`off`,children:e.tts.triggerOff}),(0,Q.jsx)(Y,{value:`inbound`,children:e.tts.triggerInbound}),(0,Q.jsx)(Y,{value:`tagged`,children:e.tts.triggerTagged}),(0,Q.jsx)(Y,{value:`always`,children:e.tts.triggerAlways})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:e.tts.provider}),(0,Q.jsx)(J,{className:Et(),value:n.provider,onChange:e=>I(e.target.value),children:E.map(t=>(0,Q.jsx)(Y,{value:t.id,children:Vt(t.id,e)},t.id))}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[D?.configured?e.tts.configured:D?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${D.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,D?.description??Ut(n.provider,e)]})]})]}),(0,Q.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,open:!M||n.provider===`tts-local-cli`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Q.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:e.stt.apiKey}),(0,Q.jsx)(Qe,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,wt(n.provider)?` ${wt(n.provider)}`:``]})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:e.stt.model}),(0,Q.jsx)(J,{className:Et(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Q.jsx)(Y,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:e.tts.voice}),(0,Q.jsx)(J,{className:Et(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,Q.jsx)(Y,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,St),children:[(0,Q.jsx)($,{children:e.tts.voice}),(0,Q.jsx)(J,{className:Et(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Q.jsx)(Y,{value:e.id,children:e.name},e.id))}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.preset}),(0,Q.jsxs)(J,{className:Et(),value:``,onChange:e=>{let t=zt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Q.jsx)(Y,{value:``,children:e.tts.localCli.presetPlaceholder}),zt.map(e=>(0,Q.jsx)(Y,{value:e.id,children:e.id},e.id))]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.command}),(0,Q.jsx)(`input`,{className:i(Tt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)($,{children:e.tts.localCli.cwd}),(0,Q.jsx)(`input`,{className:i(Tt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Q.jsxs)(J,{className:Et(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Q.jsx)(Y,{value:`wav`,children:`wav`}),(0,Q.jsx)(Y,{value:`mp3`,children:`mp3`}),(0,Q.jsx)(Y,{value:`opus`,children:`opus`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Q.jsx)(`input`,{className:Tt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,A.length>0?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:A.map(e=>(0,Q.jsx)(an,{field:e,value:Gt(k,e),onChange:t=>V(e,t),className:e.type===`textarea`?`sm:col-span-2`:St},e.key))}):null]})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(B,{type:`button`,variant:`primary`,onClick:()=>void L(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(ze,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Q.jsxs)(B,{type:`button`,variant:`secondary`,onClick:()=>{T(),S(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,Q.jsx)(fe,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Q.jsx)(`textarea`,{className:i(Tt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,Q.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function rn(e){let t=(0,X.c)(33),{checked:n,title:r,description:a,onLabel:o,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`border-accent/45 bg-accent/10 text-fg shadow-surface dark:bg-accent/15`:`border-edge bg-surface-panel text-fg hover:border-accent/35 hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl border px-4 py-3 text-left transition-colors`,b,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?o:s,h;t[7]!==p||t[8]!==m?(h=(0,Q.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===a?_=t[14]:(_=(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:a}),t[13]=a,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,x;t[18]===y?x=t[19]:(x=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=x);let S=n?`translate-x-5`:`translate-x-0.5`,C;t[20]===S?C=t[21]:(C=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,S),t[20]=S,t[21]=C);let w;t[22]===C?w=t[23]:(w=(0,Q.jsx)(`span`,{className:C}),t[22]=C,t[23]=w);let T;t[24]!==x||t[25]!==w?(T=(0,Q.jsx)(`span`,{className:x,"aria-hidden":!0,children:w}),t[24]=x,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==T||t[31]!==d?(E=(0,Q.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,T]}),t[27]=n,t[28]=l,t[29]=v,t[30]=T,t[31]=d,t[32]=E):E=t[32],E}function an(e){let t=(0,X.c)(36),{field:n,value:r,onChange:a,className:o}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===o?e=t[1]:(e=i(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,Q.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==a?(f=e=>a(Kt(n,e.target.checked)),t[9]=n,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,Q.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===o?u=t[20]:(u=i(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,Q.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,Q.jsx)(J,{id:s,className:Et(),value:l,required:n.required,onChange:e=>a(Kt(n,e.target.value)),children:(n.options??[]).map(on)}):n.type===`textarea`?(0,Q.jsx)(`textarea`,{id:s,className:i(Tt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Kt(n,e.target.value))}):n.type===`password`?(0,Q.jsx)(me,{id:s,className:o,value:l,onChange:e=>a(Kt(n,e)),placeholder:n.placeholder,labels:De}):(0,Q.jsx)(`input`,{id:s,className:Tt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Kt(n,e.target.value))}),t[23]=o,t[24]=n,t[25]=l,t[26]=s,t[27]=a,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,Q.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function on(e){return(0,Q.jsx)(Y,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function sn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function cn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Ce()}async function ln(e){let t=await l(c(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function un(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function dn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function fn(){return i(S,G)}var pn=[`brave`,`tavily`,`bing`,`searxng`];function mn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var hn=Ae();function gn(){let e=a(o(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!s(e=>e.token),[c,l]=(0,Z.useReducer)(hn,{form:null,baseline:null}),u=c.form,f=c.baseline,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(!1),v=(0,Z.useRef)(null),{data:y,error:b,isLoading:x,mutate:S}=xe(r);Ie({enabled:r,parsed:(0,Z.useMemo)(()=>y?.payload?.config===void 0?null:sn(y.payload.config),[y]),dirty:_.current,trackedParsedRef:v,dispatch:l,onResetDirty:()=>{_.current=!1}});let C=!!(r&&x&&y===void 0&&!b),w=b instanceof Error?b.message:b?String(b):null,T=(0,Z.useMemo)(()=>!u||!f?!1:JSON.stringify(u)!==JSON.stringify(f),[u,f]),E=(0,Z.useCallback)(e=>{_.current=!0,l({type:`patch`,patch:e})},[]);return st({id:`search`,dirty:T,saving:p,save:(0,Z.useCallback)(async()=>{if(!(!u||p)){m(!0),g(null);try{await cn(u),_.current=!1,l({type:`saved`,value:u}),d({type:`success`,title:t.saved})}catch(e){g(e instanceof Error?e.message:t.saveError)}finally{m(!1)}}},[u,p,t.saveError]),discard:(0,Z.useCallback)(()=>{f&&(_.current=!1,l({type:`discard`}),g(null))},[f])}),r?C?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(K,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading})]}):u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Q.jsxs)(rt,{children:[(0,Q.jsx)(nt,{icon:Re,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Q.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Q.jsx)(un,{label:t.regionLabel,description:t.regionDesc,children:(0,Q.jsxs)(J,{className:fn(),value:u.regionMode,onChange:e=>E({regionMode:e.target.value}),children:[(0,Q.jsx)(Y,{value:`auto`,children:t.regionAuto}),(0,Q.jsx)(Y,{value:`cn`,children:t.regionCn}),(0,Q.jsx)(Y,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Q.jsx)(et,{children:(0,Q.jsxs)(rt,{children:[(0,Q.jsx)(nt,{icon:ke,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:u.blocklistEnabled,onChange:e=>E({blocklistEnabled:e.target.checked})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,Q.jsx)(un,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Q.jsx)(`textarea`,{className:i(dn(),`min-h-[6rem] font-mono text-xs`),value:u.blocklistDomains.join(`
2
- `),placeholder:t.blocklistDomainsPlaceholder,disabled:!u.blocklistEnabled,onChange:e=>{E({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Q.jsxs)(rt,{children:[(0,Q.jsx)(nt,{icon:Re,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Q.jsx)(un,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:50,className:dn(),value:u.maxResults,onChange:e=>E({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),u.providers.map((n,r)=>(0,Q.jsx)(_n,{row:n,providerIndex:r,labels:t,secretLabels:Se(e.providersSettings),onChange:e=>{let t=[...u.providers];t[r]=e,E({providers:t})},onRemove:()=>{E({providers:u.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,Q.jsxs)(B,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>E({providers:[...u.providers,mn()]}),children:[(0,Q.jsx)(U,{className:`size-4`}),t.addProvider]})]})]})]}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??w??t.loadError}),(0,Q.jsx)(B,{type:`button`,variant:`secondary`,onClick:()=>void S(),children:n.refresh})]}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function _n(e){let t=(0,X.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>ln(r).then(vn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(fn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==s||t[4]!==n?(p=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=p):p=t[5];let m;t[6]===a.providerTypes?m=t[7]:(m=pn.map(e=>(0,Q.jsx)(Y,{value:e,children:a.providerTypes[e]},e)),t[6]=a.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,Q.jsx)(J,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==n?(g=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,Q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:g}),t[15]=n.disabled,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==a.disabled||t[19]!==_?(v=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,a.disabled]}),t[18]=a.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(q,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,Q.jsx)(B,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:y}),t[22]=c,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==h?(S=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,x]}),t[27]=x,t[28]=h,t[29]=S):S=t[29];let C;t[30]!==a.urlDesc||t[31]!==a.urlLabel||t[32]!==s||t[33]!==n?(C=n.type===`searxng`?(0,Q.jsx)(un,{label:a.urlLabel,description:a.urlDesc,children:(0,Q.jsx)(`input`,{type:`url`,className:dn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=a.urlDesc,t[31]=a.urlLabel,t[32]=s,t[33]=n,t[34]=C):C=t[34];let w;t[35]!==s||t[36]!==n?(w=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=w):w=t[37];let T;t[38]!==a.keyPlaceholder||t[39]!==a.keyPlaceholderMasked||t[40]!==a.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==o||t[44]!==w?(T=(0,Q.jsx)(me,{value:n.apiKey,onChange:w,placeholder:a.keyPlaceholder,labels:o,reveal:u,loadFailedLabel:a.saveError,notInConfigFile:a.keyPlaceholderMasked}),t[38]=a.keyPlaceholder,t[39]=a.keyPlaceholderMasked,t[40]=a.saveError,t[41]=u,t[42]=n.apiKey,t[43]=o,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==a.apiKeyDesc||t[47]!==a.apiKeyLabel||t[48]!==T?(E=(0,Q.jsx)(un,{label:a.apiKeyLabel,description:a.apiKeyDesc,children:T}),t[46]=a.apiKeyDesc,t[47]=a.apiKeyLabel,t[48]=T,t[49]=E):E=t[49];let D;return t[50]!==S||t[51]!==C||t[52]!==E?(D=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=D):D=t[53],D}function vn(e){return e.apiKey??null}function yn(){let e=(0,X.c)(31),t=s(wn),n=!!t,{data:r,isLoading:i}=xe(n),a;e[0]===n?a=e[1]:(a=n?c(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},e[4]=l):l=e[4];let{data:u,isLoading:d}=f(a,o,l),p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[5]=p):p=e[5];let{data:m,isLoading:h}=f(n?ve:null,Cn,p),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=f(n?ne:null,Sn,v),b;bb0:{if(!u||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==u||e[12]!==_?(t=N(u,ue(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=u,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=oe(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==u||e[19]!==_){w=[];let t=new Set((u??[]).filter(xn).map(bn)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=u,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||d||h,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function bn(e){return e.id}function xn(e){return e.configured}function Sn(){return k()}function Cn(){return Le()}function wn(e){return e.token}function Tn(e){let t=(0,X.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=yn();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-surface-hover`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(Dn)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(En),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(U,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,Q.jsxs)(B,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,Q.jsxs)(B,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,Q.jsx)(U,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,Q.jsx)(On,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function En(e){return e.configured}function Dn(e){return(0,Q.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function On(e){let t=(0,X.c)(28),{card:n,labels:r,onManage:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=i(`group relative flex flex-col justify-between rounded-2xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,H.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,Q.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=n.isCustom?(0,Q.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(E,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(Fe,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,Q.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==a||t[25]!==g||t[26]!==d?(_=(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:o,children:[d,g]}),t[24]=a,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function kn(e){let t=await u(c(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function An(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function jn(e,t){let n=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function Mn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Nn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Pn(e){let t=await u(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Fn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function In(e){let t=new Map;for(let e of Fn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Ln(e){let t=(0,X.c)(22),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Z.useState)(u),[p,m]=(0,Z.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,_;t[3]!==g||t[4]!==l?(_=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(T,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,he)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,Pe),t[7]=b):b=t[7];let x;t[8]!==a||t[9]!==o||t[10]!==v||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(x=(0,Q.jsxs)(P,{children:[y,(0,Q.jsx)(ae,{className:b,children:d.type===`pick`?(0,Q.jsx)(zn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>{let t=w(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Q.jsx)(Bn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v}):(0,Q.jsx)(Un,{initialPresetKey:d.presetKey,customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=a,t[9]=o,t[10]=v,t[11]=s,t[12]=c,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=x):x=t[17];let S;return t[18]!==g||t[19]!==n||t[20]!==x?(S=(0,Q.jsx)(je,{open:n,onOpenChange:g,children:x}),t[18]=g,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function Rn(e){let t=(0,X.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function zn(e){let t=(0,X.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:a,labels:o,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=x[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=In(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,Q.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=h);let g;t[11]===o.close?g=t[12]:(g=(0,Q.jsx)(Rn,{label:o.close}),t[11]=o.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(Re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]===a?y=t[18]:(y=e=>a(e.target.value),t[17]=a,t[18]=y);let S=o.searchPlaceholder,C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,b),t[19]=C):C=t[19];let w;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==y?(w=(0,Q.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[v,(0,Q.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:S,autoComplete:`off`,autoFocus:!0,className:C})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=y,t[23]=w):w=t[23];let T;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(T=u?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:c,className:i(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,H.press),children:[(0,Q.jsx)(be,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,Q.jsx)(M,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=o.addCustom,t[25]=o.customDescription,t[26]=c,t[27]=u,t[28]=T):T=t[28];let D;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(D=f.length===0?(0,Q.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:Fn.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:i(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,H.press),children:[(0,Q.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Q.jsx)(E,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=D):D=t[34];let O;t[35]!==T||t[36]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[T,D]}),t[35]=T,t[36]=D,t[37]=O):O=t[37];let k;return t[38]!==w||t[39]!==O||t[40]!==_?(k=(0,Q.jsxs)(Q.Fragment,{children:[_,w,O]}),t[38]=w,t[39]=O,t[40]=_,t[41]=k):k=t[41],k}function Bn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=x[e],[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),v=(0,Z.useRef)(null),y=a(r).providersSettings,S=Se(y),C=(0,Z.useMemo)(()=>ee(e,r),[e,r]),w=c?.supportsApiKey!==!1,T=c?.supportsOAuth===!0,[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(`idle`),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(null),[z,V]=(0,Z.useState)(``),te=N===`waiting`||N===`waiting_code`;(0,Z.useEffect)(()=>{if(!D||!te)return;let e=window.setInterval(()=>{(async()=>{try{let t=await An(D);t.status===`waiting_auth`||t.status===`waiting_code`?(P(t.status===`waiting_code`?`waiting_code`:`waiting`),A(t.message??null),I(t.authUrl??null),R(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),P(`success`),A(t.message??y.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),P(`error`),A(t.error??t.message??y.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[D,te,s,y.revokeFailed,y.saved]),(0,Z.useEffect)(()=>()=>{D&&Nn(D).catch(()=>{})},[D]);let ne=async()=>{P(`waiting`),A(y.oauthStarting),h(null);try{O((await kn(e)).sessionId)}catch(e){P(`error`),A(e instanceof Error?e.message:y.revokeFailed)}},re=async()=>{if(D){try{await Mn(D)}catch{}P(`idle`),A(null),O(null),I(null),R(null)}},U=async()=>{if(!(!D||!z.trim()))try{await jn(D,z.trim()),V(``),A(y.oauthProcessingCode)}catch(e){P(`error`),A(e instanceof Error?e.message:y.revokeFailed)}},W=async()=>{let t=u.trim();if(!(!t||!w)){p(!0),h(null);try{await de({[e]:t}),_(!0),window.setTimeout(s,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),"aria-label":n.back,children:(0,Q.jsx)(M,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Q.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Q.jsx)(Rn,{label:n.close})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,w?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Q.jsx)(me,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:S,inputRef:v,onKeyDown:e=>{e.key===`Enter`&&W()}})]}):null,T?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.oauth}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:y.oauthHint})]}),(0,Q.jsxs)(B,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:te,onClick:()=>void ne(),children:[te?(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,y.oauth]})]}),k?(0,Q.jsx)(`p`,{className:i(`text-xs`,N===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:k}):null,N===`waiting`||N===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[F?(0,Q.jsxs)(`a`,{href:F,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[y.openAuthPage,(0,Q.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Q.jsx)(B,{type:`button`,variant:`secondary`,onClick:()=>void re(),children:y.cancelOAuth})]}):null,L?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:L}):null,N===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Q.jsx)(`input`,{type:`text`,value:z,onChange:e=>V(e.target.value),onKeyDown:e=>e.key===`Enter`&&void U(),placeholder:y.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),(0,Q.jsx)(B,{type:`button`,variant:`primary`,onClick:()=>void U(),children:y.submitCode})]}):null]}):null,C.length>0&&w?(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map(({kind:e,href:t})=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[Ee(e,n),(0,Q.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)(B,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),w?(0,Q.jsx)(B,{type:`button`,variant:`primary`,disabled:!u.trim()||f||g,onClick:()=>void W(),children:g?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Vn(e=`custom`){if(e!==`custom`&&Te[e]){let t=Te[e].config;return{preset:e,providerId:I(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Hn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:Te[t.key]?Vn(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Un({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:o,onSaved:s}){let[c,l]=(0,Z.useReducer)(Hn,void 0,()=>Vn(e)),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=Se(a(r).providersSettings),{preset:g,providerId:_,baseUrl:v,api:y,apiKey:x,modelIds:S,error:C}=c,w=async()=>{let e=_.trim(),r=v.trim();if(!e){l({type:`setError`,value:n.providerIdRequired});return}if(!r){l({type:`setError`,value:n.baseUrlRequired});return}let i=S.map(e=>e.trim()).filter(Boolean);d(!0),l({type:`setError`,value:null});try{let n=t?.providers??{},a=g===`custom`?void 0:Te[g]?.config,o={...a??{},baseUrl:r,api:y,apiKey:x.trim()||void 0,models:i.map(e=>a?.models?.find(t=>t.id===e)??{id:e})};await le({providers:{...n,[e]:o}}),s()}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},T=async()=>{let e=_.trim()||I(g)||`custom`,t=v.trim();if(!t){l({type:`setError`,value:n.baseUrlRequired});return}p(!0),l({type:`setError`,value:null});try{let r=g===`custom`?void 0:Te[g]?.config,i=(await ce({providerId:e,baseUrl:t,apiKey:x.trim()||void 0,api:y,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));l({type:`setModelIds`,values:i}),i.length===0&&l({type:`setError`,value:n.discoverModelsHint})}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},E=_.trim()&&v.trim(),D=(y===`openai-completions`||y===`openai-responses`)&&v.trim();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),"aria-label":n.back,children:(0,Q.jsx)(M,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Q.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,Q.jsx)(Rn,{label:n.close})]}),(0,Q.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,Q.jsxs)(J,{id:`custom-preset`,value:g,onChange:e=>l({type:`applyPreset`,key:e.target.value}),className:re(),children:[(0,Q.jsx)(Y,{value:`custom`,children:n.presetCustom}),L.map(e=>(0,Q.jsx)(Y,{value:e.key,children:e.label},e.key))]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,Q.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:_,onChange:e=>l({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Q.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:v,onChange:e=>l({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,Q.jsx)(J,{id:`custom-api-type`,value:y,onChange:e=>l({type:`setApi`,value:e.target.value}),className:re(),children:He.map(e=>(0,Q.jsx)(Y,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Q.jsx)(me,{id:`custom-api-key`,value:x,onChange:e=>l({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,Q.jsxs)(B,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!D||f,onClick:()=>void T(),children:[f?(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),S.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>l({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),S.length>1?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l({type:`removeModelSlot`,index:t}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,H.press),children:(0,Q.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,Q.jsxs)(B,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>l({type:`addModelSlot`}),children:[(0,Q.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),C?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,Q.jsx)(B,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),(0,Q.jsx)(B,{type:`button`,variant:`primary`,disabled:!E||u,onClick:()=>void w(),children:u?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Wn(e){let t=(0,X.c)(156),{model:n,isNew:r,providerId:a,onSave:o,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:_(``),t[0]=n,t[1]=l);let[u,d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(Gn),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let v=m,y;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(y=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=y):y=t[8];let b=y,x;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==b?(x=()=>{if(!b())return;let e=(u.id||``).trim();o({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),s()},t[9]=u,t[10]=s,t[11]=o,t[12]=b,t[13]=x):x=t[13];let S=x,C=u,w;t[14]===C?w=t[15]:(w=A(C),t[14]=C,t[15]=w);let T=w,E=r?c.addModelTitle:c.editModelTitle,D;t[16]===E?D=t[17]:(D=(0,Q.jsx)(j,{className:`text-base font-semibold text-fg`,children:E}),t[16]=E,t[17]=D);let k;t[18]!==c.modelProviderLabel||t[19]!==a?(k=a?(0,Q.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,a]}):null,t[18]=c.modelProviderLabel,t[19]=a,t[20]=k):k=t[20];let M;t[21]!==D||t[22]!==k?(M=(0,Q.jsxs)(`div`,{children:[D,k]}),t[21]=D,t[22]=k,t[23]=M):M=t[23];let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=i(Be,`p-1.5 hover:bg-surface-base`),t[24]=N):N=t[24];let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(h,{className:`size-4`}),t[25]=P):P=t[25];let F;t[26]===c.close?F=t[27]:(F=(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:N,"aria-label":c.close,children:P})}),t[26]=c.close,t[27]=F);let I;t[28]!==M||t[29]!==F?(I=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[M,F]}),t[28]=M,t[29]=F,t[30]=I):I=t[30];let L;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=L):L=t[31];let R;t[32]===c.modelId?R=t[33]:(R=(0,Q.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,L]}),t[32]=c.modelId,t[33]=R);let V;t[34]===f?V=t[35]:(V=i(z(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=V);let ee=u.id||``,ne;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>v(`id`,e.target.value),t[36]=ne):ne=t[36];let H=!r,U;t[37]!==V||t[38]!==ee||t[39]!==H?(U=(0,Q.jsx)(`input`,{className:V,value:ee,onChange:ne,placeholder:`e.g. llama3.1:8b`,disabled:H}),t[37]=V,t[38]=ee,t[39]=H,t[40]=U):U=t[40];let W;t[41]===f?W=t[42]:(W=f.has(`id`)?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=W);let G;t[43]!==R||t[44]!==U||t[45]!==W?(G=(0,Q.jsxs)(`div`,{children:[R,U,W]}),t[43]=R,t[44]=U,t[45]=W,t[46]=G):G=t[46];let ie;t[47]===c.displayName?ie=t[48]:(ie=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=ie);let ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae=z(),t[49]=ae):ae=t[49];let K=u.name||``,oe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>v(`name`,e.target.value),t[50]=oe):oe=t[50];let q;t[51]===K?q=t[52]:(q=(0,Q.jsx)(`input`,{className:ae,value:K,onChange:oe}),t[51]=K,t[52]=q);let se;t[53]!==ie||t[54]!==q?(se=(0,Q.jsxs)(`div`,{children:[ie,q]}),t[53]=ie,t[54]=q,t[55]=se):se=t[55];let ce;t[56]===c.inputTypes?ce=t[57]:(ce=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=ce);let le;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(le=re(),t[58]=le):le=t[58];let ue;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>v(`input`,te(e.target.value)),t[59]=ue):ue=t[59];let de;t[60]===c?de=t[61]:(de=g.map(e=>(0,Q.jsx)(Y,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=de);let fe;t[62]!==T||t[63]!==de?(fe=(0,Q.jsx)(J,{className:le,value:T,onChange:ue,children:de}),t[62]=T,t[63]=de,t[64]=fe):fe=t[64];let pe;t[65]!==ce||t[66]!==fe?(pe=(0,Q.jsxs)(`div`,{children:[ce,fe]}),t[65]=ce,t[66]=fe,t[67]=pe):pe=t[67];let me=u.reasoning||!1,he;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>v(`reasoning`,e.target.checked),t[68]=he):he=t[68];let ge;t[69]===me?ge=t[70]:(ge=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:me,onChange:he}),t[69]=me,t[70]=ge);let _e;t[71]!==c.reasoning||t[72]!==ge?(_e=(0,Q.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ge,c.reasoning]}),t[71]=c.reasoning,t[72]=ge,t[73]=_e):_e=t[73];let ve;t[74]!==pe||t[75]!==_e?(ve=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[pe,_e]}),t[74]=pe,t[75]=_e,t[76]=ve):ve=t[76];let ye;t[77]===c.contextWindow?ye=t[78]:(ye=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=ye);let be;t[79]===f?be=t[80]:(be=i(z(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=be);let xe=u.contextWindow??128e3,Se;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>v(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=Se):Se=t[81];let Ce;t[82]!==be||t[83]!==xe?(Ce=(0,Q.jsx)(`input`,{type:`number`,min:1,className:be,value:xe,onChange:Se}),t[82]=be,t[83]=xe,t[84]=Ce):Ce=t[84];let we;t[85]===f?we=t[86]:(we=f.has(`contextWindow`)?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=we);let Te;t[87]!==ye||t[88]!==Ce||t[89]!==we?(Te=(0,Q.jsxs)(`div`,{children:[ye,Ce,we]}),t[87]=ye,t[88]=Ce,t[89]=we,t[90]=Te):Te=t[90];let Ee;t[91]===c.maxOutputTokens?Ee=t[92]:(Ee=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=Ee);let De;t[93]===f?De=t[94]:(De=i(z(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=De);let Oe=u.maxTokens??16384,ke;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>v(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=ke):ke=t[95];let Ae;t[96]!==De||t[97]!==Oe?(Ae=(0,Q.jsx)(`input`,{type:`number`,min:1,className:De,value:Oe,onChange:ke}),t[96]=De,t[97]=Oe,t[98]=Ae):Ae=t[98];let je;t[99]===f?je=t[100]:(je=f.has(`maxTokens`)?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=je);let Me;t[101]!==Ee||t[102]!==Ae||t[103]!==je?(Me=(0,Q.jsxs)(`div`,{children:[Ee,Ae,je]}),t[101]=Ee,t[102]=Ae,t[103]=je,t[104]=Me):Me=t[104];let Ne;t[105]!==Te||t[106]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Te,Me]}),t[105]=Te,t[106]=Me,t[107]=Ne):Ne=t[107];let Pe;t[108]===c.costSection?Pe=t[109]:(Pe=(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Pe);let Fe;t[110]===c.costInput?Fe=t[111]:(Fe=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=Fe);let Ie;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=z(),t[112]=Ie):Ie=t[112];let Le=u.cost?.input??0,Re;t[113]===u.cost?Re=t[114]:(Re=e=>v(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=Re);let ze;t[115]!==Le||t[116]!==Re?(ze=(0,Q.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[115]=Le,t[116]=Re,t[117]=ze):ze=t[117];let Ve;t[118]!==Fe||t[119]!==ze?(Ve=(0,Q.jsxs)(`div`,{children:[Fe,ze]}),t[118]=Fe,t[119]=ze,t[120]=Ve):Ve=t[120];let He;t[121]===c.costOutput?He=t[122]:(He=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=He);let Ue;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=z(),t[123]=Ue):Ue=t[123];let We=u.cost?.output??0,Ge;t[124]===u.cost?Ge=t[125]:(Ge=e=>v(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=Ge);let Ke;t[126]!==We||t[127]!==Ge?(Ke=(0,Q.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ue,value:We,onChange:Ge}),t[126]=We,t[127]=Ge,t[128]=Ke):Ke=t[128];let qe;t[129]!==He||t[130]!==Ke?(qe=(0,Q.jsxs)(`div`,{children:[He,Ke]}),t[129]=He,t[130]=Ke,t[131]=qe):qe=t[131];let Je;t[132]!==Ve||t[133]!==qe?(Je=(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Ve,qe]}),t[132]=Ve,t[133]=qe,t[134]=Je):Je=t[134];let Ye;t[135]!==Pe||t[136]!==Je?(Ye=(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Pe,Je]}),t[135]=Pe,t[136]=Je,t[137]=Ye):Ye=t[137];let Xe;t[138]!==G||t[139]!==se||t[140]!==ve||t[141]!==Ne||t[142]!==Ye?(Xe=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[G,se,ve,Ne,Ye]}),t[138]=G,t[139]=se,t[140]=ve,t[141]=Ne,t[142]=Ye,t[143]=Xe):Xe=t[143];let Ze;t[144]===c.cancel?Ze=t[145]:(Ze=(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(B,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=Ze);let Qe=r?c.addModelConfirm:c.saveModelConfirm,$e;t[146]!==S||t[147]!==Qe?($e=(0,Q.jsx)(B,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:S,children:Qe}),t[146]=S,t[147]=Qe,t[148]=$e):$e=t[148];let et;t[149]!==Ze||t[150]!==$e?(et=(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Ze,$e]}),t[149]=Ze,t[150]=$e,t[151]=et):et=t[151];let tt;return t[152]!==I||t[153]!==Xe||t[154]!==et?(tt=(0,Q.jsxs)(Q.Fragment,{children:[I,Xe,et]}),t[152]=I,t[153]=Xe,t[154]=et,t[155]=tt):tt=t[155],tt}function Gn(){return new Map}function Kn(e){let t=(0,X.c)(16),{open:n,onOpenChange:r,providerId:a,model:o,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(T,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,he)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,Pe,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==a?(f=n?(0,Q.jsx)(Wn,{model:o,isNew:s,providerId:a,onSave:c,onClose:()=>r(!1),m:l},`${a??`none`}-${o?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=o,t[5]=r,t[6]=c,t[7]=n,t[8]=a,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,Q.jsxs)(P,{children:[u,(0,Q.jsx)(ae,{className:d,onOpenAutoFocus:qn,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,Q.jsx)(je,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function qn(e){return e.preventDefault()}function Jn(e){let t=(0,X.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>pe(n).then(Yn),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,Q.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,Q.jsx)(me,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Yn(e){return e.apiKey??null}function Xn(e){let t=(0,X.c)(16),{open:n,onOpenChange:r,providerId:a,isCustom:o,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(T,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,he)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,Pe),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==o||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==a?(h=(0,Q.jsxs)(P,{children:[p,(0,Q.jsx)(ae,{className:m,children:o?(0,Q.jsx)(Qn,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Q.jsx)(Zn,{providerId:a,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=o,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=a,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,Q.jsx)(je,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function Zn({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=x[e],d=n.filter(t=>t.provider===e),[f,p]=(0,Z.useState)(l?.apiKey??``),[m,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=a(o).providersSettings,k=l?.supportsApiKey!==!1,A=l?.supportsOAuth===!0,M=l?.authMode===`oauth`&&l.authStatus===`connected`,N=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(`idle`),[V,te]=(0,Z.useState)(null),[ne,re]=(0,Z.useState)(null),[U,G]=(0,Z.useState)(``),ie=R===`waiting`||R===`waiting_code`,ae=(0,Z.useMemo)(()=>ee(e,o),[e,o]),oe=f!==(l?.apiKey??``),ce=async()=>{let t=f.trim();if(!(!t||!k||Me(t))){g(!0),S(null);try{await de({[e]:t}),v(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){S(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}};(0,Z.useEffect)(()=>{if(!P||!ie)return;let e=window.setInterval(()=>{(async()=>{try{let t=await An(P);t.status===`waiting_auth`||t.status===`waiting_code`?(z(t.status===`waiting_code`?`waiting_code`:`waiting`),L(t.message??null),te(t.authUrl??null),re(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),z(`success`),L(t.message??T.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),z(`error`),L(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ie,s,c,T.revokeFailed,T.saved]),(0,Z.useEffect)(()=>()=>{P&&Nn(P).catch(()=>{})},[P]);let le=async()=>{try{await D(e),c(),s()}catch{}},ue=async()=>{z(`waiting`),L(T.oauthStarting),S(null);try{F((await kn(e)).sessionId)}catch(e){z(`error`),L(e instanceof Error?e.message:T.revokeFailed)}},fe=async()=>{if(P){try{await Mn(P)}catch{}z(`idle`),L(null),F(null),te(null),re(null)}},pe=async()=>{if(!(!P||!U.trim()))try{await jn(P,U.trim()),G(``),L(T.oauthProcessingCode)}catch(e){z(`error`),L(e instanceof Error?e.message:T.revokeFailed)}},me=async()=>{try{await Pn(e),c(),s()}catch(e){S(e instanceof Error?e.message:T.revokeFailed)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsx)(j,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),children:(0,Q.jsx)(h,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.baseUrl?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,Q.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:l.baseUrl})]}):l?.category===`extension`?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,k?(0,Q.jsx)(Jn,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{p(e),v(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):l?.category===`extension`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:r.extensionKeyHint}),l?.extensionId?(0,Q.jsxs)(Oe,{to:`/settings/ext/${encodeURIComponent(l.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:s,children:[r.openExtensionSettings,(0,Q.jsx)(W,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,A?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:T.oauth}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:M?T.sourceOauth:T.oauthHint})]}),M?(0,Q.jsx)(B,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void me(),children:T.revoke}):(0,Q.jsxs)(B,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ie,onClick:()=>void ue(),children:[ie?(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),I?(0,Q.jsx)(`p`,{className:i(`text-xs`,R===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:I}):null,R===`waiting`||R===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[V?(0,Q.jsxs)(`a`,{href:V,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,Q.jsx)(W,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,Q.jsx)(B,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:T.cancelOAuth})]}):null,ne?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}):null,R===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Q.jsx)(`input`,{type:`text`,value:U,onChange:e=>G(e.target.value),onKeyDown:e=>e.key===`Enter`&&void pe(),placeholder:T.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),(0,Q.jsx)(B,{type:`button`,variant:`primary`,onClick:()=>void pe(),children:T.submitCode})]}):null]}):null,ae.length>0&&k?(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ae.map(({kind:e,href:t})=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[Ee(e,r),(0,Q.jsx)(W,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,Q.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,Q.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),y?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,Q.jsxs)(B,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>w(!0),children:[(0,Q.jsx)(q,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Q.jsx)(`span`,{}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:k&&oe&&!Me(f.trim())?(0,Q.jsx)(B,{type:`button`,variant:`primary`,disabled:!f.trim()||m||_,onClick:()=>void ce(),children:_?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):m?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Q.jsx)(ye,{open:C,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void le(),onCancel:()=>w(!1)})]})}function Qn({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,Z.useState)(l?.baseUrl??``),[f,p]=(0,Z.useState)(l?.apiKey??``),[m,g]=(0,Z.useState)(l?.models??[]),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),M=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:Me(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},N=async()=>{let e=M({models:m});if(e){v(!0),x(null);try{await le(e),s(),o()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{v(!1)}}},P=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await le({providers:r}),s(),o()}catch{}},F=(e,t)=>{A({model:e,isNew:t}),D(!0)},I=async e=>{if(!k)return;let t=k.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);g(t);let r=M({models:t});if(r)try{await le(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}},L=async e=>{let t=m.filter(t=>t.id!==e);g(t),T(null);let r=M({models:t});if(r)try{await le(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(j,{className:`text-base font-semibold text-fg`,children:e}),(0,Q.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),children:(0,Q.jsx)(h,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Q.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Q.jsx)(Jn,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,m.length>0?` (${m.length})`:``]}),(0,Q.jsxs)(B,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>F(null,!0),children:[(0,Q.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),m.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,Q.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),onClick:()=>F(e,!1),"aria-label":c.editModel,children:(0,Q.jsx)(V,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,H.press),onClick:()=>T(e.id),"aria-label":c.removeModel,children:(0,Q.jsx)(q,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),y?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,Q.jsxs)(B,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>C(!0),children:[(0,Q.jsx)(q,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(B,{type:`button`,variant:`primary`,disabled:_,onClick:()=>void N(),children:_?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(K,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Q.jsx)(ye,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void P(),onCancel:()=>C(!1)}),(0,Q.jsx)(ye,{open:w!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,w??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{w&&L(w)},onCancel:()=>T(null)}),(0,Q.jsx)(Kn,{open:E,onOpenChange:e=>{D(e),e||A(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void I(e),m:c})]})}var $n=[`services`,`image-models`,`voice`,`search`];function er(e){let t=(e??``).trim();return $n.includes(t)?t:`services`}function tr(){let e=(0,X.c)(59),t=o(rr),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.modelsHub,[s,c]=Ve(),l;e[2]===s?l=e[3]:(l=er(s.get(`tab`)),e[2]=s,e[3]=l);let u=l,[d,f]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),g=yn(),_;e[4]!==i.servicesHint||e[5]!==i.tabs.services?(_={id:`services`,icon:y,label:i.tabs.services,hint:i.servicesHint},e[4]=i.servicesHint,e[5]=i.tabs.services,e[6]=_):_=e[6];let v;e[7]!==i.imageModelsHint||e[8]!==i.tabs.imageModels?(v={id:`image-models`,icon:we,label:i.tabs.imageModels,hint:i.imageModelsHint},e[7]=i.imageModelsHint,e[8]=i.tabs.imageModels,e[9]=v):v=e[9];let b;e[10]!==i.tabs.voice||e[11]!==i.voiceHint?(b={id:`voice`,icon:F,label:i.tabs.voice,hint:i.voiceHint},e[10]=i.tabs.voice,e[11]=i.voiceHint,e[12]=b):b=e[12];let x;e[13]!==i.searchHint||e[14]!==i.tabs.search?(x={id:`search`,icon:Re,label:i.tabs.search,hint:i.searchHint},e[13]=i.searchHint,e[14]=i.tabs.search,e[15]=x):x=e[15];let S;e[16]!==_||e[17]!==v||e[18]!==b||e[19]!==x?(S=[_,v,b,x],e[16]=_,e[17]=v,e[18]=b,e[19]=x,e[20]=S):S=e[20];let C=S,w;e[21]===c?w=e[22]:(w=e=>{c(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=c,e[22]=w);let T=w,E=nr,D=r.settingsSections.credentials,O=i.subtitle,k;e[23]===t?k=e[24]:(k=p(t,`configuration`),e[23]=t,e[24]=k);let A;e[25]!==i.docsLink||e[26]!==i.subtitle||e[27]!==r.settingsSections.credentials||e[28]!==k?(A=(0,Q.jsx)(at,{title:D,subtitle:O,docsLink:k,docsLabel:i.docsLink}),e[25]=i.docsLink,e[26]=i.subtitle,e[27]=r.settingsSections.credentials,e[28]=k,e[29]=A):A=e[29];let j;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(ct,{}),e[30]=j):j=e[30];let M;e[31]!==u||e[32]!==i.tabsAria||e[33]!==T||e[34]!==C?(M=(0,Q.jsx)(it,{items:C,activeTab:u,onChange:T,ariaLabel:i.tabsAria,tabIdPrefix:`hub-tab`,panelIdPrefix:`hub-panel`}),e[31]=u,e[32]=i.tabsAria,e[33]=T,e[34]=C,e[35]=M):M=e[35];let N;e[36]!==u||e[37]!==i.connectedProviders||e[38]!==C?(N=C.map(e=>(0,Q.jsx)(ar,{id:e.id,activeTab:u,hint:e.hint,children:e.id===`services`?(0,Q.jsx)(Tn,{labels:i.connectedProviders,onAdd:()=>f(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,Q.jsx)(ir,{tab:e.id})},e.id)),e[36]=u,e[37]=i.connectedProviders,e[38]=C,e[39]=N):N=e[39];let P;e[40]!==d||e[41]!==i.addProviderDialog||e[42]!==t||e[43]!==g.builtinRows||e[44]!==g.customConfig?(P=(0,Q.jsx)(Ln,{open:d,onOpenChange:f,builtinRows:g.builtinRows,customConfig:g.customConfig,labels:i.addProviderDialog,language:t,onSaved:E}),e[40]=d,e[41]=i.addProviderDialog,e[42]=t,e[43]=g.builtinRows,e[44]=g.customConfig,e[45]=P):P=e[45];let I;e[46]!==i.manageProviderDialog||e[47]!==t||e[48]!==m||e[49]!==g.allModels||e[50]!==g.builtinRows||e[51]!==g.customConfig?(I=m?(0,Q.jsx)(Xn,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:g.builtinRows,customConfig:g.customConfig,allModels:g.allModels,labels:i.manageProviderDialog,language:t,onSaved:E}):null,e[46]=i.manageProviderDialog,e[47]=t,e[48]=m,e[49]=g.allModels,e[50]=g.builtinRows,e[51]=g.customConfig,e[52]=I):I=e[52];let L;return e[53]!==A||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==I?(L=(0,Q.jsxs)(ot,{children:[A,j,M,N,P,I]}),e[53]=A,e[54]=M,e[55]=N,e[56]=P,e[57]=I,e[58]=L):L=e[58],L}function nr(){m()}function rr(e){return e.language}function ir(e){let t=(0,X.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(xt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Jt,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(gn,{}),t[2]=e):e=t[2],e}}}function ar({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,Z.useRef)(a);return a&&(o.current=!0),o.current?(0,Q.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(`min-w-0 rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,a?`flex flex-col gap-3`:void 0),children:[a?(0,Q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{tr as ModelsHubPanel};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-Up_VIxLJ.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-BU1pvxmS.js","assets/preload-helper-zJ_50EbN.js","assets/dist-Mys7eFJ5.js","assets/Combination-HAlzriaz.js","assets/vendor-react-BOUWij0V.js","assets/cn-BQ_8x0bT.js","assets/vendor-swr-BIWyz7Rc.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-Ba72bFmP.js","assets/config-reload-event-Bjh2zoKp.js","assets/messages-C6Kc4Jhf.js","assets/fetch-Cs4ck8zA.js","assets/gateway-startup-retry-IvePwjFE.js","assets/toast-z0toXu32.js","assets/theme-store-Bt6vAkSB.js","assets/index-l54WfSqe.css","assets/vendor-codemirror-CNP1wPe7.js","assets/note-image-lightbox-BthwKjLA.js","assets/voice-player-store-DduWlJYV.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-AssmZFx4.js","assets/code-editor-dZTY2dRW.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-C6Kc4Jhf.js";import{n as s}from"./locale-store-Ba72bFmP.js";import{i as c}from"./theme-store-Bt6vAkSB.js";import{r as l}from"./toast-z0toXu32.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Aa as d,Bo as f,Ha as p,Ms as m,Oo as h,Ua as g,Yi as _,Zi as v,_c as y,_n as ee,an as b,bn as x,cc as te,cn as S,dn as C,eo as ne,gn as w,go as T,hn as E,i as D,ln as re,on as O,rn as ie,sn as k,ss as A,uc as j,vc as M,vn as N,vs as P,xs as F}from"./index-BU1pvxmS.js";import{n as ae,t as oe}from"./note-image-lightbox-BthwKjLA.js";import{t as se}from"./automation-suggestion-card-BHk5rtJz.js";import{r as I}from"./note-time-hm6JO_Wi.js";var L=n(),R=e(t(),1),z=r(),B={edit:h,ai_edit:ne,sync:T,restore:j};function ce(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function le({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let c=o(s(e=>e.language)).notes,f=c,{data:p}=u(e?[`note-history`,e]:null,()=>S(e)),[m,g]=(0,R.useState)(!1),[_,v]=(0,R.useState)(null),y=(0,R.useCallback)(async t=>{g(!0);try{await ee(e,t),l({type:`success`,title:c.restoreSuccess}),v(null),i()}catch{l({type:`error`,title:c.restoreFailed})}finally{g(!1)}},[e,c.restoreSuccess,c.restoreFailed,i]),b=Date.now();return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,z.jsx)(A,{className:`h-4 w-4`,"aria-hidden":!0}),c.history]}),(0,z.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,z.jsx)(d,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:p?.length?(0,z.jsx)(`ul`,{className:`divide-y divide-edge`,children:p.map(e=>{let r=B[e.trigger]??h,i=t===e.timestamp,o=_===e.timestamp;return(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:a(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:ce(e.trigger,c)}),(0,z.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:I(e.timestamp,b,f)})]}),e.snippet&&(0,z.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,z.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:c.restoreConfirm}),(0,z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),y(e.timestamp)},disabled:m,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:m?`...`:c.restore}),(0,z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),v(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:c.restore})})]},e.timestamp)})}):(0,z.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:c.historyEmpty}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:c.historyEmptyDescription})]})})]})}function ue(e){let t=(0,L.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:l,noteThreads:d,openingChat:m,onOpenChat:h,onOpenNewChat:_}=e,v=o(s(q)).notes,ee=y(),b=r?.aiDeep?.catalysis,x=b?.report??null,S;t[0]===n?S=t[1]:(S=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=S);let C;t[2]===n?C=t[3]:(C=()=>O(n),t[2]=n,t[3]=C);let T;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},t[4]=T):T=t[4];let{data:D,mutate:re,isLoading:ie}=u(S,C,T),k;t[5]===n?k=t[6]:(k=async e=>{try{await w(n,e)}catch{}},t[5]=n,t[6]=k);let A=k,j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,z.jsx)(ne,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=j):j=t[7];let M;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,z.jsx)(te,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=M):M=t[8];let N;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,z.jsx)(f,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=N):N=t[9],(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,(0,z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:v.catalysisSectionTitle})]}),(0,z.jsx)(`button`,{type:`button`,onClick:l,"aria-label":v.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:M})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,z.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:v.catalysisSectionDescription}),D?(0,z.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.contextStatusTitle}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void re(()=>E(n),{revalidate:!1}),disabled:ie,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:v.contextRebuild}),(0,z.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,D.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:D.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:D.status})]}),(0,z.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:v.contextStatusDetail.replace(`{{attachments}}`,String(D.attachments.length)).replace(`{{tokens}}`,String(D.tokenEstimate??0))}),D.attachments.length>0?(0,z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:D.attachments.slice(0,5).map(K)}):null]}):null,(0,z.jsx)(`button`,{type:`button`,onClick:c,disabled:i,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:i?v.processing:x?v.recatalyze:v.catalyzeAction}),x?(0,z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.valueHypothesis}),(0,z.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:x.valueHypothesis})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.targetUsers}),(0,z.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:x.targetUsers.slice(0,5).map(G)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.keyQuestions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.keyQuestions.slice(0,3).map(W)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.mvpPathLabel}),(0,z.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.mvpPath.slice(0,3).map(U)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.risks}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.risks.slice(0,3).map(H)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:v.nextActions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:x.nextActions.slice(0,4).map(V)})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:v.confidenceLabel.replace(`{{percent}}`,String(Math.round(x.confidence*100)))}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void A(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,b?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":v.feedbackHelpfulAria,children:(0,z.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void A(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,b?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":v.feedbackNotHelpfulAria,children:(0,z.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,z.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:v.noCatalysisReportHint}),(0,z.jsxs)(`section`,{className:`mt-6 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[N,v.relatedThreadsTitle]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v.relatedThreadsDescription})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:h,disabled:m,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:m?v.openingChat:v.openThread}),(0,z.jsx)(`button`,{type:`button`,onClick:_,disabled:m,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:v.newThread})]})]}),d.length>0?(0,z.jsx)(`div`,{className:`space-y-2`,children:d.slice(0,5).map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>ee(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||v.noteDiscussionFallback}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:v.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,z.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:v.noThreads})]})]})]})}function V(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,z.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function H(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,z.jsx)(`span`,{children:e})]},e)}function U(e,t){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,z.jsx)(`span`,{children:e})]},e)}function W(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,z.jsx)(`span`,{children:e})]},e)}function G(e){return(0,z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function K(e){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,z.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function q(e){return e.language}var J=()=>i(()=>import(`./block-editor-Up_VIxLJ.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])),Y=()=>i(()=>import(`./markdown-editor-AssmZFx4.js`).then(e=>e.n),__vite__mapDeps([22,1,3,18,6,23])),de=(0,R.lazy)(()=>J().then(e=>({default:e.BlockEditor}))),fe=(0,R.lazy)(()=>Y().then(e=>({default:e.MarkdownEditor})));function pe(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,z.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function me(e){let t=(0,L.c)(14),{mode:n,onModeChange:r,labels:i}=e,o;t[0]===i.edit?o=t[1]:(o={id:`wysiwyg`,label:i.edit,Icon:P},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:m},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:F},t[4]=i.preview,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=[o,s,c],t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:u.map(e=>{let{id:t,label:i,Icon:o}=e;return(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&J(),t===`source`&&Y()},onFocus:()=>{t===`wysiwyg`&&J(),t===`source`&&Y()},className:a(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,z.jsx)(o,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=u,t[12]=r,t[13]=d):d=t[13],d}function he(e){let t=(0,L.c)(9),{noteId:n,onBack:r,onSaved:i}=e,a=s(ge),c;t[0]===a?c=t[1]:(c=o(a),t[0]=a,t[1]=c);let l=c.notes.lightboxClose,u;t[2]!==n||t[3]!==r||t[4]!==i?(u=(0,z.jsx)(X,{noteId:n,onBack:r,onSaved:i}),t[2]=n,t[3]=r,t[4]=i,t[5]=u):u=t[5];let d;return t[6]!==l||t[7]!==u?(d=(0,z.jsx)(oe,{closeLabel:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8],d}function ge(e){return e.language}function X({noteId:e,onBack:t,onSaved:n}){let r=s(e=>e.language),i=o(r).notes,d=o(r).automations.suggestions,p=y(),m=c(e=>e.resolved)===`dark`,{openImage:h}=ae(),[g,ee]=(0,R.useState)(`wysiwyg`),[S,w]=(0,R.useState)(null),[T,E]=(0,R.useState)(null),[O,j]=(0,R.useState)(!1),[M,P]=(0,R.useState)(``),[F,oe]=(0,R.useState)(360),[I,L]=(0,R.useState)(!1),[B,ce]=(0,R.useState)(!1),[V,H]=(0,R.useState)(!1),U=(0,R.useRef)(!1),W=(0,R.useRef)(!1),G=(0,R.useRef)(null),K=(0,R.useRef)(null),q=(0,R.useRef)(null),J=(0,R.useRef)(null),Y=(0,R.useRef)(null),he=_(e=>e.setPageHeader),ge=_(e=>e.clearPageHeader),{data:X,mutate:Z}=u(e?[`note-detail`,e]:null,()=>b(e)),{data:_e=[],mutate:ve}=u(e?[`note-threads`,e]:null,()=>re(e),{revalidateOnFocus:!1});(0,R.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&Z()};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[Z,e]),(0,R.useEffect)(()=>{U.current=!1,P(``),E(null),w(null),W.current=!1},[e]),(0,R.useEffect)(()=>{!X||U.current||(P(X.title??``),U.current=!0)},[X]);let ye=X?new Date(X.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,be=(0,R.useMemo)(()=>(0,z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":i.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v),children:(0,z.jsx)(te,{className:`h-4 w-4`,"aria-hidden":!0})}),[i.back,t]),xe=(0,R.useCallback)(t=>{P(t),e&&(J.current=t,K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let t=J.current;if(J.current=null,t!==null){j(!0);try{await N(e,{title:t}),await Z(),n?.()}catch{}finally{j(!1)}}},600))},[e,Z,n]),Se=(0,R.useMemo)(()=>(0,z.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,v),children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:M||ye||void 0,children:M||ye}),O?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:i.saving}):null]}),[i.saving,O,ye,M]),Q=(0,R.useCallback)(async(t=!1)=>{H(!0);try{let n=await C(e,{forceNew:t});await Z(),await ve(),p(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){l({type:`error`,title:i.chatOpenFailedTitle,message:e instanceof Error?e.message:i.chatOpenFailedMessage})}finally{H(!1)}},[Z,ve,p,e,i.chatOpenFailedMessage,i.chatOpenFailedTitle]),Ce=(0,R.useCallback)(async()=>{ce(!0);try{await ie(e),await Z(),l({type:`success`,title:i.catalysisDone})}catch(e){l({type:`error`,title:i.catalysisFailed,message:e instanceof Error?e.message:i.chatOpenFailedMessage})}finally{ce(!1)}},[Z,e]),we=(0,R.useCallback)(()=>{w(S===`breakdown`?null:`breakdown`),!X?.aiDeep?.catalysis?.report&&!B&&Ce()},[S,B,Ce,X?.aiDeep?.catalysis?.report]),Te=(0,R.useMemo)(()=>(0,z.jsxs)(`div`,{className:a(`flex items-center gap-2`,v),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:we,disabled:B,"aria-label":i.catalysisSectionTitle,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,S===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,z.jsx)(ne,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B?i.catalyzing:i.catalyzeButton]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Q(!1),disabled:V,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,z.jsx)(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),V?i.openingChat:i.openChatButton]}),(0,z.jsx)(me,{mode:g,onModeChange:ee,labels:{edit:i.modeEdit,source:i.modeSource,preview:i.modePreview}}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>w(S===`history`?null:`history`),"aria-label":i.history,className:a(`rounded-lg p-1.5 transition-colors`,S===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,z.jsx)(A,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[B,we,Q,g,i.history,i.modeEdit,i.modePreview,i.modeSource,V,S]);(0,R.useLayoutEffect)(()=>(he({startExtra:be,main:X?Se:null,end:X?Te:null}),()=>ge()),[ge,Te,Se,be,X,he]);let Ee=(0,R.useCallback)(t=>{e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){j(!0);try{await N(e,{markdown:t}),await Z(),n?.()}catch(e){l({type:`error`,title:i.saveFailed,message:e instanceof Error?e.message:i.saveFailedHint})}finally{j(!1)}}},600))},[e,Z,i.saveFailed,i.saveFailedHint,n]),De=(0,R.useCallback)(t=>{k(e,t.timestamp).then(e=>{e&&E(e)})},[e]),Oe=(0,R.useCallback)(()=>{w(null),E(null)},[]),ke=(0,R.useCallback)(()=>{w(null),E(null),Z(),n?.()},[Z,n]);if((0,R.useEffect)(()=>()=>{G.current&&clearTimeout(G.current),K.current&&clearTimeout(K.current);let t=q.current,n=J.current;q.current=null,J.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&N(e,r)},[e]),X===void 0)return(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,z.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(X===null)return(0,z.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:i.notFoundTitle}),(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.notFoundDescription}),(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:i.back})]});let $=T!==null,Ae=$?T.title??``:M,je=$?T.markdown??``:X.markdown??``,Me=new Date(X.createdAt).getTime(),Ne=Number.isFinite(Me)&&Date.now()-Me<3600*1e3;return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(D,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,z.jsx)(D,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),Ne?(0,z.jsx)(se,{title:d.noteCreatedTitle,description:d.noteCreatedDescription,prompt:d.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},className:`mb-3 shrink-0`}):null,(0,z.jsx)(`div`,{ref:Y,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:$?(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Ae&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Ae}),je?(0,z.jsx)(x,{noteId:e,content:je,className:`opacity-80`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:i.emptyPreview})]}):(0,z.jsxs)(z.Fragment,{children:[g===`wysiwyg`&&(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,z.jsx)(`input`,{type:`text`,value:M,onChange:e=>xe(e.target.value),onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!W.current&&!t.isComposing&&(e.preventDefault(),(Y.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:i.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(pe,{}),children:(0,z.jsx)(de,{initialContent:X.markdown??``,onChange:Ee,noteId:e},`wysiwyg-${e}`)})})]}),g===`source`&&(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,z.jsx)(`input`,{type:`text`,value:M,onChange:e=>xe(e.target.value),placeholder:i.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(pe,{}),children:(0,z.jsx)(fe,{initialContent:X.markdown??``,onChange:Ee,isDark:m},`source-${e}`)})})]}),g===`preview`&&(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&h(t.currentSrc||t.src,t.alt)},children:[M&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:M}),X.markdown?(0,z.jsx)(x,{noteId:e,content:X.markdown,className:`[&_img]:cursor-zoom-in`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:i.emptyPreview})]})]})})]}),(0,z.jsx)(`div`,{className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!I&&`transition-[width] duration-300 ease-in-out`),style:{width:S?F:0},children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{width:F},children:[(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),L(!0);let n=e.clientX,r=F,i=e.pointerId,a=e=>{let t=r-(e.clientX-n);oe(Math.max(280,Math.min(600,t)))},o=()=>{try{t.releasePointerCapture(i)}catch{}L(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},className:a(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,I&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:S===`history`?(0,z.jsx)(le,{noteId:e,activeTimestamp:T?.timestamp??null,onSelect:De,onClose:Oe,onRestored:ke}):S===`breakdown`?(0,z.jsx)(ue,{noteId:e,note:X??null,catalyzing:B,onCatalyze:Ce,onClose:()=>w(null),noteThreads:_e,openingChat:V,onOpenChat:()=>Q(!1),onOpenNewChat:()=>Q(!0)}):null})]})})]})}function Z(){let e=(0,L.c)(5),{noteId:t}=M(),n=y(),r;e[0]===n?r=e[1]:(r=()=>{n(`/notes`)},e[0]=n,e[1]=r);let i=r;if(!t)return null;let a;return e[2]!==i||e[3]!==t?(a=(0,z.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,z.jsx)(he,{noteId:t,onBack:i})}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}export{Z as NoteDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{Aa as a,Gi as o,Hi as s,Ji as c,Ki as l,Ui as u,qi as d}from"./index-BU1pvxmS.js";var f=n(),p=e(t(),1),m=r(),h=(0,p.createContext)(null);function g(){let e=(0,f.c)(1),t=(0,p.useContext)(h);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:_},e[0]=t):t=e[0],t}return t}function _(){}function v(e){let t=(0,f.c)(22),{children:n,closeLabel:r}=e,g=r===void 0?`Close`:r,[_,v]=(0,p.useState)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=(e,t)=>{v({src:e,alt:t})},t[0]=y):y=t[0];let b=y,x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={openImage:b},t[1]=x):x=t[1];let S=x,C=_!==null,w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>{e||v(null)},t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,m.jsx)(o,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=T):T=t[3];let E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(E=i(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=E):E=t[4];let D=_?.alt||`Image preview`,O;t[5]===D?O=t[6]:(O=(0,m.jsx)(c,{className:`sr-only`,children:D}),t[5]=D,t[6]=O);let k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,m.jsx)(a,{className:`h-5 w-5`,"aria-hidden":!0}),t[7]=k):k=t[7];let A;t[8]===g?A=t[9]:(A=(0,m.jsx)(s,{asChild:!0,children:(0,m.jsx)(`button`,{type:`button`,"aria-label":g,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:k})}),t[8]=g,t[9]=A);let j;t[10]===_?j=t[11]:(j=_?(0,m.jsx)(`img`,{src:_.src,alt:_.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=_,t[11]=j);let M;t[12]!==A||t[13]!==j||t[14]!==O?(M=(0,m.jsxs)(l,{children:[T,(0,m.jsxs)(u,{className:E,"aria-describedby":void 0,children:[O,A,j]})]}),t[12]=A,t[13]=j,t[14]=O,t[15]=M):M=t[15];let N;t[16]!==M||t[17]!==C?(N=(0,m.jsx)(d,{open:C,onOpenChange:w,children:M}),t[16]=M,t[17]=C,t[18]=N):N=t[18];let P;return t[19]!==n||t[20]!==N?(P=(0,m.jsxs)(h.Provider,{value:S,children:[n,N]}),t[19]=n,t[20]=N,t[21]=P):P=t[21],P}export{g as n,v as t};
@@ -1 +0,0 @@
1
- var e=6e4,t=36e5,n=864e5;function r(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function i(i,a,o){let s=a-i;if(s<e)return o.justNow;if(s<t){let t=Math.floor(s/e);return o.minutesAgo.replace(`{{n}}`,String(t))}let c=r(a);if(i>=c)return o.today+` `+new Date(i).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(i>=c-n)return o.yesterday+` `+new Date(i).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(s<7*n){let e=Math.floor(s/n);return o.daysAgo.replace(`{{n}}`,String(e))}return new Date(i).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function a(e,t,i){let a=r(t);if(e>=a)return i.today;if(e>=a-n)return i.yesterday;let o=new Date(e),s=new Date(t);return o.getFullYear()===s.getFullYear()?o.toLocaleDateString(void 0,{month:`long`,day:`numeric`}):o.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function o(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}export{a as n,i as r,o as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-C6Kc4Jhf.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s}from"./fetch-Cs4ck8zA.js";import{r as c}from"./toast-z0toXu32.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{$a as u,Do as d,Eo as f,Ja as p,Lo as m,Tn as h,Uo as g,Va as _,Yi as v,Za as y,Zi as b,Zo as x,_c as S,ct as C,dc as w,fn as T,in as E,is as D,ko as O,lo as k,mn as A,nc as j,os as M,pn as N,un as P,uo as F,vn as I,wo as L,ws as R,xn as z}from"./index-BU1pvxmS.js";import{t as B}from"./voice-player-store-DduWlJYV.js";import{n as V,r as ee,t as H}from"./note-time-hm6JO_Wi.js";import{a as te,i as ne,n as U,o as re,r as ie,t as ae}from"./dist-wO9a2_ID.js";var oe=n(),W=e(t(),1),G=r();function se(e){let t=(0,oe.c)(15),{noteId:n,attachmentId:r,className:a}=e,[o,s]=(0,W.useState)(!1),c;t[0]!==r||t[1]!==n?(c=h(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c;if(o){let e;t[3]===a?e=t[4]:(e=i(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,a),t[3]=a,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsx)(M,{className:`h-4 w-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,G.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!0),t[8]=u):u=t[8];let d;t[9]===a?d=t[10]:(d=i(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,a),t[9]=a,t[10]=d);let f;return t[11]!==n||t[12]!==l||t[13]!==d?(f=(0,G.jsx)(z,{src:l,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:u,className:d}),t[11]=n,t[12]=l,t[13]=d,t[14]=f):f=t[14],f}function K(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function ce(e){let t=(0,oe.c)(38),{noteId:n,attachmentId:r,durationSec:a,className:o}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:d,attachmentId:f}=B(),p=B(J),m=d===n&&f===r,h=m&&s,_=m&&c,v=m?l:0,y=m&&u>0?u:a??0,b=y>0?Math.min(v/y*100,100):0,x;t[0]!==r||t[1]!==a||t[2]!==n||t[3]!==p?(x=e=>{e.stopPropagation(),p(n,r,a)},t[0]=r,t[1]=a,t[2]=n,t[3]=p,t[4]=x):x=t[4];let S=x,C;t[5]!==r||t[6]!==a||t[7]!==n||t[8]!==p?(C=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),p(n,r,a))},t[5]=r,t[6]=a,t[7]=n,t[8]=p,t[9]=C):C=t[9];let w=C,T;t[10]===o?T=t[11]:(T=i(`flex items-center gap-2`,o),t[10]=o,t[11]=T);let E=h?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,D;t[12]===E?D=t[13]:(D=i(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition-colors`,E),t[12]=E,t[13]=D);let k=h?`Pause`:`Play`,A;t[14]!==_||t[15]!==h?(A=_?(0,G.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):h?(0,G.jsx)(O,{className:`h-3.5 w-3.5`}):(0,G.jsx)(L,{className:`h-3.5 w-3.5 ml-0.5`}),t[14]=_,t[15]=h,t[16]=A):A=t[16];let j;t[17]!==S||t[18]!==w||t[19]!==D||t[20]!==k||t[21]!==A?(j=(0,G.jsx)(`button`,{type:`button`,onClick:S,onKeyDown:w,className:D,"aria-label":k,children:A}),t[17]=S,t[18]=w,t[19]=D,t[20]=k,t[21]=A,t[22]=j):j=t[22];let M=`${b}%`,N;t[23]===M?N=t[24]:(N=(0,G.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:M}})}),t[23]=M,t[24]=N);let P;t[25]!==y||t[26]!==m||t[27]!==v?(P=K(m&&v>0?v:y),t[25]=y,t[26]=m,t[27]=v,t[28]=P):P=t[28];let F;t[29]===P?F=t[30]:(F=(0,G.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:P}),t[29]=P,t[30]=F);let I;t[31]!==N||t[32]!==F?(I=(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[N,F]}),t[31]=N,t[32]=F,t[33]=I):I=t[33];let R;return t[34]!==I||t[35]!==T||t[36]!==j?(R=(0,G.jsxs)(`div`,{className:T,onClick:q,children:[j,I]}),t[34]=I,t[35]=T,t[36]=j,t[37]=R):R=t[37],R}function q(e){return e.stopPropagation()}function J(e){return e.toggle}var le={thought:x,todo:u,voice:m,media:D,bookmark:j,mixed:x,task:u};function ue(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Y(e){let t=(0,oe.c)(78),{note:n,onPress:r,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,u=le[n.kind]||x,p;t[0]!==c||t[1]!==n?(p=ue(n,c),t[0]=c,t[1]=n,t[2]=p):p=t[2];let m=p,h=!n.snippet?.trim(),[g]=(0,W.useState)(me),v;t[3]!==n.createdAt||t[4]!==g||t[5]!==l?(v=ee(n.createdAt,g,l),t[3]=n.createdAt,t[4]=g,t[5]=l,t[6]=v):v=t[6];let y=v,b,S;t[7]!==n.id||t[8]!==r?(b=()=>r(n.id),S=e=>{(e.key===`Enter`||e.key===` `)&&r(n.id)},t[7]=n.id,t[8]=r,t[9]=b,t[10]=S):(b=t[9],S=t[10]);let C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=i(`group relative flex cursor-pointer flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[11]=C):C=t[11];let T;t[12]!==u||t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(T=n.coverAttachmentId?(0,G.jsx)(se,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,G.jsx)(ce,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-32 shrink-0`}):(0,G.jsx)(u,{className:`mt-0.5 h-4 w-4 shrink-0 text-fg-muted`}),t[12]=u,t[13]=n.coverAttachmentId,t[14]=n.id,t[15]=n.kind,t[16]=n.voiceAttachmentId,t[17]=n.voiceDurationSec,t[18]=T):T=t[18];let E;t[19]===n.title?E=t[20]:(E=n.title&&(0,G.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[19]=n.title,t[20]=E);let D=n.title?`text-fg-muted`:h?`italic text-fg-muted`:`text-fg`,O;t[21]===D?O=t[22]:(O=i(`text-sm line-clamp-3`,D),t[21]=D,t[22]=O);let k;t[23]!==m||t[24]!==O?(k=(0,G.jsx)(`p`,{className:O,children:m}),t[23]=m,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,k]}),t[26]=k,t[27]=E,t[28]=A):A=t[28];let j;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,G.jsx)(re,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,onClick:pe,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-0 transition-opacity group-hover:opacity-100 hover:bg-surface-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":`Actions`,children:(0,G.jsx)(R,{className:`h-4 w-4`})})}),t[29]=j):j=t[29];let M;t[30]!==n.id||t[31]!==n.pinned||t[32]!==a?(M=()=>a(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=a,t[33]=M):M=t[33];let N;t[34]===n.pinned?N=t[35]:(N=n.pinned?(0,G.jsx)(f,{className:`h-4 w-4`}):(0,G.jsx)(d,{className:`h-4 w-4`}),t[34]=n.pinned,t[35]=N);let P=n.pinned?c.unpin:c.pin,F;t[36]!==M||t[37]!==N||t[38]!==P?(F=(0,G.jsxs)(U,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:M,children:[N,P]}),t[36]=M,t[37]=N,t[38]=P,t[39]=F):F=t[39];let I;t[40]!==n.id||t[41]!==o?(I=()=>o(n.id),t[40]=n.id,t[41]=o,t[42]=I):I=t[42];let L;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,G.jsx)(w,{className:`h-4 w-4`}),t[43]=L):L=t[43];let z;t[44]!==c.archive||t[45]!==I?(z=(0,G.jsxs)(U,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:I,children:[L,c.archive]}),t[44]=c.archive,t[45]=I,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,G.jsx)(te,{className:`my-1 h-px bg-edge-subtle`}),t[47]=B):B=t[47];let V;t[48]!==n.id||t[49]!==s?(V=()=>s(n.id),t[48]=n.id,t[49]=s,t[50]=V):V=t[50];let H;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,G.jsx)(_,{className:`h-4 w-4`}),t[51]=H):H=t[51];let K;t[52]!==c.delete||t[53]!==V?(K=(0,G.jsxs)(U,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:V,children:[H,c.delete]}),t[52]=c.delete,t[53]=V,t[54]=K):K=t[54];let q;t[55]!==F||t[56]!==z||t[57]!==K?(q=(0,G.jsxs)(ne,{children:[j,(0,G.jsx)(ie,{children:(0,G.jsxs)(ae,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:fe,children:[F,z,B,K]})})]}),t[55]=F,t[56]=z,t[57]=K,t[58]=q):q=t[58];let J;t[59]!==A||t[60]!==q||t[61]!==T?(J=(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[T,A,q]}),t[59]=A,t[60]=q,t[61]=T,t[62]=J):J=t[62];let Y;t[63]===n.pinned?Y=t[64]:(Y=n.pinned&&(0,G.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,G.jsx)(d,{className:`h-3 w-3`})}),t[63]=n.pinned,t[64]=Y);let X;t[65]===n.tags?X=t[66]:(X=n.tags?.map(de),t[65]=n.tags,t[66]=X);let Z;t[67]===y?Z=t[68]:(Z=(0,G.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:y}),t[67]=y,t[68]=Z);let Q;t[69]!==Y||t[70]!==X||t[71]!==Z?(Q=(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Y,X,Z]}),t[69]=Y,t[70]=X,t[71]=Z,t[72]=Q):Q=t[72];let he;return t[73]!==J||t[74]!==Q||t[75]!==b||t[76]!==S?(he=(0,G.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:b,onKeyDown:S,className:C,children:[J,Q]}),t[73]=J,t[74]=Q,t[75]=b,t[76]=S,t[77]=he):he=t[77],he}function de(e){return(0,G.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function fe(e){return e.stopPropagation()}function pe(e){return e.stopPropagation()}function me(){return Date.now()}var X=3e4;function Z(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function Q({placeholder:e,sendLabel:t,onCapture:n,onImagePick:r,onVoiceCapture:a,recordingLabel:o=`Recording…`,imageDisabled:s=!1,voiceDisabled:c=!1}){let[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(!1),[p,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(0),[v,b]=(0,W.useState)(!1),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),w=(0,W.useRef)([]),T=(0,W.useRef)(0),E=(0,W.useRef)(null),O=(0,W.useRef)(null),A=(0,W.useCallback)(()=>{E.current&&=(clearInterval(E.current),null),O.current&&=(clearTimeout(O.current),null),C.current?.getTracks().forEach(e=>e.stop()),C.current=null,S.current=null,w.current=[],h(!1),_(0)},[]);(0,W.useEffect)(()=>()=>A(),[A]);let j=(0,W.useCallback)(async()=>{let e=S.current;if(!e||e.state!==`recording`)return;b(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-T.current)/1e3)),n=e.mimeType||Z()||`audio/webm`,r=new Blob(w.current,{type:n});if(A(),r.size>0&&a){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,i=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await a(i,t)}finally{b(!1)}return}b(!1)},[A,a]),M=(0,W.useCallback)(async()=>{if(!(!a||v||p)&&!(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`))try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=Z(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);C.current=e,S.current=n,w.current=[],T.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&w.current.push(e.data)},n.start(),h(!0),_(0),E.current=setInterval(()=>{_(Math.round((Date.now()-T.current)/1e3))},250),O.current=setTimeout(()=>{j()},X)}catch{A()}},[A,a,p,j,v]),N=(0,W.useCallback)(()=>{if(p){j();return}M()},[p,M,j]),P=(0,W.useCallback)(async e=>{let t=l.trim();if(!(!t||d)){f(!0),u(``);try{await n(t,e)}catch{u(t)}finally{f(!1),x.current?.focus()}}},[l,d,n]),F=(0,W.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),P()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),P({navigate:!1}))},[P]),I=d||v;return(0,G.jsxs)(`div`,{className:i(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel px-2 py-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,p&&`border-danger ring-1 ring-danger/40`),children:[r&&(0,G.jsx)(`button`,{type:`button`,onClick:r,disabled:I||s||p,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Image`,children:(0,G.jsx)(D,{className:`h-4 w-4`})}),a&&(0,G.jsx)(`button`,{type:`button`,onClick:N,disabled:I||c||d,className:i(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,p?`bg-danger-soft text-danger hover:bg-danger-soft`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-label":p?`Stop recording`:`Voice`,"aria-pressed":p,children:p?(0,G.jsx)(y,{className:`h-4 w-4 fill-current`}):(0,G.jsx)(m,{className:`h-4 w-4`})}),p?(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:o.replace(`{{seconds}}`,String(g))}):(0,G.jsx)(`textarea`,{ref:x,value:l,onChange:e=>u(e.target.value),onKeyDown:F,placeholder:e,rows:1,disabled:I,className:`min-h-8 flex-1 resize-none bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,G.jsx)(`button`,{type:`button`,disabled:!l.trim()||I||p,onClick:e=>void P({navigate:!e.shiftKey}),"aria-label":t,className:i(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,l.trim()&&!I&&!p?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,G.jsx)(k,{className:`h-4 w-4`})})]})}var he={statusFilter:`all`,kindFilter:`all`,search:``};function $(){let e=(0,oe.c)(110),t=a(o(xe)).notes,n=!!s(be),[r,u]=(0,W.useReducer)(C,he),[d]=(0,W.useState)(ye),f=S(),m;e[0]!==n||e[1]!==r.kindFilter||e[2]!==r.search||e[3]!==r.statusFilter?(m=n?[`notes-list`,r.statusFilter,r.kindFilter,r.search]:null,e[0]=n,e[1]=r.kindFilter,e[2]=r.search,e[3]=r.statusFilter,e[4]=m):m=e[4];let h=m,g;e[5]!==r.kindFilter||e[6]!==r.search||e[7]!==r.statusFilter?(g=()=>P({status:r.statusFilter===`all`?void 0:r.statusFilter,kind:r.kindFilter===`all`?void 0:r.kindFilter,search:r.search||void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),e[5]=r.kindFilter,e[6]=r.search,e[7]=r.statusFilter,e[8]=g):g=e[8];let _;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(_={keepPreviousData:!0},e[9]=_):_=e[9];let{data:y,mutate:x,isLoading:w}=l(h,g,_),D=w&&!y,O;e[10]===y?.items?O=e[11]:(O=y?.items??[],e[10]=y?.items,e[11]=O);let k=O,j=y?.total??0,M,L;e[12]===x?(M=e[13],L=e[14]):(M=()=>{let e=()=>{x()};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},L=[x],e[12]=x,e[13]=M,e[14]=L),(0,W.useEffect)(M,L);let R=v(ve),z=v(_e),B=j>0?t.noteCount.replace(`{{count}}`,String(j)):null,ee,te;e[15]!==z||e[16]!==n||e[17]!==t.title||e[18]!==B||e[19]!==R?(ee=()=>n?(R({startExtra:null,main:(0,G.jsxs)(`div`,{className:i(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,b),children:[(0,G.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),B?(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:B}):null]}),end:null}),()=>z()):(z(),()=>z()),te=[z,n,t.title,B,R],e[15]=z,e[16]=n,e[17]=t.title,e[18]=B,e[19]=R,e[20]=ee,e[21]=te):(ee=e[20],te=e[21]),(0,W.useLayoutEffect)(ee,te);let ne;e[22]!==t.daysAgo||e[23]!==t.justNow||e[24]!==t.minutesAgo||e[25]!==t.today||e[26]!==t.yesterday?(ne={justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo},e[22]=t.daysAgo,e[23]=t.justNow,e[24]=t.minutesAgo,e[25]=t.today,e[26]=t.yesterday,e[27]=ne):ne=e[27];let U=ne,re;e[28]!==x||e[29]!==f?(re=async(e,t)=>{let n=await T(e,`web`);await x(),t?.navigate!==!1&&f(`/notes/${n.id}`)},e[28]=x,e[29]=f,e[30]=re):re=e[30];let ie=re,ae;e[31]!==x||e[32]!==t.imageUploadFailed||e[33]!==t.imageUploadFailedHint?(ae=()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let n=e.files?.[0];if(n)try{await N(n,`web`),await x()}catch(e){let n=e;c({type:`error`,title:t.imageUploadFailed,message:n instanceof Error?n.message:t.imageUploadFailedHint})}},e.click()},e[31]=x,e[32]=t.imageUploadFailed,e[33]=t.imageUploadFailedHint,e[34]=ae):ae=e[34];let se=ae,K;e[35]!==x||e[36]!==t.voiceUploadFailed||e[37]!==t.voiceUploadFailedHint?(K=async(e,n)=>{try{await A(e,n,`web`),await x()}catch(e){let n=e;c({type:`error`,title:t.voiceUploadFailed,message:n instanceof Error?n.message:t.voiceUploadFailedHint})}},e[35]=x,e[36]=t.voiceUploadFailed,e[37]=t.voiceUploadFailedHint,e[38]=K):K=e[38];let ce=K,q;e[39]===x?q=e[40]:(q=async(e,t)=>{await I(e,{pinned:t}),await x()},e[39]=x,e[40]=q);let J=q,le;e[41]===x?le=e[42]:(le=async e=>{await I(e,{status:`archived`}),await x()},e[41]=x,e[42]=le);let ue=le,de;e[43]===x?de=e[44]:(de=async e=>{await E(e),await x()},e[43]=x,e[44]=de);let fe=de,pe;e[45]===f?pe=e[46]:(pe=e=>{f(`/notes/${e}`)},e[45]=f,e[46]=pe);let me=pe;if(!n){let n;e[47]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsx)(p,{className:`h-10 w-10 text-fg-muted`}),e[47]=n):n=e[47];let r;return e[48]===t.needToken?r=e[49]:(r=(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n,(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]}),e[48]=t.needToken,e[49]=r),r}let X;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,G.jsx)(F,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),e[50]=X):X=e[50];let Z;e[51]===u?Z=e[52]:(Z=e=>u({type:`patch`,patch:{search:e.target.value}}),e[51]=u,e[52]=Z);let $;e[53]!==t.searchPlaceholder||e[54]!==Z||e[55]!==r.search?($=(0,G.jsxs)(`div`,{className:`relative`,children:[X,(0,G.jsx)(`input`,{type:`search`,value:r.search,onChange:Z,placeholder:t.searchPlaceholder,className:`w-full rounded-xl border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`})]}),e[53]=t.searchPlaceholder,e[54]=Z,e[55]=r.search,e[56]=$):$=e[56];let Se;e[57]===Symbol.for(`react.memo_cache_sentinel`)?(Se=[`all`,`inbox`,`processed`,`archived`],e[57]=Se):Se=e[57];let Ce;e[58]!==u||e[59]!==t.filterAll||e[60]!==t.filterArchived||e[61]!==t.filterInbox||e[62]!==t.filterProcessed||e[63]!==r.statusFilter?(Ce=Se.map(e=>{let n=e===`all`?t.filterAll:e===`inbox`?t.filterInbox:e===`processed`?t.filterProcessed:t.filterArchived;return(0,G.jsx)(`button`,{type:`button`,onClick:()=>u({type:`patch`,patch:{statusFilter:e}}),className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,r.statusFilter===e?`bg-accent text-white`:`bg-surface-hover text-fg-muted hover:text-fg`),children:n},e)}),e[58]=u,e[59]=t.filterAll,e[60]=t.filterArchived,e[61]=t.filterInbox,e[62]=t.filterProcessed,e[63]=r.statusFilter,e[64]=Ce):Ce=e[64];let we,Te;e[65]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,G.jsx)(`div`,{className:`mx-1 h-4 w-px bg-edge-subtle`}),Te=[`all`,`thought`,`todo`,`voice`,`media`,`bookmark`],e[65]=we,e[66]=Te):(we=e[65],Te=e[66]);let Ee;e[67]!==u||e[68]!==t.kindAll||e[69]!==t.kindBookmark||e[70]!==t.kindMedia||e[71]!==t.kindThought||e[72]!==t.kindTodo||e[73]!==t.kindVoice||e[74]!==r.kindFilter?(Ee=Te.map(e=>{let n=e===`all`?t.kindAll:e===`thought`?t.kindThought:e===`todo`?t.kindTodo:e===`voice`?t.kindVoice:e===`media`?t.kindMedia:t.kindBookmark;return(0,G.jsx)(`button`,{type:`button`,onClick:()=>u({type:`patch`,patch:{kindFilter:e}}),className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,r.kindFilter===e?`bg-accent text-white`:`bg-surface-hover text-fg-muted hover:text-fg`),children:n},e)}),e[67]=u,e[68]=t.kindAll,e[69]=t.kindBookmark,e[70]=t.kindMedia,e[71]=t.kindThought,e[72]=t.kindTodo,e[73]=t.kindVoice,e[74]=r.kindFilter,e[75]=Ee):Ee=e[75];let De;e[76]!==Ce||e[77]!==Ee?(De=(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Ce,we,Ee]}),e[76]=Ce,e[77]=Ee,e[78]=De):De=e[78];let Oe;e[79]!==$||e[80]!==De?(Oe=(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4 p-4 pb-2`,children:[$,De]}),e[79]=$,e[80]=De,e[81]=Oe):Oe=e[81];let ke;e[82]!==ue||e[83]!==fe||e[84]!==me||e[85]!==J||e[86]!==t.archive||e[87]!==t.delete||e[88]!==t.imageNote||e[89]!==t.noNotes||e[90]!==t.noNotesDescription||e[91]!==t.noText||e[92]!==t.pin||e[93]!==t.unpin||e[94]!==k||e[95]!==d||e[96]!==D||e[97]!==U?(ke=(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pt-3 pb-24 [scrollbar-gutter:stable]`,children:D?(0,G.jsx)(`div`,{className:`flex flex-col gap-3`,children:[1,2,3].map(ge)}):k.length===0?(0,G.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-2 py-16 text-center`,children:[(0,G.jsx)(p,{className:`h-8 w-8 text-fg-muted`}),(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:t.noNotes}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.noNotesDescription})]}):(0,G.jsx)(`div`,{className:`flex flex-col gap-3`,children:k.map((e,n)=>{let r=n>0?H(k[n-1].createdAt):null;return(0,G.jsxs)(`div`,{children:[H(e.createdAt)!==r&&(0,G.jsx)(`div`,{className:i(`pb-2 text-xs font-medium text-fg-muted`,n>0&&`pt-2`),children:V(e.createdAt,d,U)}),(0,G.jsx)(Y,{note:e,onPress:me,onPin:J,onArchive:ue,onDelete:fe,timeLabels:U,labels:{pin:t.pin,unpin:t.unpin,archive:t.archive,delete:t.delete,imageNote:t.imageNote,noText:t.noText}})]},e.id)})})}),e[82]=ue,e[83]=fe,e[84]=me,e[85]=J,e[86]=t.archive,e[87]=t.delete,e[88]=t.imageNote,e[89]=t.noNotes,e[90]=t.noNotesDescription,e[91]=t.noText,e[92]=t.pin,e[93]=t.unpin,e[94]=k,e[95]=d,e[96]=D,e[97]=U,e[98]=ke):ke=e[98];let Ae;e[99]!==ie||e[100]!==se||e[101]!==ce||e[102]!==t.quickCapturePlaceholder||e[103]!==t.recording||e[104]!==t.send?(Ae=(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-gradient-to-t from-surface-panel from-60% via-surface-panel/90 to-transparent px-4 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-6`,children:(0,G.jsx)(`div`,{className:`pointer-events-auto`,children:(0,G.jsx)(Q,{placeholder:t.quickCapturePlaceholder,sendLabel:t.send,onCapture:ie,onImagePick:se,onVoiceCapture:ce,recordingLabel:t.recording})})}),e[99]=ie,e[100]=se,e[101]=ce,e[102]=t.quickCapturePlaceholder,e[103]=t.recording,e[104]=t.send,e[105]=Ae):Ae=e[105];let je;return e[106]!==Oe||e[107]!==ke||e[108]!==Ae?(je=(0,G.jsxs)(`div`,{className:`relative mx-auto flex h-full min-h-0 w-full max-w-3xl flex-1 flex-col overflow-hidden`,children:[Oe,ke,Ae]}),e[106]=Oe,e[107]=ke,e[108]=Ae,e[109]=je):je=e[109],je}function ge(e){return(0,G.jsx)(`div`,{className:`h-24 animate-pulse rounded-xl bg-surface-hover`},e)}function _e(e){return e.clearPageHeader}function ve(e){return e.setPageHeader}function ye(){return Date.now()}function be(e){return e.token}function xe(e){return e.language}export{$ as NotesPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-C6Kc4Jhf.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,c,i as l,n as u,o as d,t as f}from"./fetch-Cs4ck8zA.js";import{a as p,i as m}from"./vendor-swr-BIWyz7Rc.js";import{$n as h,Ba as g,Da as _,Gi as v,Ji as y,Js as b,Ki as x,No as S,Oa as C,Os as w,Rs as T,Ss as E,Ui as D,Uo as O,Vi as k,Wa as A,Wi as j,Zs as M,_a as N,ar as P,ca as F,co as I,cr as L,ct as R,dr as z,er as B,f as V,fs as H,gi as U,go as ee,hi as W,ir as G,lr as K,mc as te,nr as q,or as J,qi as Y,qt as ne,ro as X,rr as re,sa as ie,sr as ae,ta as oe,to as se,tr as ce,ts as le,ur as ue,va as de,wr as fe,xo as pe,yc as me}from"./index-BU1pvxmS.js";import{t as he}from"./settings-collapsible-section-s-kiLAxP.js";import{n as ge,r as _e,t as ve}from"./settings-form-section-CIxIEYxU.js";import{t as ye}from"./browser-BLJWD7WI.js";import{i as be,n as xe,r as Se,t as Ce}from"./settings-page-layout--6qT7ZJa.js";var Z=n(),Q=e(t(),1);function we(e,t){let{mutate:n}=p(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),W()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await re();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await h();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await B(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await ce():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function Te(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function Ee(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:s,lanOnly:c,onRefreshQr:l}=e,u=s===void 0?!1:s,d=c===void 0?!1:c,f=o(ke),p;t[0]===f?p=t[1]:(p=a(f),t[0]=f,t[1]=p);let m=p,h=m.tunnelSettings,g=d?m.remoteAccess.lan:null,_;t[2]!==m.clipboard.copyFailed||t[3]!==h.pairCopied||t[4]!==h.pairCopyLink?(_={copy:h.pairCopyLink,copied:h.pairCopied,copyFailed:m.clipboard.copyFailed},t[2]=m.clipboard.copyFailed,t[3]=h.pairCopied,t[4]=h.pairCopyLink,t[5]=_):_=t[5];let v=_,{tunnelActive:y,tunnelStatus:b,tunnelQr:x,pairContext:S,pairBaseUrl:w,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,resetPairBaseFromContext:k,baseOk:A,localhostWarn:j,pairingBlocked:M,deepLink:N,qrPayload:P,qrDataUrl:F,qrGenFailed:I,encoding:L}=n,R;t[6]===k?R=t[7]:(R=e=>{k(e.recommended.url)},t[6]=k,t[7]=R);let z=we(r,R),B,H,U,W,G;if(t[8]!==D||t[9]!==E||t[10]!==A||t[11]!==z||t[12]!==r||t[13]!==g||t[14]!==d||t[15]!==j||t[16]!==l||t[17]!==w||t[18]!==S?.candidates||t[19]!==S?.recommended||t[20]!==M||t[21]!==T||t[22]!==u||t[23]!==h.pairBaseUrlHint||t[24]!==h.pairBaseUrlLabel||t[25]!==h.pairBaseUrlPlaceholder||t[26]!==h.pairBlockedLoopbackBody||t[27]!==h.pairBlockedNextSteps||t[28]!==h.pairBlockedTitle||t[29]!==h.pairCandidatesTitle||t[30]!==h.pairEnableLanButton||t[31]!==h.pairEnableLanEnabling||t[32]!==h.pairEnableLanSecurityAuditLink||t[33]!==h.pairInvalidBaseUrl||t[34]!==h.pairLocalhostWarning||t[35]!==h.pairSelectCandidateHint||t[36]!==h.pairSelectCandidateTitle||t[37]!==h.pairSubtitle||t[38]!==h.pairSuggestedLanLabel||t[39]!==h.pairTitle||t[40]!==h.pairTunnelActive||t[41]!==h.pairTunnelLanUrl||t[42]!==h.pairTunnelPublicUrl||t[43]!==h.pairUseSuggestedUrl||t[44]!==h.pairWaitingForTunnel||t[45]!==h.refreshQr||t[46]!==y||t[47]!==x||t[48]!==b?.publicUrl){G=Symbol.for(`react.early_return_sentinel`);bb0:{let e=S?.candidates.filter(Oe)??[],n=d?(e.find(De)?.url??e[0]?.url??``).trim():S?.recommended.url?.trim()??``,a=(d||!y)&&e.length>1,o=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:i(`text-xs font-medium`,r),children:a?h.pairSelectCandidateTitle:h.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:i(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,w.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>D(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),a?(0,$.jsx)(`p`,{className:i(`mt-1 text-[11px] leading-relaxed`,r),children:h.pairSelectCandidateHint}):null]})};if(B=u&&!d,B&&!y){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(se,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===h.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,h.pairTitle]}),t[55]=h.pairTitle,t[56]=n);let r;t[57]===h.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.pairWaitingForTunnel}),t[57]=h.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(ve,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],G=i;break bb0}let s=g?.pairTitle??h.pairTitle,c=d?g?.pairSubtitle??h.pairSubtitle:y?h.pairTunnelActive:h.pairSubtitle,f=!!(l&&(d||u&&y)),p=B?`mb-2`:`mb-3`,m;t[62]===p?m=t[63]:(m=i(`flex flex-wrap items-start justify-between gap-2`,p),t[62]=p,t[63]=m);let _;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(se,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=_):_=t[64];let v;t[65]===s?v=t[66]:(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[_,s]}),t[65]=s,t[66]=v);let k;t[67]!==B||t[68]!==c||t[69]!==h.pairSubtitle?(k=B?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:h.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c}),t[67]=B,t[68]=c,t[69]=h.pairSubtitle,t[70]=k):k=t[70];let N;t[71]!==v||t[72]!==k?(N=(0,$.jsxs)(`div`,{children:[v,k]}),t[71]=v,t[72]=k,t[73]=N):N=t[73];let P;t[74]!==l||t[75]!==f||t[76]!==h.refreshQr?(P=f?(0,$.jsxs)(C,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void l(),children:[(0,$.jsx)(ee,{className:`size-4`}),h.refreshQr]}):null,t[74]=l,t[75]=f,t[76]=h.refreshQr,t[77]=P):P=t[77],t[78]!==m||t[79]!==N||t[80]!==P?(H=(0,$.jsxs)(`div`,{className:m,children:[N,P]}),t[78]=m,t[79]=N,t[80]=P,t[81]=H):H=t[81],U=M?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:h.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:h.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:h.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(C,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:E,children:h.pairUseSuggestedUrl})]}):null,e.length>0?o(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(C,{type:`button`,className:`w-full sm:w-auto`,disabled:z.busy||!r,onClick:()=>z.setConfirmOpen(!0),children:[z.busy?(0,$.jsx)(O,{className:`size-3.5 animate-spin`}):null,z.busy?h.pairEnableLanEnabling:h.pairEnableLanButton]})}),z.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:z.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?g?.pairBlockedNextSteps??h.pairBlockedNextSteps:h.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(te,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:h.pairEnableLanSecurityAuditLink}),d&&g?.pairPublicTabLink?(0,$.jsx)(te,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairPublicTabLink}):null]})]}):null,W=y&&!d?B?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg border border-edge bg-surface-panel px-3 py-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:b?.publicUrl})]}),x?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:x.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:h.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:i(Te(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||h.pairBaseUrlPlaceholder,value:w,onChange:e=>T(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:h.pairBaseUrlHint}),!A&&w.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:h.pairInvalidBaseUrl}):null,j?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:h.pairLocalhostWarning}):null,a?o(`neutral`):null]})}t[8]=D,t[9]=E,t[10]=A,t[11]=z,t[12]=r,t[13]=g,t[14]=d,t[15]=j,t[16]=l,t[17]=w,t[18]=S?.candidates,t[19]=S?.recommended,t[20]=M,t[21]=T,t[22]=u,t[23]=h.pairBaseUrlHint,t[24]=h.pairBaseUrlLabel,t[25]=h.pairBaseUrlPlaceholder,t[26]=h.pairBlockedLoopbackBody,t[27]=h.pairBlockedNextSteps,t[28]=h.pairBlockedTitle,t[29]=h.pairCandidatesTitle,t[30]=h.pairEnableLanButton,t[31]=h.pairEnableLanEnabling,t[32]=h.pairEnableLanSecurityAuditLink,t[33]=h.pairInvalidBaseUrl,t[34]=h.pairLocalhostWarning,t[35]=h.pairSelectCandidateHint,t[36]=h.pairSelectCandidateTitle,t[37]=h.pairSubtitle,t[38]=h.pairSuggestedLanLabel,t[39]=h.pairTitle,t[40]=h.pairTunnelActive,t[41]=h.pairTunnelLanUrl,t[42]=h.pairTunnelPublicUrl,t[43]=h.pairUseSuggestedUrl,t[44]=h.pairWaitingForTunnel,t[45]=h.refreshQr,t[46]=y,t[47]=x,t[48]=b?.publicUrl,t[49]=B,t[50]=H,t[51]=U,t[52]=W,t[53]=G}else B=t[49],H=t[50],U=t[51],W=t[52],G=t[53];if(G!==Symbol.for(`react.early_return_sentinel`))return G;let K;t[82]===h.pairSecurityNote?K=t[83]:(K=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:h.pairSecurityNote}),t[82]=h.pairSecurityNote,t[83]=K);let q;t[84]!==v||t[85]!==N||t[86]!==L||t[87]!==M||t[88]!==F||t[89]!==I||t[90]!==h.pairEncoding||t[91]!==h.pairImageError||t[92]!==h.pairQrDisabled?(q=N?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[F&&!I?(0,$.jsx)(`img`,{src:F,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,L?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairEncoding}):null,I?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:h.pairImageError}):null,(0,$.jsx)(fe,{text:N,labels:v})]}):M?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairQrDisabled}):null,t[84]=v,t[85]=N,t[86]=L,t[87]=M,t[88]=F,t[89]=I,t[90]=h.pairEncoding,t[91]=h.pairImageError,t[92]=h.pairQrDisabled,t[93]=q):q=t[93];let J;t[94]!==B||t[95]!==P||t[96]!==h.deeplinkTitle?(J=P&&!B?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:h.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:P})]}):null,t[94]=B,t[95]=P,t[96]=h.deeplinkTitle,t[97]=J):J=t[97];let Y;t[98]!==B||t[99]!==h.pairMobileProbeHint||t[100]!==h.pairSchemeHint?(Y=B?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:h.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:h.pairMobileProbeHint})]}),t[98]=B,t[99]=h.pairMobileProbeHint,t[100]=h.pairSchemeHint,t[101]=Y):Y=t[101];let ne,X;t[102]===z?(ne=t[103],X=t[104]):(ne=()=>void z.runEnableLanPairing(),X=()=>{z.busy||z.setConfirmOpen(!1)},t[102]=z,t[103]=ne,t[104]=X);let re;t[105]!==z.confirmOpen||t[106]!==h.consentCancel||t[107]!==h.pairEnableLanButton||t[108]!==h.pairEnableLanConfirmBody||t[109]!==h.pairEnableLanConfirmTitle||t[110]!==ne||t[111]!==X?(re=(0,$.jsx)(V,{open:z.confirmOpen,title:h.pairEnableLanConfirmTitle,description:h.pairEnableLanConfirmBody,confirmLabel:h.pairEnableLanButton,cancelLabel:h.consentCancel,onConfirm:ne,onCancel:X}),t[105]=z.confirmOpen,t[106]=h.consentCancel,t[107]=h.pairEnableLanButton,t[108]=h.pairEnableLanConfirmBody,t[109]=h.pairEnableLanConfirmTitle,t[110]=ne,t[111]=X,t[112]=re):re=t[112];let ie;return t[113]!==K||t[114]!==q||t[115]!==J||t[116]!==Y||t[117]!==re||t[118]!==H||t[119]!==U||t[120]!==W?(ie=(0,$.jsx)(ve,{children:(0,$.jsxs)($.Fragment,{children:[H,U,W,K,q,J,Y,re]})}),t[113]=K,t[114]=q,t[115]=J,t[116]=Y,t[117]=re,t[118]=H,t[119]=U,t[120]=W,t[121]=ie):ie=t[121],ie}function De(e){return e.reachable}function Oe(e){return e.kind===`lan`}function ke(e){return e.language}function Ae(e){let t=(0,Z.c)(40),{open:n,title:r,intro:a,bullets:o,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(v,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,F)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,ie),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(y,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let b;t[6]===a?b=t[7]:(b=(0,$.jsx)(j,{className:`mt-2 text-sm text-fg-muted`,children:a}),t[6]=a,t[7]=b);let S;t[8]===o?S=t[9]:(S=o.map(je),t[8]=o,t[9]=S);let w;t[10]===S?w=t[11]:(w=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:S}),t[10]=S,t[11]=w);let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>p(e.target.checked),t[12]=T):T=t[12];let E;t[13]===f?E=t[14]:(E=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:T}),t[13]=f,t[14]=E);let O;t[15]===s?O=t[16]:(O=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=O);let k;t[17]!==O||t[18]!==E?(k=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[E,O]}),t[17]=O,t[18]=E,t[19]=k):k=t[19];let A;t[20]!==l||t[21]!==d?(A=(0,$.jsx)(C,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=A):A=t[22];let M=!f,N;t[23]!==c||t[24]!==u||t[25]!==M?(N=(0,$.jsx)(C,{type:`button`,disabled:M,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=M,t[26]=N):N=t[26];let P;t[27]!==A||t[28]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[A,N]}),t[27]=A,t[28]=N,t[29]=P):P=t[29];let I;t[30]!==k||t[31]!==P||t[32]!==_||t[33]!==b||t[34]!==w?(I=(0,$.jsxs)(x,{children:[h,(0,$.jsxs)(D,{className:g,onOpenAutoFocus:Me,children:[_,b,w,k,P]})]}),t[30]=k,t[31]=P,t[32]=_,t[33]=b,t[34]=w,t[35]=I):I=t[35];let L;return t[36]!==n||t[37]!==m||t[38]!==I?(L=(0,$.jsx)(Y,{open:n,onOpenChange:m,children:I}),t[36]=n,t[37]=m,t[38]=I,t[39]=L):L=t[39],L}function je(e){return(0,$.jsx)(`li`,{children:e},e)}function Me(e){return e.preventDefault()}function Ne(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Pe=[`preparing_frpc`,`registering`,`starting_frpc`];function Fe(e){return e?e===`reconnecting_frpc`?Pe.indexOf(`starting_frpc`):Pe.indexOf(e):-1}function Ie(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Pe.indexOf(e),i=Fe(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Le(e,t,n){let r=n.startProgress;return Ie(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Re(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function ze(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Be(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,a]=(0,Q.useState)(0),o;t[0]!==a||t[1]!==n.state?(o=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>a(Ve),1e3);return()=>window.clearInterval(e)},t[0]=a,t[1]=n.state,t[2]=o):o=t[2];let s=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==s?(c=[n.state,s],t[3]=n.state,t[4]=s,t[5]=c):c=t[5],(0,Q.useEffect)(o,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,d,f,p;if(t[6]!==n||t[7]!==r){let e=ze(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3`;let a;t[13]===r.startProgressTitle?a=t[14]:(a=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=a);let o;t[15]===r.startProgressHint?o=t[16]:(o=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=o),t[17]!==a||t[18]!==o?(d=(0,$.jsxs)(`div`,{children:[a,o]}),t[17]=a,t[18]=o,t[19]=d):d=t[19];let s=Pe.map(e=>{let t=Ie(e,n),a=Le(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(M,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(O,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(T,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:i(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Re(r,e)}),a?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:a}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:i(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Ne(n.frpcDownload.bytesReceived),` /`,` `,Ne(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===s?f=t[21]:(f=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=f),p=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12];let m;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(m=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==u||t[26]!==d||t[27]!==f||t[28]!==p||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f,p,m]}),t[25]=u,t[26]=d,t[27]=f,t[28]=p,t[29]=m,t[30]=h):h=t[30],h}function Ve(e){return e+1}function He(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Ue(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function We(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Ge(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ke(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:a,statusErr:o,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,_=d===void 0?!1:d,v,y,b,x,S,w,T;t[0]!==r||t[1]!==s?(T=Ue(r),v=r.enabled||s,y=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=i(_e(),`space-y-4`),t[9]=w):w=t[9],S=`flex flex-wrap items-start justify-between gap-3`,x=`flex items-center gap-2`,b=i(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,We(T)),t[0]=r,t[1]=s,t[2]=v,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=w,t[8]=T):(v=t[2],y=t[3],b=t[4],x=t[5],S=t[6],w=t[7],T=t[8]);let E=T===`connected`&&`bg-emerald-500`,D=T===`progress`&&`bg-amber-500 animate-pulse`,k=T===`error`&&`bg-red-500`,A=T===`off`&&`bg-fg-subtle`,j;t[10]!==E||t[11]!==D||t[12]!==k||t[13]!==A?(j=i(`size-1.5 rounded-full`,E,D,k,A),t[10]=E,t[11]=D,t[12]=k,t[13]=A,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==a||t[18]!==r||t[19]!==n?(N=a&&!r.enabled?n.loading:He(n,r),t[17]=a,t[18]=r,t[19]=n,t[20]=N):N=t[20];let P;t[21]!==M||t[22]!==N||t[23]!==b?(P=(0,$.jsxs)(`span`,{className:b,children:[M,N]}),t[21]=M,t[22]=N,t[23]=b,t[24]=P):P=t[24];let F;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(F=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ge(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=F):F=t[28];let I;t[29]!==P||t[30]!==F||t[31]!==x?(I=(0,$.jsxs)(`div`,{className:x,children:[P,F]}),t[29]=P,t[30]=F,t[31]=x,t[32]=I):I=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(H,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let R;t[34]!==I||t[35]!==S?(R=(0,$.jsxs)(`div`,{className:S,children:[I,L]}),t[34]=I,t[35]=S,t[36]=R):R=t[36];let z;t[37]===o?z=t[38]:(z=o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o instanceof Error?o.message:String(o)}):null,t[37]=o,t[38]=z);let B;t[39]!==l||t[40]!==n.consentExpiredBanner?(B=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=B):B=t[41];let V;t[42]!==v||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==y||t[47]!==r||t[48]!==_||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(V=v?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,$.jsx)(fe,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,y?(0,$.jsx)(Be,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(C,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(O,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(C,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(O,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),_&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(C,{type:`button`,disabled:s||_,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(O,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),n.start]})]}),t[42]=v,t[43]=u,t[44]=m,t[45]=h,t[46]=y,t[47]=r,t[48]=_,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=V):V=t[54];let U;return t[55]!==R||t[56]!==z||t[57]!==B||t[58]!==V||t[59]!==w?(U=(0,$.jsxs)(`section`,{className:w,children:[R,z,B,V]}),t[55]=R,t[56]=z,t[57]=B,t[58]=V,t[59]=w,t[60]=U):U=t[60],U}var qe=`https://console.xopc.ai/keys/tunnel`,Je={reconfiguring:!1};function Ye(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:a,brokerSecretConfiguredInConfig:o,brokerSecretMaskedValue:s,brokerSecretDraft:c,savingBrokerSecret:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:p,onClear:m,sectionRef:h}=e,g=(0,Q.useId)(),_=a&&!r,v=!_,[y,b]=(0,Q.useReducer)(R,Je),{reconfiguring:x}=y,S;t[0]!==o||t[1]!==c||t[2]!==r||t[3]!==x?(S=o&&!r&&!x&&!c.trim(),t[0]=o,t[1]=c,t[2]=r,t[3]=x,t[4]=S):S=t[4];let w=S,T;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(T={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=T):T=t[9];let D=T,k;t[10]===c?k=t[11]:(k=c.trim().length>0&&!ne(c.trim()),t[10]=c,t[11]=k);let A=k,j;t[12]===f?j=t[13]:(j=()=>{b({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[12]=f,t[13]=j);let P=j,F=_&&`ring-1 ring-amber-500/30`,I;t[14]===F?I=t[15]:(I=i(F),t[14]=F,t[15]=I);let L=v?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:_?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,z;t[16]===L?z=t[17]:(z=i(`flex size-9 shrink-0 items-center justify-center rounded-lg`,L),t[16]=L,t[17]=z);let B;t[18]===v?B=t[19]:(B=v?(0,$.jsx)(M,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(le,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=v,t[19]=B);let V;t[20]!==z||t[21]!==B?(V=(0,$.jsx)(`span`,{className:z,children:B}),t[20]=z,t[21]=B,t[22]=V):V=t[22];let H=v?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,U;t[23]===H?U=t[24]:(U=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:H}),t[23]=H,t[24]=U);let ee=v?n.brokerSecretReadyHint:n.brokerSecretHint,W;t[25]===ee?W=t[26]:(W=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:ee}),t[25]=ee,t[26]=W);let G;t[27]!==_||t[28]!==n.brokerSecretMissingHint?(G=_?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=_,t[28]=n.brokerSecretMissingHint,t[29]=G):G=t[29];let K;t[30]!==U||t[31]!==W||t[32]!==G?(K=(0,$.jsxs)(`div`,{children:[U,W,G]}),t[30]=U,t[31]=W,t[32]=G,t[33]=K):K=t[33];let te;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(E,{className:`size-3`,"aria-hidden":!0}),t[34]=te):te=t[34];let q;t[35]===n.brokerSecretConsoleLink?q=t[36]:(q=(0,$.jsxs)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,te]}),t[35]=n.brokerSecretConsoleLink,t[36]=q);let J;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(J=r?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-muted`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=J):J=t[39];let Y;t[40]!==o||t[41]!==c||t[42]!==r||t[43]!==s||t[44]!==A||t[45]!==P||t[46]!==d||t[47]!==g||t[48]!==_||t[49]!==m||t[50]!==f||t[51]!==p||t[52]!==x||t[53]!==l||t[54]!==D||t[55]!==w||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(Y=w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(N,{id:g,value:s,labels:D,reveal:Xe,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(C,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>{b({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(C,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(N,{id:g,value:c,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:D,disabled:l}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(C,{type:`button`,disabled:l||!A,onClick:p,children:[l?(0,$.jsx)(O,{className:`size-4 animate-spin`}):null,_?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),o||r?(0,$.jsx)(C,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear}):null,x?(0,$.jsx)(C,{type:`button`,variant:`ghost`,disabled:l,onClick:P,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=o,t[41]=c,t[42]=r,t[43]=s,t[44]=A,t[45]=P,t[46]=d,t[47]=g,t[48]=_,t[49]=m,t[50]=f,t[51]=p,t[52]=x,t[53]=l,t[54]=D,t[55]=w,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=Y):Y=t[66];let X;t[67]===u?X=t[68]:(X=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[67]=u,t[68]=X);let re;t[69]!==K||t[70]!==q||t[71]!==J||t[72]!==Y||t[73]!==X?(re=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[K,q,J,Y,X]}),t[69]=K,t[70]=q,t[71]=J,t[72]=Y,t[73]=X,t[74]=re):re=t[74];let ie;t[75]!==V||t[76]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[V,re]}),t[75]=V,t[76]=re,t[77]=ie):ie=t[77];let ae;t[78]!==ie||t[79]!==I?(ae=(0,$.jsx)(ve,{className:I,children:ie}),t[78]=ie,t[79]=I,t[80]=ae):ae=t[80];let oe;return t[81]!==h||t[82]!==ae?(oe=(0,$.jsx)(`div`,{ref:h,id:`tunnel-broker-secret-setup`,children:ae}),t[81]=h,t[82]=ae,t[83]=oe):oe=t[83],oe}function Xe(){return K().then(Ze)}function Ze(e){return e.registrationSecret??null}function Qe(e){let t=(0,Z.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=oe(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=i(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(E,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var $e=e(ye(),1),et={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function tt(e){return $e.toDataURL(e,et)}function nt(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function rt(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function it(e,t){return e?t?nt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function at(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=p(),a=(0,Q.useRef)(!1),{data:o}=m(r?`tunnel-status`:null,J,{refreshInterval:6e4}),{data:c,mutate:l}=m(r?`tunnel-pair-context`:null,G,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let u=o?.state===`connected`&&!!o.publicUrl?.trim(),f=u&&!n,{data:h,mutate:g}=m(f&&r?`tunnel-qr`:null,P,{refreshInterval:4*6e4}),{data:_,mutate:v}=m(!f&&r&&c?.pairingReady?`tunnel-pair`:null,q,{refreshInterval:4*6e4}),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(c!==C.pairContext||n!==C.preferLan)){w({pairContext:c,preferLan:n});let e=it(c,n);y!==e&&b(e)}let T=(0,Q.useCallback)(e=>{a.current=!0,b(e)},[]),E=(0,Q.useCallback)(()=>{let e=it(c,n);e&&(a.current=!0,b(e))},[c,n]),D=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),O=(0,Q.useCallback)(e=>{a.current=!1,b(e?.trim()||it(c,n))},[c,n]),A=y.trim(),j=(0,Q.useMemo)(()=>{try{let e=new URL(A);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[A]),M=j&&d(A),N=!f&&!!(c&&!c.pairingReady&&c.blockReason===`GATEWAY_LOOPBACK_ONLY`),F=!f&&j&&!M&&!!_?.pairingSecret&&(c?.pairingReady===!0||!N),I=(0,Q.useMemo)(()=>{let e=nt(c);return n?e||(A&&!rt(c,A)?A:``):A},[c,n,A]),L=(0,Q.useMemo)(()=>{if(!e)return``;if(x.trim())return x.trim();if(f&&h?.qrPayload?.trim())return h.qrPayload.trim();if(!F||!_?.pairingSecret)return``;let t=c?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=c?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?I:t?.url??A;return i?s({baseUrl:i,pairingSecret:_.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,I,_?.pairingSecret,F,x,n,A,f,h?.qrPayload,c?.candidates]),R=k(()=>tt(L),[L],{enabled:!!L,initial:null,errorData:null}),z=L?R.data:null,B=!!(L&&R.error!==null&&!R.loading);return{tunnelActive:u,tunnelStatus:o,tunnelQr:h,pairContext:c,pairBaseUrl:y,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,baseOk:j,localhostWarn:M,pairingBlocked:N,deepLink:L,qrPayload:L,qrDataUrl:z,qrGenFailed:B,encoding:!!(L&&!z&&!B),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){S(e.trim()),g({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:h?.lanUrl??null},!1);return}S(``),await l(),f?await g():c?.pairingReady&&await v()},[v,l,g,c?.pairingReady,h?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:O}}var ot={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function st({embedded:e=!1}){let t=o(e=>e.language),n=a(t).tunnelSettings,r=c(e=>e.token),s=!!r,[l,u]=(0,Q.useReducer)(R,ot),{actionError:d,starting:f,stopping:p,savingAutoStart:h,consentOpen:g,autoStartConfirmOpen:_,releaseConfirmOpen:v,releasing:y,brokerSecretDraft:b,savingBrokerSecret:x,brokerSecretNotice:S}=l,w=(0,Q.useRef)(null),T=at(r??``),{data:E}=U(s),{data:D,error:k,isLoading:A,mutate:j}=m(s?`tunnel-status`:null,J,{refreshInterval:e=>f?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),M=(0,Q.useMemo)(()=>{let e=E?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return D?.config?.autoStart===!0},[E,D?.config?.autoStart]),N=(0,Q.useMemo)(()=>{let e=E?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[E]),P=ne(N),F=D?.registrationSecret?.source===`env`,I=D?.registrationSecret?.source===`missing`,B=D?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{j()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[j]);let ee=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),G=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{starting:!0}});try{let e=await ue();await j(),W(),await T.refreshQr(e.qrPayload)}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{starting:!1}})}},[j,T.refreshQr]),K=(0,Q.useCallback)(()=>{if(!B){u({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),w.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(D?.consentRequired){u({type:`patch`,patch:{consentOpen:!0}});return}G()},[B,D?.consentRequired,G,n.brokerSecretRequiredBeforeStart]),te=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{consentOpen:!1}}),u({type:`patch`,patch:{actionError:null}});try{await L(),await Promise.all([j(),G()])}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[j,G]),q=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{stopping:!0}});try{await z(),await Promise.all([T.refreshQr(),j()]),W()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{stopping:!1}})}},[j,T.refreshQr]),Y=(0,Q.useCallback)(async e=>{u({type:`patch`,patch:{savingAutoStart:!0}}),u({type:`patch`,patch:{actionError:null}});try{await ae({autoStart:e}),W()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingAutoStart:!1}})}},[]),X=(0,Q.useCallback)(()=>{if(M){Y(!1);return}if(D?.consentRequired){u({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!D?.canAutoStart){u({type:`patch`,patch:{actionError:n.autoStartHint}});return}u({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[Y,D?.canAutoStart,D?.consentRequired,n,M]),re=(0,Q.useCallback)(async()=>{let e=b.trim();if(e){u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ae({registrationSecret:e}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),W(),await j(),u({type:`patch`,patch:{actionError:null}})}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[b,j,n.brokerSecretSaved]),ie=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ae({registrationSecret:null}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),W(),await j()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}},[j,n.brokerSecretCleared]),oe=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await z({release:!0}),await Promise.all([T.refreshQr(),j()]),W()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{releasing:!1}})}},[j,T.refreshQr]),se=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!s)return(0,$.jsx)(`div`,{className:e?void 0:`mx-auto w-full max-w-app-main px-4 py-8`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let ce=D??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:M,brokerUrl:`https://frp.xopc.ai/api`}},le=D?.consentRequired&&(ce.enabled||M||D?.consent?.acceptedAt),de=(0,$.jsx)(Ye,{t:n,brokerSecretFromEnv:F,brokerSecretMissing:I,brokerSecretConfiguredInConfig:P,brokerSecretMaskedValue:P?N:``,brokerSecretDraft:b,savingBrokerSecret:x,brokerSecretNotice:S,copyFailedLabel:a(t).clipboard.copyFailed,onDraftChange:e=>u({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void re(),onClear:()=>void ie(),sectionRef:w}),fe=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:ee,checkboxLabel:n.consentCheckbox,confirmLabel:le?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void te(),onCancel:()=>u({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(V,{open:_,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{u({type:`patch`,patch:{autoStartConfirmOpen:!1}}),Y(!0)},onCancel:()=>u({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(V,{open:v,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void oe(),onCancel:()=>u({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(Ke,{t:n,status:ce,isLoading:A,statusErr:k,starting:f,stopping:p,showConsentExpired:!!le,copyLabels:se,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:K,onStop:()=>void q()}),(0,$.jsx)(Ee,{pairQr:T,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void T.refreshQr()}),(0,$.jsxs)(he,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:h||!M&&!D?.canAutoStart,onChange:X}),n.autoStart]}),!D?.canAutoStart&&!M?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,ce.subdomain||ce.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(C,{type:`button`,variant:`secondary`,disabled:y||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(O,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(he,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(H,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Qe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),fe]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(Ke,{t:n,status:ce,isLoading:A,statusErr:k,starting:f,stopping:p,showConsentExpired:!!le,copyLabels:se,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,onStart:K,onStop:()=>void q()}),(0,$.jsx)(Ee,{pairQr:T,gatewayToken:r??``}),ce.subdomain||ce.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(C,{type:`button`,variant:`secondary`,disabled:y||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(O,{className:`size-4 animate-spin`}):null,n.release]})}):null,ce.subdomain||ce.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ve,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:h||!M&&!D?.canAutoStart,onChange:X}),n.autoStart]}),!D?.canAutoStart&&!M?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(H,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Qe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),fe]})}async function ct(){let e=await f(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function lt(e=`serve`){let t=await f(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function ut(){let e=await f(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var dt=`https://tailscale.com/download`;function ft(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:dt,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function pt({embedded:e=!1}){let t=o(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.token),[s,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),{data:f,mutate:p,isLoading:h}=m(i?`exposure-status`:null,ct,{refreshInterval:3e4}),g=f?.tailscale.hostname,_=f?.tailscale.active===!0,v=f?.tailscale.cliAvailable!==!1,y=g?`https://${g}/`:null,b=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await lt(`serve`),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]),x=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await ut(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]);if(!i)return null;let S=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(ft,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&f?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(ft,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,h&&!f?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ve,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(fe,{text:y,labels:r})}):null,u?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_?(0,$.jsxs)(C,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void x(),children:[s?(0,$.jsx)(O,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(C,{type:`button`,disabled:s||!v,onClick:()=>void b(),children:[s?(0,$.jsx)(O,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(pe,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(Qe,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?S:(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:H,title:n.title,subtitle:n.subtitle}),S]})}function mt(){let e=(0,Z.c)(26),t=o(gt),n=c(ht),r;e[0]===t?r=e[1]:(r=a(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={preferLan:!0},e[2]=s):s=e[2];let l=at(n??``,s),u;e[3]!==i.subtitle||e[4]!==i.title?(u=(0,$.jsx)(ge,{icon:I,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=u):u=e[5];let d;e[6]===i.body?d=e[7]:(d=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=d);let f;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),e[8]=f):f=e[8];let p;e[9]===i.link?p=e[10]:(p=(0,$.jsxs)(te,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,f]}),e[9]=i.link,e[10]=p);let m;e[11]!==d||e[12]!==p?(m=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[d,p]}),e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;e[14]!==u||e[15]!==m?(h=(0,$.jsxs)(ve,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=h):h=e[16];let g=n??``,_;e[17]===l?_=e[18]:(_=()=>void l.refreshQr(),e[17]=l,e[18]=_);let v;e[19]!==l||e[20]!==g||e[21]!==_?(v=(0,$.jsx)(Ee,{pairQr:l,gatewayToken:g,lanOnly:!0,onRefreshQr:_}),e[19]=l,e[20]=g,e[21]=_,e[22]=v):v=e[22];let y;return e[23]!==v||e[24]!==h?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,v]}),e[23]=v,e[24]=h,e[25]=y):y=e[25],y}function ht(e){return e.token}function gt(e){return e.language}function _t(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=o(vt),s;t[0]===i?s=t[1]:(s=a(i),t[0]=i,t[1]=s);let c=s.remoteAccess.ssh,[l,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await de(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=p):p=t[3];let m,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>void f(),h=(0,$.jsx)(w,{className:`mr-1 h-4 w-4`}),t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=l?c.copied:c.copy,_;t[6]===g?_=t[7]:(_=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(C,{type:`button`,variant:`ghost`,onClick:m,children:[h,g]})}),t[6]=g,t[7]=_);let v;t[8]!==r||t[9]!==c.hint?(v=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c.hint}):null,t[8]=r,t[9]=c.hint,t[10]=v):v=t[10];let y;t[11]!==_||t[12]!==v?(y=(0,$.jsxs)($.Fragment,{children:[p,_,v]}),t[11]=_,t[12]=v,t[13]=y):y=t[13];let b=y;if(r){let e;t[14]!==c.subtitle||t[15]!==c.title?(e=(0,$.jsx)(ge,{icon:A,title:c.title,subtitle:c.subtitle}),t[14]=c.subtitle,t[15]=c.title,t[16]=e):e=t[16];let n;t[17]===b?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:b}),t[17]=b,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ve,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let x;t[22]!==c.subtitle||t[23]!==c.title?(x=(0,$.jsx)(ge,{icon:A,title:c.title,subtitle:c.subtitle}),t[22]=c.subtitle,t[23]=c.title,t[24]=x):x=t[24];let S;t[25]===b?S=t[26]:(S=(0,$.jsx)(`div`,{className:`mt-4`,children:b}),t[25]=b,t[26]=S);let T;return t[27]!==x||t[28]!==S?(T=(0,$.jsxs)(ve,{children:[x,S]}),t[27]=x,t[28]=S,t[29]=T):T=t[29],T}function vt(e){return e.language}function yt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(_t,{embedded:!0}),e[0]=t):t=e[0],t}function bt(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function xt(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,a;t[0]===r?a=t[1]:(a=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,bt(r)),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function St(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=o(Tt),s;t[0]===r?s=t[1]:(s=a(r),t[0]=r,t[1]=s);let l=s.remoteAccess.guide,u=!!c(wt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,ct,d),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:15e3},t[3]=p):p=t[3];let{data:h}=m(u?`tunnel-status`:null,J,p),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g={refreshInterval:6e4},t[4]=g):g=t[4];let{data:_}=m(u?`tunnel-pair-context`:null,G,g);if(!u)return null;let v=f?.tailscale.active===!0,y=h?.state,b=h?.enabled&&y===`connected`,x=h?.enabled&&(y===`connecting`||y===`reconnecting`||!!h?.startProgress||!!h?.frpcDownload),C=(_?.candidates??[]).some(Ct),w=v?`active`:`off`,T=v?l.statusActive:l.statusOff,E;t[5]!==l.tailscaleCardTitle||t[6]!==w||t[7]!==T?(E={tab:`tailscale`,icon:H,title:l.tailscaleCardTitle,kind:w,statusLabel:T},t[5]=l.tailscaleCardTitle,t[6]=w,t[7]=T,t[8]=E):E=t[8];let D=b?`active`:x?`connecting`:`off`,O=b?l.statusActive:x?l.statusConnecting:l.statusOff,k;t[9]!==l.publicCardTitle||t[10]!==D||t[11]!==O?(k={tab:`public`,icon:S,title:l.publicCardTitle,kind:D,statusLabel:O},t[9]=l.publicCardTitle,t[10]=D,t[11]=O,t[12]=k):k=t[12];let j=C?`active`:`off`,M=C?l.statusActive:l.statusOff,N;t[13]!==l.reverseProxyCardTitle||t[14]!==j||t[15]!==M?(N={tab:`reverse-proxy`,icon:X,title:l.reverseProxyCardTitle,kind:j,statusLabel:M},t[13]=l.reverseProxyCardTitle,t[14]=j,t[15]=M,t[16]=N):N=t[16];let P;t[17]!==l.sshCardStatus||t[18]!==l.sshCardTitle?(P={tab:`ssh`,icon:A,title:l.sshCardTitle,kind:`off`,statusLabel:l.sshCardStatus},t[17]=l.sshCardStatus,t[18]=l.sshCardTitle,t[19]=P):P=t[19];let F;t[20]!==l.lanCardStatus||t[21]!==l.lanCardTitle?(F={tab:`lan`,icon:I,title:l.lanCardTitle,kind:`off`,statusLabel:l.lanCardStatus},t[20]=l.lanCardStatus,t[21]=l.lanCardTitle,t[22]=F):F=t[22];let L;t[23]!==k||t[24]!==N||t[25]!==P||t[26]!==F||t[27]!==E?(L=[E,k,N,P,F],t[23]=k,t[24]=N,t[25]=P,t[26]=F,t[27]=E,t[28]=L):L=t[28];let R=L,z;return t[29]!==R||t[30]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:R.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:i(`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-2.5 text-left transition-colors`,`hover:border-edge hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(xt,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=R,t[30]=n,t[31]=z):z=t[31],z}function Ct(e){return e.kind===`reverse-proxy`}function wt(e){return e.token}function Tt(e){return e.language}function Et(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:a,icon:o,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-2xl bg-surface-base px-4 py-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==a||t[6]!==l?(p=a&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=a,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let x;return t[22]!==s||t[23]!==y||t[24]!==v?(x=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=x):x=t[25],x}function Dt(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=o(At),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let s=i.remoteAccess,l=s.guide,u=!!c(kt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,ct,d),p;t[3]===f?.conflicts?p=t[4]:(p=f?.conflicts??[],t[3]=f?.conflicts,t[4]=p);let h=p;if(!u){let e;return t[5]===l.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.needToken}),t[5]=l.needToken,t[6]=e),e}let g;t[7]===n?g=t[8]:(g=(0,$.jsx)(St,{onOpenTab:n}),t[7]=n,t[8]=g);let _;t[9]!==h||t[10]!==l.conflictsHint||t[11]!==l.conflictsTitle?(_=h.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:l.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:l.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:h.map(Ot)})]}):null,t[9]=h,t[10]=l.conflictsHint,t[11]=l.conflictsTitle,t[12]=_):_=t[12];let v;t[13]===l.pickMethod?v=t[14]:(v=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.pickMethod}),t[13]=l.pickMethod,t[14]=v);let y;t[15]===n?y=t[16]:(y=()=>n(`tailscale`),t[15]=n,t[16]=y);let b;t[17]!==l.configure||t[18]!==l.recommended||t[19]!==l.tailscaleCardDesc||t[20]!==l.tailscaleCardTitle||t[21]!==y?(b=(0,$.jsx)(Et,{icon:H,title:l.tailscaleCardTitle,description:l.tailscaleCardDesc,recommended:!0,recommendedLabel:l.recommended,openLabel:l.configure,onOpen:y}),t[17]=l.configure,t[18]=l.recommended,t[19]=l.tailscaleCardDesc,t[20]=l.tailscaleCardTitle,t[21]=y,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(x=()=>n(`public`),t[23]=n,t[24]=x);let C;t[25]!==l.configure||t[26]!==l.publicCardDesc||t[27]!==l.publicCardTitle||t[28]!==x?(C=(0,$.jsx)(Et,{icon:S,title:l.publicCardTitle,description:l.publicCardDesc,openLabel:l.configure,onOpen:x}),t[25]=l.configure,t[26]=l.publicCardDesc,t[27]=l.publicCardTitle,t[28]=x,t[29]=C):C=t[29];let w;t[30]===n?w=t[31]:(w=()=>n(`reverse-proxy`),t[30]=n,t[31]=w);let T;t[32]!==l.configure||t[33]!==l.reverseProxyCardDesc||t[34]!==l.reverseProxyCardTitle||t[35]!==w?(T=(0,$.jsx)(Et,{icon:X,title:l.reverseProxyCardTitle,description:l.reverseProxyCardDesc,openLabel:l.configure,onOpen:w}),t[32]=l.configure,t[33]=l.reverseProxyCardDesc,t[34]=l.reverseProxyCardTitle,t[35]=w,t[36]=T):T=t[36];let E;t[37]===n?E=t[38]:(E=()=>n(`ssh`),t[37]=n,t[38]=E);let D;t[39]!==l.configure||t[40]!==l.sshCardDesc||t[41]!==l.sshCardTitle||t[42]!==E?(D=(0,$.jsx)(Et,{icon:A,title:l.sshCardTitle,description:l.sshCardDesc,openLabel:l.configure,onOpen:E}),t[39]=l.configure,t[40]=l.sshCardDesc,t[41]=l.sshCardTitle,t[42]=E,t[43]=D):D=t[43];let O;t[44]===n?O=t[45]:(O=()=>n(`lan`),t[44]=n,t[45]=O);let k;t[46]!==l.configure||t[47]!==l.lanCardDesc||t[48]!==l.lanCardTitle||t[49]!==O?(k=(0,$.jsx)(Et,{icon:I,title:l.lanCardTitle,description:l.lanCardDesc,openLabel:l.configure,onOpen:O}),t[46]=l.configure,t[47]=l.lanCardDesc,t[48]=l.lanCardTitle,t[49]=O,t[50]=k):k=t[50];let j;t[51]!==C||t[52]!==T||t[53]!==D||t[54]!==k||t[55]!==b?(j=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,C,T,D,k]}),t[51]=C,t[52]=T,t[53]=D,t[54]=k,t[55]=b,t[56]=j):j=t[56];let M;t[57]!==j||t[58]!==v?(M=(0,$.jsxs)(`div`,{children:[v,j]}),t[57]=j,t[58]=v,t[59]=M):M=t[59];let N;t[60]===l.oneAtATimeHint?N=t[61]:(N=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:l.oneAtATimeHint}),t[60]=l.oneAtATimeHint,t[61]=N);let P;t[62]===s.advanced.proxyTitle?P=t[63]:(P=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.advanced.proxyTitle}),t[62]=s.advanced.proxyTitle,t[63]=P);let F;t[64]===s.advanced.proxyBody?F=t[65]:(F=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.advanced.proxyBody}),t[64]=s.advanced.proxyBody,t[65]=F);let L;t[66]!==r||t[67]!==s.advanced.proxyDocs?(L=(0,$.jsx)(Qe,{language:r,label:s.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=s.advanced.proxyDocs,t[68]=L):L=t[68];let R;t[69]!==P||t[70]!==F||t[71]!==L?(R=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-4 py-3`,children:[P,F,L]}),t[69]=P,t[70]=F,t[71]=L,t[72]=R):R=t[72];let z;t[73]!==l.docsLink||t[74]!==r?(z=(0,$.jsx)(Qe,{language:r,label:l.docsLink}),t[73]=l.docsLink,t[74]=r,t[75]=z):z=t[75];let B;return t[76]!==M||t[77]!==N||t[78]!==R||t[79]!==z||t[80]!==g||t[81]!==_?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[g,_,M,N,R,z]}),t[76]=M,t[77]=N,t[78]=R,t[79]=z,t[80]=g,t[81]=_,t[82]=B):B=t[82],B}function Ot(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function kt(e){return e.token}function At(e){return e.language}async function jt(e){let t=await f(l(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Mt(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Nt(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Pt(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||Nt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Ft(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function It(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Lt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Rt(){let e=o(e=>e.language),t=a(e).remoteAccess.reverseProxy,n=!!c(e=>e.token),r=Pt(),{mutate:l}=p(),{data:u,mutate:d}=m(n?`tunnel-pair-context`:null,G,{refreshInterval:6e4}),f=It(u),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)({busy:!1,result:null}),[y,b]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{h||(f?g(f):r&&g(r))},[f,r,h]);let x=(0,Q.useMemo)(()=>h.trim()||(f??r??``),[f,r,h]),S=!f&&!!r&&x===r,w=Lt(u),{data:T,mutate:E}=m(n&&x?[`reverse-proxy-pair`,x]:null,()=>q(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>!x||!T?.pairingSecret?``:s({baseUrl:x,pairingSecret:T.pairingSecret,lanUrl:w}),[x,w,T?.pairingSecret]),A=k(()=>tt(D),[D],{enabled:!!D,initial:null,errorData:null}),j=(0,Q.useCallback)(async()=>{let e=h.trim()||x;if(e){v({busy:!0,result:null});try{v({busy:!1,result:await jt(e)})}catch(e){v({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[h,x]),M=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){b({busy:!0,error:null});try{await Mt(e),await d(),await l(`tunnel-pair-context`),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[x,l,d]),N=(0,Q.useCallback)(async()=>{b({busy:!0,error:null});try{await Mt(null),await d(),await l(`tunnel-pair-context`),g(``),v({busy:!1,result:null}),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}},[l,d]),P=(0,Q.useCallback)(async()=>{await E()},[E]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:H,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:i(Ft(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:h,onChange:e=>{g(e.target.value),v({busy:!1,result:null})}}),(0,$.jsxs)(C,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void j(),disabled:_.busy||!h.trim(),children:[_.busy?(0,$.jsx)(O,{className:`size-3.5 animate-spin`}):null,_.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),S&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,_.result?(0,$.jsx)(zt,{result:_.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[x&&f!==x?(0,$.jsxs)(C,{type:`button`,onClick:()=>void M(),disabled:y.busy,children:[y.busy?(0,$.jsx)(O,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,f?(0,$.jsx)(C,{type:`button`,variant:`ghost`,onClick:()=>void N(),disabled:y.busy,children:t.clear}):null]}),y.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:y.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(ve,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),D?(0,$.jsxs)(C,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void P(),children:[(0,$.jsx)(ee,{className:`size-4`}),t.refreshQr]}):null]}),x?T?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,x,w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,w]}):null]}),A.data?(0,$.jsx)(`img`,{src:A.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):A.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(fe,{text:D,labels:{copy:t.copyLink,copied:t.copied,copyFailed:a(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function zt(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Bt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Vt(e){return e&&Bt.includes(e)?e:`guide`}function Ht(e,t){return e.tabs[t]}function Ut(e,t){return e.tabIntro[t]}function Wt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Gt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Dt,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(st,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Rt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yt,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(mt,{}),t[6]=e):e=t[6],e}}}function Kt(){let e=(0,Z.c)(2),t=o(Jt),n=a(t).remoteAccess,r=!!c(qt),[i,s]=me(),l=Vt(i.get(`tab`)),u;e[0]===s?u=e[1]:(u=e=>{s(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=s,e[1]=u);let d=u,f=Ut(n,l),p=Bt.map(e=>({id:e,label:Ht(n,e)}));return(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)(Qe,{language:t,label:n.docsLink,section:Wt(l),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{items:p,activeTab:l,onChange:d,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(Se,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Ht(n,l),hint:l===`public`?void 0:f,children:(0,$.jsx)(Gt,{tab:l,onOpenTab:d})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function qt(e){return e.token}function Jt(e){return e.language}export{Kt as RemoteAccessHub};