@xopcai/xopc 0.0.114 → 0.0.115

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 (375) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  3. package/dist/extensions/feishu/src/workflow-progress.js +1 -1
  4. package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
  5. package/dist/extensions/telegram/src/inbound-processor.js +1 -1
  6. package/dist/extensions/telegram/src/plugin.js +1 -1
  7. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  8. package/dist/extensions/telegram/src/update-offset-store.js +1 -1
  9. package/dist/extensions/telegram/src/workflow-progress.js +1 -1
  10. package/dist/extensions/telegram/xopc.extension.json +1 -1
  11. package/dist/extensions/weixin/src/api/api.js +2 -2
  12. package/dist/extensions/weixin/src/auth/accounts.js +1 -1
  13. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  14. package/dist/extensions/weixin/src/media/data-url.js +1 -1
  15. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  16. package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
  17. package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
  18. package/dist/extensions/weixin/src/plugin.js +1 -1
  19. package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
  20. package/dist/extensions/weixin/src/workflow-progress.js +1 -1
  21. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Fp-p7bP1.js → agent-avatar-dicebear-DVnBfANm.js} +1 -1
  22. package/dist/gateway/static/root/assets/agent-browser-settings-page-DPXc4hz8.js +6 -0
  23. package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-CTJ0YnRQ.js +1 -0
  24. package/dist/gateway/static/root/assets/agents-zJXQfJ_W.js +71 -0
  25. package/dist/gateway/static/root/assets/{app-management-settings-panel-v24i25Oj.js → app-management-settings-panel-DzGbdr04.js} +1 -1
  26. package/dist/gateway/static/root/assets/{appearance-settings-ycbdJRuZ.js → appearance-settings-BQpPSTHD.js} +1 -1
  27. package/dist/gateway/static/root/assets/apps-page-CPjfyzSD.js +1 -0
  28. package/dist/gateway/static/root/assets/{archive-plugin-CJzSADJo.js → archive-plugin-CXu-Csep.js} +1 -1
  29. package/dist/gateway/static/root/assets/{attachment-load-BTAB4zGS.js → attachment-load-BAjgOoGY.js} +1 -1
  30. package/dist/gateway/static/root/assets/{binary-plugins-DXR1-mct.js → binary-plugins-BSBgB2hO.js} +1 -1
  31. package/dist/gateway/static/root/assets/{block-editor-CzQri9h2.js → block-editor-BpXw9TTR.js} +44 -44
  32. package/dist/gateway/static/root/assets/channels-settings-BbPUpzWB.js +1 -0
  33. package/dist/gateway/static/root/assets/{config-api-DRqjEvAx.js → config-api-NOoPiIYz.js} +1 -1
  34. package/dist/gateway/static/root/assets/connectors-settings-CAXYMOdp.js +2 -0
  35. package/dist/gateway/static/root/assets/{cron-api-BXaZXv1o.js → cron-api-C9BOqAXd.js} +1 -1
  36. package/dist/gateway/static/root/assets/cron-page-DuUbBeKI.js +3 -0
  37. package/dist/gateway/static/root/assets/dreaming-settings-DQ4DtiK1.js +1 -0
  38. package/dist/gateway/static/root/assets/{extension-debug-page-DSkqMYo7.js → extension-debug-page-D9kgUHCc.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-page-h2dGDbMN.js → extension-page-CGyhXqzR.js} +1 -1
  40. package/dist/gateway/static/root/assets/{extension-settings-page-hN99RhOi.js → extension-settings-page-DL8Xquqd.js} +1 -1
  41. package/dist/gateway/static/root/assets/{fetch-D9QqUtzZ.js → fetch-D0VXA932.js} +1 -1
  42. package/dist/gateway/static/root/assets/{format-interval-label-D6E687rG.js → format-interval-label-Be8SmgUw.js} +1 -1
  43. package/dist/gateway/static/root/assets/{gateway-config-api-CLt_SKTC.js → gateway-config-api-C-xjn__h.js} +1 -1
  44. package/dist/gateway/static/root/assets/{gateway-settings-1PDi4lI0.js → gateway-settings-BMPwIjKI.js} +1 -1
  45. package/dist/gateway/static/root/assets/{gateway-startup-retry-N7Z_sz7p.js → gateway-startup-retry-DERUH61L.js} +1 -1
  46. package/dist/gateway/static/root/assets/goal-detail-page-BJsyjJnF.js +1 -0
  47. package/dist/gateway/static/root/assets/goals-config-api-BPmqWk90.js +1 -0
  48. package/dist/gateway/static/root/assets/goals-page-BerDgIhw.js +2 -0
  49. package/dist/gateway/static/root/assets/goals-settings-ByTjeAto.js +1 -0
  50. package/dist/gateway/static/root/assets/{heartbeat-config-api-DGPadTw-.js → heartbeat-config-api-Bfdzr8oV.js} +1 -1
  51. package/dist/gateway/static/root/assets/{heartbeat-settings-BHHAs8ZX.js → heartbeat-settings-TbHgcjTn.js} +1 -1
  52. package/dist/gateway/static/root/assets/{index-DefIdW9q.js → index-AkTrf6Pb.js} +56 -56
  53. package/dist/gateway/static/root/assets/index-fh5sXTj9.css +1 -0
  54. package/dist/gateway/static/root/assets/{interval-presets-CEklPQ_r.js → interval-presets-utKbuCRY.js} +1 -1
  55. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Ce_aQ8Iv.js → keyboard-shortcuts-settings-CjqS6c6V.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-DGXuPf5B.js +2 -0
  57. package/dist/gateway/static/root/assets/{markdown-split-BMz3xPXO.js → markdown-split-DW8C47iB.js} +1 -1
  58. package/dist/gateway/static/root/assets/{media-plugins-BalOSoz9.js → media-plugins-D6HwDhDT.js} +1 -1
  59. package/dist/gateway/static/root/assets/messages-upgxw6Ub.js +3 -0
  60. package/dist/gateway/static/root/assets/models-hub-panel-Bot16nn7.js +2 -0
  61. package/dist/gateway/static/root/assets/note-detail-page-Brlyou8M.js +2 -0
  62. package/dist/gateway/static/root/assets/{note-image-lightbox-C5D1Q5mY.js → note-image-lightbox-pJM35Pz5.js} +1 -1
  63. package/dist/gateway/static/root/assets/notes-page-DvZ4pwc-.js +1 -0
  64. package/dist/gateway/static/root/assets/{preview-open-alternatives-CYFR5U9l.js → preview-open-alternatives-CVwHuyN6.js} +1 -1
  65. package/dist/gateway/static/root/assets/remote-access-hub-BZEDmxbZ.js +1 -0
  66. package/dist/gateway/static/root/assets/{save-bar-controls-BQ79Z5IP.js → save-bar-controls-Ba-UEk7x.js} +1 -1
  67. package/dist/gateway/static/root/assets/{schedule-field-Bgk6Emue.js → schedule-field-CNN9595U.js} +1 -1
  68. package/dist/gateway/static/root/assets/{schema-form-DzS36TMa.js → schema-form-DnNMmtD5.js} +1 -1
  69. package/dist/gateway/static/root/assets/sessions-page-DdGGlsfn.js +1 -0
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-DlkEkPf9.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-collapsible-section-CdjFnSAy.js → settings-collapsible-section-CmOz80i5.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-form-section-DZLy_exu.js → settings-form-section-BmK7JJOV.js} +1 -1
  73. package/dist/gateway/static/root/assets/settings-page-DFPTrsPF.js +1 -0
  74. package/dist/gateway/static/root/assets/setup-status-panel-CYCCfgh4.js +1 -0
  75. package/dist/gateway/static/root/assets/{share-preview-page-_qRDr4g_.js → share-preview-page-Dp2qGrHC.js} +1 -1
  76. package/dist/gateway/static/root/assets/shares-settings-Bff1pGd0.js +1 -0
  77. package/dist/gateway/static/root/assets/skill-reload-api-CJGKpBur.js +1 -0
  78. package/dist/gateway/static/root/assets/skills-page-C6ocduTD.js +2 -0
  79. package/dist/gateway/static/root/assets/{system-settings-panel-hqaBF5aG.js → system-settings-panel-5jrIEr5b.js} +1 -1
  80. package/dist/gateway/static/root/assets/{use-agent-defaults-form-zbVIQLOA.js → use-agent-defaults-form-BuiXLIs5.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-CbXq97rT.js → use-channel-catalog-CHlO8J9G.js} +1 -1
  82. package/dist/gateway/static/root/assets/{use-settings-tab-guard-DwS3drWK.js → use-settings-tab-guard-CW5JORnl.js} +1 -1
  83. package/dist/gateway/static/root/assets/voice-api-key-field-DDoQyghO.js +1 -0
  84. package/dist/gateway/static/root/assets/{voice-player-store-DSuOd9zy.js → voice-player-store-DDDWYHvg.js} +1 -1
  85. package/dist/gateway/static/root/assets/{workflow-page.utils-C0Uq3xyq.js → workflow-page.utils-CKjeEGqx.js} +1 -1
  86. package/dist/gateway/static/root/assets/workflows-page-B604ehHG.js +18 -0
  87. package/dist/gateway/static/root/index.html +5 -5
  88. package/dist/gateway/static/root/logo.svg +4 -3
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/agent-manager.js +6 -6
  91. package/dist/src/agent/agent-scope.js +1 -1
  92. package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
  93. package/dist/src/agent/bootstrap/project-agents-context.js +1 -1
  94. package/dist/src/agent/context/workspace-seed.js +2 -2
  95. package/dist/src/agent/context/workspace-state.js +1 -1
  96. package/dist/src/agent/context/workspace.js +1 -1
  97. package/dist/src/agent/embedded/session-tool-result-guard.js +8 -1
  98. package/dist/src/agent/embedded/session-tool-result-guard.js.map +1 -1
  99. package/dist/src/agent/goals/checklist-judge.d.ts +1 -0
  100. package/dist/src/agent/goals/checklist-judge.js +3 -2
  101. package/dist/src/agent/goals/checklist-judge.js.map +1 -1
  102. package/dist/src/agent/goals/evaluate-turn.d.ts +1 -1
  103. package/dist/src/agent/goals/evaluate-turn.js +1 -0
  104. package/dist/src/agent/goals/evaluate-turn.js.map +1 -1
  105. package/dist/src/agent/goals/goal-locale.js +2 -2
  106. package/dist/src/agent/goals/post-turn.d.ts +6 -1
  107. package/dist/src/agent/goals/post-turn.js +15 -6
  108. package/dist/src/agent/goals/post-turn.js.map +1 -1
  109. package/dist/src/agent/image/load-image-media.js +2 -2
  110. package/dist/src/agent/ipc/inbox.js +3 -3
  111. package/dist/src/agent/ipc/socket.js +1 -1
  112. package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
  113. package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
  114. package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
  115. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  116. package/dist/src/agent/memory/builtin-memory-store.js +1 -1
  117. package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
  118. package/dist/src/agent/memory/dreaming/events.js +1 -1
  119. package/dist/src/agent/memory/dreaming/last-run.js +1 -1
  120. package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
  121. package/dist/src/agent/memory/dreaming/preview.js +1 -1
  122. package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
  123. package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
  124. package/dist/src/agent/memory/dreaming/utils.js +1 -1
  125. package/dist/src/agent/memory/memory-flush.js +1 -1
  126. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  127. package/dist/src/agent/models/manager.js +1 -1
  128. package/dist/src/agent/prompt/memory/index.js +1 -1
  129. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  130. package/dist/src/agent/reply/post-compaction-context.js +1 -1
  131. package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
  132. package/dist/src/agent/sandbox/path-policy.js +2 -2
  133. package/dist/src/agent/service.js +4 -4
  134. package/dist/src/agent/session/session-inspector.js +1 -1
  135. package/dist/src/agent/skills/config.js +2 -2
  136. package/dist/src/agent/skills/filesystem-watcher.js +1 -1
  137. package/dist/src/agent/skills/hub-hash.js +2 -2
  138. package/dist/src/agent/skills/hub-lock.js +1 -1
  139. package/dist/src/agent/skills/hub-pull.js +2 -2
  140. package/dist/src/agent/skills/index.js +2 -2
  141. package/dist/src/agent/skills/installer.js +2 -2
  142. package/dist/src/agent/skills/managed-store.js +1 -1
  143. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  144. package/dist/src/agent/skills/skill-manager.js +1 -1
  145. package/dist/src/agent/skills/skill-view-path.js +1 -1
  146. package/dist/src/agent/skills/test-framework.js +1 -1
  147. package/dist/src/agent/starter-agents.js +1 -1
  148. package/dist/src/agent/tools/dreaming-tool.js +1 -1
  149. package/dist/src/agent/tools/find.js +1 -1
  150. package/dist/src/agent/tools/grep.js +1 -1
  151. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  152. package/dist/src/agent/tools/skill-manage-tool.js +1 -1
  153. package/dist/src/agent/tools/workflow-tool.js +1 -1
  154. package/dist/src/agent/workflow/catalog.js +1 -1
  155. package/dist/src/agent/workflow/snapshot.d.ts +10 -0
  156. package/dist/src/agent/workflow/snapshot.js +136 -1
  157. package/dist/src/agent/workflow/snapshot.js.map +1 -1
  158. package/dist/src/ai-assist/text-assist.js +1 -1
  159. package/dist/src/auth/credentials.js +2 -2
  160. package/dist/src/auth/profiles/store.js +2 -2
  161. package/dist/src/auth/sync-provider-auth.js +1 -1
  162. package/dist/src/browser/cache-dir-policy.js +1 -1
  163. package/dist/src/browser/cdp-local-launcher.js +2 -2
  164. package/dist/src/browser/pipeline/source.js +1 -1
  165. package/dist/src/browser/providers/browser-ext-install.js +4 -4
  166. package/dist/src/browser/providers/cloakbrowser.js +5 -5
  167. package/dist/src/browser/providers/playwright-doctor.js +1 -1
  168. package/dist/src/browser/stealth.js +1 -1
  169. package/dist/src/channels/catalog/channel-catalog-service.d.ts +2 -1
  170. package/dist/src/channels/catalog/channel-catalog-service.js +133 -16
  171. package/dist/src/channels/catalog/channel-catalog-service.js.map +1 -1
  172. package/dist/src/channels/catalog/channel-catalog-types.d.ts +13 -0
  173. package/dist/src/channels/outbound/persist-store.js +1 -1
  174. package/dist/src/channels/pairing/allow-from-file.js +1 -1
  175. package/dist/src/channels/pairing/pairing-store.js +2 -2
  176. package/dist/src/chat-commands/agent-edit.js +2 -2
  177. package/dist/src/chat-commands/builtins/config.js +2 -2
  178. package/dist/src/cli/commands/config.js +1 -1
  179. package/dist/src/cli/commands/doctor/checks/channel-config.js +14 -1
  180. package/dist/src/cli/commands/doctor/checks/channel-config.js.map +1 -1
  181. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
  182. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  183. package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
  184. package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
  185. package/dist/src/cli/commands/extension-create.js +1 -1
  186. package/dist/src/cli/commands/extension-dev.js +2 -2
  187. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  188. package/dist/src/cli/commands/extension-pack.js +2 -2
  189. package/dist/src/cli/commands/extension.js +3 -3
  190. package/dist/src/cli/commands/gateway/logs.js +1 -1
  191. package/dist/src/cli/commands/image.js +1 -1
  192. package/dist/src/cli/commands/init.js +2 -2
  193. package/dist/src/cli/commands/models.js +1 -1
  194. package/dist/src/cli/commands/skills-test.js +1 -1
  195. package/dist/src/cli/templates.js +1 -1
  196. package/dist/src/cli/utils/gateway-client.js +1 -1
  197. package/dist/src/cli/utils/init-workspace-core.js +2 -2
  198. package/dist/src/config/agent-profile.js +1 -1
  199. package/dist/src/config/agent-typed-models.js +1 -1
  200. package/dist/src/config/gateway-bind.js +1 -1
  201. package/dist/src/config/index.js +7 -7
  202. package/dist/src/config/loader.js +4 -4
  203. package/dist/src/config/models-json.js +2 -2
  204. package/dist/src/config/paths-state.js +1 -1
  205. package/dist/src/config/paths.js +1 -1
  206. package/dist/src/config/profile.js +1 -1
  207. package/dist/src/config/reload.js +1 -1
  208. package/dist/src/config/schema.d.ts +8 -0
  209. package/dist/src/config/schema.js +7 -0
  210. package/dist/src/config/schema.js.map +1 -1
  211. package/dist/src/config/web-patch.d.ts +1 -0
  212. package/dist/src/config/web-patch.js +1 -0
  213. package/dist/src/config/web-patch.js.map +1 -1
  214. package/dist/src/config/workspace-path.js +1 -1
  215. package/dist/src/cron/executor.js +1 -1
  216. package/dist/src/cron/service.js +1 -1
  217. package/dist/src/daemon/constants.js +1 -1
  218. package/dist/src/daemon/install-plan.js +2 -2
  219. package/dist/src/daemon/launchd.js +2 -2
  220. package/dist/src/daemon/schtasks.js +2 -2
  221. package/dist/src/daemon/systemd.js +2 -2
  222. package/dist/src/extensions/bundle-mcp.js +1 -1
  223. package/dist/src/extensions/discover-extensions.js +2 -2
  224. package/dist/src/extensions/health.js +1 -1
  225. package/dist/src/extensions/install.js +2 -2
  226. package/dist/src/extensions/loader.js +2 -2
  227. package/dist/src/extensions/lockfile.js +3 -3
  228. package/dist/src/extensions/security.js +1 -1
  229. package/dist/src/extensions/update.js +2 -2
  230. package/dist/src/gateway/agents-admin.js +2 -2
  231. package/dist/src/gateway/file-path-classifier.js +2 -2
  232. package/dist/src/gateway/hono/app.js +5 -1
  233. package/dist/src/gateway/hono/app.js.map +1 -1
  234. package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -1
  235. package/dist/src/gateway/hono/lib/config-payload.js +7 -4
  236. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  237. package/dist/src/gateway/hono/lib/extension-store.js +2 -2
  238. package/dist/src/gateway/hono/lib/static-ui.js +2 -2
  239. package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
  240. package/dist/src/gateway/hono/middleware/strict-rate-limit.js +19 -5
  241. package/dist/src/gateway/hono/middleware/strict-rate-limit.js.map +1 -1
  242. package/dist/src/gateway/hono/routes/agents.js +1 -1
  243. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  244. package/dist/src/gateway/hono/routes/channels.js +18 -14
  245. package/dist/src/gateway/hono/routes/channels.js.map +1 -1
  246. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  247. package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
  248. package/dist/src/gateway/hono/routes/dreaming.js +1 -1
  249. package/dist/src/gateway/hono/routes/host-fs.js +2 -2
  250. package/dist/src/gateway/hono/routes/models.js +1 -1
  251. package/dist/src/gateway/hono/routes/shares.js +1 -1
  252. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  253. package/dist/src/gateway/hono/routes/workspace.js +2 -2
  254. package/dist/src/gateway/lock.js +3 -3
  255. package/dist/src/gateway/ports.js +1 -1
  256. package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
  257. package/dist/src/gateway/rate-limit/buckets.js +12 -0
  258. package/dist/src/gateway/rate-limit/buckets.js.map +1 -1
  259. package/dist/src/gateway/service/config-coordinator.js +1 -1
  260. package/dist/src/gateway/service/marketplace-service.js +2 -2
  261. package/dist/src/gateway/service.js +4 -4
  262. package/dist/src/gateway/workspace-fs-file-list.js +1 -1
  263. package/dist/src/goals/goal-workflow-judge.js +2 -2
  264. package/dist/src/i18n/goals-bundle.js +1 -1
  265. package/dist/src/i18n/index.js +1 -1
  266. package/dist/src/i18n/share-tool-bundle.js +2 -2
  267. package/dist/src/infra/brew.js +1 -1
  268. package/dist/src/infra/package-json.js +1 -1
  269. package/dist/src/infra/package-update-steps.js +1 -1
  270. package/dist/src/infra/path-env.js +2 -2
  271. package/dist/src/infra/restart.js +1 -1
  272. package/dist/src/infra/stable-node-path.js +1 -1
  273. package/dist/src/infra/update-check.js +1 -1
  274. package/dist/src/infra/update-global.js +1 -1
  275. package/dist/src/infra/update-lock.js +2 -2
  276. package/dist/src/infra/update-restart.js +1 -1
  277. package/dist/src/infra/update-runner.js +1 -1
  278. package/dist/src/infra/update-startup.js +1 -1
  279. package/dist/src/infra/write-file-atomic.js +2 -2
  280. package/dist/src/media/store.js +1 -1
  281. package/dist/src/notes/agent-context.js +1 -1
  282. package/dist/src/notes/service.js +1 -1
  283. package/dist/src/notes/store.js +2 -2
  284. package/dist/src/project-trust/trust-store.js +2 -2
  285. package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
  286. package/dist/src/providers/index.js +1 -1
  287. package/dist/src/providers/model-registry.js +4 -4
  288. package/dist/src/session/init-session-turn.js +1 -1
  289. package/dist/src/session/resolve-session.js +1 -1
  290. package/dist/src/session/session-title.js +2 -2
  291. package/dist/src/session/store.js +1 -1
  292. package/dist/src/share/share-auto.js +2 -2
  293. package/dist/src/share/share-store.js +3 -3
  294. package/dist/src/share/share-thumbnail.js +2 -2
  295. package/dist/src/share/share-zip.js +1 -1
  296. package/dist/src/share/site-share-store.js +3 -3
  297. package/dist/src/share/site-static-serve.js +1 -1
  298. package/dist/src/storage/sqlite/connection.js +1 -1
  299. package/dist/src/storage/sqlite/memory-index-repository.js +2 -2
  300. package/dist/src/storage/sqlite/migrations/discover.js +1 -1
  301. package/dist/src/storage/sqlite/migrations/runner.js +1 -1
  302. package/dist/src/storage/sqlite/schema.js +1 -1
  303. package/dist/src/tui/backends/embedded-backend.d.ts +8 -1
  304. package/dist/src/tui/backends/embedded-backend.js +73 -0
  305. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  306. package/dist/src/tui/backends/gateway-sse-backend.d.ts +2 -1
  307. package/dist/src/tui/backends/gateway-sse-backend.js +24 -0
  308. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  309. package/dist/src/tui/clipboard-image.js +3 -3
  310. package/dist/src/tui/components/chat-log.d.ts +2 -0
  311. package/dist/src/tui/components/chat-log.js +19 -0
  312. package/dist/src/tui/components/chat-log.js.map +1 -1
  313. package/dist/src/tui/extension-host/autocomplete.d.ts +3 -2
  314. package/dist/src/tui/extension-host/autocomplete.js +17 -3
  315. package/dist/src/tui/extension-host/autocomplete.js.map +1 -1
  316. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  317. package/dist/src/tui/extension-host/runtime.d.ts +5 -0
  318. package/dist/src/tui/extension-host/runtime.js +1 -1
  319. package/dist/src/tui/extension-host/runtime.js.map +1 -1
  320. package/dist/src/tui/theme-manager.js +1 -1
  321. package/dist/src/tui/tui-backend.d.ts +14 -0
  322. package/dist/src/tui/tui-command-formatters.js +4 -4
  323. package/dist/src/tui/tui-commands.d.ts +16 -3
  324. package/dist/src/tui/tui-commands.js +49 -21
  325. package/dist/src/tui/tui-commands.js.map +1 -1
  326. package/dist/src/tui/tui-keybindings-file.js +1 -1
  327. package/dist/src/tui/tui-scoped-models.js +2 -2
  328. package/dist/src/tui/tui-settings.js +1 -1
  329. package/dist/src/tui/tui-startup-resources.js +1 -1
  330. package/dist/src/tui/tui-startup-text.js +1 -1
  331. package/dist/src/tui/tui-startup-text.js.map +1 -1
  332. package/dist/src/tui/tui.js +78 -7
  333. package/dist/src/tui/tui.js.map +1 -1
  334. package/dist/src/tunnel/frpc-binary.js +4 -4
  335. package/dist/src/tunnel/frpc-config.js +1 -1
  336. package/dist/src/tunnel/frpc-extract.js +1 -1
  337. package/dist/src/tunnel/tunnel-state.js +1 -1
  338. package/dist/src/utils/logger/audit.js +1 -1
  339. package/dist/src/utils/logger/log-store.js +1 -1
  340. package/dist/src/utils/logger/rotation.js +1 -1
  341. package/dist/src/utils/logger/streams.js +1 -1
  342. package/dist/src/voice/tts/audio.js +1 -1
  343. package/dist/src/voice/tts/providers/edge-speech.js +2 -2
  344. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  345. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  346. package/dist/src/workflows/store/event-store.js +1 -1
  347. package/dist/src/workflows/store/run-store.js +1 -1
  348. package/package.json +1 -1
  349. package/dist/gateway/static/root/assets/agent-browser-settings-page-CWh7trjd.js +0 -6
  350. package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-kC8OuLoj.js +0 -1
  351. package/dist/gateway/static/root/assets/agents-DJWG26Si.js +0 -71
  352. package/dist/gateway/static/root/assets/apps-page-0V3DXZ7J.js +0 -1
  353. package/dist/gateway/static/root/assets/channels-settings-CIKOkYdO.js +0 -1
  354. package/dist/gateway/static/root/assets/connectors-settings-ClrDS5jH.js +0 -2
  355. package/dist/gateway/static/root/assets/cron-page-Chi_4u4P.js +0 -3
  356. package/dist/gateway/static/root/assets/dreaming-settings-B0_rs2tj.js +0 -1
  357. package/dist/gateway/static/root/assets/goal-detail-page-D_wwXL-t.js +0 -1
  358. package/dist/gateway/static/root/assets/goals-page-DZ2toZ8y.js +0 -2
  359. package/dist/gateway/static/root/assets/goals-settings-LFlwtIKE.js +0 -1
  360. package/dist/gateway/static/root/assets/index-DzmWBkq-.css +0 -1
  361. package/dist/gateway/static/root/assets/logs-page-j_D2QTuQ.js +0 -2
  362. package/dist/gateway/static/root/assets/messages-BN_WiUg0.js +0 -3
  363. package/dist/gateway/static/root/assets/models-hub-panel-CMH_TmZz.js +0 -2
  364. package/dist/gateway/static/root/assets/note-detail-page-O18BrQPq.js +0 -2
  365. package/dist/gateway/static/root/assets/notes-page-B_ZYCmY9.js +0 -1
  366. package/dist/gateway/static/root/assets/remote-access-hub-CwKgWixY.js +0 -1
  367. package/dist/gateway/static/root/assets/sessions-page-C4fcD-7B.js +0 -1
  368. package/dist/gateway/static/root/assets/settings-advanced-gate-Ad2OJ86w.js +0 -1
  369. package/dist/gateway/static/root/assets/settings-page-D2BMY5wo.js +0 -1
  370. package/dist/gateway/static/root/assets/setup-status-panel-aWwxl_E1.js +0 -1
  371. package/dist/gateway/static/root/assets/shares-settings-DUE83uIf.js +0 -1
  372. package/dist/gateway/static/root/assets/skill-reload-api-mWKJcrog.js +0 -1
  373. package/dist/gateway/static/root/assets/skills-page-0Sx1Q58n.js +0 -2
  374. package/dist/gateway/static/root/assets/voice-api-key-field-D6HR0hR2.js +0 -1
  375. package/dist/gateway/static/root/assets/workflows-page-DW0fmWhQ.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-JdwAhgNB.js";import{t as a}from"./messages-BN_WiUg0.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-D9QqUtzZ.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{$ as p,$o as m,$r as h,Ai as g,Ao as _,B as v,Ci as y,Di as b,Ei as x,G as S,H as C,Ha as w,Ii as T,Ja as E,Ka as D,Ni as O,Oa as k,Oi as A,Pa as j,Q as M,Qr as N,Si as P,Sr as F,Ti as I,V as L,Wi as R,X as z,Xr as B,Yr as V,Z as H,ai as U,at as W,bn as ee,bo as te,ct as ne,di as G,ei as K,fa as re,fo as ie,gi as q,gs as ae,h as oe,ha as se,hi as ce,ii as le,it as J,ji as Y,ka as ue,ki as X,kr as de,ks as fe,lt as pe,ni as me,ns as he,nt as ge,os as _e,ot as ve,pa as ye,ri as be,rs as xe,rt as Se,st as Ce,ti as we,tt as Te,vi as Ee,vn as De,ws as Oe,xr as ke,ya as Ae,yn as je}from"./index-DefIdW9q.js";import{a as Me,c as Ne,d as Pe,l as Fe,n as Ie,o as Le,r as Re,s as ze,t as Be,u as Ve}from"./voice-api-key-field-D6HR0hR2.js";import{t as He}from"./settings-advanced-gate-Ad2OJ86w.js";import{t as Ue}from"./settings-collapsible-section-CdjFnSAy.js";import{n as We,t as Ge}from"./settings-form-section-DZLy_exu.js";import{i as Ke,l as qe,r as Je,t as Ye}from"./config-api-DRqjEvAx.js";import{n as Xe,t as Ze}from"./save-bar-controls-BQ79Z5IP.js";var Z=n(),Q=e(t(),1),$=r();async function Qe(){let e=await u(c(`/api/image/providers`));if(!e.ok)throw Error(`Image providers: HTTP ${e.status}`);return(await e.json()).payload?.providers??[]}function $e(e){let t=new Set,n=[];for(let r of e){let e=r.models.length>0?r.models:r.defaultModel?[r.defaultModel]:[];for(let i of e){let e=`${r.id}/${i}`;t.has(e)||(t.add(e),n.push(e))}}return n}function et(e,t){let n=$e(e.filter(e=>e.configured===!0));return!t||n.includes(t)?n:[t,...n]}function tt(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/[/\s]+/).filter(Boolean);return e.filter(e=>{let t=e.toLowerCase();return r.every(e=>t.includes(e))})}var nt=`image-generation-providers`;function rt(e){let t=(0,Z.c)(80),{value:n,disabled:r,placeholder:a,searchPlaceholder:o,noMatches:s,registryEmptyHint:c,outOfFilterNote:l,className:u,onChange:d}=e,[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},t[0]=_):_=t[0];let{data:v,isLoading:b,error:S}=f(nt,Qe,_),C;t[1]===n?C=t[2]:(C=n.trim(),t[1]=n,t[2]=C);let w=C,T;t[3]===v?T=t[4]:(T=$e((v??[]).filter(ot)),t[3]=v,t[4]=T);let E=T,D;t[5]===v?D=t[6]:(D=v??[],t[5]=v,t[6]=D);let O;t[7]!==D||t[8]!==w?(O=et(D,w),t[7]=D,t[8]=w,t[9]=O):O=t[9];let k=O,j;t[10]!==k||t[11]!==h?(j=tt(k,h),t[10]=k,t[11]=h,t[12]=j):j=t[12];let M=j,N;t[13]!==E||t[14]!==l||t[15]!==w?(N=!!l&&!!w&&!E.includes(w),t[13]=E,t[14]=l,t[15]=w,t[16]=N):N=t[16];let P=N,F;t[17]!==a||t[18]!==n?(F=n.trim()?n:a,t[17]=a,t[18]=n,t[19]=F):F=t[19];let L=F,R;t[20]!==a||t[21]!==n?(R=n.trim()||a,t[20]=a,t[21]=n,t[22]=R):R=t[22];let z=R,B;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{m(e),e||g(``)},t[23]=B):B=t[23];let V=B,H=r||b,W=b?`…`:z,te;t[24]===u?te=t[25]:(te=i(I,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,y.transition,y.press,`hover:border-edge hover:bg-surface-hover/45`,A,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,u),t[24]=u,t[25]=te);let ne=b?`…`:L,G;t[26]===ne?G=t[27]:(G=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:ne}),t[26]=ne,t[27]=G);let K;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(he,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[28]=K):K=t[28];let re;t[29]!==p||t[30]!==H||t[31]!==W||t[32]!==te||t[33]!==G?(re=(0,$.jsx)(U,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:H,title:W,className:te,"aria-haspopup":`listbox`,"aria-expanded":p,children:[G,K]})}),t[29]=p,t[30]=H,t[31]=W,t[32]=te,t[33]=G,t[34]=re):re=t[34];let ie;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ie=i(`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,ee),t[35]=ie):ie=t[35];let q;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(q=i(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,x),t[36]=q):q=t[36];let ae;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>g(e.target.value),t[37]=ae):ae=t[37];let oe;t[38]!==h||t[39]!==o?(oe=(0,$.jsx)(`input`,{type:`search`,className:q,placeholder:o,value:h,onChange:ae,onKeyDown:it}),t[38]=h,t[39]=o,t[40]=oe):oe=t[40];let se;t[41]===S?se=t[42]:(se=S?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:S instanceof Error?S.message:`Failed to load image providers`}):null,t[41]=S,t[42]=se);let ce;t[43]!==k||t[44]!==S||t[45]!==b||t[46]!==s||t[47]!==c?(ce=!S&&k.length===0&&!b?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:c??s}):null,t[43]=k,t[44]=S,t[45]=b,t[46]=s,t[47]=c,t[48]=ce):ce=t[48];let J;t[49]!==k||t[50]!==S||t[51]!==M.length||t[52]!==s?(J=!S&&k.length>0&&M.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:s}):null,t[49]=k,t[50]=S,t[51]=M.length,t[52]=s,t[53]=J):J=t[53];let Y;if(t[54]!==M||t[55]!==d||t[56]!==n){let e;t[58]!==d||t[59]!==n?(e=e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===n,className:i(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,y.press,e===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{d(e),m(!1),g(``)},children:[(0,$.jsx)(_e,{className:i(`size-4 shrink-0`,e!==n&&`invisible`),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e})]},e),t[58]=d,t[59]=n,t[60]=e):e=t[60],Y=M.map(e),t[54]=M,t[55]=d,t[56]=n,t[57]=Y}else Y=t[57];let ue;t[61]!==o||t[62]!==se||t[63]!==ce||t[64]!==J||t[65]!==Y?(ue=(0,$.jsxs)(`div`,{className:`max-h-60 overflow-auto`,role:`listbox`,"aria-label":o,children:[se,ce,J,Y]}),t[61]=o,t[62]=se,t[63]=ce,t[64]=J,t[65]=Y,t[66]=ue):ue=t[66];let X;t[67]!==oe||t[68]!==ue?(X=(0,$.jsx)(be,{children:(0,$.jsxs)(me,{className:ie,side:`bottom`,sideOffset:4,align:`end`,onOpenAutoFocus:at,children:[oe,ue]})}),t[67]=oe,t[68]=ue,t[69]=X):X=t[69];let de;t[70]!==p||t[71]!==re||t[72]!==X?(de=(0,$.jsxs)(le,{open:p,onOpenChange:V,modal:!1,children:[re,X]}),t[70]=p,t[71]=re,t[72]=X,t[73]=de):de=t[73];let fe;t[74]!==l||t[75]!==P?(fe=P?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400/90`,children:l}):null,t[74]=l,t[75]=P,t[76]=fe):fe=t[76];let pe;return t[77]!==de||t[78]!==fe?(pe=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[de,fe]}),t[77]=de,t[78]=fe,t[79]=pe):pe=t[79],pe}function it(e){return e.stopPropagation()}function at(e){return e.preventDefault()}function ot(e){return e.configured===!0}function st(e,t,n){let r=e.trim();return r?`model:${r}`:`empty:${n.slice(0,t).filter(e=>!e.trim()).length}`}function ct(e){let t=(0,Z.c)(37),{a:n,chat:r,form:i,update:a}=e,o;t[0]!==n.cardModelsSubtitle||t[1]!==n.cardModelsTitle?(o=(0,$.jsx)(We,{icon:ie,title:n.cardModelsTitle,subtitle:n.cardModelsSubtitle}),t[0]=n.cardModelsSubtitle,t[1]=n.cardModelsTitle,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=e=>a({imageModel:e}),t[3]=a,t[4]=s);let c;t[5]!==n.visionOutOfFilterNote||t[6]!==n.visionRegistryEmpty||t[7]!==r.modelNoMatches||t[8]!==r.modelPlaceholder||t[9]!==r.modelSearchPlaceholder||t[10]!==i.imageModel||t[11]!==s?(c=(0,$.jsx)(S,{value:i.imageModel,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,capabilitiesFilter:`vision`,registryEmptyHint:n.visionRegistryEmpty,outOfFilterNote:n.visionOutOfFilterNote,onChange:s}),t[5]=n.visionOutOfFilterNote,t[6]=n.visionRegistryEmpty,t[7]=r.modelNoMatches,t[8]=r.modelPlaceholder,t[9]=r.modelSearchPlaceholder,t[10]=i.imageModel,t[11]=s,t[12]=c):c=t[12];let l;t[13]!==n.desc.imageModel||t[14]!==n.label.imageModel||t[15]!==c?(l=(0,$.jsx)(qe,{label:n.label.imageModel,description:n.desc.imageModel,children:c}),t[13]=n.desc.imageModel,t[14]=n.label.imageModel,t[15]=c,t[16]=l):l=t[16];let u;t[17]===a?u=t[18]:(u=e=>a({imageGenerationModel:e}),t[17]=a,t[18]=u);let d;t[19]!==n.imageGenOutOfFilterNote||t[20]!==n.imageGenRegistryEmpty||t[21]!==r.modelNoMatches||t[22]!==r.modelPlaceholder||t[23]!==r.modelSearchPlaceholder||t[24]!==i.imageGenerationModel||t[25]!==u?(d=(0,$.jsx)(rt,{value:i.imageGenerationModel,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,registryEmptyHint:n.imageGenRegistryEmpty,outOfFilterNote:n.imageGenOutOfFilterNote,onChange:u}),t[19]=n.imageGenOutOfFilterNote,t[20]=n.imageGenRegistryEmpty,t[21]=r.modelNoMatches,t[22]=r.modelPlaceholder,t[23]=r.modelSearchPlaceholder,t[24]=i.imageGenerationModel,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.desc.imageGenerationModel||t[28]!==n.label.imageGenerationModel||t[29]!==d?(f=(0,$.jsx)(qe,{label:n.label.imageGenerationModel,description:n.desc.imageGenerationModel,children:d}),t[27]=n.desc.imageGenerationModel,t[28]=n.label.imageGenerationModel,t[29]=d,t[30]=f):f=t[30];let p;t[31]!==l||t[32]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-5`,children:[l,f]}),t[31]=l,t[32]=f,t[33]=p):p=t[33];let m;return t[34]!==o||t[35]!==p?(m=(0,$.jsxs)(Ge,{children:[o,p]}),t[34]=o,t[35]=p,t[36]=m):m=t[36],m}function lt(e){let t=(0,Z.c)(45),{a:n,chat:r,form:i,update:a}=e,o=n.label.imageModelFallbacks,s=n.desc.imageModelFallbacks,c;t[0]!==n.removeModelFallback||t[1]!==n.visionOutOfFilterNote||t[2]!==n.visionRegistryEmpty||t[3]!==r||t[4]!==i.imageModelFallbacks||t[5]!==a?(c=i.imageModelFallbacks.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(S,{value:e,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,capabilitiesFilter:`vision`,registryEmptyHint:n.visionRegistryEmpty,outOfFilterNote:n.visionOutOfFilterNote,onChange:e=>{let n=[...i.imageModelFallbacks];n[t]=e,a({imageModelFallbacks:n})}})}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageModelFallbacks:i.imageModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(R,{className:`size-4`,strokeWidth:1.75})})]},st(e,t,i.imageModelFallbacks))),t[0]=n.removeModelFallback,t[1]=n.visionOutOfFilterNote,t[2]=n.visionRegistryEmpty,t[3]=r,t[4]=i.imageModelFallbacks,t[5]=a,t[6]=c):c=t[6];let l;t[7]!==i.imageModelFallbacks||t[8]!==a?(l=()=>a({imageModelFallbacks:[...i.imageModelFallbacks,``]}),t[7]=i.imageModelFallbacks,t[8]=a,t[9]=l):l=t[9];let u;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(k,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[10]=u):u=t[10];let d;t[11]!==n.addModelFallback||t[12]!==l?(d=(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:l,children:[u,n.addModelFallback]}),t[11]=n.addModelFallback,t[12]=l,t[13]=d):d=t[13];let f;t[14]!==c||t[15]!==d?(f=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,d]}),t[14]=c,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==n.desc.imageModelFallbacks||t[18]!==n.label.imageModelFallbacks||t[19]!==f?(p=(0,$.jsx)(qe,{label:o,description:s,children:f}),t[17]=n.desc.imageModelFallbacks,t[18]=n.label.imageModelFallbacks,t[19]=f,t[20]=p):p=t[20];let m=n.label.imageGenerationModelFallbacks,h=n.desc.imageGenerationModelFallbacks,g;t[21]!==n.imageGenOutOfFilterNote||t[22]!==n.imageGenRegistryEmpty||t[23]!==n.removeModelFallback||t[24]!==r||t[25]!==i.imageGenerationModelFallbacks||t[26]!==a?(g=i.imageGenerationModelFallbacks.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(rt,{value:e,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,registryEmptyHint:n.imageGenRegistryEmpty,outOfFilterNote:n.imageGenOutOfFilterNote,onChange:e=>{let n=[...i.imageGenerationModelFallbacks];n[t]=e,a({imageGenerationModelFallbacks:n})}})}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageGenerationModelFallbacks:i.imageGenerationModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(R,{className:`size-4`,strokeWidth:1.75})})]},st(e,t,i.imageGenerationModelFallbacks))),t[21]=n.imageGenOutOfFilterNote,t[22]=n.imageGenRegistryEmpty,t[23]=n.removeModelFallback,t[24]=r,t[25]=i.imageGenerationModelFallbacks,t[26]=a,t[27]=g):g=t[27];let _;t[28]!==i.imageGenerationModelFallbacks||t[29]!==a?(_=()=>a({imageGenerationModelFallbacks:[...i.imageGenerationModelFallbacks,``]}),t[28]=i.imageGenerationModelFallbacks,t[29]=a,t[30]=_):_=t[30];let v;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(k,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[31]=v):v=t[31];let y;t[32]!==n.addModelFallback||t[33]!==_?(y=(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:_,children:[v,n.addModelFallback]}),t[32]=n.addModelFallback,t[33]=_,t[34]=y):y=t[34];let b;t[35]!==g||t[36]!==y?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[g,y]}),t[35]=g,t[36]=y,t[37]=b):b=t[37];let x;t[38]!==n.desc.imageGenerationModelFallbacks||t[39]!==n.label.imageGenerationModelFallbacks||t[40]!==b?(x=(0,$.jsx)(qe,{label:m,description:h,children:b}),t[38]=n.desc.imageGenerationModelFallbacks,t[39]=n.label.imageGenerationModelFallbacks,t[40]=b,t[41]=x):x=t[41];let C;return t[42]!==x||t[43]!==p?(C=(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p,x]}),t[42]=x,t[43]=p,t[44]=C):C=t[44],C}function ut(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g)}var dt=()=>c(Pe);function ft(e){return{imageModel:e.imageModel,imageModelFallbacks:e.imageModelFallbacks,imageGenerationModel:e.imageGenerationModel,imageGenerationModelFallbacks:e.imageGenerationModelFallbacks,imageGenerationModelTimeoutMs:e.imageGenerationModelTimeoutMs,imageGenerationModelAutoProviderFallback:e.imageGenerationModelAutoProviderFallback}}function pt(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 mt=v(),ht={loading:!0,saving:!1,savedFlash:!1,error:void 0};function gt({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.imageModelsSettings,c=!!s(e=>e.token),[l,u]=(0,Q.useReducer)(mt,{form:null,baseline:null}),p=l.form,m=l.baseline,[h,g]=(0,Q.useReducer)(C,ht),{loading:_,saving:v,error:y}=h,b=de(),x=(0,Q.useMemo)(()=>new Set(b.map(e=>e.id)),[b]),S=(0,Q.useCallback)(async()=>{if(c){g({type:`patch`,patch:{loading:!0,error:void 0}});try{let e=await Ye();u({type:`sync`,value:structuredClone(e)})}catch(e){g({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{loading:!1}})}}},[c]);(0,Q.useEffect)(()=>{S()},[S]);let w=(0,Q.useCallback)(e=>{u({type:`patch`,patch:e})},[]),{data:T=[]}=f(c?dt():null,Ve,{revalidateOnFocus:!1}),D=T.some(e=>e.configured),O=F(c),k=Ne(T),A=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(ft(p))!==JSON.stringify(ft(m)),[p,m]),j=A||k.credDirty;(0,Q.useEffect)(()=>{if(!j)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[j]);let M=(0,Q.useCallback)(async()=>{if(p){g({type:`patch`,patch:{saving:!0,error:void 0}});try{try{Je(p.paramsJson)}catch(e){g({type:`patch`,patch:{error:e instanceof SyntaxError?n.agentSettings.advanced.paramsInvalidJson:e instanceof Error?e.message:n.agentSettings.advanced.paramsInvalidJson}});return}let e=[];A&&e.push(Ke(p).then(()=>{u({type:`saved`,value:structuredClone(p)}),O.mutate?.()})),k.credDirty&&e.push(k.saveCredentials(r.credentialsSaveError)),await Promise.all(e),g({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:r.saved})}catch(e){g({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{saving:!1}})}}},[p,A,O,n.agentSettings,k,r.credentialsSaveError]),N=(0,Q.useCallback)(()=>{m&&(u({type:`discard`}),k.credDirty&&k.onDiscardCredentials(),g({type:`patch`,patch:{error:void 0,savedFlash:!1}}))},[m,k]);Xe({id:`image-models`,dirty:j,saving:v,save:M,discard:N});let P=(0,Q.useMemo)(()=>pt(r),[r]),I=(0,Q.useMemo)(()=>({getApiKey:n.providersSettings.getApiKey,getApiKeyIntl:n.providersSettings.getApiKeyIntl,getApiKeyCn:n.providersSettings.getApiKeyCn}),[n.providersSettings]),L=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,R=e?`w-full text-sm text-fg-muted`:`mx-auto w-full max-w-app-main px-4 py-8 text-sm text-fg-muted`,z=e?`flex w-full items-center gap-2 text-sm text-fg-muted`:`mx-auto flex w-full max-w-app-main items-center gap-2 px-4 py-8 text-sm text-fg-muted`;return c?_||!p?(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsx)(E,{className:`size-4 animate-spin`}),` Loading…`]}):(0,$.jsxs)(`div`,{className:L,children:[e?null:(0,$.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:N,disabled:!j||v,children:r.discard}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,onClick:()=>void M(),disabled:!j||v,children:[v?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(Ae,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`ml-1.5`,children:v?r.saving:r.save})]})]})]}),y?(0,$.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:y}):null,(0,$.jsx)(ct,{form:p,update:w,a:n.agentSettings,chat:n.chat}),(0,$.jsx)(Ue,{advancedOnly:!0,showLabel:r.fallbackChainsTitle,hideLabel:r.fallbackChainsTitle,children:(0,$.jsx)(lt,{form:p,update:w,a:n.agentSettings,chat:n.chat})}),(0,$.jsx)(Ue,{advancedOnly:!0,showLabel:r.runtimeTuningTitle,hideLabel:r.runtimeTuningTitle,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,children:r.timeoutLabel}),(0,$.jsx)(`input`,{type:`number`,min:0,step:1e3,className:i(ut(),`max-w-48`),value:p.imageGenerationModelTimeoutMs??``,placeholder:`120000`,onChange:e=>{let t=e.target.value.trim(),n=t===``?null:Math.max(0,Math.floor(Number(t)));w({imageGenerationModelTimeoutMs:n&&n>0?n:null})}}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.timeoutHint})]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:p.imageGenerationModelAutoProviderFallback,onChange:e=>w({imageGenerationModelAutoProviderFallback:e.target.checked}),"aria-label":r.autoFallbackLabel}),(0,$.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:r.autoFallbackLabel}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:r.autoFallbackHint})]})]})]})}),(0,$.jsx)(Ue,{advancedOnly:!0,icon:ye,showLabel:r.providersTitle,hideLabel:r.providersTitle,defaultOpen:D,children:T.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.providersEmpty}):(0,$.jsx)(Fe,{summaries:T,credDraft:k.credDraft,credBaseline:k.credBaseline,credDirty:k.credDirty,credSaving:k.credSaving,credError:k.credError,credSavedFlash:k.credSavedFlash,credNoopFlash:k.credNoopFlash,updateCredRow:k.updateCredRow,onDiscardCredentials:k.onDiscardCredentials,onSaveCredentials:()=>void k.saveCredentials(r.credentialsSaveError),extensionIds:x,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:t,apiKeyLinkLabels:I,messages:P})})]}):(0,$.jsx)(`div`,{className:R,children:t===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var _t=b;function vt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function yt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function bt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function xt(){return i(X,b)}var St=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Ct=[{id:`whisper-1`,name:`Whisper-1`}],wt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Tt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Et=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Dt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Ot=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],kt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],At=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],jt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],Mt=[{id:`openai`,capability:`tts`,displayName:`OpenAI`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.openai`}},{id:`alibaba`,capability:`tts`,displayName:`Alibaba DashScope`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.alibaba`}},{id:`minimax`,capability:`tts`,displayName:`MiniMax`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.minimax`}},{id:`edge`,capability:`tts`,displayName:`Microsoft Edge`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!1,configPath:`messages.tts.providers.edge`}},{id:`tts-local-cli`,capability:`tts`,displayName:`Local CLI`,aliases:[`cli`,`local-cli`],configured:!1,fields:[],diagnostics:{requiresApiKey:!1,configPath:`messages.tts.providers.tts-local-cli`}}],Nt=[{id:`alibaba`,capability:`stt`,displayName:`Alibaba DashScope`,aliases:[`dashscope`,`paraformer`],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`tools.media.audio.providers.alibaba`}},{id:`openai`,capability:`stt`,displayName:`OpenAI Whisper`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`tools.media.audio.providers.openai`}}];function Pt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Ft(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 It(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Lt(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 Rt(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 zt(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 Bt({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.voiceSettings,i=!!s(e=>e.token),[l,u]=(0,Q.useReducer)(zt,{form:null,baseline:null}),p=l.form,m=l.baseline,[h,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(!1),C=(0,Q.useRef)({parsed:null,models:void 0}),{data:w,error:T,isLoading:D,mutate:O}=F(i),{data:k,error:A,isLoading:j,mutate:M}=f(i?c(`/api/voice/models`):null,Ie,{revalidateOnFocus:!1}),{data:N,error:P,isLoading:I}=f(i?c(`/api/voice/providers`):null,Re,{revalidateOnFocus:!1}),{data:L,error:R,isLoading:z}=f(i?c(`/api/voice/stt-providers`):null,Me,{revalidateOnFocus:!1}),B=(0,Q.useMemo)(()=>N?.providers??Mt,[N]),V=(0,Q.useMemo)(()=>L?.providers??Nt,[L]),H=(0,Q.useMemo)(()=>w?.payload?.config===void 0?null:Le(w.payload.config),[w]),U=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]);i?H!==null&&k!==void 0&&!S.current&&(C.current.parsed!==H||C.current.models!==k)&&(C.current={parsed:H,models:k},u({type:`sync`,value:H}),g(k)):(C.current.parsed!==null||C.current.models!==void 0)&&(C.current={parsed:null,models:void 0},u({type:`reset`}),g(null),S.current=!1);let W=!!(i&&(H===null||k===void 0||N===void 0||L===void 0)&&(D||j||I||z)),ee=T instanceof Error?T.message:T?String(T):A instanceof Error?A.message:A?String(A):P instanceof Error?P.message:P?String(P):R instanceof Error?R.message:R?String(R):null,te=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),ne=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),K=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),re=(0,Q.useCallback)(e=>{S.current=!0,u({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}}}}})},[]),ie=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),q=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ae=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),oe=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),se=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ce=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]),le=(0,Q.useCallback)(async()=>{if(!(!p||v)){y(!0),x(null);try{await ze(p),u({type:`saved`,value:p}),S.current=!1,d({type:`success`,title:r.saved})}catch(e){x(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}},[p,v,r.saveError]),J=(0,Q.useCallback)(()=>{m&&(S.current=!1,u({type:`discard`}),x(null))},[m]);Xe({id:`voice`,dirty:U,saving:v,save:le,discard:J});let ue=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,X=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;if(!i)return(0,$.jsxs)(`div`,{className:X,children:[e?null:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.voice}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(W)return(0,$.jsx)(`div`,{className:X,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(E,{className:`size-4 animate-spin`}),r.loading]})});if(!p||h===null)return(0,$.jsxs)(`div`,{className:X,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b??ee??r.loadError}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>{O(),M()},children:r.retry})]});let de=p.stt,fe=p.tts,pe=It(r);return(0,$.jsxs)(`div`,{className:ue,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,$.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.voice}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,$.jsxs)(`a`,{href:G(t,`voice`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,$.jsx)(_,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,disabled:!U||v,onClick:J,children:r.discard}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!U||v,onClick:()=>void le(),children:v?r.saving:r.save})]})]}),U&&!e?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,b?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(Vt,{v:r,apiKeyLabels:pe,stt:de,models:h,sttProviders:V,updateStt:te,updateSttAlibaba:ne,updateSttOpenai:K,updateSttFallback:re}),(0,$.jsx)(Kt,{v:r,apiKeyLabels:pe,tts:fe,models:h,ttsProviders:B,updateTts:ie,updateTtsAlibaba:q,updateTtsOpenai:ae,updateTtsEdge:oe,updateTtsMinimax:se,updateTtsLocalCli:ce})]}),(0,$.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,$.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,$.jsx)(`strong`,{className:`text-accent`,children:r.notes.title}),` `,r.notes.duration]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:r.notes.envVars})]})]})}function Vt(e){let t=(0,Z.c)(60),{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:St,p=o?.stt?.openai?.length?o.stt.openai:Ct,m;if(t[0]!==a.provider||t[1]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));if(a.provider&&!e.has(a.provider)){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3];let n;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=[{key:`apiKey`,label:`API Key`,type:`password`,secret:!0},{key:`model`,label:`Model`,type:`string`}],t[4]=n):n=t[4];let r=`tools.media.audio.providers.${a.provider}`,i;t[5]===r?i=t[6]:(i={requiresApiKey:!0,configPath:r},t[5]=r,t[6]=i);let o;t[7]!==a.provider||t[8]!==i?(o={id:a.provider,capability:`stt`,displayName:a.provider,aliases:e,configured:!1,fields:n,diagnostics:i},t[7]=a.provider,t[8]=i,t[9]=o):o=t[9],m.push(o)}t[0]=a.provider,t[1]=s,t[2]=m}else m=t[2];let h=m,g,_,v,y,b;if(t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==h||t[14]!==a||t[15]!==c||t[16]!==l||t[17]!==d||t[18]!==u||t[19]!==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(Gt),C;t[25]!==a.provider||t[26]!==a.providers||t[27]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[25]=a.provider,t[26]=a.providers,t[27]=c,t[28]=C):C=t[28];let T=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let E;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(w,{className:`size-4 text-accent`,strokeWidth:1.75}),t[29]=E):E=t[29];let D;t[30]===n.stt.title?D=t[31]:(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[E,n.stt.title]}),t[30]=n.stt.title,t[31]=D);let O;t[32]===n.stt.description?O=t[33]:(O=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[32]=n.stt.description,t[33]=O),t[34]!==D||t[35]!==O?(b=(0,$.jsxs)(`div`,{className:`mb-4`,children:[D,O]}),t[34]=D,t[35]=O,t[36]=b):b=t[36],g=`space-y-4`;let k;t[37]===n.stt.enable?k=t[38]:(k=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.enable}),t[37]=n.stt.enable,t[38]=k);let A;t[39]===n.stt.enableDesc?A=t[40]:(A=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.enableDesc}),t[39]=n.stt.enableDesc,t[40]=A);let j;t[41]!==k||t[42]!==A?(j=(0,$.jsxs)(`div`,{children:[k,A]}),t[41]=k,t[42]=A,t[43]=j):j=t[43];let M;t[44]===c?M=t[45]:(M=e=>c({enabled:e.target.checked}),t[44]=c,t[45]=M);let N;t[46]!==a.enabled||t[47]!==M?(N=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.enabled,onChange:M}),t[46]=a.enabled,t[47]=M,t[48]=N):N=t[48],t[49]!==j||t[50]!==N?(_=(0,$.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:[j,N]}),t[49]=j,t[50]=N,t[51]=_):_=t[51],v=a.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.stt.provider}),(0,$.jsx)(`select`,{className:xt(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[Pt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.stt.model}),a.provider===`alibaba`?(0,$.jsx)(`select`,{className:xt(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(Wt)}):a.provider===`openai`?(0,$.jsx)(`select`,{className:xt(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(Ut)}):a.provider===`groq`?(0,$.jsx)(`select`,{className:xt(),value:m||wt[0].id,onChange:e=>T({model:e.target.value}),children:wt.map(Ht)}):(0,$.jsx)(`input`,{className:bt(),value:m,onChange:e=>T({model:e.target.value}),placeholder:a.provider})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.stt.apiKey}),(0,$.jsx)(Be,{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}):T({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,vt(a.provider)?` ${vt(a.provider)}`:``]})]})]}),S.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,$.jsx)(Zt,{field:e,value:Lt(x,e),onChange:t=>T({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:_t},e.key))}):null,(0,$.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,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[10]=f,t[11]=r,t[12]=p,t[13]=h,t[14]=a,t[15]=c,t[16]=l,t[17]=d,t[18]=u,t[19]=n,t[20]=g,t[21]=_,t[22]=v,t[23]=y,t[24]=b}else g=t[20],_=t[21],v=t[22],y=t[23],b=t[24];let x;t[52]!==g||t[53]!==_||t[54]!==v?(x=(0,$.jsxs)(`div`,{className:g,children:[_,v]}),t[52]=g,t[53]=_,t[54]=v,t[55]=x):x=t[55];let S;return t[56]!==y||t[57]!==b||t[58]!==x?(S=(0,$.jsxs)(`section`,{className:y,children:[b,x]}),t[56]=y,t[57]=b,t[58]=x,t[59]=S):S=t[59],S}function Ht(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ut(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Wt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Gt(e){return e.key!==`apiKey`&&e.key!==`model`}function Kt(e){let t=(0,Z.c)(76),{v:n,apiKeyLabels:r,tts:a,models:o,ttsProviders:s,updateTts:c,updateTtsAlibaba:l,updateTtsOpenai:u,updateTtsEdge:d,updateTtsMinimax:f,updateTtsLocalCli:p}=e,m;t[0]===n?m=t[1]:(m=e=>e===`off`?n.tts.triggerDescOff:e===`always`?n.tts.triggerDescAlways:e===`inbound`?n.tts.triggerDescInbound:e===`tagged`?n.tts.triggerDescTagged:``,t[0]=n,t[1]=m);let h=m,g=o?.tts?.openai?.length?o.tts.openai:Tt,_=o?.ttsVoices?.openai?.length?o.ttsVoices.openai:Et,v=o?.tts?.alibaba?.length?o.tts.alibaba:Dt,y=o?.ttsVoices?.alibaba?.length?o.ttsVoices.alibaba:Ot,b=o?.ttsVoices?.edge?.length?o.ttsVoices.edge:kt,x=o?.tts?.minimax?.length?o.tts.minimax:At,S=o?.ttsVoices?.minimax?.length?o.ttsVoices.minimax:jt,C;if(t[2]!==a.provider||t[3]!==s){let e=new Set;C=[];for(let t of s)e.has(t.id)||(e.add(t.id),C.push(t));if(a.provider&&!e.has(a.provider)){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[5]=e):e=t[5];let n;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=[{key:`apiKey`,label:`API Key`,type:`password`,secret:!0},{key:`model`,label:`Model`,type:`string`},{key:`voice`,label:`Voice`,type:`string`}],t[6]=n):n=t[6];let r=`messages.tts.providers.${a.provider}`,i;t[7]===r?i=t[8]:(i={requiresApiKey:!0,configPath:r},t[7]=r,t[8]=i);let o;t[9]!==i||t[10]!==a.provider?(o={id:a.provider,capability:`tts`,displayName:a.provider,aliases:e,configured:!1,fields:n,diagnostics:i},t[9]=i,t[10]=a.provider,t[11]=o):o=t[11],C.push(o)}t[2]=a.provider,t[3]=s,t[4]=C}else C=t[4];let w=C,E,D,O,k,A;if(t[12]!==r||t[13]!==w||t[14]!==h||t[15]!==a||t[16]!==v||t[17]!==x||t[18]!==g||t[19]!==y||t[20]!==b||t[21]!==S||t[22]!==_||t[23]!==c||t[24]!==l||t[25]!==d||t[26]!==p||t[27]!==f||t[28]!==u||t[29]!==n){let e=w.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s={...a.provider===`openai`?a.openai??{}:{},...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`edge`?a.edge??{}:{},...a.provider===`minimax`?a.minimax??{}:{},...a.provider===`tts-local-cli`?a[`tts-local-cli`]??{}:{},...o??{}},m=(e?.fields??[]).filter(Xt),C;t[35]!==a.provider||t[36]!==a.providers||t[37]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[35]=a.provider,t[36]=a.providers,t[37]=c,t[38]=C):C=t[38];let j=C,M;t[39]!==a.provider||t[40]!==j||t[41]!==d||t[42]!==f||t[43]!==u?(M=(e,t)=>{let n={[e.key]:t};j(n),a.provider===`openai`&&e.key===`baseUrl`?u(n):a.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?f(n):a.provider===`edge`&&e.key===`lang`&&d(n)},t[39]=a.provider,t[40]=j,t[41]=d,t[42]=f,t[43]=u,t[44]=M):M=t[44];let N=M;k=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let P;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(T,{className:`size-4 text-accent`,strokeWidth:1.75}),t[45]=P):P=t[45];let F;t[46]===n.tts.title?F=t[47]:(F=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,n.tts.title]}),t[46]=n.tts.title,t[47]=F);let I;t[48]===n.tts.description?I=t[49]:(I=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.tts.description}),t[48]=n.tts.description,t[49]=I),t[50]!==F||t[51]!==I?(A=(0,$.jsxs)(`div`,{className:`mb-4`,children:[F,I]}),t[50]=F,t[51]=I,t[52]=A):A=t[52],E=`space-y-4`;let L;t[53]===n.tts.enable?L=t[54]:(L=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.tts.enable}),t[53]=n.tts.enable,t[54]=L);let R;t[55]===n.tts.enableDesc?R=t[56]:(R=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.tts.enableDesc}),t[55]=n.tts.enableDesc,t[56]=R);let z;t[57]!==L||t[58]!==R?(z=(0,$.jsxs)(`div`,{children:[L,R]}),t[57]=L,t[58]=R,t[59]=z):z=t[59];let B;t[60]===c?B=t[61]:(B=e=>c({enabled:e.target.checked}),t[60]=c,t[61]=B);let V;t[62]!==B||t[63]!==a.enabled?(V=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.enabled,onChange:B}),t[62]=B,t[63]=a.enabled,t[64]=V):V=t[64],t[65]!==z||t[66]!==V?(D=(0,$.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:[z,V]}),t[65]=z,t[66]=V,t[67]=D):D=t[67],O=a.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.tts.trigger}),(0,$.jsxs)(`select`,{className:xt(),value:a.trigger,onChange:e=>c({trigger:e.target.value}),children:[(0,$.jsx)(`option`,{value:`off`,children:n.tts.triggerOff}),(0,$.jsx)(`option`,{value:`always`,children:n.tts.triggerAlways}),(0,$.jsx)(`option`,{value:`inbound`,children:n.tts.triggerInbound}),(0,$.jsx)(`option`,{value:`tagged`,children:n.tts.triggerTagged})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:h(a.trigger)})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.tts.provider}),(0,$.jsx)(`select`,{className:xt(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:w.map(e=>(0,$.jsx)(`option`,{value:e.id,children:Ft(e.id,n)},e.id))})]})]}),a.provider===`openai`||a.provider===`alibaba`||a.provider===`minimax`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.stt.apiKey}),(0,$.jsx)(Be,{kind:`tts`,providerId:a.provider,fieldId:`voice-tts-${a.provider}-api-key`,value:a.provider===`openai`?a.openai?.apiKey??``:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.minimax?.apiKey??``,onChange:e=>{a.provider===`openai`?u({apiKey:e}):a.provider===`alibaba`?l({apiKey:e}):f({apiKey:e})},labels:r,placeholder:a.provider===`minimax`?`eyJ...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,yt(a.provider)?` ${yt(a.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.stt.model}),(0,$.jsx)(`select`,{className:xt(),value:a.provider===`openai`?a.openai?.model??``:a.provider===`alibaba`?a.alibaba?.model??``:a.minimax?.model??``,onChange:e=>{a.provider===`openai`?u({model:e.target.value}):a.provider===`alibaba`?l({model:e.target.value}):f({model:e.target.value})},children:(a.provider===`openai`?g:a.provider===`alibaba`?v:x).map(Yt)})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.tts.voice}),(0,$.jsx)(`select`,{className:xt(),value:a.provider===`openai`?a.openai?.voice??``:a.provider===`alibaba`?a.alibaba?.voice??``:a.minimax?.voice??``,onChange:e=>{a.provider===`openai`?u({voice:e.target.value}):a.provider===`alibaba`?l({voice:e.target.value}):f({voice:e.target.value})},children:(a.provider===`openai`?_:a.provider===`alibaba`?y:S).map(Jt)})]})]}):null,a.provider===`edge`?(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_t),children:[(0,$.jsx)($t,{children:n.tts.voice}),(0,$.jsx)(`select`,{className:xt(),value:a.edge?.voice??``,onChange:e=>d({voice:e.target.value}),children:b.map(qt)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.edgeHint})]}):null,a.provider===`tts-local-cli`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)($t,{children:n.tts.localCli.command}),(0,$.jsx)(`input`,{className:i(bt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:a[`tts-local-cli`]?.command??``,onChange:e=>p({command:e.target.value}),placeholder:n.tts.localCli.commandPlaceholder}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.commandDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)($t,{children:n.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:i(bt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:a[`tts-local-cli`]?.cwd??``,onChange:e=>p({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.cwdDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)($t,{children:n.tts.localCli.outputFormat}),(0,$.jsxs)(`select`,{className:xt(),value:a[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>p({outputFormat:e.target.value}),children:[(0,$.jsx)(`option`,{value:`wav`,children:`wav`}),(0,$.jsx)(`option`,{value:`mp3`,children:`mp3`}),(0,$.jsx)(`option`,{value:`opus`,children:`opus`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.outputFormatDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)($t,{children:n.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:bt(),type:`number`,min:0,step:1e3,value:typeof a[`tts-local-cli`]?.timeoutMs==`number`?String(a[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){p({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&p({timeoutMs:n})},placeholder:`30000`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.timeoutMsDesc})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.tts.localCli.hint})]}):null,m.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:m.map(e=>(0,$.jsx)(Zt,{field:e,value:Lt(s,e),onChange:t=>N(e,t),className:e.type===`textarea`?`sm:col-span-2`:_t},e.key))}):null]}):null,t[12]=r,t[13]=w,t[14]=h,t[15]=a,t[16]=v,t[17]=x,t[18]=g,t[19]=y,t[20]=b,t[21]=S,t[22]=_,t[23]=c,t[24]=l,t[25]=d,t[26]=p,t[27]=f,t[28]=u,t[29]=n,t[30]=E,t[31]=D,t[32]=O,t[33]=k,t[34]=A}else E=t[30],D=t[31],O=t[32],k=t[33],A=t[34];let j;t[68]!==E||t[69]!==D||t[70]!==O?(j=(0,$.jsxs)(`div`,{className:E,children:[D,O]}),t[68]=E,t[69]=D,t[70]=O,t[71]=j):j=t[71];let M;return t[72]!==k||t[73]!==A||t[74]!==j?(M=(0,$.jsxs)(`section`,{className:k,children:[A,j]}),t[72]=k,t[73]=A,t[74]=j,t[75]=M):M=t[75],M}function qt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Jt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Yt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Xt(e){return![`apiKey`,`model`,`voice`].includes(e.key)}function Zt(e){let t=(0,Z.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,$.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,$.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,$.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(Rt(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,$.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,$.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,$.jsx)($t,{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,$.jsx)(`select`,{id:s,className:xt(),value:l,required:n.required,onChange:e=>a(Rt(n,e.target.value)),children:(n.options??[]).map(Qt)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:i(bt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Rt(n,e.target.value))}):n.type===`password`?(0,$.jsx)(Ee,{id:s,className:o,value:l,onChange:e=>a(Rt(n,e)),placeholder:n.placeholder,labels:ce}):(0,$.jsx)(`input`,{id:s,className:bt(),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(Rt(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,$.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,$.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 Qt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function $t(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function en(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 tn(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}}}})}),ke()}async function nn(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 rn(e){let t=(0,Z.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.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,$.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,$.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 an(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function on(){return i(X,b)}var sn=[`brave`,`tavily`,`bing`,`searxng`];function cn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var ln=v();function un({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.webSearchSettings,c=n.logs,l=!!s(e=>e.token),[u,f]=(0,Q.useReducer)(ln,{form:null,baseline:null}),p=u.form,m=u.baseline,[h,g]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(null),{data:S,error:C,isLoading:w,mutate:T}=F(l);L({enabled:l,parsed:(0,Q.useMemo)(()=>S?.payload?.config===void 0?null:en(S.payload.config),[S]),dirty:b.current,trackedParsedRef:x,dispatch:f,onResetDirty:()=>{b.current=!1}});let D=!!(l&&w&&S===void 0&&!C),O=C instanceof Error?C.message:C?String(C):null,A=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]),j=(0,Q.useCallback)(e=>{b.current=!0,f({type:`patch`,patch:e})},[]),M=(0,Q.useCallback)(async()=>{if(!(!p||h)){g(!0),y(null);try{await tn(p),b.current=!1,f({type:`saved`,value:p}),d({type:`success`,title:r.saved})}catch(e){y(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}},[p,h,r.saveError]),N=(0,Q.useCallback)(()=>{m&&(b.current=!1,f({type:`discard`}),y(null))},[m]);Xe({id:`search`,dirty:A,saving:h,save:M,discard:N});let P=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,I=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;return l?D?(0,$.jsxs)(`div`,{className:i(I,`items-center`),children:[(0,$.jsx)(E,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading})]}):p?(0,$.jsxs)(`div`,{className:P,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,$.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,$.jsxs)(`a`,{href:G(t,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,$.jsx)(_,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,disabled:!A||h,onClick:N,children:r.discard}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!A||h,onClick:()=>void M(),children:h?r.saving:r.save})]})]}),A&&!e?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,v?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null,(0,$.jsxs)(Ge,{children:[(0,$.jsx)(We,{icon:se,title:r.sectionRegion,subtitle:r.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(rn,{label:r.regionLabel,description:r.regionDesc,children:(0,$.jsxs)(`select`,{className:on(),value:p.regionMode,onChange:e=>j({regionMode:e.target.value}),children:[(0,$.jsx)(`option`,{value:`auto`,children:r.regionAuto}),(0,$.jsx)(`option`,{value:`cn`,children:r.regionCn}),(0,$.jsx)(`option`,{value:`global`,children:r.regionGlobal})]})})})]}),(0,$.jsx)(He,{children:(0,$.jsxs)(Ge,{children:[(0,$.jsx)(We,{icon:ae,title:r.sectionBlocklist,subtitle:r.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:p.blocklistEnabled,onChange:e=>j({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:r.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.blocklistEnabledDesc})]})]}),(0,$.jsx)(rn,{label:r.blocklistDomains,description:r.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:i(an(),`min-h-[6rem] font-mono text-xs`),value:p.blocklistDomains.join(`
2
- `),placeholder:r.blocklistDomainsPlaceholder,disabled:!p.blocklistEnabled,onChange:e=>{j({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(Ge,{children:[(0,$.jsx)(We,{icon:se,title:r.sectionSearch,subtitle:r.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(rn,{label:r.maxResultsLabel,description:r.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:an(),value:p.maxResults,onChange:e=>j({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.providersTitle}),p.providers.map((e,t)=>(0,$.jsx)(dn,{row:e,providerIndex:t,labels:r,secretLabels:q(n.providersSettings),onChange:e=>{let n=[...p.providers];n[t]=e,j({providers:n})},onRemove:()=>{j({providers:p.providers.filter((e,n)=>n!==t)})}},`${e.type}:${e.url}:${e.apiKey}:${e.disabled}`)),(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>j({providers:[...p.providers,cn()]}),children:[(0,$.jsx)(k,{className:`size-4`}),r.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r.footerHint})]}):(0,$.jsxs)(`div`,{className:I,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v??O??r.loadError}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void T(),children:c.refresh})]}):(0,$.jsxs)(`div`,{className:I,children:[e?null:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function dn(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>nn(r).then(fn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(on(),`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=sn.map(e=>(0,$.jsx)(`option`,{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,$.jsx)(`select`,{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,$.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,$.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,$.jsx)(R,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,$.jsx)(Y,{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,$.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,$.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,$.jsx)(rn,{label:a.urlLabel,description:a.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:an(),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,$.jsx)(Ee,{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,$.jsx)(rn,{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,$.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 fn(e){return e.apiKey??null}var pn=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function mn(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function hn(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function gn(){let e=await u(c(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(mn(t)||`HTTP ${e.status}`);return{...t.payload,config:hn(t.payload.config)}}async function _n(e){let t=await u(c(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(mn(n)||`HTTP ${t.status}`);return await Ce(),n.payload}function vn(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}function yn(){let e=(0,Z.c)(31),t=s(wn),n=!!t,{data:r,isLoading:i}=F(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?ne: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?ve: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=ge(u,J(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=hn(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 gn()}function Cn(){return pe()}function wn(e){return e.token}function Tn(e){let t=(0,Z.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,$.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,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,$.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,$.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,$.jsx)(k,{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,$.jsxs)(Y,{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,$.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,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,$.jsx)(k,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,$.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,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function On(e){let t=(0,Z.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`,y.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,$.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,$.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,$.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,$.jsx)(m,{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,$.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,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let h;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(re,{className:`size-3`,"aria-hidden":!0}),t[18]=h):h=t[18];let g;t[19]===r.manage?g=t[20]:(g=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[h,r.manage]}),t[19]=r.manage,t[20]=g);let _;t[21]!==g||t[22]!==p?(_=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,g]}),t[21]=g,t[22]=p,t[23]=_):_=t[23];let v;return t[24]!==a||t[25]!==_||t[26]!==d?(v=(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:o,children:[d,_]}),t[24]=a,t[25]=_,t[26]=d,t[27]=v):v=t[27],v}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`,`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}var Ln={ollama:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`},lmstudio:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`},openrouter:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``},zhipuCn:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`},zaiGeneral:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`}};function Rn(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var zn=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function Bn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function Vn(){return i(X,b)}function Hn(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function Un(e){return e===`text,image`?[`text`,`image`]:[`text`]}function Wn(e){let t=(0,Z.c)(21),{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,Q.useState)(u),[p,m]=(0,Q.useState)(``),g;t[1]===r?g=t[2]:(g=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=g);let _=g,v;t[3]!==_||t[4]!==l?(v=()=>{l(),_(!1)},t[3]=_,t[4]=l,t[5]=v):v=t[5];let y=v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(N,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,je)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=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`,De),t[7]=x):x=t[7];let S;t[8]!==a||t[9]!==o||t[10]!==y||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.providerId||t[15]!==d.type?(S=(0,$.jsxs)(h,{children:[b,(0,$.jsx)(B,{className:x,children:d.type===`pick`?(0,$.jsx)(Kn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>f({type:`builtin`,providerId:e}),onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,$.jsx)(qn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y}):(0,$.jsx)(Xn,{customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y})})]}),t[8]=a,t[9]=o,t[10]=y,t[11]=s,t[12]=c,t[13]=p,t[14]=d.providerId,t[15]=d.type,t[16]=S):S=t[16];let C;return t[17]!==_||t[18]!==n||t[19]!==S?(C=(0,$.jsx)(K,{open:n,onOpenChange:_,children:S}),t[17]=_,t[18]=n,t[19]=S,t[20]=C):C=t[20],C}function Gn(e){let t=(0,Z.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`,y.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function Kn(e){let t=(0,Z.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=z[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 h=p,_;t[9]===o.step1Title?_=t[10]:(_=(0,$.jsx)(we,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=_);let v;t[11]===o.close?v=t[12]:(v=(0,$.jsx)(Gn,{label:o.close}),t[11]=o.close,t[12]=v);let b;t[13]!==_||t[14]!==v?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[_,v]}),t[13]=_,t[14]=v,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(se,{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]=x):x=t[16];let S;t[17]===a?S=t[18]:(S=e=>a(e.target.value),t[17]=a,t[18]=S);let C=o.searchPlaceholder,w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w=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`,g),t[19]=w):w=t[19];let T;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==S?(T=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[x,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:S,placeholder:C,autoComplete:`off`,autoFocus:!0,className:w})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=S,t[23]=T):T=t[23];let E;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(E=u?null:(0,$.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`,y.press),children:[(0,$.jsx)(te,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,$.jsx)(xe,{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]=E):E=t[28];let D;t[29]!==f.length||t[30]!==h||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(D=f.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:Fn.map(e=>{let t=h.get(e)??[];return t.length===0?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.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`,y.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(m,{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]=h,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=D):D=t[34];let O;t[35]!==E||t[36]!==D?(O=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[E,D]}),t[35]=E,t[36]=D,t[37]=O):O=t[37];let k;return t[38]!==T||t[39]!==O||t[40]!==b?(k=(0,$.jsxs)($.Fragment,{children:[b,T,O]}),t[38]=T,t[39]=O,t[40]=b,t[41]=k):k=t[41],k}function qn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=z[e],[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(null),S=a(r).providersSettings,C=q(S),w=(0,Q.useMemo)(()=>H(e,r),[e,r]),T=c?.supportsApiKey!==!1,D=c?.supportsOAuth===!0,[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(`idle`),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(``),U=N===`waiting`||N===`waiting_code`;(0,Q.useEffect)(()=>{if(!O||!U)return;let e=window.setInterval(()=>{(async()=>{try{let t=await An(O);t.status===`waiting_auth`||t.status===`waiting_code`?(P(t.status===`waiting_code`?`waiting_code`:`waiting`),j(t.message??null),I(t.authUrl??null),R(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),P(`success`),j(t.message??S.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),P(`error`),j(t.error??t.message??S.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[O,U,s,S.revokeFailed,S.saved]),(0,Q.useEffect)(()=>()=>{O&&Nn(O).catch(()=>{})},[O]);let W=async()=>{P(`waiting`),j(S.oauthStarting),_(null);try{k((await kn(e)).sessionId)}catch(e){P(`error`),j(e instanceof Error?e.message:S.revokeFailed)}},ee=async()=>{if(O){try{await Mn(O)}catch{}P(`idle`),j(null),k(null),I(null),R(null)}},te=async()=>{if(!(!O||!B.trim()))try{await jn(O,B.trim()),V(``),j(S.oauthProcessingCode)}catch(e){P(`error`),j(e instanceof Error?e.message:S.revokeFailed)}},ne=async()=>{let t=u.trim();if(!(!t||!T)){p(!0),_(null);try{await Se({[e]:t}),b(!0),window.setTimeout(s,600)}catch(e){_(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,y.press),"aria-label":n.back,children:(0,$.jsx)(xe,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(we,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(Gn,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,T?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(Ee,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:C,inputRef:x,onKeyDown:e=>{e.key===`Enter`&&ne()}})]}):null,D?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:S.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:S.oauthHint})]}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:U,onClick:()=>void W(),children:[U?(0,$.jsx)(E,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,S.oauth]})]}),A?(0,$.jsx)(`p`,{className:i(`text-xs`,N===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:A}):null,N===`waiting`||N===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[F?(0,$.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:[S.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void ee(),children:S.cancelOAuth})]}):null,L?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:L}):null,N===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:B,onChange:e=>V(e.target.value),onKeyDown:e=>e.key===`Enter`&&void te(),placeholder:S.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`,g)}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>void te(),children:S.submitCode})]}):null]}):null,w.length>0&&T?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[M(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,h?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),T?(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!u.trim()||f||v,onClick:()=>void ne(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(E,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Jn(e=`custom`){if(e!==`custom`&&Ln[e]){let t=Ln[e];return{preset:e,providerId:Rn(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Yn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:Ln[t.key]?{...Jn(t.key),modelIds:e.modelIds}: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`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Xn({customConfig:e,labels:t,language:n,onBack:r,onSaved:o}){let[s,c]=(0,Q.useReducer)(Yn,void 0,()=>Jn()),[l,u]=(0,Q.useState)(!1),d=q(a(n).providersSettings),{preset:f,providerId:p,baseUrl:m,api:h,apiKey:_,modelIds:v,error:b}=s,x=async()=>{let n=p.trim(),r=m.trim();if(!n){c({type:`setError`,value:t.providerIdRequired});return}if(!r){c({type:`setError`,value:t.baseUrlRequired});return}let i=v.map(e=>e.trim()).filter(Boolean);u(!0),c({type:`setError`,value:null});try{let t=e?.providers??{},a={baseUrl:r,api:h,apiKey:_.trim()||void 0,models:i.map(e=>({id:e}))};await _n({providers:{...t,[n]:a}}),o()}catch(e){c({type:`setError`,value:e instanceof Error?e.message:t.saveError})}finally{u(!1)}},S=p.trim()&&m.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,y.press),"aria-label":t.back,children:(0,$.jsx)(xe,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(we,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:t.step2CustomTitle}),(0,$.jsx)(Gn,{label:t.close})]}),(0,$.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:t.presetLabel}),(0,$.jsxs)(`select`,{id:`custom-preset`,value:f,onChange:e=>c({type:`applyPreset`,key:e.target.value}),className:Vn(),children:[(0,$.jsx)(`option`,{value:`custom`,children:t.presetCustom}),(0,$.jsx)(`option`,{value:`ollama`,children:t.presetOllama}),(0,$.jsx)(`option`,{value:`lmstudio`,children:t.presetLmStudio}),(0,$.jsx)(`option`,{value:`openrouter`,children:t.presetOpenRouter}),(0,$.jsx)(`option`,{value:`zhipuCn`,children:t.presetZhipuCn}),(0,$.jsx)(`option`,{value:`zaiGeneral`,children:t.presetZaiGeneral})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:t.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:p,onChange:e=>c({type:`setProviderId`,value:e.target.value}),placeholder:t.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,g)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:t.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:m,onChange:e=>c({type:`setBaseUrl`,value:e.target.value}),placeholder:t.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,g)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:t.apiTypeLabel}),(0,$.jsx)(`select`,{id:`custom-api-type`,value:h,onChange:e=>c({type:`setApi`,value:e.target.value}),className:Vn(),children:pn.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:t.apiKeyLabel}),(0,$.jsx)(Ee,{id:`custom-api-key`,value:_,onChange:e=>c({type:`setApiKey`,value:e}),placeholder:t.apiKeyPlaceholder,labels:d})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.modelIdLabel}),v.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>c({type:`updateModelId`,index:n,value:e.target.value}),placeholder:t.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`,g)}),v.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>c({type:`removeModelSlot`,index:n}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,y.press),children:(0,$.jsx)(O,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${n}`)),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>c({type:`addModelSlot`}),children:[(0,$.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),t.addModel]})]}),b?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:r,children:t.cancel}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!S||l,onClick:()=>void x(),children:l?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(E,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t.saving]}):t.save})]})]})}function Zn(e){let t=(0,Z.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}:vn(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(Qn),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 h=m,g;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(g=()=>{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]=g):g=t[8];let _=g,v;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==_?(v=()=>{if(!_())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]=_,t[13]=v):v=t[13];let y=v,b=u,x;t[14]===b?x=t[15]:(x=Hn(b),t[14]=b,t[15]=x);let S=x,C=r?c.addModelTitle:c.editModelTitle,w;t[16]===C?w=t[17]:(w=(0,$.jsx)(we,{className:`text-base font-semibold text-fg`,children:C}),t[16]=C,t[17]=w);let T;t[18]!==c.modelProviderLabel||t[19]!==a?(T=a?(0,$.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]=T):T=t[20];let E;t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(`div`,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(D=i(P,`p-1.5 hover:bg-surface-base`),t[24]=D):D=t[24];let k;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(O,{className:`size-4`}),t[25]=k):k=t[25];let A;t[26]===c.close?A=t[27]:(A=(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:D,"aria-label":c.close,children:k})}),t[26]=c.close,t[27]=A);let j;t[28]!==E||t[29]!==A?(j=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[E,A]}),t[28]=E,t[29]=A,t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=M):M=t[31];let N;t[32]===c.modelId?N=t[33]:(N=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,M]}),t[32]=c.modelId,t[33]=N);let F;t[34]===f?F=t[35]:(F=i(Bn(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=F);let I=u.id||``,L;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>h(`id`,e.target.value),t[36]=L):L=t[36];let R=!r,z;t[37]!==F||t[38]!==I||t[39]!==R?(z=(0,$.jsx)(`input`,{className:F,value:I,onChange:L,placeholder:`e.g. llama3.1:8b`,disabled:R}),t[37]=F,t[38]=I,t[39]=R,t[40]=z):z=t[40];let B;t[41]===f?B=t[42]:(B=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=B);let H;t[43]!==N||t[44]!==z||t[45]!==B?(H=(0,$.jsxs)(`div`,{children:[N,z,B]}),t[43]=N,t[44]=z,t[45]=B,t[46]=H):H=t[46];let U;t[47]===c.displayName?U=t[48]:(U=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=U);let W;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(W=Bn(),t[49]=W):W=t[49];let ee=u.name||``,te;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>h(`name`,e.target.value),t[50]=te):te=t[50];let ne;t[51]===ee?ne=t[52]:(ne=(0,$.jsx)(`input`,{className:W,value:ee,onChange:te}),t[51]=ee,t[52]=ne);let G;t[53]!==U||t[54]!==ne?(G=(0,$.jsxs)(`div`,{children:[U,ne]}),t[53]=U,t[54]=ne,t[55]=G):G=t[55];let K;t[56]===c.inputTypes?K=t[57]:(K=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=K);let re;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(re=Vn(),t[58]=re):re=t[58];let ie;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>h(`input`,Un(e.target.value)),t[59]=ie):ie=t[59];let q;t[60]===c?q=t[61]:(q=zn.map(e=>(0,$.jsx)(`option`,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=q);let ae;t[62]!==S||t[63]!==q?(ae=(0,$.jsx)(`select`,{className:re,value:S,onChange:ie,children:q}),t[62]=S,t[63]=q,t[64]=ae):ae=t[64];let oe;t[65]!==K||t[66]!==ae?(oe=(0,$.jsxs)(`div`,{children:[K,ae]}),t[65]=K,t[66]=ae,t[67]=oe):oe=t[67];let se=u.reasoning||!1,ce;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>h(`reasoning`,e.target.checked),t[68]=ce):ce=t[68];let le;t[69]===se?le=t[70]:(le=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:se,onChange:ce}),t[69]=se,t[70]=le);let J;t[71]!==c.reasoning||t[72]!==le?(J=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[le,c.reasoning]}),t[71]=c.reasoning,t[72]=le,t[73]=J):J=t[73];let ue;t[74]!==oe||t[75]!==J?(ue=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[oe,J]}),t[74]=oe,t[75]=J,t[76]=ue):ue=t[76];let X;t[77]===c.contextWindow?X=t[78]:(X=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=X);let de;t[79]===f?de=t[80]:(de=i(Bn(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=de);let fe=u.contextWindow??128e3,pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=pe):pe=t[81];let me;t[82]!==de||t[83]!==fe?(me=(0,$.jsx)(`input`,{type:`number`,min:1,className:de,value:fe,onChange:pe}),t[82]=de,t[83]=fe,t[84]=me):me=t[84];let he;t[85]===f?he=t[86]:(he=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=he);let ge;t[87]!==X||t[88]!==me||t[89]!==he?(ge=(0,$.jsxs)(`div`,{children:[X,me,he]}),t[87]=X,t[88]=me,t[89]=he,t[90]=ge):ge=t[90];let _e;t[91]===c.maxOutputTokens?_e=t[92]:(_e=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=_e);let ve;t[93]===f?ve=t[94]:(ve=i(Bn(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=ve);let ye=u.maxTokens??16384,be;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=be):be=t[95];let xe;t[96]!==ve||t[97]!==ye?(xe=(0,$.jsx)(`input`,{type:`number`,min:1,className:ve,value:ye,onChange:be}),t[96]=ve,t[97]=ye,t[98]=xe):xe=t[98];let Se;t[99]===f?Se=t[100]:(Se=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Se);let Ce;t[101]!==_e||t[102]!==xe||t[103]!==Se?(Ce=(0,$.jsxs)(`div`,{children:[_e,xe,Se]}),t[101]=_e,t[102]=xe,t[103]=Se,t[104]=Ce):Ce=t[104];let Te;t[105]!==ge||t[106]!==Ce?(Te=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ge,Ce]}),t[105]=ge,t[106]=Ce,t[107]=Te):Te=t[107];let Ee;t[108]===c.costSection?Ee=t[109]:(Ee=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Ee);let De;t[110]===c.costInput?De=t[111]:(De=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=De);let Oe;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=Bn(),t[112]=Oe):Oe=t[112];let ke=u.cost?.input??0,Ae;t[113]===u.cost?Ae=t[114]:(Ae=e=>h(`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]=Ae);let je;t[115]!==ke||t[116]!==Ae?(je=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Oe,value:ke,onChange:Ae}),t[115]=ke,t[116]=Ae,t[117]=je):je=t[117];let Me;t[118]!==De||t[119]!==je?(Me=(0,$.jsxs)(`div`,{children:[De,je]}),t[118]=De,t[119]=je,t[120]=Me):Me=t[120];let Ne;t[121]===c.costOutput?Ne=t[122]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Ne);let Pe;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=Bn(),t[123]=Pe):Pe=t[123];let Fe=u.cost?.output??0,Ie;t[124]===u.cost?Ie=t[125]:(Ie=e=>h(`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]=Ie);let Le;t[126]!==Fe||t[127]!==Ie?(Le=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[126]=Fe,t[127]=Ie,t[128]=Le):Le=t[128];let Re;t[129]!==Ne||t[130]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[129]=Ne,t[130]=Le,t[131]=Re):Re=t[131];let ze;t[132]!==Me||t[133]!==Re?(ze=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Me,Re]}),t[132]=Me,t[133]=Re,t[134]=ze):ze=t[134];let Be;t[135]!==Ee||t[136]!==ze?(Be=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Ee,ze]}),t[135]=Ee,t[136]=ze,t[137]=Be):Be=t[137];let Ve;t[138]!==H||t[139]!==G||t[140]!==ue||t[141]!==Te||t[142]!==Be?(Ve=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[H,G,ue,Te,Be]}),t[138]=H,t[139]=G,t[140]=ue,t[141]=Te,t[142]=Be,t[143]=Ve):Ve=t[143];let He;t[144]===c.cancel?He=t[145]:(He=(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=He);let Ue=r?c.addModelConfirm:c.saveModelConfirm,We;t[146]!==y||t[147]!==Ue?(We=(0,$.jsx)(Y,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:Ue}),t[146]=y,t[147]=Ue,t[148]=We):We=t[148];let Ge;t[149]!==He||t[150]!==We?(Ge=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[He,We]}),t[149]=He,t[150]=We,t[151]=Ge):Ge=t[151];let Ke;return t[152]!==j||t[153]!==Ve||t[154]!==Ge?(Ke=(0,$.jsxs)($.Fragment,{children:[j,Ve,Ge]}),t[152]=j,t[153]=Ve,t[154]=Ge,t[155]=Ke):Ke=t[155],Ke}function Qn(){return new Map}function $n(e){let t=(0,Z.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,$.jsx)(N,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,je)}),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`,De,`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,$.jsx)(Zn,{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,$.jsxs)(h,{children:[u,(0,$.jsx)(B,{className:d,onOpenAutoFocus:er,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,$.jsx)(K,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function er(e){return e.preventDefault()}function tr(e){let t=(0,Z.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>W(n).then(nr),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.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,$.jsx)(Ee,{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,$.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 nr(e){return e.apiKey??null}function rr(e){let t=(0,Z.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,$.jsx)(N,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,je)}),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`,De),t[1]=m):m=t[1];let g;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?(g=(0,$.jsxs)(h,{children:[p,(0,$.jsx)(B,{className:m,children:o?(0,$.jsx)(ar,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,$.jsx)(ir,{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]=g):g=t[11];let _;return t[12]!==r||t[13]!==n||t[14]!==g?(_=(0,$.jsx)(K,{open:n,onOpenChange:r,children:g}),t[12]=r,t[13]=n,t[14]=g,t[15]=_):_=t[15],_}function ir({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=z[e],d=n.filter(t=>t.provider===e),[f,h]=(0,Q.useState)(l?.apiKey??``),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,k]=(0,Q.useState)(!1),A=a(o).providersSettings,j=l?.supportsApiKey!==!1,N=l?.supportsOAuth===!0,P=l?.authMode===`oauth`&&l.authStatus===`connected`,F=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[I,L]=(0,Q.useState)(null),[B,U]=(0,Q.useState)(null),[W,ee]=(0,Q.useState)(`idle`),[te,ne]=(0,Q.useState)(null),[G,K]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(``),q=W===`waiting`||W===`waiting_code`,ae=(0,Q.useMemo)(()=>H(e,o),[e,o]),se=f!==(l?.apiKey??``),ce=async()=>{let t=f.trim();if(!(!t||!j||Te(t))){b(!0),w(null);try{await Se({[e]:t}),S(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){w(e instanceof Error?e.message:r.saveError)}finally{b(!1)}}};(0,Q.useEffect)(()=>{if(!I||!q)return;let e=window.setInterval(()=>{(async()=>{try{let t=await An(I);t.status===`waiting_auth`||t.status===`waiting_code`?(ee(t.status===`waiting_code`?`waiting_code`:`waiting`),U(t.message??null),ne(t.authUrl??null),K(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),ee(`success`),U(t.message??A.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),ee(`error`),U(t.error??t.message??A.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[I,q,s,c,A.revokeFailed,A.saved]),(0,Q.useEffect)(()=>()=>{I&&Nn(I).catch(()=>{})},[I]);let le=async()=>{try{await p(e),c(),s()}catch{}},J=async()=>{ee(`waiting`),U(A.oauthStarting),w(null);try{L((await kn(e)).sessionId)}catch(e){ee(`error`),U(e instanceof Error?e.message:A.revokeFailed)}},ue=async()=>{if(I){try{await Mn(I)}catch{}ee(`idle`),U(null),L(null),ne(null),K(null)}},X=async()=>{if(!(!I||!re.trim()))try{await jn(I,re.trim()),ie(``),U(A.oauthProcessingCode)}catch(e){ee(`error`),U(e instanceof Error?e.message:A.revokeFailed)}},de=async()=>{try{await Pn(e),c(),s()}catch(e){w(e instanceof Error?e.message:A.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(we,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,y.press),children:(0,$.jsx)(O,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.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,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,j?(0,$.jsx)(tr,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{h(e),S(!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,$.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,$.jsx)(`p`,{children:r.extensionKeyHint}),l?.extensionId?(0,$.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,$.jsx)(_,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,N?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:A.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:P?A.sourceOauth:A.oauthHint})]}),P?(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void de(),children:A.revoke}):(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:q,onClick:()=>void J(),children:[q?(0,$.jsx)(E,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),A.oauth]})]}),B?(0,$.jsx)(`p`,{className:i(`text-xs`,W===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:B}):null,W===`waiting`||W===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[te?(0,$.jsxs)(`a`,{href:te,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,$.jsx)(_,{className:`size-4`,"aria-hidden":!0}),A.openAuthPage]}):null,(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void ue(),children:A.cancelOAuth})]}):null,G?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:G}):null,W===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:re,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void X(),placeholder:A.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`,g)}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>void X(),children:A.submitCode})]}):null]}):null,ae.length>0&&j?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ae.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[M(e,r),(0,$.jsx)(_,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,$.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,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[F?(0,$.jsxs)(Y,{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:()=>k(!0),children:[(0,$.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:j&&se&&!Te(f.trim())?(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!f.trim()||v||x,onClick:()=>void ce(),children:x?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(E,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(oe,{open:T,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void le(),onCancel:()=>k(!1)})]})}function ar({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,Q.useState)(l?.baseUrl??``),[f,p]=(0,Q.useState)(l?.apiKey??``),[m,h]=(0,Q.useState)(l?.models??[]),[_,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[D,A]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),P=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:Te(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},F=async()=>{let e=P({models:m});if(e){v(!0),x(null);try{await _n(e),s(),o()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{v(!1)}}},I=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await _n({providers:r}),s(),o()}catch{}},L=(e,t)=>{N({model:e,isNew:t}),A(!0)},z=async e=>{if(!M)return;let t=M.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=P({models:t});if(r)try{await _n(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}},B=async e=>{let t=m.filter(t=>t.id!==e);h(t),T(null);let r=P({models:t});if(r)try{await _n(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(we,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(V,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,y.press),children:(0,$.jsx)(O,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.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`,g)})]}),(0,$.jsx)(tr,{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,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,m.length>0?` (${m.length})`:``]}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>L(null,!0),children:[(0,$.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,$.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,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,y.press),onClick:()=>L(e,!1),"aria-label":c.editModel,children:(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.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`,y.press),onClick:()=>T(e.id),"aria-label":c.removeModel,children:(0,$.jsx)(R,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),b?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(Y,{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,$.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:_,onClick:()=>void F(),children:_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(E,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(oe,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void I(),onCancel:()=>C(!1)}),(0,$.jsx)(oe,{open:w!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,w??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{w&&B(w)},onCancel:()=>T(null)}),(0,$.jsx)($n,{open:D,onOpenChange:e=>{A(e),e||N(null)},providerId:e,model:M?.model??null,isNew:M?.isNew??!1,onSave:e=>void z(e),m:c})]})}var or=[`services`,`image-models`,`voice`,`search`];function sr(e){let t=(e??``).trim();return or.includes(t)?t:`services`}function cr(){let e=(0,Z.c)(72),t=o(ur),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,s=r.modelsHub,[c,l]=fe(),u;e[2]===c?u=e[3]:(u=sr(c.get(`tab`)),e[2]=c,e[3]=u);let d=u,[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),g=yn(),v;e[4]!==s.servicesHint||e[5]!==s.tabs.services?(v={id:`services`,icon:ue,label:s.tabs.services,hint:s.servicesHint},e[4]=s.servicesHint,e[5]=s.tabs.services,e[6]=v):v=e[6];let b;e[7]!==s.imageModelsHint||e[8]!==s.tabs.imageModels?(b={id:`image-models`,icon:ie,label:s.tabs.imageModels,hint:s.imageModelsHint},e[7]=s.imageModelsHint,e[8]=s.tabs.imageModels,e[9]=b):b=e[9];let x;e[10]!==s.tabs.voice||e[11]!==s.voiceHint?(x={id:`voice`,icon:w,label:s.tabs.voice,hint:s.voiceHint},e[10]=s.tabs.voice,e[11]=s.voiceHint,e[12]=x):x=e[12];let S;e[13]!==s.searchHint||e[14]!==s.tabs.search?(S={id:`search`,icon:se,label:s.tabs.search,hint:s.searchHint},e[13]=s.searchHint,e[14]=s.tabs.search,e[15]=S):S=e[15];let C;e[16]!==v||e[17]!==b||e[18]!==x||e[19]!==S?(C=[v,b,x,S],e[16]=v,e[17]=b,e[18]=x,e[19]=S,e[20]=C):C=e[20];let T=C,E;e[21]===l?E=e[22]:(E=e=>{l(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=l,e[22]=E);let D=E,O=lr,k;e[23]===r.settingsSections.credentials?k=e[24]:(k=(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.settingsSections.credentials}),e[23]=r.settingsSections.credentials,e[24]=k);let A;e[25]===s.subtitle?A=e[26]:(A=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.subtitle}),e[25]=s.subtitle,e[26]=A);let j;e[27]===t?j=e[28]:(j=G(t,`configuration`),e[27]=t,e[28]=j);let M;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),e[29]=M):M=e[29];let N;e[30]!==s.docsLink||e[31]!==j?(N=(0,$.jsxs)(`a`,{href:j,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[s.docsLink,M]}),e[30]=s.docsLink,e[31]=j,e[32]=N):N=e[32];let P;e[33]!==N||e[34]!==k||e[35]!==A?(P=(0,$.jsx)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[k,A,N]})}),e[33]=N,e[34]=k,e[35]=A,e[36]=P):P=e[36];let F;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(Ze,{}),e[37]=F):F=e[37];let I=s.tabsAria,L;e[38]!==d||e[39]!==D?(L=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),D(or[(or.indexOf(d)+(e.key===`ArrowRight`?1:-1)+or.length)%or.length]))},e[38]=d,e[39]=D,e[40]=L):L=e[40];let R;e[41]!==d||e[42]!==D||e[43]!==T?(R=T.map(e=>{let{id:t,icon:n,label:r}=e,a=t===d;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,id:`hub-tab-${t}`,"aria-controls":`hub-panel-${t}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,y.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>D(t),children:[(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r})]},t)}),e[41]=d,e[42]=D,e[43]=T,e[44]=R):R=e[44];let z;e[45]!==s.tabsAria||e[46]!==L||e[47]!==R?(z=(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,"aria-label":I,onKeyDown:L,children:R}),e[45]=s.tabsAria,e[46]=L,e[47]=R,e[48]=z):z=e[48];let B;e[49]!==d||e[50]!==s.connectedProviders||e[51]!==T?(B=T.map(e=>(0,$.jsx)(fr,{id:e.id,activeTab:d,hint:e.hint,children:e.id===`services`?(0,$.jsx)(Tn,{labels:s.connectedProviders,onAdd:()=>p(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,$.jsx)(dr,{tab:e.id})},e.id)),e[49]=d,e[50]=s.connectedProviders,e[51]=T,e[52]=B):B=e[52];let V;e[53]!==f||e[54]!==s.addProviderDialog||e[55]!==t||e[56]!==g.builtinRows||e[57]!==g.customConfig?(V=(0,$.jsx)(Wn,{open:f,onOpenChange:p,builtinRows:g.builtinRows,customConfig:g.customConfig,labels:s.addProviderDialog,language:t,onSaved:O}),e[53]=f,e[54]=s.addProviderDialog,e[55]=t,e[56]=g.builtinRows,e[57]=g.customConfig,e[58]=V):V=e[58];let H;e[59]!==s.manageProviderDialog||e[60]!==t||e[61]!==m||e[62]!==g.allModels||e[63]!==g.builtinRows||e[64]!==g.customConfig?(H=m?(0,$.jsx)(rr,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:g.builtinRows,customConfig:g.customConfig,allModels:g.allModels,labels:s.manageProviderDialog,language:t,onSaved:O}):null,e[59]=s.manageProviderDialog,e[60]=t,e[61]=m,e[62]=g.allModels,e[63]=g.builtinRows,e[64]=g.customConfig,e[65]=H):H=e[65];let U;return e[66]!==P||e[67]!==z||e[68]!==B||e[69]!==V||e[70]!==H?(U=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[P,F,z,B,V,H]}),e[66]=P,e[67]=z,e[68]=B,e[69]=V,e[70]=H,e[71]=U):U=e[71],U}function lr(){Ce()}function ur(e){return e.language}function dr(e){let t=(0,Z.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,$.jsx)(gt,{embedded:!0}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bt,{embedded:!0}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(un,{embedded:!0}),t[2]=e):e=t[2],e}}}function fr({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,Q.useRef)(a);return a&&(o.current=!0),o.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(a?`flex min-w-0 flex-col gap-3`:void 0),children:[a?(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{cr as ModelsHubPanel};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-CzQri9h2.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-DefIdW9q.js","assets/preload-helper-zJ_50EbN.js","assets/dist-CkobR7mk.js","assets/Combination-BzaXOLd9.js","assets/dist-DokQNVMQ.js","assets/vendor-react-BOUWij0V.js","assets/cn-JdwAhgNB.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-DjbfSsfA.js","assets/config-reload-event-Bjh2zoKp.js","assets/messages-BN_WiUg0.js","assets/fetch-D9QqUtzZ.js","assets/gateway-startup-retry-N7Z_sz7p.js","assets/toast-z0toXu32.js","assets/theme-store-CD2wtgZV.js","assets/index-DzmWBkq-.css","assets/vendor-codemirror-CNP1wPe7.js","assets/note-image-lightbox-C5D1Q5mY.js","assets/voice-player-store-DSuOd9zy.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-JdwAhgNB.js";import{t as o}from"./messages-BN_WiUg0.js";import{t as s}from"./locale-store-DjbfSsfA.js";import{i as c}from"./theme-store-CD2wtgZV.js";import{r as l}from"./toast-z0toXu32.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Bo as d,Ct as f,Ds as p,Eo as m,Et as h,Ga as g,Ki as _,Ni as v,Os as y,Ot as b,Pa as x,Sa as S,Tt as C,_t as w,aa as ee,dt as T,gt as E,ho as D,ht as te,ko as O,li as k,mt as A,oi as j,pt as M,qi as N,vs as ne,wt as re,ys as P,yt as ie}from"./index-DefIdW9q.js";import{n as ae,t as F}from"./note-image-lightbox-C5D1Q5mY.js";import{r as I}from"./note-time-hm6JO_Wi.js";var L=n(),R=e(t(),1),z=r(),B={edit:x,ai_edit:ee,sync:S,restore:P};function V(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function oe({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let c=o(s(e=>e.language)).notes,d=c,{data:f}=u(e?[`note-history`,e]:null,()=>E(e)),[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(null),_=(0,R.useCallback)(async t=>{m(!0);try{await C(e,t),l({type:`success`,title:c.restoreSuccess}),g(null),i()}catch{l({type:`error`,title:c.restoreFailed})}finally{m(!1)}},[e,c.restoreSuccess,c.restoreFailed,i]),y=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)(D,{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)(v,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:f?.length?(0,z.jsx)(`ul`,{className:`divide-y divide-edge`,children:f.map(e=>{let r=B[e.trigger]??x,i=t===e.timestamp,o=h===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:V(e.trigger,c)}),(0,z.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:I(e.timestamp,y,d)})]}),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(),_(e.timestamp)},disabled:p,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:p?`...`:c.restore}),(0,z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g(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(),g(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 se(e){let t=(0,L.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:l,noteThreads:d,openingChat:m,onOpenChat:h,onOpenNewChat:v}=e,y=o(s(J)).notes,b=p(),x=r?.aiDeep?.catalysis,S=x?.report??null,C;t[0]===n?C=t[1]:(C=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=C);let w;t[2]===n?w=t[3]:(w=()=>A(n),t[2]=n,t[3]=w);let T;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},t[4]=T):T=t[4];let{data:E,mutate:D,isLoading:te}=u(C,w,T),O;t[5]===n?O=t[6]:(O=async e=>{try{await re(n,e)}catch{}},t[5]=n,t[6]=O);let k=O,j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,z.jsx)(ee,{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)(ne,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=M):M=t[8];let P;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,z.jsx)(g,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=P):P=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:y.catalysisSectionTitle})]}),(0,z.jsx)(`button`,{type:`button`,onClick:l,"aria-label":y.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:y.catalysisSectionDescription}),E?(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:y.contextStatusTitle}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void D(()=>f(n),{revalidate:!1}),disabled:te,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:y.contextRebuild}),(0,z.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,E.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:E.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:E.status})]}),(0,z.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:y.contextStatusDetail.replace(`{{attachments}}`,String(E.attachments.length)).replace(`{{tokens}}`,String(E.tokenEstimate??0))}),E.attachments.length>0?(0,z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:E.attachments.slice(0,5).map(q)}):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?y.processing:S?y.recatalyze:y.catalyzeAction}),S?(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:y.valueHypothesis}),(0,z.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:S.valueHypothesis})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:y.targetUsers}),(0,z.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:S.targetUsers.slice(0,5).map(K)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:y.keyQuestions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.keyQuestions.slice(0,3).map(G)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:y.mvpPathLabel}),(0,z.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.mvpPath.slice(0,3).map(W)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:y.risks}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.risks.slice(0,3).map(U)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:y.nextActions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.nextActions.slice(0,4).map(H)})]}),(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:y.confidenceLabel.replace(`{{percent}}`,String(Math.round(S.confidence*100)))}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,x?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":y.feedbackHelpfulAria,children:(0,z.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,x?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":y.feedbackNotHelpfulAria,children:(0,z.jsx)(N,{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:y.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:[P,y.relatedThreadsTitle]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:y.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?y.openingChat:y.openThread}),(0,z.jsx)(`button`,{type:`button`,onClick:v,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:y.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:()=>b(`/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||y.noteDiscussionFallback}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:y.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:y.noThreads})]})]})]})}function H(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 U(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 W(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 G(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 K(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 q(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 J(e){return e.language}var Y=()=>i(()=>import(`./block-editor-CzQri9h2.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,22,23])),X=()=>i(()=>import(`./markdown-editor-AssmZFx4.js`).then(e=>e.n),__vite__mapDeps([24,1,3,20,7,25])),ce=(0,R.lazy)(()=>Y().then(e=>({default:e.BlockEditor}))),le=(0,R.lazy)(()=>X().then(e=>({default:e.MarkdownEditor})));function ue(){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 de(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:m},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:d},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:O},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,f;return t[10]!==n||t[11]!==u||t[12]!==r?(f=(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`&&Y(),t===`source`&&X()},onFocus:()=>{t===`wysiwyg`&&Y(),t===`source`&&X()},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]=f):f=t[13],f}function Z(e){let t=(0,L.c)(9),{noteId:n,onBack:r,onSaved:i}=e,a=s(Q),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)(fe,{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)(F,{closeLabel:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8],d}function Q(e){return e.language}function fe({noteId:e,onBack:t,onSaved:n}){let r=o(s(e=>e.language)).notes,i=p(),d=c(e=>e.resolved)===`dark`,{openImage:f}=ae(),[m,_]=(0,R.useState)(`wysiwyg`),[v,y]=(0,R.useState)(null),[x,S]=(0,R.useState)(null),[C,E]=(0,R.useState)(!1),[O,A]=(0,R.useState)(``),[N,re]=(0,R.useState)(360),[P,F]=(0,R.useState)(!1),[I,L]=(0,R.useState)(!1),[B,V]=(0,R.useState)(!1),H=(0,R.useRef)(!1),U=(0,R.useRef)(!1),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=(0,R.useRef)(null),q=(0,R.useRef)(null),J=(0,R.useRef)(null),Y=j(e=>e.setPageHeader),X=j(e=>e.clearPageHeader),{data:Z,mutate:Q}=u(e?[`note-detail`,e]:null,()=>M(e)),{data:fe=[],mutate:pe}=u(e?[`note-threads`,e]:null,()=>w(e),{revalidateOnFocus:!1});(0,R.useEffect)(()=>{H.current=!1,A(``),S(null),y(null),U.current=!1},[e]),(0,R.useEffect)(()=>{!Z||H.current||(A(Z.title??``),H.current=!0)},[Z]);let me=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,he=(0,R.useMemo)(()=>(0,z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,k),children:(0,z.jsx)(ne,{className:`h-4 w-4`,"aria-hidden":!0})}),[r.back,t]),ge=(0,R.useCallback)(t=>{A(t),e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){E(!0);try{await h(e,{title:t}),await Q(),n?.()}catch{}finally{E(!1)}}},600))},[e,Q,n]),_e=(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`,k),children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:O||me||void 0,children:O||me}),C?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:r.saving}):null]}),[r.saving,C,me,O]),$=(0,R.useCallback)(async(t=!1)=>{V(!0);try{let n=await ie(e,{forceNew:t});await Q(),await pe(),i(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){l({type:`error`,title:r.chatOpenFailedTitle,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{V(!1)}},[Q,pe,i,e,r.chatOpenFailedMessage,r.chatOpenFailedTitle]),ve=(0,R.useCallback)(async()=>{L(!0);try{await T(e),await Q(),l({type:`success`,title:r.catalysisDone})}catch(e){l({type:`error`,title:r.catalysisFailed,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{L(!1)}},[Q,e]),ye=(0,R.useCallback)(()=>{y(v===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!I&&ve()},[v,I,ve,Z?.aiDeep?.catalysis?.report]),be=(0,R.useMemo)(()=>(0,z.jsxs)(`div`,{className:a(`flex items-center gap-2`,k),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:ye,disabled:I,"aria-label":r.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`,v===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,z.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),I?r.catalyzing:r.catalyzeButton]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(!1),disabled:B,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)(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B?r.openingChat:r.openChatButton]}),(0,z.jsx)(de,{mode:m,onModeChange:_,labels:{edit:r.modeEdit,source:r.modeSource,preview:r.modePreview}}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>y(v===`history`?null:`history`),"aria-label":r.history,className:a(`rounded-lg p-1.5 transition-colors`,v===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,z.jsx)(D,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[I,ye,$,m,r.history,r.modeEdit,r.modePreview,r.modeSource,B,v]);(0,R.useLayoutEffect)(()=>(Y({startExtra:he,main:Z?_e:null,end:Z?be:null}),()=>X()),[X,be,_e,he,Z,Y]);let xe=(0,R.useCallback)(t=>{e&&(K.current=t,W.current&&clearTimeout(W.current),W.current=setTimeout(async()=>{let t=K.current;if(K.current=null,t!==null){E(!0);try{await h(e,{markdown:t}),await Q(),n?.()}catch(e){l({type:`error`,title:r.saveFailed,message:e instanceof Error?e.message:r.saveFailedHint})}finally{E(!1)}}},600))},[e,Q,r.saveFailed,r.saveFailedHint,n]),Se=(0,R.useCallback)(t=>{te(e,t.timestamp).then(e=>{e&&S(e)})},[e]),Ce=(0,R.useCallback)(()=>{y(null),S(null)},[]),we=(0,R.useCallback)(()=>{y(null),S(null),Q(),n?.()},[Q,n]);if((0,R.useEffect)(()=>()=>{W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current);let t=K.current,n=q.current;K.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&h(e,r)},[e]),Z===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(Z===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:r.notFoundTitle}),(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.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:r.back})]});let Te=x!==null,Ee=Te?x.title??``:O,De=Te?x.markdown??``:Z.markdown??``;return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,z.jsx)(`div`,{ref:J,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:Te?(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Ee&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Ee}),De?(0,z.jsx)(b,{noteId:e,content:De,className:`opacity-80`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]}):(0,z.jsxs)(z.Fragment,{children:[m===`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:O,onChange:e=>ge(e.target.value),onCompositionStart:()=>{U.current=!0},onCompositionEnd:()=>{U.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!U.current&&!t.isComposing&&(e.preventDefault(),(J.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:r.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)(ue,{}),children:(0,z.jsx)(ce,{initialContent:Z.markdown??``,onChange:xe,noteId:e},`wysiwyg-${e}`)})})]}),m===`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:O,onChange:e=>ge(e.target.value),placeholder:r.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)(ue,{}),children:(0,z.jsx)(le,{initialContent:Z.markdown??``,onChange:xe,isDark:d},`source-${e}`)})})]}),m===`preview`&&(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&f(t.currentSrc||t.src,t.alt)},children:[O&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:O}),Z.markdown?(0,z.jsx)(b,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]})]})})}),(0,z.jsx)(`div`,{className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!P&&`transition-[width] duration-300 ease-in-out`),style:{width:v?N:0},children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{width:N},children:[(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),F(!0);let n=e.clientX,r=N,i=e.pointerId,a=e=>{let t=r-(e.clientX-n);re(Math.max(280,Math.min(600,t)))},o=()=>{try{t.releasePointerCapture(i)}catch{}F(!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`,P&&`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:v===`history`?(0,z.jsx)(oe,{noteId:e,activeTimestamp:x?.timestamp??null,onSelect:Se,onClose:Ce,onRestored:we}):v===`breakdown`?(0,z.jsx)(se,{noteId:e,note:Z??null,catalyzing:I,onCatalyze:ve,onClose:()=>y(null),noteThreads:fe,openingChat:B,onOpenChat:()=>$(!1),onOpenNewChat:()=>$(!0)}):null})]})})]})}function pe(){let e=(0,L.c)(5),{noteId:t}=y(),n=p(),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)(Z,{noteId:t,onBack:i})}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}export{pe 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-JdwAhgNB.js";import{t as a}from"./messages-BN_WiUg0.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s}from"./fetch-D9QqUtzZ.js";import{r as c}from"./toast-z0toXu32.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{$i as u,Aa as d,Ds as f,Et as p,Fa as m,H as h,Ha as g,Ja as _,Ma as v,Mo as y,Na as b,Nt as x,St as S,Wi as C,bs as w,bt as T,fo as E,fs as D,ft as O,ha as k,ia as A,kt as j,li as M,ma as N,mo as P,na as F,no as I,oi as L,vt as R,xt as z}from"./index-DefIdW9q.js";import{t as B}from"./voice-player-store-DSuOd9zy.js";import{n as V,r as ee,t as te}from"./note-time-hm6JO_Wi.js";import{a as ne,i as re,n as H,o as ie,r as ae,t as oe}from"./dist-By6Rh2ee.js";var se=n(),U=e(t(),1),W=r();function ce(e){let t=(0,se.c)(15),{noteId:n,attachmentId:r,className:a}=e,[o,s]=(0,U.useState)(!1),c;t[0]!==r||t[1]!==n?(c=x(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,W.jsx)(P,{className:`h-4 w-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,W.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,W.jsx)(j,{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 G(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 le(e){let t=(0,se.c)(38),{noteId:n,attachmentId:r,durationSec:a,className:o}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:f,attachmentId:p}=B(),h=B(q),g=f===n&&p===r,v=g&&s,y=g&&c,b=g?l:0,x=g&&u>0?u:a??0,S=x>0?Math.min(b/x*100,100):0,C;t[0]!==r||t[1]!==a||t[2]!==n||t[3]!==h?(C=e=>{e.stopPropagation(),h(n,r,a)},t[0]=r,t[1]=a,t[2]=n,t[3]=h,t[4]=C):C=t[4];let w=C,T;t[5]!==r||t[6]!==a||t[7]!==n||t[8]!==h?(T=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),h(n,r,a))},t[5]=r,t[6]=a,t[7]=n,t[8]=h,t[9]=T):T=t[9];let E=T,D;t[10]===o?D=t[11]:(D=i(`flex items-center gap-2`,o),t[10]=o,t[11]=D);let O=v?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,k;t[12]===O?k=t[13]:(k=i(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition-colors`,O),t[12]=O,t[13]=k);let A=v?`Pause`:`Play`,j;t[14]!==y||t[15]!==v?(j=y?(0,W.jsx)(_,{className:`h-3.5 w-3.5 animate-spin`}):v?(0,W.jsx)(m,{className:`h-3.5 w-3.5`}):(0,W.jsx)(d,{className:`h-3.5 w-3.5 ml-0.5`}),t[14]=y,t[15]=v,t[16]=j):j=t[16];let M;t[17]!==w||t[18]!==E||t[19]!==k||t[20]!==A||t[21]!==j?(M=(0,W.jsx)(`button`,{type:`button`,onClick:w,onKeyDown:E,className:k,"aria-label":A,children:j}),t[17]=w,t[18]=E,t[19]=k,t[20]=A,t[21]=j,t[22]=M):M=t[22];let N=`${S}%`,P;t[23]===N?P=t[24]:(P=(0,W.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,W.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:N}})}),t[23]=N,t[24]=P);let F;t[25]!==x||t[26]!==g||t[27]!==b?(F=G(g&&b>0?b:x),t[25]=x,t[26]=g,t[27]=b,t[28]=F):F=t[28];let I;t[29]===F?I=t[30]:(I=(0,W.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:F}),t[29]=F,t[30]=I);let L;t[31]!==P||t[32]!==I?(L=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[P,I]}),t[31]=P,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==L||t[35]!==D||t[36]!==M?(R=(0,W.jsxs)(`div`,{className:D,onClick:K,children:[M,L]}),t[34]=L,t[35]=D,t[36]=M,t[37]=R):R=t[37],R}function K(e){return e.stopPropagation()}function q(e){return e.toggle}var ue={thought:I,todo:A,voice:g,media:E,bookmark:D,mixed:I,task:A};function de(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function J(e){let t=(0,se.c)(78),{note:n,onPress:r,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,u=ue[n.kind]||I,d;t[0]!==c||t[1]!==n?(d=de(n,c),t[0]=c,t[1]=n,t[2]=d):d=t[2];let f=d,p=!n.snippet?.trim(),[m]=(0,U.useState)(Y),h;t[3]!==n.createdAt||t[4]!==m||t[5]!==l?(h=ee(n.createdAt,m,l),t[3]=n.createdAt,t[4]=m,t[5]=l,t[6]=h):h=t[6];let g=h,_,x;t[7]!==n.id||t[8]!==r?(_=()=>r(n.id),x=e=>{(e.key===`Enter`||e.key===` `)&&r(n.id)},t[7]=n.id,t[8]=r,t[9]=_,t[10]=x):(_=t[9],x=t[10]);let S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=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]=S):S=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,W.jsx)(ce,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,W.jsx)(le,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-32 shrink-0`}):(0,W.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,W.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`:p?`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]!==f||t[24]!==O?(k=(0,W.jsx)(`p`,{className:O,children:f}),t[23]=f,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,W.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,W.jsx)(ie,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,onClick:me,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,W.jsx)(y,{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,W.jsx)(v,{className:`h-4 w-4`}):(0,W.jsx)(b,{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,W.jsxs)(H,{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 L;t[40]!==n.id||t[41]!==o?(L=()=>o(n.id),t[40]=n.id,t[41]=o,t[42]=L):L=t[42];let R;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,W.jsx)(w,{className:`h-4 w-4`}),t[43]=R):R=t[43];let z;t[44]!==c.archive||t[45]!==L?(z=(0,W.jsxs)(H,{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:L,children:[R,c.archive]}),t[44]=c.archive,t[45]=L,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,W.jsx)(ne,{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 te;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,W.jsx)(C,{className:`h-4 w-4`}),t[51]=te):te=t[51];let G;t[52]!==c.delete||t[53]!==V?(G=(0,W.jsxs)(H,{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:[te,c.delete]}),t[52]=c.delete,t[53]=V,t[54]=G):G=t[54];let K;t[55]!==F||t[56]!==z||t[57]!==G?(K=(0,W.jsxs)(re,{children:[j,(0,W.jsx)(ae,{children:(0,W.jsxs)(oe,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:pe,children:[F,z,B,G]})})]}),t[55]=F,t[56]=z,t[57]=G,t[58]=K):K=t[58];let q;t[59]!==A||t[60]!==K||t[61]!==T?(q=(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[T,A,K]}),t[59]=A,t[60]=K,t[61]=T,t[62]=q):q=t[62];let J;t[63]===n.pinned?J=t[64]:(J=n.pinned&&(0,W.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,W.jsx)(b,{className:`h-3 w-3`})}),t[63]=n.pinned,t[64]=J);let X;t[65]===n.tags?X=t[66]:(X=n.tags?.map(fe),t[65]=n.tags,t[66]=X);let Z;t[67]===g?Z=t[68]:(Z=(0,W.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:g}),t[67]=g,t[68]=Z);let Q;t[69]!==J||t[70]!==X||t[71]!==Z?(Q=(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[J,X,Z]}),t[69]=J,t[70]=X,t[71]=Z,t[72]=Q):Q=t[72];let he;return t[73]!==q||t[74]!==Q||t[75]!==_||t[76]!==x?(he=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:_,onKeyDown:x,className:S,children:[q,Q]}),t[73]=q,t[74]=Q,t[75]=_,t[76]=x,t[77]=he):he=t[77],he}function fe(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function pe(e){return e.stopPropagation()}function me(e){return e.stopPropagation()}function Y(){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,U.useState)(``),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!1),[h,_]=(0,U.useState)(0),[v,y]=(0,U.useState)(!1),b=(0,U.useRef)(null),x=(0,U.useRef)(null),S=(0,U.useRef)(null),C=(0,U.useRef)([]),w=(0,U.useRef)(0),T=(0,U.useRef)(null),D=(0,U.useRef)(null),O=(0,U.useCallback)(()=>{T.current&&=(clearInterval(T.current),null),D.current&&=(clearTimeout(D.current),null),S.current?.getTracks().forEach(e=>e.stop()),S.current=null,x.current=null,C.current=[],m(!1),_(0)},[]);(0,U.useEffect)(()=>()=>O(),[O]);let k=(0,U.useCallback)(async()=>{let e=x.current;if(!e||e.state!==`recording`)return;y(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-w.current)/1e3)),n=e.mimeType||Z()||`audio/webm`,r=new Blob(C.current,{type:n});if(O(),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{y(!1)}return}y(!1)},[O,a]),A=(0,U.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);S.current=e,x.current=n,C.current=[],w.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&C.current.push(e.data)},n.start(),m(!0),_(0),T.current=setInterval(()=>{_(Math.round((Date.now()-w.current)/1e3))},250),D.current=setTimeout(()=>{k()},X)}catch{O()}},[O,a,p,k,v]),j=(0,U.useCallback)(()=>{if(p){k();return}A()},[p,A,k]),M=(0,U.useCallback)(async e=>{let t=l.trim();if(!(!t||d)){f(!0),u(``);try{await n(t,e)}catch{u(t)}finally{f(!1),b.current?.focus()}}},[l,d,n]),P=(0,U.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),M()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),M({navigate:!1}))},[M]),I=d||v;return(0,W.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,W.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,W.jsx)(E,{className:`h-4 w-4`})}),a&&(0,W.jsx)(`button`,{type:`button`,onClick:j,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,W.jsx)(F,{className:`h-4 w-4 fill-current`}):(0,W.jsx)(g,{className:`h-4 w-4`})}),p?(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:o.replace(`{{seconds}}`,String(h))}):(0,W.jsx)(`textarea`,{ref:b,value:l,onChange:e=>u(e.target.value),onKeyDown:P,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,W.jsx)(`button`,{type:`button`,disabled:!l.trim()||I||p,onClick:e=>void M({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,W.jsx)(N,{className:`h-4 w-4`})})]})}var he={statusFilter:`all`,kindFilter:`all`,search:``};function $(){let e=(0,se.c)(107),t=a(o(xe)).notes,n=!!s(be),[r,d]=(0,U.useReducer)(h,he),[m]=(0,U.useState)(ye),g=f(),_;e[0]!==n||e[1]!==r.kindFilter||e[2]!==r.search||e[3]!==r.statusFilter?(_=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]=_):_=e[4];let v=_,y;e[5]!==r.kindFilter||e[6]!==r.search||e[7]!==r.statusFilter?(y=()=>R({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]=y):y=e[8];let b;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(b={keepPreviousData:!0},e[9]=b):b=e[9];let{data:x,mutate:C,isLoading:w}=l(v,y,b),E=w&&!x,D;e[10]===x?.items?D=e[11]:(D=x?.items??[],e[10]=x?.items,e[11]=D);let A=D,j=x?.total??0,N=L(ve),P=L(_e),F=j>0?t.noteCount.replace(`{{count}}`,String(j)):null,I,B;e[12]!==P||e[13]!==n||e[14]!==t.title||e[15]!==F||e[16]!==N?(I=()=>n?(N({startExtra:null,main:(0,W.jsxs)(`div`,{className:i(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,M),children:[(0,W.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),F?(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:F}):null]}),end:null}),()=>P()):(P(),()=>P()),B=[P,n,t.title,F,N],e[12]=P,e[13]=n,e[14]=t.title,e[15]=F,e[16]=N,e[17]=I,e[18]=B):(I=e[17],B=e[18]),(0,U.useLayoutEffect)(I,B);let ee;e[19]!==t.daysAgo||e[20]!==t.justNow||e[21]!==t.minutesAgo||e[22]!==t.today||e[23]!==t.yesterday?(ee={justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo},e[19]=t.daysAgo,e[20]=t.justNow,e[21]=t.minutesAgo,e[22]=t.today,e[23]=t.yesterday,e[24]=ee):ee=e[24];let ne=ee,re;e[25]!==C||e[26]!==g?(re=async(e,t)=>{let n=await T(e,`web`);await C(),t?.navigate!==!1&&g(`/notes/${n.id}`)},e[25]=C,e[26]=g,e[27]=re):re=e[27];let H=re,ie;e[28]!==C||e[29]!==t.imageUploadFailed||e[30]!==t.imageUploadFailedHint?(ie=()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let n=e.files?.[0];if(n)try{await z(n,`web`),await C()}catch(e){let n=e;c({type:`error`,title:t.imageUploadFailed,message:n instanceof Error?n.message:t.imageUploadFailedHint})}},e.click()},e[28]=C,e[29]=t.imageUploadFailed,e[30]=t.imageUploadFailedHint,e[31]=ie):ie=e[31];let ae=ie,oe;e[32]!==C||e[33]!==t.voiceUploadFailed||e[34]!==t.voiceUploadFailedHint?(oe=async(e,n)=>{try{await S(e,n,`web`),await C()}catch(e){let n=e;c({type:`error`,title:t.voiceUploadFailed,message:n instanceof Error?n.message:t.voiceUploadFailedHint})}},e[32]=C,e[33]=t.voiceUploadFailed,e[34]=t.voiceUploadFailedHint,e[35]=oe):oe=e[35];let ce=oe,G;e[36]===C?G=e[37]:(G=async(e,t)=>{await p(e,{pinned:t}),await C()},e[36]=C,e[37]=G);let le=G,K;e[38]===C?K=e[39]:(K=async e=>{await p(e,{status:`archived`}),await C()},e[38]=C,e[39]=K);let q=K,ue;e[40]===C?ue=e[41]:(ue=async e=>{await O(e),await C()},e[40]=C,e[41]=ue);let de=ue,fe;e[42]===g?fe=e[43]:(fe=e=>{g(`/notes/${e}`)},e[42]=g,e[43]=fe);let pe=fe;if(!n){let n;e[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsx)(u,{className:`h-10 w-10 text-fg-muted`}),e[44]=n):n=e[44];let r;return e[45]===t.needToken?r=e[46]:(r=(0,W.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n,(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]}),e[45]=t.needToken,e[46]=r),r}let me;e[47]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,W.jsx)(k,{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[47]=me):me=e[47];let Y;e[48]===d?Y=e[49]:(Y=e=>d({type:`patch`,patch:{search:e.target.value}}),e[48]=d,e[49]=Y);let X;e[50]!==t.searchPlaceholder||e[51]!==Y||e[52]!==r.search?(X=(0,W.jsxs)(`div`,{className:`relative`,children:[me,(0,W.jsx)(`input`,{type:`search`,value:r.search,onChange:Y,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[50]=t.searchPlaceholder,e[51]=Y,e[52]=r.search,e[53]=X):X=e[53];let Z;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(Z=[`all`,`inbox`,`processed`,`archived`],e[54]=Z):Z=e[54];let $;e[55]!==d||e[56]!==t.filterAll||e[57]!==t.filterArchived||e[58]!==t.filterInbox||e[59]!==t.filterProcessed||e[60]!==r.statusFilter?($=Z.map(e=>{let n=e===`all`?t.filterAll:e===`inbox`?t.filterInbox:e===`processed`?t.filterProcessed:t.filterArchived;return(0,W.jsx)(`button`,{type:`button`,onClick:()=>d({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[55]=d,e[56]=t.filterAll,e[57]=t.filterArchived,e[58]=t.filterInbox,e[59]=t.filterProcessed,e[60]=r.statusFilter,e[61]=$):$=e[61];let Se,Ce;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,W.jsx)(`div`,{className:`mx-1 h-4 w-px bg-edge-subtle`}),Ce=[`all`,`thought`,`todo`,`voice`,`media`,`bookmark`],e[62]=Se,e[63]=Ce):(Se=e[62],Ce=e[63]);let we;e[64]!==d||e[65]!==t.kindAll||e[66]!==t.kindBookmark||e[67]!==t.kindMedia||e[68]!==t.kindThought||e[69]!==t.kindTodo||e[70]!==t.kindVoice||e[71]!==r.kindFilter?(we=Ce.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,W.jsx)(`button`,{type:`button`,onClick:()=>d({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[64]=d,e[65]=t.kindAll,e[66]=t.kindBookmark,e[67]=t.kindMedia,e[68]=t.kindThought,e[69]=t.kindTodo,e[70]=t.kindVoice,e[71]=r.kindFilter,e[72]=we):we=e[72];let Te;e[73]!==$||e[74]!==we?(Te=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[$,Se,we]}),e[73]=$,e[74]=we,e[75]=Te):Te=e[75];let Ee;e[76]!==X||e[77]!==Te?(Ee=(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4 p-4 pb-2`,children:[X,Te]}),e[76]=X,e[77]=Te,e[78]=Ee):Ee=e[78];let De;e[79]!==q||e[80]!==de||e[81]!==pe||e[82]!==le||e[83]!==t.archive||e[84]!==t.delete||e[85]!==t.imageNote||e[86]!==t.noNotes||e[87]!==t.noNotesDescription||e[88]!==t.noText||e[89]!==t.pin||e[90]!==t.unpin||e[91]!==A||e[92]!==m||e[93]!==E||e[94]!==ne?(De=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pt-3 pb-24 [scrollbar-gutter:stable]`,children:E?(0,W.jsx)(`div`,{className:`flex flex-col gap-3`,children:[1,2,3].map(ge)}):A.length===0?(0,W.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-2 py-16 text-center`,children:[(0,W.jsx)(u,{className:`h-8 w-8 text-fg-muted`}),(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:t.noNotes}),(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.noNotesDescription})]}):(0,W.jsx)(`div`,{className:`flex flex-col gap-3`,children:A.map((e,n)=>{let r=n>0?te(A[n-1].createdAt):null;return(0,W.jsxs)(`div`,{children:[te(e.createdAt)!==r&&(0,W.jsx)(`div`,{className:i(`pb-2 text-xs font-medium text-fg-muted`,n>0&&`pt-2`),children:V(e.createdAt,m,ne)}),(0,W.jsx)(J,{note:e,onPress:pe,onPin:le,onArchive:q,onDelete:de,timeLabels:ne,labels:{pin:t.pin,unpin:t.unpin,archive:t.archive,delete:t.delete,imageNote:t.imageNote,noText:t.noText}})]},e.id)})})}),e[79]=q,e[80]=de,e[81]=pe,e[82]=le,e[83]=t.archive,e[84]=t.delete,e[85]=t.imageNote,e[86]=t.noNotes,e[87]=t.noNotesDescription,e[88]=t.noText,e[89]=t.pin,e[90]=t.unpin,e[91]=A,e[92]=m,e[93]=E,e[94]=ne,e[95]=De):De=e[95];let Oe;e[96]!==H||e[97]!==ae||e[98]!==ce||e[99]!==t.quickCapturePlaceholder||e[100]!==t.recording||e[101]!==t.send?(Oe=(0,W.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,W.jsx)(`div`,{className:`pointer-events-auto`,children:(0,W.jsx)(Q,{placeholder:t.quickCapturePlaceholder,sendLabel:t.send,onCapture:H,onImagePick:ae,onVoiceCapture:ce,recordingLabel:t.recording})})}),e[96]=H,e[97]=ae,e[98]=ce,e[99]=t.quickCapturePlaceholder,e[100]=t.recording,e[101]=t.send,e[102]=Oe):Oe=e[102];let ke;return e[103]!==Ee||e[104]!==De||e[105]!==Oe?(ke=(0,W.jsxs)(`div`,{className:`relative mx-auto flex h-full min-h-0 w-full max-w-3xl flex-1 flex-col overflow-hidden`,children:[Ee,De,Oe]}),e[103]=Ee,e[104]=De,e[105]=Oe,e[106]=ke):ke=e[106],ke}function ge(e){return(0,W.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-JdwAhgNB.js";import{t as a}from"./messages-BN_WiUg0.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{a as s,c,i as l,n as u,o as d,t as f}from"./fetch-D9QqUtzZ.js";import{a as p,i as m}from"./vendor-swr-BIWyz7Rc.js";import{$r as h,Ai as g,Ao as _,Da as v,H as y,Io as b,Ja as x,Ji as S,Jr as C,Ko as w,Qr as T,Ra as E,Sa as D,Sr as O,Ui as k,Xr as A,Zr as j,an as M,bo as N,ca as P,cn as F,dn as I,ei as L,fn as R,h as z,hn as B,in as V,ji as H,jn as ee,ks as U,ln as W,lo as te,mn as ne,oa as re,on as G,os as ie,pa as K,pi as q,pn as J,rn as Y,rs as X,sn as ae,ti as oe,tt as se,un as ce,vi as le,vn as ue,ws as de,xr as fe,yi as pe,yn as me}from"./index-DefIdW9q.js";import{t as he}from"./settings-collapsible-section-CdjFnSAy.js";import{n as ge,r as _e,t as ve}from"./settings-form-section-DZLy_exu.js";import{t as ye}from"./browser-BLJWD7WI.js";var Z=n(),Q=e(t(),1);function be(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`),fe()])},[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 ae();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await Y();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await V(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await M():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 xe(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function Se(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(Te),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:S,pairContext:C,pairBaseUrl:w,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:O,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 B=be(r,R),V,U,W,te,ne;if(t[8]!==O||t[9]!==E||t[10]!==A||t[11]!==B||t[12]!==r||t[13]!==g||t[14]!==d||t[15]!==j||t[16]!==l||t[17]!==w||t[18]!==C?.candidates||t[19]!==C?.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]!==S||t[48]!==b?.publicUrl){ne=Symbol.for(`react.early_return_sentinel`);bb0:{let e=C?.candidates.filter(we)??[],n=d?(e.find(Ce)?.url??e[0]?.url??``).trim():C?.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:()=>O(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(V=u&&!d,V&&!y){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(re,{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],ne=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=V?`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)(re,{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]!==V||t[68]!==c||t[69]!==h.pairSubtitle?(k=V?(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]=V,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)(H,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void l(),children:[(0,$.jsx)(D,{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?(U=(0,$.jsxs)(`div`,{className:m,children:[N,P]}),t[78]=m,t[79]=N,t[80]=P,t[81]=U):U=t[81],W=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)(H,{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)(H,{type:`button`,className:`w-full sm:w-auto`,disabled:B.busy||!r,onClick:()=>B.setConfirmOpen(!0),children:[B.busy?(0,$.jsx)(x,{className:`size-3.5 animate-spin`}):null,B.busy?h.pairEnableLanEnabling:h.pairEnableLanButton]})}),B.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:B.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)(de,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:h.pairEnableLanSecurityAuditLink}),d&&g?.pairPublicTabLink?(0,$.jsx)(de,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairPublicTabLink}):null]})]}):null,te=y&&!d?V?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})]}),S?.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:S.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(xe(),`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]=O,t[9]=E,t[10]=A,t[11]=B,t[12]=r,t[13]=g,t[14]=d,t[15]=j,t[16]=l,t[17]=w,t[18]=C?.candidates,t[19]=C?.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]=S,t[48]=b?.publicUrl,t[49]=V,t[50]=U,t[51]=W,t[52]=te,t[53]=ne}else V=t[49],U=t[50],W=t[51],te=t[52],ne=t[53];if(ne!==Symbol.for(`react.early_return_sentinel`))return ne;let G;t[82]===h.pairSecurityNote?G=t[83]:(G=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:h.pairSecurityNote}),t[82]=h.pairSecurityNote,t[83]=G);let ie;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?(ie=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)(ee,{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]=ie):ie=t[93];let K;t[94]!==V||t[95]!==P||t[96]!==h.deeplinkTitle?(K=P&&!V?(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]=V,t[95]=P,t[96]=h.deeplinkTitle,t[97]=K):K=t[97];let q;t[98]!==V||t[99]!==h.pairMobileProbeHint||t[100]!==h.pairSchemeHint?(q=V?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]=V,t[99]=h.pairMobileProbeHint,t[100]=h.pairSchemeHint,t[101]=q):q=t[101];let J,Y;t[102]===B?(J=t[103],Y=t[104]):(J=()=>void B.runEnableLanPairing(),Y=()=>{B.busy||B.setConfirmOpen(!1)},t[102]=B,t[103]=J,t[104]=Y);let X;t[105]!==B.confirmOpen||t[106]!==h.consentCancel||t[107]!==h.pairEnableLanButton||t[108]!==h.pairEnableLanConfirmBody||t[109]!==h.pairEnableLanConfirmTitle||t[110]!==J||t[111]!==Y?(X=(0,$.jsx)(z,{open:B.confirmOpen,title:h.pairEnableLanConfirmTitle,description:h.pairEnableLanConfirmBody,confirmLabel:h.pairEnableLanButton,cancelLabel:h.consentCancel,onConfirm:J,onCancel:Y}),t[105]=B.confirmOpen,t[106]=h.consentCancel,t[107]=h.pairEnableLanButton,t[108]=h.pairEnableLanConfirmBody,t[109]=h.pairEnableLanConfirmTitle,t[110]=J,t[111]=Y,t[112]=X):X=t[112];let ae;return t[113]!==G||t[114]!==ie||t[115]!==K||t[116]!==q||t[117]!==X||t[118]!==U||t[119]!==W||t[120]!==te?(ae=(0,$.jsx)(ve,{children:(0,$.jsxs)($.Fragment,{children:[U,W,te,G,ie,K,q,X]})}),t[113]=G,t[114]=ie,t[115]=K,t[116]=q,t[117]=X,t[118]=U,t[119]=W,t[120]=te,t[121]=ae):ae=t[121],ae}function Ce(e){return e.reachable}function we(e){return e.kind===`lan`}function Te(e){return e.language}function Ee(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 g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(T,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,me)}),t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=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`,ue),t[3]=_):_=t[3];let v;t[4]===r?v=t[5]:(v=(0,$.jsx)(oe,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=v);let y;t[6]===a?y=t[7]:(y=(0,$.jsx)(j,{className:`mt-2 text-sm text-fg-muted`,children:a}),t[6]=a,t[7]=y);let b;t[8]===o?b=t[9]:(b=o.map(De),t[8]=o,t[9]=b);let x;t[10]===b?x=t[11]:(x=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:b}),t[10]=b,t[11]=x);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===s?w=t[16]:(w=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=w);let E;t[17]!==w||t[18]!==C?(E=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=E):E=t[19];let D;t[20]!==l||t[21]!==d?(D=(0,$.jsx)(H,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=D):D=t[22];let O=!f,k;t[23]!==c||t[24]!==u||t[25]!==O?(k=(0,$.jsx)(H,{type:`button`,disabled:O,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=O,t[26]=k):k=t[26];let M;t[27]!==D||t[28]!==k?(M=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[D,k]}),t[27]=D,t[28]=k,t[29]=M):M=t[29];let N;t[30]!==E||t[31]!==M||t[32]!==v||t[33]!==y||t[34]!==x?(N=(0,$.jsxs)(h,{children:[g,(0,$.jsxs)(A,{className:_,onOpenAutoFocus:Oe,children:[v,y,x,E,M]})]}),t[30]=E,t[31]=M,t[32]=v,t[33]=y,t[34]=x,t[35]=N):N=t[35];let P;return t[36]!==n||t[37]!==m||t[38]!==N?(P=(0,$.jsx)(L,{open:n,onOpenChange:m,children:N}),t[36]=n,t[37]=m,t[38]=N,t[39]=P):P=t[39],P}function De(e){return(0,$.jsx)(`li`,{children:e},e)}function Oe(e){return e.preventDefault()}function ke(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ae=[`preparing_frpc`,`registering`,`starting_frpc`];function je(e){return e?e===`reconnecting_frpc`?Ae.indexOf(`starting_frpc`):Ae.indexOf(e):-1}function Me(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ae.indexOf(e),i=je(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Ne(e,t,n){let r=n.startProgress;return Me(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 Pe(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Fe(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 Ie(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(Le),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=Fe(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=Ae.map(e=>{let t=Me(e,n),a=Ne(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)(ie,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(x,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(w,{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:Pe(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:[ke(n.frpcDownload.bytesReceived),` /`,` `,ke(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 Le(e){return e+1}function Re(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 ze(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function Be(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 Ve(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 He(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,g=d===void 0?!1:d,_,y,b,S,C,w,T;t[0]!==r||t[1]!==s?(T=ze(r),_=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],C=`flex flex-wrap items-start justify-between gap-3`,S=`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`,Be(T)),t[0]=r,t[1]=s,t[2]=_,t[3]=y,t[4]=b,t[5]=S,t[6]=C,t[7]=w,t[8]=T):(_=t[2],y=t[3],b=t[4],S=t[5],C=t[6],w=t[7],T=t[8]);let E=T===`connected`&&`bg-emerald-500`,D=T===`progress`&&`bg-amber-500 animate-pulse`,O=T===`error`&&`bg-red-500`,A=T===`off`&&`bg-fg-subtle`,j;t[10]!==E||t[11]!==D||t[12]!==O||t[13]!==A?(j=i(`size-1.5 rounded-full`,E,D,O,A),t[10]=E,t[11]=D,t[12]=O,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 P;t[17]!==a||t[18]!==r||t[19]!==n?(P=a&&!r.enabled?n.loading:Re(n,r),t[17]=a,t[18]=r,t[19]=n,t[20]=P):P=t[20];let F;t[21]!==M||t[22]!==P||t[23]!==b?(F=(0,$.jsxs)(`span`,{className:b,children:[M,P]}),t[21]=M,t[22]=P,t[23]=b,t[24]=F):F=t[24];let I;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(I=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ve(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=I):I=t[28];let L;t[29]!==F||t[30]!==I||t[31]!==S?(L=(0,$.jsxs)(`div`,{className:S,children:[F,I]}),t[29]=F,t[30]=I,t[31]=S,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(N,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=R):R=t[33];let z;t[34]!==L||t[35]!==C?(z=(0,$.jsxs)(`div`,{className:C,children:[L,R]}),t[34]=L,t[35]=C,t[36]=z):z=t[36];let B;t[37]===o?B=t[38]:(B=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]=B);let V;t[39]!==l||t[40]!==n.consentExpiredBanner?(V=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]=V):V=t[41];let U;t[42]!==_||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==y||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(U=_?(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)(ee,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,y?(0,$.jsx)(Ie,{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)(H,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(x,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(H,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(x,{className:`size-4 animate-spin`}):(0,$.jsx)(v,{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)(k,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(H,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(x,{className:`size-4 animate-spin`}):(0,$.jsx)(v,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=u,t[44]=m,t[45]=h,t[46]=y,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=U):U=t[54];let W;return t[55]!==z||t[56]!==B||t[57]!==V||t[58]!==U||t[59]!==w?(W=(0,$.jsxs)(`section`,{className:w,children:[z,B,V,U]}),t[55]=z,t[56]=B,t[57]=V,t[58]=U,t[59]=w,t[60]=W):W=t[60],W}var Ue=`https://console.xopc.ai/keys/tunnel`,We={reconfiguring:!1};function Ge(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)(),v=a&&!r,b=!v,[S,C]=(0,Q.useReducer)(y,We),{reconfiguring:w}=S,T;t[0]!==o||t[1]!==c||t[2]!==r||t[3]!==w?(T=o&&!r&&!w&&!c.trim(),t[0]=o,t[1]=c,t[2]=r,t[3]=w,t[4]=T):T=t[4];let E=T,D;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(D={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]=D):D=t[9];let O=D,k;t[10]===c?k=t[11]:(k=c.trim().length>0&&!se(c.trim()),t[10]=c,t[11]=k);let A=k,j;t[12]===f?j=t[13]:(j=()=>{C({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[12]=f,t[13]=j);let M=j,N=v&&`ring-1 ring-amber-500/30`,P;t[14]===N?P=t[15]:(P=i(N),t[14]=N,t[15]=P);let F=b?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:v?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,I;t[16]===F?I=t[17]:(I=i(`flex size-9 shrink-0 items-center justify-center rounded-lg`,F),t[16]=F,t[17]=I);let L;t[18]===b?L=t[19]:(L=b?(0,$.jsx)(ie,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=b,t[19]=L);let R;t[20]!==I||t[21]!==L?(R=(0,$.jsx)(`span`,{className:I,children:L}),t[20]=I,t[21]=L,t[22]=R):R=t[22];let z=b?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,B;t[23]===z?B=t[24]:(B=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:z}),t[23]=z,t[24]=B);let V=b?n.brokerSecretReadyHint:n.brokerSecretHint,ee;t[25]===V?ee=t[26]:(ee=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:V}),t[25]=V,t[26]=ee);let U;t[27]!==v||t[28]!==n.brokerSecretMissingHint?(U=v?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=v,t[28]=n.brokerSecretMissingHint,t[29]=U):U=t[29];let W;t[30]!==B||t[31]!==ee||t[32]!==U?(W=(0,$.jsxs)(`div`,{children:[B,ee,U]}),t[30]=B,t[31]=ee,t[32]=U,t[33]=W):W=t[33];let ne;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(_,{className:`size-3`,"aria-hidden":!0}),t[34]=ne):ne=t[34];let re;t[35]===n.brokerSecretConsoleLink?re=t[36]:(re=(0,$.jsxs)(`a`,{href:Ue,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,ne]}),t[35]=n.brokerSecretConsoleLink,t[36]=re);let G;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(G=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]=G):G=t[39];let K;t[40]!==o||t[41]!==c||t[42]!==r||t[43]!==s||t[44]!==A||t[45]!==M||t[46]!==d||t[47]!==g||t[48]!==v||t[49]!==m||t[50]!==f||t[51]!==p||t[52]!==w||t[53]!==l||t[54]!==O||t[55]!==E||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?(K=E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(le,{id:g,value:s,labels:O,reveal:Ke,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(H,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>{C({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(H,{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)(le,{id:g,value:c,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:O,disabled:l}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(H,{type:`button`,disabled:l||!A,onClick:p,children:[l?(0,$.jsx)(x,{className:`size-4 animate-spin`}):null,v?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),o||r?(0,$.jsx)(H,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear}):null,w?(0,$.jsx)(H,{type:`button`,variant:`ghost`,disabled:l,onClick:M,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=o,t[41]=c,t[42]=r,t[43]=s,t[44]=A,t[45]=M,t[46]=d,t[47]=g,t[48]=v,t[49]=m,t[50]=f,t[51]=p,t[52]=w,t[53]=l,t[54]=O,t[55]=E,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]=K):K=t[66];let q;t[67]===u?q=t[68]:(q=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[67]=u,t[68]=q);let J;t[69]!==W||t[70]!==re||t[71]!==G||t[72]!==K||t[73]!==q?(J=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[W,re,G,K,q]}),t[69]=W,t[70]=re,t[71]=G,t[72]=K,t[73]=q,t[74]=J):J=t[74];let Y;t[75]!==R||t[76]!==J?(Y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[R,J]}),t[75]=R,t[76]=J,t[77]=Y):Y=t[77];let X;t[78]!==Y||t[79]!==P?(X=(0,$.jsx)(ve,{className:P,children:Y}),t[78]=Y,t[79]=P,t[80]=X):X=t[80];let ae;return t[81]!==h||t[82]!==X?(ae=(0,$.jsx)(`div`,{ref:h,id:`tunnel-broker-secret-setup`,children:X}),t[81]=h,t[82]=X,t[83]=ae):ae=t[83],ae}function Ke(){return J().then(qe)}function qe(e){return e.registrationSecret??null}function Je(e){let t=(0,Z.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=q(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)(_,{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 Ye=e(ye(),1),Xe={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function Ze(e){return Ye.toDataURL(e,Xe)}function Qe(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 $e(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function et(e,t){return e?t?Qe(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function tt(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=p(),a=(0,Q.useRef)(!1),{data:o}=m(r?`tunnel-status`:null,ce,{refreshInterval:6e4}),{data:c,mutate:l}=m(r?`tunnel-pair-context`:null,F,{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,W,{refreshInterval:4*6e4}),{data:_,mutate:v}=m(!f&&r&&c?.pairingReady?`tunnel-pair`:null,G,{refreshInterval:4*6e4}),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[w,T]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(c!==w.pairContext||n!==w.preferLan)){T({pairContext:c,preferLan:n});let e=et(c,n);y!==e&&b(e)}let E=(0,Q.useCallback)(e=>{a.current=!0,b(e)},[]),D=(0,Q.useCallback)(()=>{let e=et(c,n);e&&(a.current=!0,b(e))},[c,n]),O=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),k=(0,Q.useCallback)(e=>{a.current=!1,b(e?.trim()||et(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`),P=!f&&j&&!M&&!!_?.pairingSecret&&(c?.pairingReady===!0||!N),I=(0,Q.useMemo)(()=>{let e=Qe(c);return n?e||(A&&!$e(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(!P||!_?.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,P,x,n,A,f,h?.qrPayload,c?.candidates]),R=C(()=>Ze(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:E,applySuggestedPairUrl:D,applyCandidateUrl:O,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:k}}var nt={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function rt({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)(y,nt),{actionError:d,starting:f,stopping:p,savingAutoStart:h,consentOpen:g,autoStartConfirmOpen:_,releaseConfirmOpen:v,releasing:b,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:w}=l,T=(0,Q.useRef)(null),E=tt(r??``),{data:D}=O(s),{data:k,error:A,isLoading:j,mutate:M}=m(s?`tunnel-status`:null,ce,{refreshInterval:e=>f?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),P=(0,Q.useMemo)(()=>{let e=D?.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 k?.config?.autoStart===!0},[D,k?.config?.autoStart]),F=(0,Q.useMemo)(()=>{let e=D?.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``},[D]),L=se(F),V=k?.registrationSecret?.source===`env`,ee=k?.registrationSecret?.source===`missing`,U=k?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{M()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[M]);let W=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),te=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{starting:!0}});try{let e=await ne();await M(),fe(),await E.refreshQr(e.qrPayload)}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{starting:!1}})}},[M,E.refreshQr]),re=(0,Q.useCallback)(()=>{if(!U){u({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),T.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(k?.consentRequired){u({type:`patch`,patch:{consentOpen:!0}});return}te()},[U,k?.consentRequired,te,n.brokerSecretRequiredBeforeStart]),G=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{consentOpen:!1}}),u({type:`patch`,patch:{actionError:null}});try{await R(),await Promise.all([M(),te()])}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[M,te]),ie=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{stopping:!0}});try{await B(),await Promise.all([E.refreshQr(),M()]),fe()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{stopping:!1}})}},[M,E.refreshQr]),K=(0,Q.useCallback)(async e=>{u({type:`patch`,patch:{savingAutoStart:!0}}),u({type:`patch`,patch:{actionError:null}});try{await I({autoStart:e}),fe()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Q.useCallback)(()=>{if(P){K(!1);return}if(k?.consentRequired){u({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!k?.canAutoStart){u({type:`patch`,patch:{actionError:n.autoStartHint}});return}u({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,k?.canAutoStart,k?.consentRequired,n,P]),J=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await I({registrationSecret:e}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),fe(),await M(),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}})}}},[S,M,n.brokerSecretSaved]),Y=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await I({registrationSecret:null}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),fe(),await M()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}},[M,n.brokerSecretCleared]),X=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await B({release:!0}),await Promise.all([E.refreshQr(),M()]),fe()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{releasing:!1}})}},[M,E.refreshQr]),ae=(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 oe=k??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:P,brokerUrl:`https://frp.xopc.ai/api`}},le=k?.consentRequired&&(oe.enabled||P||k?.consent?.acceptedAt),ue=(0,$.jsx)(Ge,{t:n,brokerSecretFromEnv:V,brokerSecretMissing:ee,brokerSecretConfiguredInConfig:L,brokerSecretMaskedValue:L?F:``,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:w,copyFailedLabel:a(t).clipboard.copyFailed,onDraftChange:e=>u({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void J(),onClear:()=>void Y(),sectionRef:T}),de=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ee,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:W,checkboxLabel:n.consentCheckbox,confirmLabel:le?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void G(),onCancel:()=>u({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(z,{open:_,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{u({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>u({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(z,{open:v,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void X(),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,ue,(0,$.jsx)(He,{t:n,status:oe,isLoading:j,statusErr:A,starting:f,stopping:p,showConsentExpired:!!le,copyLabels:ae,startDisabled:!U,startDisabledReason:U?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:re,onStop:()=>void ie()}),(0,$.jsx)(Se,{pairQr:E,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void E.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`,!P&&!k?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:h||!P&&!k?.canAutoStart,onChange:q}),n.autoStart]}),!k?.canAutoStart&&!P?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,oe.subdomain||oe.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(H,{type:`button`,variant:`secondary`,disabled:b||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(x,{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)(N,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Je,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),de]}):(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,ue,(0,$.jsx)(He,{t:n,status:oe,isLoading:j,statusErr:A,starting:f,stopping:p,showConsentExpired:!!le,copyLabels:ae,startDisabled:!U,startDisabledReason:U?void 0:n.brokerSecretRequiredBeforeStart,onStart:re,onStop:()=>void ie()}),(0,$.jsx)(Se,{pairQr:E,gatewayToken:r??``}),oe.subdomain||oe.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(H,{type:`button`,variant:`secondary`,disabled:b||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(x,{className:`size-4 animate-spin`}):null,n.release]})}):null,oe.subdomain||oe.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`,!P&&!k?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:h||!P&&!k?.canAutoStart,onChange:q}),n.autoStart]}),!k?.canAutoStart&&!P?(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)(N,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Je,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),de]})}async function it(){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 at(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 ot(){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 st=`https://tailscale.com/download`;function ct(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:st,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function lt({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,it,{refreshInterval:3e4}),g=f?.tailscale.hostname,_=f?.tailscale.active===!0,y=f?.tailscale.cliAvailable!==!1,b=g?`https://${g}/`:null,S=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await at(`serve`),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]),C=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await ot(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]);if(!i)return null;let w=(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)(ct,{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)(ct,{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}),b?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(ee,{text:b,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)(H,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void C(),children:[s?(0,$.jsx)(x,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(H,{type:`button`,disabled:s||!y,onClick:()=>void S(),children:[s?(0,$.jsx)(x,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(v,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(Je,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?w:(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:N,title:n.title,subtitle:n.subtitle}),w]})}function ut(){let e=(0,Z.c)(26),t=o(ft),n=c(dt),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=tt(n??``,s),u;e[3]!==i.subtitle||e[4]!==i.title?(u=(0,$.jsx)(ge,{icon:K,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)(_,{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)(de,{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??``,v;e[17]===l?v=e[18]:(v=()=>void l.refreshQr(),e[17]=l,e[18]=v);let y;e[19]!==l||e[20]!==g||e[21]!==v?(y=(0,$.jsx)(Se,{pairQr:l,gatewayToken:g,lanOnly:!0,onRefreshQr:v}),e[19]=l,e[20]=g,e[21]=v,e[22]=y):y=e[22];let b;return e[23]!==y||e[24]!==h?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,y]}),e[23]=y,e[24]=h,e[25]=b):b=e[25],b}function dt(e){return e.token}function ft(e){return e.language}function pt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=o(mt),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 pe(`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)(b,{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)(H,{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 x=y;if(r){let e;t[14]!==c.subtitle||t[15]!==c.title?(e=(0,$.jsx)(ge,{icon:S,title:c.title,subtitle:c.subtitle}),t[14]=c.subtitle,t[15]=c.title,t[16]=e):e=t[16];let n;t[17]===x?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:x}),t[17]=x,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 C;t[22]!==c.subtitle||t[23]!==c.title?(C=(0,$.jsx)(ge,{icon:S,title:c.title,subtitle:c.subtitle}),t[22]=c.subtitle,t[23]=c.title,t[24]=C):C=t[24];let w;t[25]===x?w=t[26]:(w=(0,$.jsx)(`div`,{className:`mt-4`,children:x}),t[25]=x,t[26]=w);let T;return t[27]!==C||t[28]!==w?(T=(0,$.jsxs)(ve,{children:[C,w]}),t[27]=C,t[28]=w,t[29]=T):T=t[29],T}function mt(e){return e.language}function ht(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(pt,{embedded:!0}),e[0]=t):t=e[0],t}function gt(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 _t(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`,gt(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 vt(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=o(xt),s;t[0]===r?s=t[1]:(s=a(r),t[0]=r,t[1]=s);let l=s.remoteAccess.guide,u=!!c(bt),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,it,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,ce,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,F,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(yt),w=v?`active`:`off`,T=v?l.statusActive:l.statusOff,D;t[5]!==l.tailscaleCardTitle||t[6]!==w||t[7]!==T?(D={tab:`tailscale`,icon:N,title:l.tailscaleCardTitle,kind:w,statusLabel:T},t[5]=l.tailscaleCardTitle,t[6]=w,t[7]=T,t[8]=D):D=t[8];let O=b?`active`:x?`connecting`:`off`,k=b?l.statusActive:x?l.statusConnecting:l.statusOff,A;t[9]!==l.publicCardTitle||t[10]!==O||t[11]!==k?(A={tab:`public`,icon:E,title:l.publicCardTitle,kind:O,statusLabel:k},t[9]=l.publicCardTitle,t[10]=O,t[11]=k,t[12]=A):A=t[12];let j=C?`active`:`off`,M=C?l.statusActive:l.statusOff,I;t[13]!==l.reverseProxyCardTitle||t[14]!==j||t[15]!==M?(I={tab:`reverse-proxy`,icon:P,title:l.reverseProxyCardTitle,kind:j,statusLabel:M},t[13]=l.reverseProxyCardTitle,t[14]=j,t[15]=M,t[16]=I):I=t[16];let L;t[17]!==l.sshCardStatus||t[18]!==l.sshCardTitle?(L={tab:`ssh`,icon:S,title:l.sshCardTitle,kind:`off`,statusLabel:l.sshCardStatus},t[17]=l.sshCardStatus,t[18]=l.sshCardTitle,t[19]=L):L=t[19];let R;t[20]!==l.lanCardStatus||t[21]!==l.lanCardTitle?(R={tab:`lan`,icon:K,title:l.lanCardTitle,kind:`off`,statusLabel:l.lanCardStatus},t[20]=l.lanCardStatus,t[21]=l.lanCardTitle,t[22]=R):R=t[22];let z;t[23]!==A||t[24]!==I||t[25]!==L||t[26]!==R||t[27]!==D?(z=[D,A,I,L,R],t[23]=A,t[24]=I,t[25]=L,t[26]=R,t[27]=D,t[28]=z):z=t[28];let B=z,V;return t[29]!==B||t[30]!==n?(V=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:B.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)(_t,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=B,t[30]=n,t[31]=V):V=t[31],V}function yt(e){return e.kind===`reverse-proxy`}function bt(e){return e.token}function xt(e){return e.language}function St(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)(X,{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 b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Ct(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=o(Et),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(Tt),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,it,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)(vt,{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(wt)})]}):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)(St,{icon:N,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)(St,{icon:E,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)(St,{icon:P,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 D;t[37]===n?D=t[38]:(D=()=>n(`ssh`),t[37]=n,t[38]=D);let O;t[39]!==l.configure||t[40]!==l.sshCardDesc||t[41]!==l.sshCardTitle||t[42]!==D?(O=(0,$.jsx)(St,{icon:S,title:l.sshCardTitle,description:l.sshCardDesc,openLabel:l.configure,onOpen:D}),t[39]=l.configure,t[40]=l.sshCardDesc,t[41]=l.sshCardTitle,t[42]=D,t[43]=O):O=t[43];let k;t[44]===n?k=t[45]:(k=()=>n(`lan`),t[44]=n,t[45]=k);let A;t[46]!==l.configure||t[47]!==l.lanCardDesc||t[48]!==l.lanCardTitle||t[49]!==k?(A=(0,$.jsx)(St,{icon:K,title:l.lanCardTitle,description:l.lanCardDesc,openLabel:l.configure,onOpen:k}),t[46]=l.configure,t[47]=l.lanCardDesc,t[48]=l.lanCardTitle,t[49]=k,t[50]=A):A=t[50];let j;t[51]!==C||t[52]!==T||t[53]!==O||t[54]!==A||t[55]!==b?(j=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,C,T,O,A]}),t[51]=C,t[52]=T,t[53]=O,t[54]=A,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 F;t[60]===l.oneAtATimeHint?F=t[61]:(F=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:l.oneAtATimeHint}),t[60]=l.oneAtATimeHint,t[61]=F);let I;t[62]===s.advanced.proxyTitle?I=t[63]:(I=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.advanced.proxyTitle}),t[62]=s.advanced.proxyTitle,t[63]=I);let L;t[64]===s.advanced.proxyBody?L=t[65]:(L=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.advanced.proxyBody}),t[64]=s.advanced.proxyBody,t[65]=L);let R;t[66]!==r||t[67]!==s.advanced.proxyDocs?(R=(0,$.jsx)(Je,{language:r,label:s.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=s.advanced.proxyDocs,t[68]=R):R=t[68];let z;t[69]!==I||t[70]!==L||t[71]!==R?(z=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-4 py-3`,children:[I,L,R]}),t[69]=I,t[70]=L,t[71]=R,t[72]=z):z=t[72];let B;t[73]!==l.docsLink||t[74]!==r?(B=(0,$.jsx)(Je,{language:r,label:l.docsLink}),t[73]=l.docsLink,t[74]=r,t[75]=B):B=t[75];let V;return t[76]!==M||t[77]!==F||t[78]!==z||t[79]!==B||t[80]!==g||t[81]!==_?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[g,_,M,F,z,B]}),t[76]=M,t[77]=F,t[78]=z,t[79]=B,t[80]=g,t[81]=_,t[82]=V):V=t[82],V}function wt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Tt(e){return e.token}function Et(e){return e.language}async function Dt(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 Ot(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function kt(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 At(){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`)||kt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function jt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function Mt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Nt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Pt(){let e=o(e=>e.language),t=a(e).remoteAccess.reverseProxy,n=!!c(e=>e.token),r=At(),{mutate:l}=p(),{data:u,mutate:d}=m(n?`tunnel-pair-context`:null,F,{refreshInterval:6e4}),f=Mt(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 S=(0,Q.useMemo)(()=>h.trim()||(f??r??``),[f,r,h]),w=!f&&!!r&&S===r,T=Nt(u),{data:E,mutate:O}=m(n&&S?[`reverse-proxy-pair`,S]:null,()=>G(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),k=(0,Q.useMemo)(()=>!S||!E?.pairingSecret?``:s({baseUrl:S,pairingSecret:E.pairingSecret,lanUrl:T}),[S,T,E?.pairingSecret]),A=C(()=>Ze(k),[k],{enabled:!!k,initial:null,errorData:null}),j=(0,Q.useCallback)(async()=>{let e=h.trim()||S;if(e){v({busy:!0,result:null});try{v({busy:!1,result:await Dt(e)})}catch(e){v({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[h,S]),M=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){b({busy:!0,error:null});try{await Ot(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)})}}},[S,l,d]),P=(0,Q.useCallback)(async()=>{b({busy:!0,error:null});try{await Ot(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]),I=(0,Q.useCallback)(async()=>{await O()},[O]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:N,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(jt(),`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)(H,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void j(),disabled:_.busy||!h.trim(),children:[_.busy?(0,$.jsx)(x,{className:`size-3.5 animate-spin`}):null,_.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),w&&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)(Ft,{result:_.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[S&&f!==S?(0,$.jsxs)(H,{type:`button`,onClick:()=>void M(),disabled:y.busy,children:[y.busy?(0,$.jsx)(x,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,f?(0,$.jsx)(H,{type:`button`,variant:`ghost`,onClick:()=>void P(),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})]}),k?(0,$.jsxs)(H,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void I(),children:[(0,$.jsx)(D,{className:`size-4`}),t.refreshQr]}):null]}),S?E?.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:`}),` `,S,T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,T]}):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)(ee,{text:k,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 Ft(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 It=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Lt(e){return e&&It.includes(e)?e:`guide`}function Rt(e,t){return e.tabs[t]}function zt(e,t){return e.tabIntro[t]}function Bt(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 Vt(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)(Ct,{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)(lt,{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)(rt,{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)(Pt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ht,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ut,{}),t[6]=e):e=t[6],e}}}function Ht(){let e=(0,Z.c)(2),t=o(Wt),n=a(t).remoteAccess,r=!!c(Ut),[s,l]=U(),u=Lt(s.get(`tab`)),d;e[0]===l?d=e[1]:(d=e=>{l(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=l,e[1]=d);let f=d,p=zt(n,u);return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-5 px-4 py-8`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.pageTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.pageSubtitle}),(0,$.jsx)(Je,{language:t,label:n.docsLink,section:Bt(u),className:`mt-1`})]}),r?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,role:`tablist`,"aria-label":n.tabsAria,onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=It[(It.indexOf(u)+(e.key===`ArrowRight`?1:-1)+It.length)%It.length];f(t)},children:[(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:It.map(e=>{let t=e===u;return(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,id:`remote-access-tab-${e}`,"aria-controls":`remote-access-panel-${e}`,className:i(`shrink-0 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>f(e),children:Rt(n,e)},e)})}),u===`public`?null:(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:p}),(0,$.jsx)(`div`,{role:`tabpanel`,id:`remote-access-panel-${u}`,"aria-labelledby":`remote-access-tab-${u}`,className:`min-w-0`,children:(0,$.jsx)(Vt,{tab:u,onOpenTab:f})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Ut(e){return e.token}function Wt(e){return e.language}export{Ht as RemoteAccessHub};