@xopcai/xopc 0.0.142 → 0.0.143

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 (543) hide show
  1. package/README.md +1 -1
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/activity-center-store-jITiX2vJ.js +1 -0
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BawPxiu5.js → agent-avatar-dicebear-DiME9u_P.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-DzBXhZXO.js +2 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-81xd1p9R.js → app-management-settings-panel-Cuo7SbUP.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-DYeQsYU8.js → appearance-settings-DUfdNQqk.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-CKuKK5AU.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-D_oa7oti.js → archive-plugin-B-Qk6cGr.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Cd-bwI2N.js → attachment-load-Di6EEbQX.js} +1 -1
  12. package/dist/gateway/static/root/assets/automation-suggestion-card-DGxvRxtO.js +1 -0
  13. package/dist/gateway/static/root/assets/automations-page-D-FF_WKV.js +4 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-O8svLKWw.js → binary-plugins-ZaOZDH2I.js} +1 -1
  15. package/dist/gateway/static/root/assets/block-editor-BTFhjWfg.js +184 -0
  16. package/dist/gateway/static/root/assets/browser-settings-page-BvKLdEQt.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-dJy1Eqgx.js → capability-presets-api-BU-pVZiZ.js} +1 -1
  18. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DgyeEwzh.js +2 -0
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-Bfuhp2ty.js → channel-recipient-api-DuulnhIj.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-BbVsdD_I.js +1 -0
  21. package/dist/gateway/static/root/assets/channels-status-swr-B5lVrUsN.js +1 -0
  22. package/dist/gateway/static/root/assets/check-BODqo66o.js +1 -0
  23. package/dist/gateway/static/root/assets/chunk-QUQL4437-DXsxWP7r.js +4 -0
  24. package/dist/gateway/static/root/assets/circle-alert-RzVebuX2.js +1 -0
  25. package/dist/gateway/static/root/assets/connectors-page-B8QqVy3I.js +2 -0
  26. package/dist/gateway/static/root/assets/{desktop-pet-DFMfIb5F.js → desktop-pet---yzVxVR.js} +1 -1
  27. package/dist/gateway/static/root/assets/desktop-pet-settings-Dc3gqBJE.js +1 -0
  28. package/dist/gateway/static/root/assets/{directory-picker-path-field-BrYt1gAr.js → directory-picker-path-field-DCmOGLtK.js} +1 -1
  29. package/dist/gateway/static/root/assets/dreaming-settings-BgT5KZVe.js +3 -0
  30. package/dist/gateway/static/root/assets/{extension-debug-page-Bh630pLD.js → extension-debug-page-ByaKTTq4.js} +1 -1
  31. package/dist/gateway/static/root/assets/extension-page-BmRzHAZr.js +1 -0
  32. package/dist/gateway/static/root/assets/extension-settings-page-JUtwIhbF.js +1 -0
  33. package/dist/gateway/static/root/assets/{fetch-B1WtuprY.js → fetch-8QNN25Sh.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-De2N821l.js → gateway-config-api-CxicF50_.js} +1 -1
  35. package/dist/gateway/static/root/assets/gateway-settings-Bz2I_EO5.js +1 -0
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-nEujFSDj.js → gateway-startup-retry-5YBnS9Fj.js} +1 -1
  37. package/dist/gateway/static/root/assets/goal-create-dialog-VcoyuZGN.js +1 -0
  38. package/dist/gateway/static/root/assets/goal-detail-page-Cilkap2G.js +4 -0
  39. package/dist/gateway/static/root/assets/{goals-config-api-DUy3eEse.js → goals-config-api-CwcHRdC0.js} +1 -1
  40. package/dist/gateway/static/root/assets/goals-page-C6eoni4z.js +2 -0
  41. package/dist/gateway/static/root/assets/goals-settings-o4i-qAOS.js +1 -0
  42. package/dist/gateway/static/root/assets/heartbeat-settings-DQQkETX8.js +1 -0
  43. package/dist/gateway/static/root/assets/index-BKRqeRHm.js +257 -0
  44. package/dist/gateway/static/root/assets/index-CphxClbs.css +1 -0
  45. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CVIwwM15.js → keyboard-shortcuts-settings-LT6qB-ua.js} +1 -1
  46. package/dist/gateway/static/root/assets/logs-page-Dli2e3fS.js +7 -0
  47. package/dist/gateway/static/root/assets/{markdown-split-B_6us9j7.js → markdown-split-Dw-yE2-y.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-D_fryIyj.js → media-plugins-D9NNNUgE.js} +1 -1
  49. package/dist/gateway/static/root/assets/messages-CzKxM6I4.js +5 -0
  50. package/dist/gateway/static/root/assets/models-hub-panel-DVn2Q1Ik.js +2 -0
  51. package/dist/gateway/static/root/assets/notes-page-CRgbJGgk.js +1 -0
  52. package/dist/gateway/static/root/assets/notes-workbench-BxZRHLWx.js +2 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-D_8jGlqx.js → page-tabs-D4hkWVt_.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-BBLMK8Mp.js → preview-open-alternatives-CIckv0uy.js} +1 -1
  55. package/dist/gateway/static/root/assets/project-detail-page-Doz53xLn.js +1 -0
  56. package/dist/gateway/static/root/assets/projects-page-DoMtcRLg.js +1 -0
  57. package/dist/gateway/static/root/assets/remote-access-hub-BeHVEgrm.js +1 -0
  58. package/dist/gateway/static/root/assets/{save-bar-controls-DVS3FR5r.js → save-bar-controls-B0b42kB2.js} +1 -1
  59. package/dist/gateway/static/root/assets/{schedule-field-D6vKd6-T.js → schedule-field-BtjEkczK.js} +1 -1
  60. package/dist/gateway/static/root/assets/{schema-form-BPy4lbIh.js → schema-form-Bf0bk3i6.js} +1 -1
  61. package/dist/gateway/static/root/assets/sessions-page-Bk4bQsBe.js +1 -0
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-DdFyaRMm.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-collapsible-section-WzdikxPt.js → settings-collapsible-section-BTKTdTNX.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-form-section-CvfzhBV-.js → settings-form-section-DL4P0sAj.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BxR-Ulhi.js → settings-loading-skeleton-BV6KFNj4.js} +1 -1
  66. package/dist/gateway/static/root/assets/settings-page-B_4DsX5W.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-page-layout-CKefvbYi.js → settings-page-layout-CyGlrInB.js} +1 -1
  68. package/dist/gateway/static/root/assets/setup-status-panel-DJ1_MLgX.js +1 -0
  69. package/dist/gateway/static/root/assets/share-preview-page-BQBV7YrV.js +2 -0
  70. package/dist/gateway/static/root/assets/shares-settings-0VuFLBeU.js +1 -0
  71. package/dist/gateway/static/root/assets/skill-reload-api-DO87Ckeo.js +1 -0
  72. package/dist/gateway/static/root/assets/skills-page-D3VdtxAn.js +2 -0
  73. package/dist/gateway/static/root/assets/{system-settings-panel-BokgAgf7.js → system-settings-panel-D85fBBuI.js} +1 -1
  74. package/dist/gateway/static/root/assets/{typed-models-lib-BwHlNL3L.js → typed-models-lib-CwEuYrHX.js} +1 -1
  75. package/dist/gateway/static/root/assets/{use-channel-catalog-DR11ap3A.js → use-channel-catalog-COXIfXcl.js} +1 -1
  76. package/dist/gateway/static/root/assets/user-context-page-m9JVQ73F.js +1 -0
  77. package/dist/gateway/static/root/assets/user-profile-fields-editor-DtQiuY7E.js +1 -0
  78. package/dist/gateway/static/root/assets/user-profile-settings-panel-CWM0fEpb.js +1 -0
  79. package/dist/gateway/static/root/assets/{utils-BKUWB-TT.js → utils--BO6xT3u.js} +1 -1
  80. package/dist/gateway/static/root/assets/voice-api-key-field-LoT3wgZ9.js +1 -0
  81. package/dist/gateway/static/root/assets/with-selector-aYPsXwdl.js +1 -0
  82. package/dist/gateway/static/root/assets/work-item-detail-page-DSTMz_mO.js +1 -0
  83. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CL_rnAUB.js → workflow-run-setup-panel-B35lJzvm.js} +2 -2
  84. package/dist/gateway/static/root/assets/workflows-page-BfSm9oR8.js +11 -0
  85. package/dist/gateway/static/root/assets/workflows-page-DLioOiRN.css +1 -0
  86. package/dist/gateway/static/root/connector-icons/README.md +11 -0
  87. package/dist/gateway/static/root/connector-icons/airtable.svg +13 -0
  88. package/dist/gateway/static/root/connector-icons/asana.svg +15 -0
  89. package/dist/gateway/static/root/connector-icons/brave-search.svg +1 -0
  90. package/dist/gateway/static/root/connector-icons/clickup.svg +19 -0
  91. package/dist/gateway/static/root/connector-icons/composio.svg +266 -0
  92. package/dist/gateway/static/root/connector-icons/discord.svg +15 -0
  93. package/dist/gateway/static/root/connector-icons/dropbox.svg +152 -0
  94. package/dist/gateway/static/root/connector-icons/excel.svg +56 -0
  95. package/dist/gateway/static/root/connector-icons/fetch.svg +6 -0
  96. package/dist/gateway/static/root/connector-icons/figma.svg +178 -0
  97. package/dist/gateway/static/root/connector-icons/filesystem.svg +6 -0
  98. package/dist/gateway/static/root/connector-icons/github.svg +10 -0
  99. package/dist/gateway/static/root/connector-icons/gmail.svg +3 -0
  100. package/dist/gateway/static/root/connector-icons/google-calendar.svg +3 -0
  101. package/dist/gateway/static/root/connector-icons/google-docs.svg +25 -0
  102. package/dist/gateway/static/root/connector-icons/google-drive.svg +25 -0
  103. package/dist/gateway/static/root/connector-icons/google-sheets.svg +1 -0
  104. package/dist/gateway/static/root/connector-icons/hubspot.svg +142 -0
  105. package/dist/gateway/static/root/connector-icons/jira.svg +15 -0
  106. package/dist/gateway/static/root/connector-icons/linear.svg +5 -0
  107. package/dist/gateway/static/root/connector-icons/memory.svg +5 -0
  108. package/dist/gateway/static/root/connector-icons/microsoft-teams.svg +33 -0
  109. package/dist/gateway/static/root/connector-icons/notion.svg +5 -0
  110. package/dist/gateway/static/root/connector-icons/one-drive.svg +13 -0
  111. package/dist/gateway/static/root/connector-icons/outlook.svg +76 -0
  112. package/dist/gateway/static/root/connector-icons/playwright.svg +9 -0
  113. package/dist/gateway/static/root/connector-icons/salesforce.svg +17 -0
  114. package/dist/gateway/static/root/connector-icons/sequential-thinking.svg +8 -0
  115. package/dist/gateway/static/root/connector-icons/shopify.svg +5 -0
  116. package/dist/gateway/static/root/connector-icons/slack.svg +9 -0
  117. package/dist/gateway/static/root/connector-icons/spotify.svg +43 -0
  118. package/dist/gateway/static/root/connector-icons/stripe.svg +11 -0
  119. package/dist/gateway/static/root/connector-icons/telegram.svg +130 -0
  120. package/dist/gateway/static/root/connector-icons/time.svg +6 -0
  121. package/dist/gateway/static/root/connector-icons/todoist.svg +277 -0
  122. package/dist/gateway/static/root/connector-icons/trello.svg +19 -0
  123. package/dist/gateway/static/root/connector-icons/twitter.svg +128 -0
  124. package/dist/gateway/static/root/connector-icons/whatsapp.svg +61 -0
  125. package/dist/gateway/static/root/connector-icons/youtube.svg +11 -0
  126. package/dist/gateway/static/root/index.html +9 -6
  127. package/dist/package.js +1 -1
  128. package/dist/src/agent/agent-manager.d.ts +2 -0
  129. package/dist/src/agent/agent-manager.js +8 -0
  130. package/dist/src/agent/agent-manager.js.map +1 -1
  131. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  132. package/dist/src/agent/background-review/prompts.js +3 -2
  133. package/dist/src/agent/background-review/prompts.js.map +1 -1
  134. package/dist/src/agent/embedded/session-tool-result-guard.js +1 -1
  135. package/dist/src/agent/embedded/xopc-tools-bridge.d.ts +9 -0
  136. package/dist/src/agent/embedded/xopc-tools-bridge.js +71 -3
  137. package/dist/src/agent/embedded/xopc-tools-bridge.js.map +1 -1
  138. package/dist/src/agent/goals/post-turn.js +5 -4
  139. package/dist/src/agent/goals/post-turn.js.map +1 -1
  140. package/dist/src/agent/mcp/mcp-transport.js +4 -1
  141. package/dist/src/agent/mcp/mcp-transport.js.map +1 -1
  142. package/dist/src/agent/memory/context/planner.d.ts +1 -0
  143. package/dist/src/agent/memory/context/planner.js +60 -14
  144. package/dist/src/agent/memory/context/planner.js.map +1 -1
  145. package/dist/src/agent/memory/context/types.d.ts +3 -1
  146. package/dist/src/agent/memory/lifecycle.d.ts +11 -0
  147. package/dist/src/agent/memory/lifecycle.js +50 -0
  148. package/dist/src/agent/memory/lifecycle.js.map +1 -0
  149. package/dist/src/agent/memory/source-origin.d.ts +3 -0
  150. package/dist/src/agent/memory/source-origin.js +19 -0
  151. package/dist/src/agent/memory/source-origin.js.map +1 -0
  152. package/dist/src/agent/memory/understanding/service.js +5 -0
  153. package/dist/src/agent/memory/understanding/service.js.map +1 -1
  154. package/dist/src/agent/memory/user-context-coordinator.js +7 -2
  155. package/dist/src/agent/memory/user-context-coordinator.js.map +1 -1
  156. package/dist/src/agent/prompt/sections/behavior.d.ts +2 -0
  157. package/dist/src/agent/prompt/sections/behavior.js +30 -1
  158. package/dist/src/agent/prompt/sections/behavior.js.map +1 -1
  159. package/dist/src/agent/prompt/sections/tooling.js +1 -1
  160. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  161. package/dist/src/agent/prompt/service-prompt-builder.js +8 -1
  162. package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
  163. package/dist/src/agent/prompt/system-prompt.d.ts +2 -0
  164. package/dist/src/agent/prompt/system-prompt.js +6 -3
  165. package/dist/src/agent/prompt/system-prompt.js.map +1 -1
  166. package/dist/src/agent/service/process-direct-streaming.js +22 -0
  167. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  168. package/dist/src/agent/service.d.ts +2 -0
  169. package/dist/src/agent/service.js +9 -3
  170. package/dist/src/agent/service.js.map +1 -1
  171. package/dist/src/agent/starter-agents.js +1 -1
  172. package/dist/src/agent/starter-agents.js.map +1 -1
  173. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  174. package/dist/src/agent/tool-manuals/xopc-use.js +1 -1
  175. package/dist/src/agent/tool-manuals/xopc-use.js.map +1 -1
  176. package/dist/src/agent/tools/composio-tool.d.ts +18 -5
  177. package/dist/src/agent/tools/composio-tool.js +252 -35
  178. package/dist/src/agent/tools/composio-tool.js.map +1 -1
  179. package/dist/src/agent/tools/factory.js +7 -3
  180. package/dist/src/agent/tools/factory.js.map +1 -1
  181. package/dist/src/agent/tools/index.d.ts +1 -1
  182. package/dist/src/agent/tools/index.js +2 -2
  183. package/dist/src/agent/tools/workflow-tool.d.ts +0 -1
  184. package/dist/src/agent/tools/workflow-tool.js +3 -16
  185. package/dist/src/agent/tools/workflow-tool.js.map +1 -1
  186. package/dist/src/agent/workflow/builtins/index.d.ts +2 -28
  187. package/dist/src/agent/workflow/builtins/index.js +226 -41
  188. package/dist/src/agent/workflow/builtins/index.js.map +1 -1
  189. package/dist/src/agent/workflow/catalog.d.ts +32 -34
  190. package/dist/src/agent/workflow/catalog.js +158 -154
  191. package/dist/src/agent/workflow/catalog.js.map +1 -1
  192. package/dist/src/agent/workflow/index.d.ts +4 -6
  193. package/dist/src/agent/workflow/index.js +2 -5
  194. package/dist/src/agent/workflow/snapshot.d.ts +2 -2
  195. package/dist/src/agent/workflow/snapshot.js +2 -2
  196. package/dist/src/agent/workflow/snapshot.js.map +1 -1
  197. package/dist/src/agent/workflow/structured-output-tool.d.ts +2 -2
  198. package/dist/src/agent/workflow/structured-output-tool.js +2 -2
  199. package/dist/src/agent/workflow/structured-output-tool.js.map +1 -1
  200. package/dist/src/agent/workflow/subagent-runner.js +1 -1
  201. package/dist/src/agent/workflow/types.d.ts +31 -26
  202. package/dist/src/agent-manifest/index.d.ts +1 -0
  203. package/dist/src/agent-manifest/index.js +3 -1
  204. package/dist/src/agent-manifest/index.js.map +1 -1
  205. package/dist/src/agent-manifest/preset-chain.d.ts +10 -0
  206. package/dist/src/agent-manifest/preset-chain.js +32 -0
  207. package/dist/src/agent-manifest/preset-chain.js.map +1 -0
  208. package/dist/src/agent-manifest/resolver.js +3 -10
  209. package/dist/src/agent-manifest/resolver.js.map +1 -1
  210. package/dist/src/agent-manifest/schema.d.ts +4 -4
  211. package/dist/src/automations/api/routes.js +13 -1
  212. package/dist/src/automations/api/routes.js.map +1 -1
  213. package/dist/src/automations/domain/validation.d.ts +14 -14
  214. package/dist/src/automations/draft/automation-draft-validator.d.ts +3 -3
  215. package/dist/src/browser/providers/browser-ext-install.d.ts +11 -1
  216. package/dist/src/browser/providers/browser-ext-install.js +39 -14
  217. package/dist/src/browser/providers/browser-ext-install.js.map +1 -1
  218. package/dist/src/capabilities/store-connector.d.ts +0 -1
  219. package/dist/src/capabilities/store-connector.js +3 -5
  220. package/dist/src/capabilities/store-connector.js.map +1 -1
  221. package/dist/src/chat-commands/builtins/review.js +72 -73
  222. package/dist/src/chat-commands/builtins/review.js.map +1 -1
  223. package/dist/src/chat-commands/builtins/workflow.js +9 -54
  224. package/dist/src/chat-commands/builtins/workflow.js.map +1 -1
  225. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  226. package/dist/src/cli/commands/extension-create.js +2 -2
  227. package/dist/src/cli/commands/extension-create.js.map +1 -1
  228. package/dist/src/cli/commands/extension-marketplace.js +42 -36
  229. package/dist/src/cli/commands/extension-marketplace.js.map +1 -1
  230. package/dist/src/cli/commands/extension-pack.d.ts +6 -0
  231. package/dist/src/cli/commands/extension-pack.js +3 -2
  232. package/dist/src/cli/commands/extension-pack.js.map +1 -1
  233. package/dist/src/commands/agents.config.d.ts +1 -0
  234. package/dist/src/commands/agents.config.js +1 -0
  235. package/dist/src/commands/agents.config.js.map +1 -1
  236. package/dist/src/config/schema.d.ts +6 -6
  237. package/dist/src/config/schema.js +6 -22
  238. package/dist/src/config/schema.js.map +1 -1
  239. package/dist/src/config/web-patch.d.ts +1 -1
  240. package/dist/src/connectors/approval.d.ts +2 -0
  241. package/dist/src/connectors/approval.js +33 -0
  242. package/dist/src/connectors/approval.js.map +1 -0
  243. package/dist/src/connectors/auth-provider-registry.d.ts +9 -0
  244. package/dist/src/connectors/auth-provider-registry.js +17 -0
  245. package/dist/src/connectors/auth-provider-registry.js.map +1 -0
  246. package/dist/src/connectors/builtin-catalog.js +55 -116
  247. package/dist/src/connectors/builtin-catalog.js.map +1 -1
  248. package/dist/src/connectors/catalog.js +7 -2
  249. package/dist/src/connectors/catalog.js.map +1 -1
  250. package/dist/src/connectors/composio-catalog.d.ts +19 -0
  251. package/dist/src/connectors/composio-catalog.js +237 -0
  252. package/dist/src/connectors/composio-catalog.js.map +1 -0
  253. package/dist/src/connectors/composio-logo.d.ts +1 -0
  254. package/dist/src/connectors/composio-logo.js +51 -0
  255. package/dist/src/connectors/composio-logo.js.map +1 -0
  256. package/dist/src/connectors/composio-sessions.d.ts +116 -0
  257. package/dist/src/connectors/composio-sessions.js +296 -0
  258. package/dist/src/connectors/composio-sessions.js.map +1 -0
  259. package/dist/src/connectors/composio-triggers.d.ts +17 -0
  260. package/dist/src/connectors/composio-triggers.js +48 -5
  261. package/dist/src/connectors/composio-triggers.js.map +1 -1
  262. package/dist/src/connectors/composio.d.ts +31 -2
  263. package/dist/src/connectors/composio.js +374 -151
  264. package/dist/src/connectors/composio.js.map +1 -1
  265. package/dist/src/connectors/connector-memory-sync.d.ts +15 -0
  266. package/dist/src/connectors/connector-memory-sync.js +90 -0
  267. package/dist/src/connectors/connector-memory-sync.js.map +1 -0
  268. package/dist/src/connectors/install.js +35 -92
  269. package/dist/src/connectors/install.js.map +1 -1
  270. package/dist/src/connectors/instances.js +6 -2
  271. package/dist/src/connectors/instances.js.map +1 -1
  272. package/dist/src/connectors/integration-strategy.d.ts +3 -0
  273. package/dist/src/connectors/integration-strategy.js +29 -0
  274. package/dist/src/connectors/integration-strategy.js.map +1 -0
  275. package/dist/src/connectors/policy.d.ts +13 -0
  276. package/dist/src/connectors/policy.js +48 -0
  277. package/dist/src/connectors/policy.js.map +1 -0
  278. package/dist/src/connectors/providers.js +1 -1
  279. package/dist/src/connectors/runtime-adapter-registry.d.ts +25 -0
  280. package/dist/src/connectors/runtime-adapter-registry.js +154 -0
  281. package/dist/src/connectors/runtime-adapter-registry.js.map +1 -0
  282. package/dist/src/connectors/types.d.ts +113 -4
  283. package/dist/src/connectors/workflow-preflight.d.ts +20 -0
  284. package/dist/src/connectors/workflow-preflight.js +70 -0
  285. package/dist/src/connectors/workflow-preflight.js.map +1 -0
  286. package/dist/src/extensions/install-transaction.d.ts +16 -0
  287. package/dist/src/extensions/install-transaction.js +76 -0
  288. package/dist/src/extensions/install-transaction.js.map +1 -0
  289. package/dist/src/extensions/install.d.ts +2 -0
  290. package/dist/src/extensions/install.js +23 -1
  291. package/dist/src/extensions/install.js.map +1 -1
  292. package/dist/src/gateway/agents-admin.d.ts +2 -0
  293. package/dist/src/gateway/agents-admin.js +7 -0
  294. package/dist/src/gateway/agents-admin.js.map +1 -1
  295. package/dist/src/gateway/capability-presets-admin.d.ts +11 -0
  296. package/dist/src/gateway/capability-presets-admin.js +11 -4
  297. package/dist/src/gateway/capability-presets-admin.js.map +1 -1
  298. package/dist/src/gateway/chat-stream/mapper.js +17 -0
  299. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  300. package/dist/src/gateway/chat-stream/protocol.d.ts +18 -1
  301. package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -3
  302. package/dist/src/gateway/hono/routes/agents.js +3 -0
  303. package/dist/src/gateway/hono/routes/agents.js.map +1 -1
  304. package/dist/src/gateway/hono/routes/capability-presets.js +19 -1
  305. package/dist/src/gateway/hono/routes/capability-presets.js.map +1 -1
  306. package/dist/src/gateway/hono/routes/connectors.js +188 -25
  307. package/dist/src/gateway/hono/routes/connectors.js.map +1 -1
  308. package/dist/src/gateway/hono/routes/goals.js +22 -3
  309. package/dist/src/gateway/hono/routes/goals.js.map +1 -1
  310. package/dist/src/gateway/hono/routes/home.d.ts +60 -1
  311. package/dist/src/gateway/hono/routes/home.js +244 -18
  312. package/dist/src/gateway/hono/routes/home.js.map +1 -1
  313. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  314. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  315. package/dist/src/gateway/hono/routes/memory.js +14 -1
  316. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  317. package/dist/src/gateway/hono/routes/projects.js +103 -2
  318. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  319. package/dist/src/gateway/hono/routes/public-gateway.js +93 -0
  320. package/dist/src/gateway/hono/routes/public-gateway.js.map +1 -1
  321. package/dist/src/gateway/hono/routes/workflows.js +137 -22
  322. package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
  323. package/dist/src/gateway/hono/routes/you.d.ts +23 -0
  324. package/dist/src/gateway/hono/routes/you.js +538 -0
  325. package/dist/src/gateway/hono/routes/you.js.map +1 -0
  326. package/dist/src/gateway/hono/sse.d.ts +2 -1
  327. package/dist/src/gateway/hono/sse.js +2 -1
  328. package/dist/src/gateway/hono/sse.js.map +1 -1
  329. package/dist/src/gateway/service/marketplace-service.d.ts +13 -1
  330. package/dist/src/gateway/service/marketplace-service.js +96 -40
  331. package/dist/src/gateway/service/marketplace-service.js.map +1 -1
  332. package/dist/src/gateway/service.d.ts +2 -0
  333. package/dist/src/gateway/service.js +7 -1
  334. package/dist/src/gateway/service.js.map +1 -1
  335. package/dist/src/goals/goal-service.d.ts +7 -5
  336. package/dist/src/goals/goal-service.js +25 -13
  337. package/dist/src/goals/goal-service.js.map +1 -1
  338. package/dist/src/goals/goal-store.js +46 -7
  339. package/dist/src/goals/goal-store.js.map +1 -1
  340. package/dist/src/goals/types.d.ts +24 -0
  341. package/dist/src/storage/sqlite/connector-repository.d.ts +49 -0
  342. package/dist/src/storage/sqlite/connector-repository.js +385 -0
  343. package/dist/src/storage/sqlite/connector-repository.js.map +1 -0
  344. package/dist/src/storage/sqlite/index.d.ts +3 -0
  345. package/dist/src/storage/sqlite/index.js +4 -1
  346. package/dist/src/storage/sqlite/migrations/030_connectors.sql +94 -0
  347. package/dist/src/storage/sqlite/migrations/031_connector_approvals.sql +24 -0
  348. package/dist/src/storage/sqlite/migrations/032_connector_webhook_deliveries.sql +15 -0
  349. package/dist/src/storage/sqlite/migrations/033_user_trust_policies.sql +6 -0
  350. package/dist/src/storage/sqlite/migrations/034_allow_global_auto_trust.sql +14 -0
  351. package/dist/src/storage/sqlite/migrations/035_user_profile_prompt_state.sql +7 -0
  352. package/dist/src/storage/sqlite/migrations/036_goal_outcome_metric.sql +12 -0
  353. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  354. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  355. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  356. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  357. package/dist/src/storage/sqlite/schema.js +1 -1
  358. package/dist/src/storage/sqlite/user-profile-setup-repository.d.ts +3 -0
  359. package/dist/src/storage/sqlite/user-profile-setup-repository.js +34 -0
  360. package/dist/src/storage/sqlite/user-profile-setup-repository.js.map +1 -0
  361. package/dist/src/storage/sqlite/user-trust-repository.d.ts +3 -0
  362. package/dist/src/storage/sqlite/user-trust-repository.js +34 -0
  363. package/dist/src/storage/sqlite/user-trust-repository.js.map +1 -0
  364. package/dist/src/tui/components/assistant-message.js +15 -0
  365. package/dist/src/tui/components/assistant-message.js.map +1 -1
  366. package/dist/src/tui/tui-agent-events.js +85 -1
  367. package/dist/src/tui/tui-agent-events.js.map +1 -1
  368. package/dist/src/tui/tui-command-formatters.js +7 -7
  369. package/dist/src/tui/tui-command-formatters.js.map +1 -1
  370. package/dist/src/tui/tui-commands.js +1 -1
  371. package/dist/src/tui/tui-startup-resources.js +1 -1
  372. package/dist/src/user-context/import.d.ts +12 -0
  373. package/dist/src/user-context/import.js +48 -0
  374. package/dist/src/user-context/import.js.map +1 -0
  375. package/dist/src/user-context/profile.d.ts +37 -0
  376. package/dist/src/user-context/profile.js +165 -0
  377. package/dist/src/user-context/profile.js.map +1 -0
  378. package/dist/src/user-context/projection.d.ts +54 -0
  379. package/dist/src/user-context/projection.js +121 -0
  380. package/dist/src/user-context/projection.js.map +1 -0
  381. package/dist/src/user-context/source-recommendations.d.ts +13 -0
  382. package/dist/src/user-context/source-recommendations.js +86 -0
  383. package/dist/src/user-context/source-recommendations.js.map +1 -0
  384. package/dist/src/user-context/trust-policy.d.ts +11 -0
  385. package/dist/src/user-context/trust-policy.js +31 -0
  386. package/dist/src/user-context/trust-policy.js.map +1 -0
  387. package/dist/src/workflows/authoring/index.d.ts +1 -0
  388. package/dist/src/workflows/authoring/index.js +2 -0
  389. package/dist/src/workflows/authoring/workflow-draft-store.d.ts +33 -0
  390. package/dist/src/workflows/authoring/workflow-draft-store.js +74 -0
  391. package/dist/src/workflows/authoring/workflow-draft-store.js.map +1 -0
  392. package/dist/src/workflows/domain/definition-utils.d.ts +6 -4
  393. package/dist/src/workflows/domain/definition-utils.js +28 -26
  394. package/dist/src/workflows/domain/definition-utils.js.map +1 -1
  395. package/dist/src/workflows/domain/definition.d.ts +79 -6
  396. package/dist/src/workflows/domain/event.d.ts +18 -2
  397. package/dist/src/workflows/domain/index.js +3 -3
  398. package/dist/src/workflows/domain/run.d.ts +16 -2
  399. package/dist/src/workflows/domain/run.js.map +1 -1
  400. package/dist/src/workflows/domain/validation.d.ts +9 -5
  401. package/dist/src/workflows/domain/validation.js +183 -40
  402. package/dist/src/workflows/domain/validation.js.map +1 -1
  403. package/dist/src/workflows/draft/workflow-draft-prompt.d.ts +2 -3
  404. package/dist/src/workflows/draft/workflow-draft-prompt.js +31 -73
  405. package/dist/src/workflows/draft/workflow-draft-prompt.js.map +1 -1
  406. package/dist/src/workflows/draft/workflow-draft-service.js +4 -8
  407. package/dist/src/workflows/draft/workflow-draft-service.js.map +1 -1
  408. package/dist/src/workflows/draft/workflow-draft-validator.js +29 -37
  409. package/dist/src/workflows/draft/workflow-draft-validator.js.map +1 -1
  410. package/dist/src/workflows/draft/workflow-draft.types.d.ts +4 -4
  411. package/dist/src/workflows/engine/projector.js +43 -1
  412. package/dist/src/workflows/engine/projector.js.map +1 -1
  413. package/dist/src/workflows/engine/workflow-engine.d.ts +2 -3
  414. package/dist/src/workflows/engine/workflow-engine.js +24 -4
  415. package/dist/src/workflows/engine/workflow-engine.js.map +1 -1
  416. package/dist/src/workflows/index.js +4 -7
  417. package/dist/src/workflows/registry/catalog-workflow-definition-registry.js +1 -9
  418. package/dist/src/workflows/registry/catalog-workflow-definition-registry.js.map +1 -1
  419. package/dist/src/workflows/runtime/graph-workflow-runtime.d.ts +10 -0
  420. package/dist/src/workflows/runtime/graph-workflow-runtime.js +295 -0
  421. package/dist/src/workflows/runtime/graph-workflow-runtime.js.map +1 -0
  422. package/dist/src/workflows/runtime/index.d.ts +1 -2
  423. package/dist/src/workflows/runtime/index.js +2 -5
  424. package/dist/src/workflows/runtime/workflow-runtime-port.d.ts +5 -8
  425. package/dist/src/workflows/service/workflow-run-service.js +15 -1
  426. package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
  427. package/dist/src/workflows/service/workflow-run-service.types.d.ts +2 -1
  428. package/package.json +4 -3
  429. package/dist/gateway/static/root/assets/agents-CyvCIHnB.js +0 -2
  430. package/dist/gateway/static/root/assets/apps-page-DK_Vx6nl.js +0 -1
  431. package/dist/gateway/static/root/assets/automation-suggestion-card-B1LV3YYv.js +0 -1
  432. package/dist/gateway/static/root/assets/automations-page-fzrovqhv.js +0 -4
  433. package/dist/gateway/static/root/assets/block-editor-Dhj5f4Bx.js +0 -184
  434. package/dist/gateway/static/root/assets/browser-settings-page-BDn-n-UB.js +0 -8
  435. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Co5ipo_Q.js +0 -1
  436. package/dist/gateway/static/root/assets/channels-settings-BWlpaxg9.js +0 -1
  437. package/dist/gateway/static/root/assets/channels-status-swr-D_jkIZLV.js +0 -1
  438. package/dist/gateway/static/root/assets/connectors-page-BcekbW4q.js +0 -2
  439. package/dist/gateway/static/root/assets/desktop-pet-settings-BJCUuL8Y.js +0 -1
  440. package/dist/gateway/static/root/assets/dreaming-settings-BN1Z2mIo.js +0 -3
  441. package/dist/gateway/static/root/assets/extension-page-B-1KxvVy.js +0 -1
  442. package/dist/gateway/static/root/assets/extension-settings-page-BF9NACI3.js +0 -1
  443. package/dist/gateway/static/root/assets/gateway-settings-DN9sNREz.js +0 -1
  444. package/dist/gateway/static/root/assets/goal-create-dialog-BpoQW8cD.js +0 -1
  445. package/dist/gateway/static/root/assets/goal-detail-page-CBRSPd0b.js +0 -4
  446. package/dist/gateway/static/root/assets/goals-page-BCcBi407.js +0 -2
  447. package/dist/gateway/static/root/assets/goals-settings-pkTXzXkh.js +0 -1
  448. package/dist/gateway/static/root/assets/heartbeat-settings-ezsufgLQ.js +0 -1
  449. package/dist/gateway/static/root/assets/index-B8s8Pq5U.css +0 -1
  450. package/dist/gateway/static/root/assets/index-DcUaXYeb.js +0 -262
  451. package/dist/gateway/static/root/assets/logs-page-DQtTRXtj.js +0 -7
  452. package/dist/gateway/static/root/assets/messages-BXNELNBa.js +0 -3
  453. package/dist/gateway/static/root/assets/models-hub-panel-BP2M9n6Q.js +0 -2
  454. package/dist/gateway/static/root/assets/notes-page-CspveYaO.js +0 -1
  455. package/dist/gateway/static/root/assets/notes-workbench-BHwzJ0OC.js +0 -2
  456. package/dist/gateway/static/root/assets/project-detail-page-Dy3rsobs.js +0 -1
  457. package/dist/gateway/static/root/assets/projects-page-CWKpPE0L.js +0 -1
  458. package/dist/gateway/static/root/assets/remote-access-hub-CqNRyXEo.js +0 -1
  459. package/dist/gateway/static/root/assets/sessions-page-MEME7ivF.js +0 -1
  460. package/dist/gateway/static/root/assets/settings-advanced-gate-JVd0qaSF.js +0 -1
  461. package/dist/gateway/static/root/assets/settings-page-DYEbB1EV.js +0 -1
  462. package/dist/gateway/static/root/assets/setup-status-panel-dWN8BJ3z.js +0 -1
  463. package/dist/gateway/static/root/assets/share-preview-page-D8foINzP.js +0 -2
  464. package/dist/gateway/static/root/assets/shares-settings-Tgbv1s7G.js +0 -1
  465. package/dist/gateway/static/root/assets/skill-reload-api-D_YK0b_Z.js +0 -1
  466. package/dist/gateway/static/root/assets/skills-page-DGytfoZK.js +0 -2
  467. package/dist/gateway/static/root/assets/toast-z0toXu32.js +0 -1
  468. package/dist/gateway/static/root/assets/user-profile-settings-panel-8YtygcJp.js +0 -1
  469. package/dist/gateway/static/root/assets/voice-api-key-field-BVH71EFf.js +0 -1
  470. package/dist/gateway/static/root/assets/work-item-detail-page-JeTE7XNM.js +0 -1
  471. package/dist/gateway/static/root/assets/workflow-start-dialog-_u8Uc1ze.js +0 -1
  472. package/dist/gateway/static/root/assets/workflows-page-ixgk_y1l.js +0 -18
  473. package/dist/src/agent/workflow/builtins/audit-repo.d.ts +0 -13
  474. package/dist/src/agent/workflow/builtins/audit-repo.js +0 -183
  475. package/dist/src/agent/workflow/builtins/audit-repo.js.map +0 -1
  476. package/dist/src/agent/workflow/builtins/client-proposal.d.ts +0 -12
  477. package/dist/src/agent/workflow/builtins/client-proposal.js +0 -164
  478. package/dist/src/agent/workflow/builtins/client-proposal.js.map +0 -1
  479. package/dist/src/agent/workflow/builtins/competitor-scan.d.ts +0 -12
  480. package/dist/src/agent/workflow/builtins/competitor-scan.js +0 -164
  481. package/dist/src/agent/workflow/builtins/competitor-scan.js.map +0 -1
  482. package/dist/src/agent/workflow/builtins/content-draft.d.ts +0 -13
  483. package/dist/src/agent/workflow/builtins/content-draft.js +0 -159
  484. package/dist/src/agent/workflow/builtins/content-draft.js.map +0 -1
  485. package/dist/src/agent/workflow/builtins/content-repurpose.d.ts +0 -11
  486. package/dist/src/agent/workflow/builtins/content-repurpose.js +0 -146
  487. package/dist/src/agent/workflow/builtins/content-repurpose.js.map +0 -1
  488. package/dist/src/agent/workflow/builtins/debug-incident.d.ts +0 -13
  489. package/dist/src/agent/workflow/builtins/debug-incident.js +0 -177
  490. package/dist/src/agent/workflow/builtins/debug-incident.js.map +0 -1
  491. package/dist/src/agent/workflow/builtins/decision-compare.d.ts +0 -13
  492. package/dist/src/agent/workflow/builtins/decision-compare.js +0 -187
  493. package/dist/src/agent/workflow/builtins/decision-compare.js.map +0 -1
  494. package/dist/src/agent/workflow/builtins/implementation-plan.d.ts +0 -12
  495. package/dist/src/agent/workflow/builtins/implementation-plan.js +0 -185
  496. package/dist/src/agent/workflow/builtins/implementation-plan.js.map +0 -1
  497. package/dist/src/agent/workflow/builtins/inbox-triage.d.ts +0 -11
  498. package/dist/src/agent/workflow/builtins/inbox-triage.js +0 -158
  499. package/dist/src/agent/workflow/builtins/inbox-triage.js.map +0 -1
  500. package/dist/src/agent/workflow/builtins/meeting-prep.d.ts +0 -12
  501. package/dist/src/agent/workflow/builtins/meeting-prep.js +0 -152
  502. package/dist/src/agent/workflow/builtins/meeting-prep.js.map +0 -1
  503. package/dist/src/agent/workflow/builtins/multi-perspective-review.d.ts +0 -14
  504. package/dist/src/agent/workflow/builtins/multi-perspective-review.js +0 -171
  505. package/dist/src/agent/workflow/builtins/multi-perspective-review.js.map +0 -1
  506. package/dist/src/agent/workflow/builtins/offer-design.d.ts +0 -12
  507. package/dist/src/agent/workflow/builtins/offer-design.js +0 -170
  508. package/dist/src/agent/workflow/builtins/offer-design.js.map +0 -1
  509. package/dist/src/agent/workflow/builtins/pr-review.d.ts +0 -12
  510. package/dist/src/agent/workflow/builtins/pr-review.js +0 -178
  511. package/dist/src/agent/workflow/builtins/pr-review.js.map +0 -1
  512. package/dist/src/agent/workflow/builtins/release-check.d.ts +0 -11
  513. package/dist/src/agent/workflow/builtins/release-check.js +0 -174
  514. package/dist/src/agent/workflow/builtins/release-check.js.map +0 -1
  515. package/dist/src/agent/workflow/builtins/research.d.ts +0 -13
  516. package/dist/src/agent/workflow/builtins/research.js +0 -188
  517. package/dist/src/agent/workflow/builtins/research.js.map +0 -1
  518. package/dist/src/agent/workflow/builtins/weekly-review.d.ts +0 -12
  519. package/dist/src/agent/workflow/builtins/weekly-review.js +0 -139
  520. package/dist/src/agent/workflow/builtins/weekly-review.js.map +0 -1
  521. package/dist/src/agent/workflow/last-run-memory.d.ts +0 -42
  522. package/dist/src/agent/workflow/last-run-memory.js +0 -60
  523. package/dist/src/agent/workflow/last-run-memory.js.map +0 -1
  524. package/dist/src/agent/workflow/lint.d.ts +0 -38
  525. package/dist/src/agent/workflow/lint.js +0 -74
  526. package/dist/src/agent/workflow/lint.js.map +0 -1
  527. package/dist/src/agent/workflow/meta-locale.d.ts +0 -12
  528. package/dist/src/agent/workflow/meta-locale.js +0 -62
  529. package/dist/src/agent/workflow/meta-locale.js.map +0 -1
  530. package/dist/src/agent/workflow/parser.d.ts +0 -20
  531. package/dist/src/agent/workflow/parser.js +0 -152
  532. package/dist/src/agent/workflow/parser.js.map +0 -1
  533. package/dist/src/agent/workflow/runtime.d.ts +0 -34
  534. package/dist/src/agent/workflow/runtime.js +0 -402
  535. package/dist/src/agent/workflow/runtime.js.map +0 -1
  536. package/dist/src/connectors/oauth.d.ts +0 -22
  537. package/dist/src/connectors/oauth.js +0 -99
  538. package/dist/src/connectors/oauth.js.map +0 -1
  539. package/dist/src/workflows/runtime/script-runtime.d.ts +0 -3
  540. package/dist/src/workflows/runtime/script-runtime.js +0 -3
  541. package/dist/src/workflows/runtime/script-workflow-runtime.d.ts +0 -5
  542. package/dist/src/workflows/runtime/script-workflow-runtime.js +0 -15
  543. package/dist/src/workflows/runtime/script-workflow-runtime.js.map +0 -1
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BXNELNBa.js";import{a as o,n as s,o as c,t as l}from"./fetch-B1WtuprY.js";import{n as u}from"./locale-store-Ba72bFmP.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{$a as p,$t as m,Ca as h,Co as g,Dl as _,Do as v,Ds as y,Dt as b,Eo as x,Es as S,Et as C,Ft as w,Io as T,It as E,Ja as D,Jt as O,Ka as k,Lt as A,Ml as j,Mo as M,Ms as N,Nc as P,Nt as F,Oo as I,Os as L,Pt as R,Qn as z,Qt as B,So as ee,T as V,Tt as te,Ua as ne,Us as re,Wa as ie,Wo as H,Xt as U,Ya as ae,Ys as W,Yt as oe,Zt as se,_n as ce,al as le,an as ue,ar as de,ba as G,bc as fe,cn as pe,co as me,dn as he,ds as ge,en as _e,es as ve,fc as ye,fn as be,gn as xe,go as Se,hn as Ce,ho as we,in as Te,io as K,ko as q,ln as Ee,lo as De,mn as Oe,nl as ke,nn as Ae,on as je,oo as J,pn as Me,ps as Ne,qa as Pe,qs as Fe,rn as Ie,ro as Le,sn as Re,tn as ze,us as Be,va as Ve,vl as He,vn as Ue,vo as We,ya as Ge,yn as Ke}from"./index-DcUaXYeb.js";import{n as qe,t as Je}from"./settings-page-layout-CKefvbYi.js";import{r as Ye}from"./settings-loading-skeleton-BxR-Ulhi.js";import{a as Xe,c as Ze,d as Qe,f as $e,l as et,n as tt,o as nt,r as rt,s as it,t as at,u as ot}from"./voice-api-key-field-BVH71EFf.js";import{t as st}from"./settings-advanced-gate-JVd0qaSF.js";import{t as ct}from"./settings-collapsible-section-WzdikxPt.js";import{n as lt,t as ut}from"./settings-form-section-CvfzhBV-.js";import{t as dt}from"./page-tabs-D_8jGlqx.js";import{n as ft,t as pt}from"./save-bar-controls-DVS3FR5r.js";var Y=n(),X=e(t(),1),Z=r(),mt=()=>c($e),ht=e=>{let t=e?.trim();return c(t?`/api/image/capabilities?agentId=${encodeURIComponent(t)}`:`/api/image/capabilities`)},gt=()=>c(`/api/global-defaults`),_t=()=>`image-models-agents`,vt={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function yt(e){let t=await s(e);if(!t.payload)throw Error(`Invalid image capabilities response`);return t.payload}function bt(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function xt(e){return e.map(e=>e.trim()).filter(Boolean)}function St(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=xt(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=xt(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function Ct(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function wt(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,n),e)}function Tt(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 Et={saving:!1,savedFlash:!1,error:void 0};function Dt(e){let t=(0,Y.c)(40),{current:n,agentId:r,agentOptions:i,t:a,onAgentIdChange:o}=e,s=n?.effectiveImageModel??null,c=n?.imageModelSource??`none`,l=n?.imageModelRoleId??n?.imageModelRoleDescription??``,u;t[0]!==l||t[1]!==c||t[2]!==a.runtimeUnderstandingAutoProvider||t[3]!==a.runtimeUnderstandingAutoRole||t[4]!==a.runtimeUnderstandingExplicit||t[5]!==a.runtimeUnderstandingNone?(u=c===`explicit`?a.runtimeUnderstandingExplicit:c===`auto-role`?wt(a.runtimeUnderstandingAutoRole,{role:l||`unknown`}):c===`auto-provider`?a.runtimeUnderstandingAutoProvider:a.runtimeUnderstandingNone,t[0]=l,t[1]=c,t[2]=a.runtimeUnderstandingAutoProvider,t[3]=a.runtimeUnderstandingAutoRole,t[4]=a.runtimeUnderstandingExplicit,t[5]=a.runtimeUnderstandingNone,t[6]=u):u=t[6];let d=u,f;t[7]!==n||t[8]!==a.runtimeUnderstandingFallbacks||t[9]!==a.runtimeUnderstandingNoFallbacks?(f=n?.effectiveImageModelFallbacks?.length?wt(a.runtimeUnderstandingFallbacks,{models:n.effectiveImageModelFallbacks.join(`, `)}):a.runtimeUnderstandingNoFallbacks,t[7]=n,t[8]=a.runtimeUnderstandingFallbacks,t[9]=a.runtimeUnderstandingNoFallbacks,t[10]=f):f=t[10];let p=f,m;t[11]===a.runtimeUnderstandingTitle?m=t[12]:(m=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.runtimeUnderstandingTitle}),t[11]=a.runtimeUnderstandingTitle,t[12]=m);let h;t[13]===d?h=t[14]:(h=(0,Z.jsx)(`p`,{className:`mt-1 max-w-[72ch] text-xs leading-relaxed text-fg-muted`,children:d}),t[13]=d,t[14]=h);let g;t[15]!==m||t[16]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[15]=m,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==r||t[19]!==i||t[20]!==o||t[21]!==a.runtimeAgentLabel?(_=i.length>0?(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs font-medium text-fg-muted sm:w-56`,children:[a.runtimeAgentLabel,(0,Z.jsx)(Le,{value:r,options:i,placeholder:a.runtimeAgentLabel,allowEmpty:!1,triggerClassName:`bg-surface-panel`,onChange:o})]}):null,t[18]=r,t[19]=i,t[20]=o,t[21]=a.runtimeAgentLabel,t[22]=_):_=t[22];let v;t[23]!==g||t[24]!==_?(v=(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[g,_]}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y=s??a.noModelSelected,b;t[26]===y?b=t[27]:(b=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:y}),t[26]=y,t[27]=b);let x;t[28]===p?x=t[29]:(x=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:p}),t[28]=p,t[29]=x);let S;t[30]!==x||t[31]!==b?(S=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2 shadow-surface`,children:[b,x]}),t[30]=x,t[31]=b,t[32]=S):S=t[32];let C;t[33]!==i.length||t[34]!==a.runtimeAgentHint?(C=i.length>0?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:a.runtimeAgentHint}):null,t[33]=i.length,t[34]=a.runtimeAgentHint,t[35]=C):C=t[35];let w;return t[36]!==S||t[37]!==C||t[38]!==v?(w=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[v,S,C]}),t[36]=S,t[37]=C,t[38]=v,t[39]=w):w=t[39],w}function Ot(e){let t=(0,Y.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let g=h,_;t[7]!==c||t[8]!==g||t[9]!==f?(_=()=>{g&&f([...c,g])},t[7]=c,t[8]=g,t[9]=f,t[10]=_):_=t[10];let v=_,y;t[11]!==c||t[12]!==f?(y=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=y):y=t[13];let b=y,x;t[14]!==c||t[15]!==f?(x=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=x):x=t[16];let C=x,w;t[17]===n?w=t[18]:(w=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=w);let T;t[19]===r?T=t[20]:(T=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,Z.jsxs)(`div`,{className:`mb-3`,children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]===c?D=t[25]:(D=new Set(c),t[24]=c,t[25]=D);let O;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==D||t[30]!==s?(O=(0,Z.jsx)(Le,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:D,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=D,t[30]=s,t[31]=O):O=t[31];let k;t[32]!==i||t[33]!==O?(k=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,O]}),t[32]=i,t[33]=O,t[34]=k):k=t[34];let A;t[35]===a?A=t[36]:(A=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=A);let j;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==C||t[43]!==m||t[44]!==b?(j=c.length===0?(0,Z.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg bg-surface-subtle px-3 text-sm font-normal text-fg-subtle shadow-surface`,children:o}):c.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,Z.jsx)(Le,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>b(t,e)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=C,t[43]=m,t[44]=b,t[45]=j):j=t[45];let M=!g,N;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":`true`}),t[46]=N):N=t[46];let P;t[47]!==v||t[48]!==a||t[49]!==M?(P=(0,Z.jsxs)(`button`,{type:`button`,onClick:v,disabled:M,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[N,a]}),t[47]=v,t[48]=a,t[49]=M,t[50]=P):P=t[50];let F;t[51]!==j||t[52]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[j,P]}),t[51]=j,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==A||t[55]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,F]}),t[54]=A,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==k||t[58]!==I?(L=(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[k,I]}),t[57]=k,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==E?(R=(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[E,L]}),t[60]=L,t[61]=E,t[62]=R):R=t[62],R}function kt(){let e=(0,Y.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Array.from({length:2}).map(At),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(G,{className:`h-4 w-36`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[t,(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[n,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,Z.jsx)(G,{className:`h-10 rounded-lg`}),(0,Z.jsx)(G,{className:`h-16 rounded-lg`})]})]})]}),e[2]=r):r=e[2],r}function At(e,t){return(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsx)(G,{className:`h-4 w-40`}),(0,Z.jsx)(G,{className:`mt-2 h-3 w-72 max-w-full`}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,Z.jsx)(G,{className:`h-10 rounded-lg`}),(0,Z.jsx)(G,{className:`h-10 rounded-lg`}),(0,Z.jsx)(G,{className:`h-9 w-36 rounded-lg`})]})]},t)}function jt(){let e=u(e=>e.language),t=a(e),n=t.imageModelsSettings,r=!!o(e=>e.token),[i,s]=(0,X.useReducer)(b,Et),{saving:c,error:l}=i,p=h(),m=(0,X.useMemo)(()=>new Set(p.map(e=>e.id)),[p]),{data:g=[],isLoading:_}=f(r?mt():null,Qe,{revalidateOnFocus:!1}),{data:v,isLoading:y}=f(r?_t():null,de,{revalidateOnFocus:!1}),[x,S]=(0,X.useState)(``);(0,X.useEffect)(()=>{v&&S(e=>e&&v.agents.some(t=>t.id===e)?e:v.defaultId||v.agents[0]?.id||``)},[v]);let{data:C,isLoading:w,mutate:T}=f(r?ht(x):null,yt,{revalidateOnFocus:!1}),{data:D,isLoading:O,mutate:k}=f(r?gt():null,E,{revalidateOnFocus:!1}),j=g.some(e=>e.configured),M=et(g),[N,P]=(0,X.useState)(vt),[F,I]=(0,X.useState)(vt);(0,X.useEffect)(()=>{if(!D?.models)return;let e=bt(D.models);P(e),I(e)},[D?.models]);let L=JSON.stringify(N)!==JSON.stringify(F),R=M.credDirty||L;(0,X.useEffect)(()=>{if(!R)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[R]),ft({id:`image-models`,dirty:R,saving:c,save:(0,X.useCallback)(async()=>{s({type:`patch`,patch:{saving:!0,error:void 0}});try{if(L){if(!D?.models)throw Error(n.loadError);let e=await A(St(D.models,N));await k(e,!1),await T();let t=bt(e.models);P(t),I(t)}M.credDirty&&(await M.saveCredentials(n.credentialsSaveError),await T()),s({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:n.saved})}catch(e){s({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{saving:!1}})}},[M,D?.models,L,N,k,T,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,X.useCallback)(()=>{M.credDirty&&M.onDiscardCredentials(),L&&P(F),s({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[M,F,L])});let B=(0,X.useMemo)(()=>Tt(n),[n]),ee=(0,X.useMemo)(()=>Ct(C?.imageUnderstanding.providers??[]),[C?.imageUnderstanding.providers]),V=(0,X.useMemo)(()=>Ct(C?.imageGeneration.providers??[]),[C?.imageGeneration.providers]),te=(0,X.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]),ne=(0,X.useMemo)(()=>(v?.agents??[]).map(e=>({value:e.id,label:z(e,t.agentsSettings)})),[v?.agents,t.agentsSettings]);return r?_||w||O||y?(0,Z.jsx)(kt,{}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l?(0,Z.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:l}):null,(0,Z.jsx)(Dt,{current:C?.current,agentId:x,agentOptions:ne,t:n,onAgentIdChange:S}),(0,Z.jsx)(Ot,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:N.imageModel,fallbackValues:N.imageModelFallbacks,options:ee,emptyLabel:n.noModelSelected,onValueChange:e=>P(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>P(t=>({...t,imageModelFallbacks:e}))}),(0,Z.jsx)(Ot,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:N.imageGenerationModel,fallbackValues:N.imageGenerationModelFallbacks,options:V,emptyLabel:n.noModelSelected,onValueChange:e=>P(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>P(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,Z.jsx)(`input`,{type:`number`,min:1,value:N.imageGenerationModelTimeoutMs,onChange:e=>P(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:N.imageGenerationModelAutoProviderFallback,onChange:e=>P(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,Z.jsx)(ct,{icon:ge,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:j,children:g.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Z.jsx)(ot,{summaries:g,credDraft:M.credDraft,credBaseline:M.credBaseline,credDirty:M.credDirty,credSaving:M.credSaving,credError:M.credError,credSavedFlash:M.credSavedFlash,credNoopFlash:M.credNoopFlash,updateCredRow:M.updateCredRow,onDiscardCredentials:M.onDiscardCredentials,onSaveCredentials:()=>void M.saveCredentials(n.credentialsSaveError),extensionIds:m,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:te,messages:B})})]}):(0,Z.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Mt=x;function Nt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Pt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Ft(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I,`dark:border-edge`)}function Q(){return i(v,x)}function It(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Lt(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var Rt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],zt=[{id:`whisper-1`,name:`Whisper-1`}],Bt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Vt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Ht=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Ut=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Wt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Gt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Kt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],qt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],Jt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Yt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Xt(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 Zt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Qt(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function $t(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function en(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 tn(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 nn(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 rn(){let e=a(u(e=>e.language)).voiceSettings,t=!!o(e=>e.token),[n,r]=(0,X.useReducer)(nn,{form:null,baseline:null}),i=n.form,s=n.baseline,[l,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),v=(0,X.useRef)(!1),y=(0,X.useRef)({parsed:null,models:void 0}),{data:b,error:x,isLoading:S,mutate:C}=Ge(t),{data:w,error:T,isLoading:E,mutate:D}=f(t?c(`/api/voice/models`):null,tt,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=f(t?c(`/api/voice/providers`):null,rt,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=f(t?c(`/api/voice/stt-providers`):null,Xe,{revalidateOnFocus:!1}),P=(0,X.useMemo)(()=>O?.providers??[],[O]),F=(0,X.useMemo)(()=>j?.providers??[],[j]),I=(0,X.useMemo)(()=>b?.payload?.config===void 0?null:nt(b.payload.config),[b]),L=(0,X.useMemo)(()=>!i||!s?!1:JSON.stringify(i)!==JSON.stringify(s),[i,s]);t?I!==null&&w!==void 0&&!v.current&&(y.current.parsed!==I||y.current.models!==w)&&(y.current={parsed:I,models:w},r({type:`sync`,value:I}),p(w)):(y.current.parsed!==null||y.current.models!==void 0)&&(y.current={parsed:null,models:void 0},r({type:`reset`}),p(null),v.current=!1);let R=!!(t&&(I===null||w===void 0||O===void 0||j===void 0)&&(S||E||A||N)),z=x instanceof Error?x.message:x?String(x):T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):M instanceof Error?M.message:M?String(M):null,B=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),ee=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),V=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),te=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ne=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),re=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ie=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),H=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),U=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ae=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(ft({id:`voice`,dirty:L,saving:m,save:(0,X.useCallback)(async()=>{if(!(!i||m)){h(!0),_(null);try{await it(i),r({type:`saved`,value:i}),v.current=!1,d({type:`success`,title:e.saved})}catch(t){_(t instanceof Error?t.message:e.saveError)}finally{h(!1)}}},[i,m,e.saveError]),discard:(0,X.useCallback)(()=>{s&&(v.current=!1,r({type:`discard`}),_(null))},[s])}),!t)return(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.needToken})});if(R)return(0,Z.jsx)(Ye,{rows:4});if(!i||l===null)return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??z??e.loadError}),(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:e.retry})]});let W=i.stt,oe=i.tts,se=$t(e);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(an,{v:e,stt:W,tts:oe}),(0,Z.jsx)(sn,{v:e,apiKeyLabels:se,stt:W,models:l,sttProviders:F,updateStt:B,updateSttAlibaba:ee,updateSttOpenai:V,updateSttFallback:te}),(0,Z.jsx)(fn,{v:e,apiKeyLabels:se,tts:oe,models:l,ttsProviders:P,updateTts:ne,updateTtsAlibaba:re,updateTtsOpenai:ie,updateTtsEdge:H,updateTtsMinimax:U,updateTtsLocalCli:ae})]}),(0,Z.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,Z.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Z.jsx)(`strong`,{className:`text-accent`,children:e.notes.title}),` `,e.notes.duration]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.notes.envVars})]})]})}function an(e){let t=(0,Y.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Yt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Z.jsx)(on,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Zt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Z.jsx)(on,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Xt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Z.jsx)(on,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function on(e){let t=(0,Y.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s=a?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=i(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Z.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function sn(e){let t=(0,Y.c)(46),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:Rt,p=o?.stt?.openai?.length?o.stt.openai:zt,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==a||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter(dn),C;t[17]!==a.provider||t[18]!==a.providers||t[19]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[17]=a.provider,t[18]=a.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(re,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==a.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,Z.jsx)(pn,{checked:a.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=a.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=a.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:n.stt.provider}),(0,Z.jsx)(K,{className:Q(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Z.jsxs)(J,{value:e.id,children:[Yt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,Z.jsx)(K,{className:Q(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(un)}):a.provider===`openai`?(0,Z.jsx)(K,{className:Q(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(ln)}):a.provider===`groq`?(0,Z.jsx)(K,{className:Q(),value:m||Bt[0].id,onChange:e=>w({model:e.target.value}),children:Bt.map(cn)}):(0,Z.jsx)(`input`,{className:Ft(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:n.stt.apiKey}),(0,Z.jsx)(at,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Nt(a.provider)?` ${Nt(a.provider)}`:``]})]})]}),S.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Z.jsx)(mn,{field:e,value:en(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Mt},e.key))}):null,(0,Z.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,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,Z.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,Z.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function cn(e){return(0,Z.jsx)(J,{value:e.id,children:e.name},e.id)}function ln(e){return(0,Z.jsx)(J,{value:e.id,children:e.name},e.id)}function un(e){return(0,Z.jsx)(J,{value:e.id,children:e.name},e.id)}function dn(e){return e.key!==`apiKey`&&e.key!==`model`}function fn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:a,updateTts:o,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Vt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Ht,m=r?.tts?.alibaba?.length?r.tts.alibaba:Ut,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Wt,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Gt,_=r?.tts?.minimax?.length?r.tts.minimax:Kt,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:qt,[y,b]=(0,X.useState)(e.tts.test.sampleText),[x,S]=(0,X.useState)({status:`idle`}),C=(0,X.useRef)(null),w=(0,X.useRef)(null),E=(0,X.useCallback)(()=>{C.current?.pause(),C.current=null,w.current&&=(URL.revokeObjectURL(w.current),null)},[]),D=(0,X.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.id)||(e.add(n.id),t.push(n));return t},[a]),O=D.find(e=>e.id===n.provider),k=n.providers?.[n.provider],A={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...k??{}},j=(O?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),M=!!O?.diagnostics.requiresApiKey,N=!!O?.configured||!M,P=n.enabled?N?`ready`:`action`:`muted`,F=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,I=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,X.useEffect)(()=>()=>E(),[E]);let R=(0,X.useCallback)(e=>{o({provider:e}),S({status:`idle`})},[o]),z=(0,X.useCallback)(async()=>{let t=y.trim();if(!t){S({status:`error`,message:e.tts.test.emptyText});return}E(),S({status:`loading`});try{let r=await Ze({text:t,provider:n.provider,providerConfig:A,...F?{model:F}:{},...I?{voice:I}:{}}),i=Lt(r.audio,r.mimeType);w.current=i;let a=new Audio(i);C.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,It(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>S({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>S({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),S({status:`playing`,summary:o})}catch(e){E(),S({status:`error`,message:e instanceof Error?e.message:String(e)})}},[F,I,A,E,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),B=(0,X.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),ee=(0,X.useCallback)((e,t)=>{let r={[e.key]:t};B(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,B,l,u,c]);return(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(T,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(pn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>o({enabled:e})}),(0,Z.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,P===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:P===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?N?`${e.tts.statusReady} ${Xt(n.provider,e)}${I?` · ${I}`:``}`:`${e.tts.statusNeedsSetup} ${Xt(n.provider,e)} · ${O?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:e.tts.trigger}),(0,Z.jsxs)(K,{className:Q(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,Z.jsx)(J,{value:`off`,children:e.tts.triggerOff}),(0,Z.jsx)(J,{value:`inbound`,children:e.tts.triggerInbound}),(0,Z.jsx)(J,{value:`tagged`,children:e.tts.triggerTagged}),(0,Z.jsx)(J,{value:`always`,children:e.tts.triggerAlways})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:e.tts.provider}),(0,Z.jsx)(K,{className:Q(),value:n.provider,onChange:e=>R(e.target.value),children:D.map(t=>(0,Z.jsx)(J,{value:t.id,children:Xt(t.id,e)},t.id))}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[O?.configured?e.tts.configured:O?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${O.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,O?.description??Qt(n.provider,e)]})]})]}),(0,Z.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!N||n.provider===`tts-local-cli`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:e.stt.apiKey}),(0,Z.jsx)(at,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Pt(n.provider)?` ${Pt(n.provider)}`:``]})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:e.stt.model}),(0,Z.jsx)(K,{className:Q(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Z.jsx)(J,{value:e.id,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(K,{className:Q(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,Z.jsx)(J,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Mt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(K,{className:Q(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Z.jsx)(J,{value:e.id,children:e.name},e.id))}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.preset}),(0,Z.jsxs)(K,{className:Q(),value:``,onChange:e=>{let t=Jt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Z.jsx)(J,{value:``,children:e.tts.localCli.presetPlaceholder}),Jt.map(e=>(0,Z.jsx)(J,{value:e.id,children:e.id},e.id))]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.command}),(0,Z.jsx)(`input`,{className:i(Ft(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.cwd}),(0,Z.jsx)(`input`,{className:i(Ft(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Z.jsxs)(K,{className:Q(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Z.jsx)(J,{value:`wav`,children:`wav`}),(0,Z.jsx)(J,{value:`mp3`,children:`mp3`}),(0,Z.jsx)(J,{value:`opus`,children:`opus`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Z.jsx)(`input`,{className:Ft(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,j.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:j.map(e=>(0,Z.jsx)(mn,{field:e,value:en(A,e),onChange:t=>ee(e,t),className:e.type===`textarea`?`sm:col-span-2`:Mt},e.key))}):null]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(q,{type:`button`,variant:`primary`,onClick:()=>void z(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,Z.jsx)(W,{className:`size-4 animate-spin`}):(0,Z.jsx)(L,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,onClick:()=>{E(),S(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,Z.jsx)(ve,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Z.jsx)(`textarea`,{className:i(Ft(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,Z.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function pn(e){let t=(0,Y.c)(33),{checked:n,title:r,description:a,onLabel:o,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,I,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?o:s,h;t[7]!==p||t[8]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===a?_=t[14]:(_=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:a}),t[13]=a,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,Z.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,Z.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,Z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,w]}),t[27]=n,t[28]=l,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function mn(e){let t=(0,Y.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,Z.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,Z.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,Z.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(tn(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,Z.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,Z.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,Z.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,Z.jsx)(K,{id:s,className:Q(),value:l,required:n.required,onChange:e=>a(tn(n,e.target.value)),children:(n.options??[]).map(hn)}):n.type===`textarea`?(0,Z.jsx)(`textarea`,{id:s,className:i(Ft(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(tn(n,e.target.value))}):n.type===`password`?(0,Z.jsx)(We,{id:s,className:o,value:l,onChange:e=>a(tn(n,e)),placeholder:n.placeholder,labels:we}):(0,Z.jsx)(`input`,{id:s,className:Ft(),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(tn(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,Z.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,Z.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 hn(e){return(0,Z.jsx)(J,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function gn(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 _n(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 s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Ve()}async function vn(e){let t=await s(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 yn(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.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,Z.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,Z.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 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`,I,`dark:border-edge`)}function xn(){return i(v,x)}var Sn=[`brave`,`tavily`,`bing`,`searxng`];function Cn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var wn=te();function Tn(){let e=a(u(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!o(e=>e.token),[s,c]=(0,X.useReducer)(wn,{form:null,baseline:null}),l=s.form,f=s.baseline,[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=(0,X.useRef)(!1),v=(0,X.useRef)(null),{data:y,error:b,isLoading:x,mutate:w}=Ge(r);C({enabled:r,parsed:(0,X.useMemo)(()=>y?.payload?.config===void 0?null:gn(y.payload.config),[y]),dirty:_.current,trackedParsedRef:v,dispatch:c,onResetDirty:()=>{_.current=!1}});let T=!!(r&&x&&y===void 0&&!b),E=b instanceof Error?b.message:b?String(b):null,D=(0,X.useMemo)(()=>!l||!f?!1:JSON.stringify(l)!==JSON.stringify(f),[l,f]),O=(0,X.useCallback)(e=>{_.current=!0,c({type:`patch`,patch:e})},[]);return ft({id:`search`,dirty:D,saving:p,save:(0,X.useCallback)(async()=>{if(!(!l||p)){m(!0),g(null);try{await _n(l),_.current=!1,c({type:`saved`,value:l}),d({type:`success`,title:t.saved})}catch(e){g(e instanceof Error?e.message:t.saveError)}finally{m(!1)}}},[l,p,t.saveError]),discard:(0,X.useCallback)(()=>{f&&(_.current=!1,c({type:`discard`}),g(null))},[f])}),r?T?(0,Z.jsx)(Ye,{rows:3}):l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Z.jsxs)(ut,{children:[(0,Z.jsx)(lt,{icon:Ne,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Z.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Z.jsx)(yn,{label:t.regionLabel,description:t.regionDesc,children:(0,Z.jsxs)(K,{className:xn(),value:l.regionMode,onChange:e=>O({regionMode:e.target.value}),children:[(0,Z.jsx)(J,{value:`auto`,children:t.regionAuto}),(0,Z.jsx)(J,{value:`cn`,children:t.regionCn}),(0,Z.jsx)(J,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Z.jsx)(st,{children:(0,Z.jsxs)(ut,{children:[(0,Z.jsx)(lt,{icon:He,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:l.blocklistEnabled,onChange:e=>O({blocklistEnabled:e.target.checked})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,Z.jsx)(yn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Z.jsx)(`textarea`,{className:i(bn(),`min-h-[6rem] font-mono text-xs`),value:l.blocklistDomains.join(`
2
- `),placeholder:t.blocklistDomainsPlaceholder,disabled:!l.blocklistEnabled,onChange:e=>{O({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Z.jsxs)(ut,{children:[(0,Z.jsx)(lt,{icon:Ne,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Z.jsx)(yn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:50,className:bn(),value:l.maxResults,onChange:e=>O({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),l.providers.map((n,r)=>(0,Z.jsx)(En,{row:n,providerIndex:r,labels:t,secretLabels:Se(e.providersSettings),onChange:e=>{let t=[...l.providers];t[r]=e,O({providers:t})},onRemove:()=>{O({providers:l.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>O({providers:[...l.providers,Cn()]}),children:[(0,Z.jsx)(S,{className:`size-4`}),t.addProvider]})]})]})]}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??E??t.loadError}),(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void w(),children:n.refresh})]}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function En(e){let t=(0,Y.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>vn(r).then(Dn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(xn(),`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,Z.jsx)(J,{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,Z.jsx)(K,{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,Z.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,Z.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,Z.jsx)(H,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,Z.jsx)(q,{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,Z.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,Z.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,Z.jsx)(yn,{label:a.urlLabel,description:a.urlDesc,children:(0,Z.jsx)(`input`,{type:`url`,className:bn(),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,Z.jsx)(We,{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,Z.jsx)(yn,{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,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=D):D=t[53],D}function Dn(e){return e.apiKey??null}function On(){let e=(0,Y.c)(31),t=o(Nn),n=!!t,{data:r,isLoading:i}=Ge(n),a;e[0]===n?a=e[1]:(a=n?c(`/api/providers/meta`):null,e[0]=n,e[1]=a);let s;e[2]===t?s=e[3]:(s=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=s);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,s,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?Ue:null,Mn,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?xe:null,jn,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=be(u,Oe(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=B(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(An).map(kn)),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 kn(e){return e.id}function An(e){return e.configured}function jn(){return se()}function Mn(){return Ke()}function Nn(e){return e.token}function Pn(e){let t=(0,Y.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=On();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(G,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(In)})]}),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(Fn),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,Z.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,Z.jsx)(S,{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,Z.jsxs)(q,{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,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,Z.jsx)(S,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,Z.jsx)(Ln,{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 Fn(e){return e.configured}function In(e){return(0,Z.jsx)(G,{className:`h-32 rounded-2xl`},e)}function Ln(e){let t=(0,Y.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 bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,g.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,Z.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,Z.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,Z.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,Z.jsx)(ke,{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,Z.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,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Be,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let _;t[21]!==h||t[22]!==p?(_=(0,Z.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=_):_=t[23];let v;return t[24]!==a||t[25]!==_||t[26]!==d?(v=(0,Z.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 Rn(e){let t=await l(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 zn(e){let t=await l(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function Bn(e,t){let n=await l(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 Vn(e){let t=await l(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Hn(e){let t=await l(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Un(e){let t=await l(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Wn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Gn(e){let t=new Map;for(let e of Wn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Kn(e){let t=(0,Y.c)(22),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,X.useState)(u),[p,m]=(0,X.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,_;t[3]!==g||t[4]!==l?(_=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(k,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,De)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,me),t[7]=b):b=t[7];let x;t[8]!==a||t[9]!==o||t[10]!==v||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(x=(0,Z.jsxs)(Pe,{children:[y,(0,Z.jsx)(ie,{className:b,children:d.type===`pick`?(0,Z.jsx)(Jn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>{let t=ue(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Z.jsx)(Yn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v}):(0,Z.jsx)(Qn,{initialPresetKey:d.presetKey,customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=a,t[9]=o,t[10]=v,t[11]=s,t[12]=c,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=x):x=t[17];let S;return t[18]!==g||t[19]!==n||t[20]!==x?(S=(0,Z.jsx)(D,{open:n,onOpenChange:g,children:x}),t[18]=g,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function qn(e){let t=(0,Y.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`,g.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function Jn(e){let t=(0,Y.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=F[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=Gn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=h);let _;t[11]===o.close?_=t[12]:(_=(0,Z.jsx)(qn,{label:o.close}),t[11]=o.close,t[12]=_);let v;t[13]!==h||t[14]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,_]}),t[13]=h,t[14]=_,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Ne,{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]=y):y=t[16];let b;t[17]===a?b=t[18]:(b=e=>a(e.target.value),t[17]=a,t[18]=b);let x=o.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=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`,I),t[19]=S):S=t[19];let C;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==b?(C=(0,Z.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[y,(0,Z.jsx)(`input`,{type:`search`,value:r,onChange:b,placeholder:x,autoComplete:`off`,autoFocus:!0,className:S})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=b,t[23]=C):C=t[23];let w;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(w=u?null:(0,Z.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`,g.press),children:[(0,Z.jsx)(fe,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,Z.jsx)(le,{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]=w):w=t[28];let T;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(T=f.length===0?(0,Z.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Wn.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,Z.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`,g.press),children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Z.jsx)(ke,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=T):T=t[34];let E;t[35]!==w||t[36]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[w,T]}),t[35]=w,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==C||t[39]!==E||t[40]!==v?(D=(0,Z.jsxs)(Z.Fragment,{children:[v,C,E]}),t[38]=C,t[39]=E,t[40]=v,t[41]=D):D=t[41],D}function Yn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=F[e],[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),y=(0,X.useRef)(null),b=a(r).providersSettings,x=Se(b),S=(0,X.useMemo)(()=>R(e,r),[e,r]),C=c?.supportsApiKey!==!1,T=c?.supportsOAuth===!0,[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(null),[A,j]=(0,X.useState)(`idle`),[M,N]=(0,X.useState)(null),[P,L]=(0,X.useState)(null),[z,B]=(0,X.useState)(``),ee=A===`waiting`||A===`waiting_code`;(0,X.useEffect)(()=>{if(!E||!ee)return;let e=window.setInterval(()=>{(async()=>{try{let t=await zn(E);t.status===`waiting_auth`||t.status===`waiting_code`?(j(t.status===`waiting_code`?`waiting_code`:`waiting`),k(t.message??null),N(t.authUrl??null),L(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),j(`success`),k(t.message??b.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),j(`error`),k(t.error??t.message??b.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[E,ee,s,b.revokeFailed,b.saved]),(0,X.useEffect)(()=>()=>{E&&Hn(E).catch(()=>{})},[E]);let V=async()=>{j(`waiting`),k(b.oauthStarting),h(null);try{D((await Rn(e)).sessionId)}catch(e){j(`error`),k(e instanceof Error?e.message:b.revokeFailed)}},te=async()=>{if(E){try{await Vn(E)}catch{}j(`idle`),k(null),D(null),N(null),L(null)}},ne=async()=>{if(!(!E||!z.trim()))try{await Bn(E,z.trim()),B(``),k(b.oauthProcessingCode)}catch(e){j(`error`),k(e instanceof Error?e.message:b.revokeFailed)}},re=async()=>{let t=u.trim();if(!(!t||!C)){p(!0),h(null);try{await Me({[e]:t}),v(!0),window.setTimeout(s,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.press),"aria-label":n.back,children:(0,Z.jsx)(le,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Z.jsx)(qn,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,C?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(We,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:x,inputRef:y,onKeyDown:e=>{e.key===`Enter`&&re()}})]}):null,T?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:b.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.oauthHint})]}),(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ee,onClick:()=>void V(),children:[ee?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,b.oauth]})]}),O?(0,Z.jsx)(`p`,{className:i(`text-xs`,A===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:O}):null,A===`waiting`||A===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[M?(0,Z.jsxs)(`a`,{href:M,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:[b.openAuthPage,(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void te(),children:b.cancelOAuth})]}):null,P?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:P}):null,A===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ne(),placeholder:b.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`,I)}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,onClick:()=>void ne(),children:b.submitCode})]}):null]}):null,S.length>0&&C?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:S.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[w(e,n),(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),C?(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!u.trim()||f||_,onClick:()=>void re(),children:_?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ke,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Xn(e=`custom`){if(e!==`custom`&&ze[e]){let t=ze[e].config;return{preset:e,providerId:Re(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Zn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:ze[t.key]?Xn(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Qn({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:o,onSaved:s}){let[c,l]=(0,X.useReducer)(Zn,void 0,()=>Xn(e)),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),h=Se(a(r).providersSettings),{preset:_,providerId:v,baseUrl:y,api:b,apiKey:x,modelIds:C,error:w}=c,T=async()=>{let e=v.trim(),r=y.trim();if(!e){l({type:`setError`,value:n.providerIdRequired});return}if(!r){l({type:`setError`,value:n.baseUrlRequired});return}let i=C.map(e=>e.trim()).filter(Boolean);d(!0),l({type:`setError`,value:null});try{let n=t?.providers??{},a=_===`custom`?void 0:ze[_]?.config,o={...a??{},baseUrl:r,api:b,apiKey:x.trim()||void 0,models:i.map(e=>a?.models?.find(t=>t.id===e)??{id:e})};await m({providers:{...n,[e]:o}}),s()}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},E=async()=>{let e=v.trim()||Re(_)||`custom`,t=y.trim();if(!t){l({type:`setError`,value:n.baseUrlRequired});return}p(!0),l({type:`setError`,value:null});try{let r=_===`custom`?void 0:ze[_]?.config,i=(await U({providerId:e,baseUrl:t,apiKey:x.trim()||void 0,api:b,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));l({type:`setModelIds`,values:i}),i.length===0&&l({type:`setError`,value:n.discoverModelsHint})}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},D=v.trim()&&y.trim(),k=(b===`openai-completions`||b===`openai-responses`)&&y.trim();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.press),"aria-label":n.back,children:(0,Z.jsx)(le,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,Z.jsx)(qn,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,Z.jsxs)(K,{id:`custom-preset`,value:_,onChange:e=>l({type:`applyPreset`,key:e.target.value}),className:pe(),children:[(0,Z.jsx)(J,{value:`custom`,children:n.presetCustom}),Ae.map(e=>(0,Z.jsx)(J,{value:e.key,children:e.label},e.key))]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,Z.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:v,onChange:e=>l({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,I)})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:y,onChange:e=>l({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,I)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,Z.jsx)(K,{id:`custom-api-type`,value:b,onChange:e=>l({type:`setApi`,value:e.target.value}),className:pe(),children:O.map(e=>(0,Z.jsx)(J,{value:e.value,children:e.label},e.value))})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(We,{id:`custom-api-key`,value:x,onChange:e=>l({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:h})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!k||f,onClick:()=>void E(),children:[f?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),C.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>l({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,I)}),C.length>1?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>l({type:`removeModelSlot`,index:t}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,g.press),children:(0,Z.jsx)(M,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>l({type:`addModelSlot`}),children:[(0,Z.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),w?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!D||u,onClick:()=>void T(),children:u?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function $n(e){let t=(0,Y.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}:oe(``),t[0]=n,t[1]=l);let[u,d]=(0,X.useState)(l),[f,p]=(0,X.useState)(er),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=je(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,Z.jsx)(ae,{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,Z.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,Z.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(ee,`p-1.5 hover:bg-surface-base`),t[24]=D):D=t[24];let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(M,{className:`size-4`}),t[25]=O):O=t[25];let k;t[26]===c.close?k=t[27]:(k=(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:D,"aria-label":c.close,children:O})}),t[26]=c.close,t[27]=k);let A;t[28]!==E||t[29]!==k?(A=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[E,k]}),t[28]=E,t[29]=k,t[30]=A):A=t[30];let j;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=j):j=t[31];let N;t[32]===c.modelId?N=t[33]:(N=(0,Z.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,j]}),t[32]=c.modelId,t[33]=N);let P;t[34]===f?P=t[35]:(P=i(Ie(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=P);let F=u.id||``,I;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>h(`id`,e.target.value),t[36]=I):I=t[36];let L=!r,R;t[37]!==P||t[38]!==F||t[39]!==L?(R=(0,Z.jsx)(`input`,{className:P,value:F,onChange:I,placeholder:`e.g. llama3.1:8b`,disabled:L}),t[37]=P,t[38]=F,t[39]=L,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=f.has(`id`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=z);let B;t[43]!==N||t[44]!==R||t[45]!==z?(B=(0,Z.jsxs)(`div`,{children:[N,R,z]}),t[43]=N,t[44]=R,t[45]=z,t[46]=B):B=t[46];let V;t[47]===c.displayName?V=t[48]:(V=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=V);let te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(te=Ie(),t[49]=te):te=t[49];let re=u.name||``,ie;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>h(`name`,e.target.value),t[50]=ie):ie=t[50];let H;t[51]===re?H=t[52]:(H=(0,Z.jsx)(`input`,{className:te,value:re,onChange:ie}),t[51]=re,t[52]=H);let U;t[53]!==V||t[54]!==H?(U=(0,Z.jsxs)(`div`,{children:[V,H]}),t[53]=V,t[54]=H,t[55]=U):U=t[55];let W;t[56]===c.inputTypes?W=t[57]:(W=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=W);let se;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(se=pe(),t[58]=se):se=t[58];let ce;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>h(`input`,Te(e.target.value)),t[59]=ce):ce=t[59];let le;t[60]===c?le=t[61]:(le=_e.map(e=>(0,Z.jsx)(J,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=le);let ue;t[62]!==S||t[63]!==le?(ue=(0,Z.jsx)(K,{className:se,value:S,onChange:ce,children:le}),t[62]=S,t[63]=le,t[64]=ue):ue=t[64];let de;t[65]!==W||t[66]!==ue?(de=(0,Z.jsxs)(`div`,{children:[W,ue]}),t[65]=W,t[66]=ue,t[67]=de):de=t[67];let G=u.reasoning||!1,fe;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>h(`reasoning`,e.target.checked),t[68]=fe):fe=t[68];let me;t[69]===G?me=t[70]:(me=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:G,onChange:fe}),t[69]=G,t[70]=me);let he;t[71]!==c.reasoning||t[72]!==me?(he=(0,Z.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[me,c.reasoning]}),t[71]=c.reasoning,t[72]=me,t[73]=he):he=t[73];let ge;t[74]!==de||t[75]!==he?(ge=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[de,he]}),t[74]=de,t[75]=he,t[76]=ge):ge=t[76];let ve;t[77]===c.contextWindow?ve=t[78]:(ve=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=ve);let ye;t[79]===f?ye=t[80]:(ye=i(Ie(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=ye);let be=u.contextWindow??128e3,xe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=xe):xe=t[81];let Se;t[82]!==ye||t[83]!==be?(Se=(0,Z.jsx)(`input`,{type:`number`,min:1,className:ye,value:be,onChange:xe}),t[82]=ye,t[83]=be,t[84]=Se):Se=t[84];let Ce;t[85]===f?Ce=t[86]:(Ce=f.has(`contextWindow`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=Ce);let we;t[87]!==ve||t[88]!==Se||t[89]!==Ce?(we=(0,Z.jsxs)(`div`,{children:[ve,Se,Ce]}),t[87]=ve,t[88]=Se,t[89]=Ce,t[90]=we):we=t[90];let Ee;t[91]===c.maxOutputTokens?Ee=t[92]:(Ee=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=Ee);let De;t[93]===f?De=t[94]:(De=i(Ie(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=De);let Oe=u.maxTokens??16384,ke;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=ke):ke=t[95];let Ae;t[96]!==De||t[97]!==Oe?(Ae=(0,Z.jsx)(`input`,{type:`number`,min:1,className:De,value:Oe,onChange:ke}),t[96]=De,t[97]=Oe,t[98]=Ae):Ae=t[98];let Me;t[99]===f?Me=t[100]:(Me=f.has(`maxTokens`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Me);let Ne;t[101]!==Ee||t[102]!==Ae||t[103]!==Me?(Ne=(0,Z.jsxs)(`div`,{children:[Ee,Ae,Me]}),t[101]=Ee,t[102]=Ae,t[103]=Me,t[104]=Ne):Ne=t[104];let Pe;t[105]!==we||t[106]!==Ne?(Pe=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[we,Ne]}),t[105]=we,t[106]=Ne,t[107]=Pe):Pe=t[107];let Fe;t[108]===c.costSection?Fe=t[109]:(Fe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Fe);let Le;t[110]===c.costInput?Le=t[111]:(Le=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=Le);let Re;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Re=Ie(),t[112]=Re):Re=t[112];let ze=u.cost?.input??0,Be;t[113]===u.cost?Be=t[114]:(Be=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]=Be);let Ve;t[115]!==ze||t[116]!==Be?(Ve=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Re,value:ze,onChange:Be}),t[115]=ze,t[116]=Be,t[117]=Ve):Ve=t[117];let He;t[118]!==Le||t[119]!==Ve?(He=(0,Z.jsxs)(`div`,{children:[Le,Ve]}),t[118]=Le,t[119]=Ve,t[120]=He):He=t[120];let Ue;t[121]===c.costOutput?Ue=t[122]:(Ue=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Ue);let We;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(We=Ie(),t[123]=We):We=t[123];let Ge=u.cost?.output??0,Ke;t[124]===u.cost?Ke=t[125]:(Ke=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]=Ke);let qe;t[126]!==Ge||t[127]!==Ke?(qe=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:We,value:Ge,onChange:Ke}),t[126]=Ge,t[127]=Ke,t[128]=qe):qe=t[128];let Je;t[129]!==Ue||t[130]!==qe?(Je=(0,Z.jsxs)(`div`,{children:[Ue,qe]}),t[129]=Ue,t[130]=qe,t[131]=Je):Je=t[131];let Ye;t[132]!==He||t[133]!==Je?(Ye=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[He,Je]}),t[132]=He,t[133]=Je,t[134]=Ye):Ye=t[134];let Xe;t[135]!==Fe||t[136]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Fe,Ye]}),t[135]=Fe,t[136]=Ye,t[137]=Xe):Xe=t[137];let Ze;t[138]!==B||t[139]!==U||t[140]!==ge||t[141]!==Pe||t[142]!==Xe?(Ze=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[B,U,ge,Pe,Xe]}),t[138]=B,t[139]=U,t[140]=ge,t[141]=Pe,t[142]=Xe,t[143]=Ze):Ze=t[143];let Qe;t[144]===c.cancel?Qe=t[145]:(Qe=(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=Qe);let $e=r?c.addModelConfirm:c.saveModelConfirm,et;t[146]!==y||t[147]!==$e?(et=(0,Z.jsx)(q,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:$e}),t[146]=y,t[147]=$e,t[148]=et):et=t[148];let tt;t[149]!==Qe||t[150]!==et?(tt=(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Qe,et]}),t[149]=Qe,t[150]=et,t[151]=tt):tt=t[151];let nt;return t[152]!==A||t[153]!==Ze||t[154]!==tt?(nt=(0,Z.jsxs)(Z.Fragment,{children:[A,Ze,tt]}),t[152]=A,t[153]=Ze,t[154]=tt,t[155]=nt):nt=t[155],nt}function er(){return new Map}function tr(e){let t=(0,Y.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,Z.jsx)(k,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,De)}),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`,me,`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,Z.jsx)($n,{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,Z.jsxs)(Pe,{children:[u,(0,Z.jsx)(ie,{className:d,onOpenAutoFocus:nr,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,Z.jsx)(D,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function nr(e){return e.preventDefault()}function rr(e){let t=(0,Y.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Ce(n).then(ir),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,Z.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,Z.jsx)(We,{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,Z.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 ir(e){return e.apiKey??null}function ar(e){let t=(0,Y.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,Z.jsx)(k,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,De)}),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`,me),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==o||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==a?(h=(0,Z.jsxs)(Pe,{children:[p,(0,Z.jsx)(ie,{className:m,children:o?(0,Z.jsx)(sr,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Z.jsx)(or,{providerId:a,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=o,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=a,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,Z.jsx)(D,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function or({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=F[e],d=n.filter(t=>t.provider===e),[f,p]=(0,X.useState)(l?.apiKey??``),[m,h]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),T=a(o).providersSettings,E=l?.supportsApiKey!==!1,D=l?.supportsOAuth===!0,O=l?.authMode===`oauth`&&l.authStatus===`connected`,k=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[A,j]=(0,X.useState)(null),[N,L]=(0,X.useState)(null),[z,B]=(0,X.useState)(`idle`),[ee,te]=(0,X.useState)(null),[re,ie]=(0,X.useState)(null),[U,oe]=(0,X.useState)(``),se=z===`waiting`||z===`waiting_code`,ce=(0,X.useMemo)(()=>R(e,o),[e,o]),le=f!==(l?.apiKey??``),ue=async()=>{let t=f.trim();if(!(!t||!E||he(t))){h(!0),x(null);try{await Me({[e]:t}),y(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){x(e instanceof Error?e.message:r.saveError)}finally{h(!1)}}};(0,X.useEffect)(()=>{if(!A||!se)return;let e=window.setInterval(()=>{(async()=>{try{let t=await zn(A);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),L(t.message??null),te(t.authUrl??null),ie(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),B(`success`),L(t.message??T.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),B(`error`),L(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[A,se,s,c,T.revokeFailed,T.saved]),(0,X.useEffect)(()=>()=>{A&&Hn(A).catch(()=>{})},[A]);let de=async()=>{try{await Ee(e),c(),s()}catch{}},G=async()=>{B(`waiting`),L(T.oauthStarting),x(null);try{j((await Rn(e)).sessionId)}catch(e){B(`error`),L(e instanceof Error?e.message:T.revokeFailed)}},fe=async()=>{if(A){try{await Vn(A)}catch{}B(`idle`),L(null),j(null),te(null),ie(null)}},pe=async()=>{if(!(!A||!U.trim()))try{await Bn(A,U.trim()),oe(``),L(T.oauthProcessingCode)}catch(e){B(`error`),L(e instanceof Error?e.message:T.revokeFailed)}},me=async()=>{try{await Un(e),c(),s()}catch(e){x(e instanceof Error?e.message:T.revokeFailed)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.press),children:(0,Z.jsx)(M,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.baseUrl?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,Z.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,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,E?(0,Z.jsx)(rr,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{p(e),y(!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,Z.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,Z.jsx)(`p`,{children:r.extensionKeyHint}),l?.extensionId?(0,Z.jsxs)(_,{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,Z.jsx)(P,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,D?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:T.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:O?T.sourceOauth:T.oauthHint})]}),O?(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void me(),children:T.revoke}):(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:se,onClick:()=>void G(),children:[se?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(Fe,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),N?(0,Z.jsx)(`p`,{className:i(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:N}):null,z===`waiting`||z===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee?(0,Z.jsxs)(`a`,{href:ee,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,Z.jsx)(P,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:T.cancelOAuth})]}):null,re?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:re}):null,z===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:U,onChange:e=>oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&void pe(),placeholder:T.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,I)}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,onClick:()=>void pe(),children:T.submitCode})]}):null]}):null,ce.length>0&&E?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ce.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[w(e,r),(0,Z.jsx)(P,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,Z.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,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),b?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[k?(0,Z.jsxs)(q,{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,Z.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:E&&le&&!he(f.trim())?(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!f.trim()||m||v,onClick:()=>void ue(),children:v?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ke,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):m?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Z.jsx)(V,{open:S,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void de(),onCancel:()=>C(!1)})]})}function sr({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,X.useState)(l?.baseUrl??``),[f,p]=(0,X.useState)(l?.apiKey??``),[h,_]=(0,X.useState)(l?.models??[]),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),j=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:he(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},P=async()=>{let e=j({models:h});if(e){y(!0),x(null);try{await m(e),s(),o()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{y(!1)}}},F=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await m({providers:r}),s(),o()}catch{}},L=(e,t)=>{A({model:e,isNew:t}),O(!0)},R=async e=>{if(!k)return;let t=k.isNew?[...h,e]:h.map(t=>t.id===e.id?e:t);_(t);let r=j({models:t});if(r)try{await m(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}},z=async e=>{let t=h.filter(t=>t.id!==e);_(t),E(null);let r=j({models:t});if(r)try{await m(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:e}),(0,Z.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,Z.jsx)(ne,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.press),children:(0,Z.jsx)(M,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.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`,I)})]}),(0,Z.jsx)(rr,{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,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,h.length>0?` (${h.length})`:``]}),(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>L(null,!0),children:[(0,Z.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),h.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,Z.jsx)(`ul`,{className:`space-y-2`,children:h.map(e=>(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,g.press),onClick:()=>L(e,!1),"aria-label":c.editModel,children:(0,Z.jsx)(N,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.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`,g.press),onClick:()=>E(e.id),"aria-label":c.removeModel,children:(0,Z.jsx)(H,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),b?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>w(!0),children:[(0,Z.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:v,onClick:()=>void P(),children:v?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Z.jsx)(V,{open:C,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void F(),onCancel:()=>w(!1)}),(0,Z.jsx)(V,{open:T!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,T??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{T&&z(T)},onCancel:()=>E(null)}),(0,Z.jsx)(tr,{open:D,onOpenChange:e=>{O(e),e||A(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void R(e),m:c})]})}var cr=[`services`,`image-models`,`voice`,`search`];function lr(e){let t=(e??``).trim();return t===`providers`||t===`catalog`?`services`:cr.includes(t)?t:`services`}function ur(){let e=(0,Y.c)(59),t=u(fr),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.modelsHub,[o,s]=j(),c;e[2]===o?c=e[3]:(c=lr(o.get(`tab`)),e[2]=o,e[3]=c);let l=c,[d,f]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=On(),_;e[4]!==i.servicesHint||e[5]!==i.tabs.services?(_={id:`services`,icon:y,label:i.tabs.services,hint:i.servicesHint},e[4]=i.servicesHint,e[5]=i.tabs.services,e[6]=_):_=e[6];let v;e[7]!==i.imageModelsHint||e[8]!==i.tabs.imageModels?(v={id:`image-models`,icon:ye,label:i.tabs.imageModels,hint:i.imageModelsHint},e[7]=i.imageModelsHint,e[8]=i.tabs.imageModels,e[9]=v):v=e[9];let b;e[10]!==i.tabs.voice||e[11]!==i.voiceHint?(b={id:`voice`,icon:re,label:i.tabs.voice,hint:i.voiceHint},e[10]=i.tabs.voice,e[11]=i.voiceHint,e[12]=b):b=e[12];let x;e[13]!==i.searchHint||e[14]!==i.tabs.search?(x={id:`search`,icon:Ne,label:i.tabs.search,hint:i.searchHint},e[13]=i.searchHint,e[14]=i.tabs.search,e[15]=x):x=e[15];let S;e[16]!==_||e[17]!==v||e[18]!==b||e[19]!==x?(S=[_,v,b,x],e[16]=_,e[17]=v,e[18]=b,e[19]=x,e[20]=S):S=e[20];let C=S,w;e[21]===s?w=e[22]:(w=e=>{s(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=s,e[22]=w);let T=w,E=dr,D=r.settingsSections.credentials,O=i.subtitle,k;e[23]===t?k=e[24]:(k=p(t,`configuration`),e[23]=t,e[24]=k);let A;e[25]!==i.docsLink||e[26]!==i.subtitle||e[27]!==r.settingsSections.credentials||e[28]!==k?(A=(0,Z.jsx)(qe,{title:D,subtitle:O,docsLink:k,docsLabel:i.docsLink}),e[25]=i.docsLink,e[26]=i.subtitle,e[27]=r.settingsSections.credentials,e[28]=k,e[29]=A):A=e[29];let M;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(pt,{}),e[30]=M):M=e[30];let N;e[31]!==l||e[32]!==i.tabsAria||e[33]!==T||e[34]!==C?(N=(0,Z.jsx)(dt,{items:C,activeTab:l,onChange:T,ariaLabel:i.tabsAria,tabIdPrefix:`hub-tab`,panelIdPrefix:`hub-panel`}),e[31]=l,e[32]=i.tabsAria,e[33]=T,e[34]=C,e[35]=N):N=e[35];let P;e[36]!==l||e[37]!==i.connectedProviders||e[38]!==C?(P=C.map(e=>(0,Z.jsx)(mr,{id:e.id,activeTab:l,hint:e.hint,children:e.id===`services`?(0,Z.jsx)(Pn,{labels:i.connectedProviders,onAdd:()=>f(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,Z.jsx)(pr,{tab:e.id})},e.id)),e[36]=l,e[37]=i.connectedProviders,e[38]=C,e[39]=P):P=e[39];let F;e[40]!==d||e[41]!==i.addProviderDialog||e[42]!==t||e[43]!==g.builtinRows||e[44]!==g.customConfig?(F=(0,Z.jsx)(Kn,{open:d,onOpenChange:f,builtinRows:g.builtinRows,customConfig:g.customConfig,labels:i.addProviderDialog,language:t,onSaved:E}),e[40]=d,e[41]=i.addProviderDialog,e[42]=t,e[43]=g.builtinRows,e[44]=g.customConfig,e[45]=F):F=e[45];let I;e[46]!==i.manageProviderDialog||e[47]!==t||e[48]!==m||e[49]!==g.allModels||e[50]!==g.builtinRows||e[51]!==g.customConfig?(I=m?(0,Z.jsx)(ar,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:g.builtinRows,customConfig:g.customConfig,allModels:g.allModels,labels:i.manageProviderDialog,language:t,onSaved:E}):null,e[46]=i.manageProviderDialog,e[47]=t,e[48]=m,e[49]=g.allModels,e[50]=g.builtinRows,e[51]=g.customConfig,e[52]=I):I=e[52];let L;return e[53]!==A||e[54]!==N||e[55]!==P||e[56]!==F||e[57]!==I?(L=(0,Z.jsxs)(Je,{children:[A,M,N,P,F,I]}),e[53]=A,e[54]=N,e[55]=P,e[56]=F,e[57]=I,e[58]=L):L=e[58],L}function dr(){ce()}function fr(e){return e.language}function pr(e){let t=(0,Y.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,Z.jsx)(jt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(rn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Tn,{}),t[2]=e):e=t[2],e}}}function mr({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,X.useRef)(a);return a&&(o.current=!0),o.current?(0,Z.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(`min-w-0 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,a?`flex flex-col gap-3`:void 0),children:[a?(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{ur as ModelsHubPanel};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{jl as n}from"./index-DcUaXYeb.js";import{t as r}from"./notes-workbench-BHwzJ0OC.js";var i=e(),a=t();function o(){let e=(0,i.c)(2),{noteId:t}=n(),o;return e[0]===t?o=e[1]:(o=(0,a.jsx)(r,{selectedNoteId:t,basePath:`/notes`,managePageHeader:!0,showLibrary:!0,allowMediaCapture:!0,listWidthStorageKey:`xopc.notes.listWidth`}),e[0]=t,e[1]=o),o}export{o as NotesPage};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-Dhj5f4Bx.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-DcUaXYeb.js","assets/preload-helper-zJ_50EbN.js","assets/dist-Mys7eFJ5.js","assets/Combination-HAlzriaz.js","assets/vendor-react-BOUWij0V.js","assets/vendor-swr-BIWyz7Rc.js","assets/cn-BQ_8x0bT.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-Ba72bFmP.js","assets/config-reload-event-Bjh2zoKp.js","assets/messages-BXNELNBa.js","assets/fetch-B1WtuprY.js","assets/gateway-startup-retry-nEujFSDj.js","assets/toast-z0toXu32.js","assets/theme-store-Bt6vAkSB.js","assets/index-B8s8Pq5U.css","assets/vendor-codemirror-C1WKjCk5.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-jD1LPiP-.js","assets/code-editor--tMO38Tr.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-BXNELNBa.js";import{a as s}from"./fetch-B1WtuprY.js";import{c,n as l}from"./locale-store-Ba72bFmP.js";import{i as u}from"./theme-store-Bt6vAkSB.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Al as p,An as m,Ao as h,As as g,Bn as _,Br as v,Cl as y,Cn as b,Dn as x,Dt as S,En as C,Es as w,Fc as T,Fn as E,Ga as D,Gn as O,Go as k,Hn as A,Hr as j,In as M,Is as N,Ja as P,Ka as F,Kc as ee,Ko as I,Ks as L,Ln as R,Lr as te,Mc as ne,Mn as re,Mo as z,Ms as ie,Nn as ae,On as B,Os as V,Pn as H,Ps as U,Rn as oe,Rr as se,Sn as ce,Tn as le,Ua as ue,Uc as de,Un as fe,Us as pe,Vn as me,Vr as W,Wa as G,Wo as K,Xa as he,Ya as ge,Ys as _e,Zo as q,_ as ve,bs as J,dc as ye,es as be,fc as xe,fs as Se,hc as Ce,io as we,jn as Te,js as Ee,kc as De,kn as Oe,mc as ke,ml as Ae,ns as je,oo as Me,ps as Ne,qa as Pe,rs as Y,sc as Fe,wl as Ie,wn as Le,xl as Re,zr as ze}from"./index-DcUaXYeb.js";import{t as Be}from"./automation-suggestion-card-B1LV3YYv.js";var X=e(t(),1),Z=n(),Q=r(),Ve={noteId:null,attachmentId:null,playing:!1,currentTime:0,duration:0,loading:!1},$=null,He=null,Ue=null,We=null;function Ge(){return $||($=new Audio,$.addEventListener(`timeupdate`,()=>{qe.setState({currentTime:$.currentTime})}),$.addEventListener(`loadedmetadata`,()=>{let e=$.duration;Number.isFinite(e)&&qe.setState({duration:e})}),$.addEventListener(`ended`,()=>{qe.setState({playing:!1,currentTime:0}),$.currentTime=0}),$.addEventListener(`pause`,()=>{qe.setState({playing:!1})}),$.addEventListener(`play`,()=>{qe.setState({playing:!0})})),$}function Ke(){Ue&&We&&fe(Ue,We),He=null,Ue=null,We=null}var qe=c()((e,t)=>({...Ve,play:async(n,r,i)=>{let a=Ge(),o=t();if(o.noteId===n&&o.attachmentId===r&&He){a.play();return}a.pause(),Ke(),e({noteId:n,attachmentId:r,playing:!1,currentTime:0,duration:i??0,loading:!0});try{let t=await A(n,r);He=t,Ue=n,We=r,a.src=t,await a.play(),e({loading:!1})}catch{e({loading:!1,playing:!1}),Ke()}},pause:()=>{Ge().pause()},toggle:(e,n,r)=>{let i=t();i.noteId===e&&i.attachmentId===n&&i.playing?t().pause():t().play(e,n,r)},seek:t=>{let n=Ge();n.currentTime=t,e({currentTime:t})},reset:()=>{Ge().pause(),Ge().src=``,Ke(),e(Ve)}})),Je=(0,X.createContext)(null);function Ye(){let e=(0,Z.c)(1),t=(0,X.useContext)(Je);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:Xe},e[0]=t):t=e[0],t}return t}function Xe(){}function Ze(e){let t=(0,Z.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[o,s]=(0,X.useState)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{s({src:e,alt:t})},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u={openImage:l},t[1]=u):u=t[1];let d=u,f=o!==null,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>{e||s(null)},t[2]=p):p=t[2];let m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(F,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=m):m=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=a(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=h):h=t[4];let g=o?.alt||`Image preview`,_;t[5]===g?_=t[6]:(_=(0,Q.jsx)(ge,{className:`sr-only`,children:g}),t[5]=g,t[6]=_);let v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(z,{className:`h-5 w-5`,"aria-hidden":!0}),t[7]=v):v=t[7];let y;t[8]===i?y=t[9]:(y=(0,Q.jsx)(ue,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":i,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:v})}),t[8]=i,t[9]=y);let b;t[10]===o?b=t[11]:(b=o?(0,Q.jsx)(`img`,{src:o.src,alt:o.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=o,t[11]=b);let x;t[12]!==y||t[13]!==b||t[14]!==_?(x=(0,Q.jsxs)(Pe,{children:[m,(0,Q.jsxs)(G,{className:h,"aria-describedby":void 0,children:[_,y,b]})]}),t[12]=y,t[13]=b,t[14]=_,t[15]=x):x=t[15];let S;t[16]!==x||t[17]!==f?(S=(0,Q.jsx)(P,{open:f,onOpenChange:p,children:x}),t[16]=x,t[17]=f,t[18]=S):S=t[18];let C;return t[19]!==n||t[20]!==S?(C=(0,Q.jsxs)(Je.Provider,{value:d,children:[n,S]}),t[19]=n,t[20]=S,t[21]=C):C=t[21],C}function Qe(e){let t=(0,Z.c)(15),{noteId:n,attachmentId:r,className:i}=e,[o,s]=(0,X.useState)(!1),c;t[0]!==r||t[1]!==n?(c=O(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c;if(o){let e;t[3]===i?e=t[4]:(e=a(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,i),t[3]=i,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(ke,{className:`h-4 w-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,Q.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]===i?d=t[10]:(d=a(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,i),t[9]=i,t[10]=d);let f;return t[11]!==n||t[12]!==l||t[13]!==d?(f=(0,Q.jsx)(me,{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}var $e=6e4,et=36e5,tt=864e5;function nt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function rt(e,t,n){let r=t-e;if(r<$e)return n.justNow;if(r<et){let e=Math.floor(r/$e);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=nt(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(e>=i-tt)return n.yesterday+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(r<7*tt){let e=Math.floor(r/tt);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function it(e,t,n){let r=nt(t);if(e>=r)return n.today;if(e>=r-tt)return n.yesterday;let i=new Date(e),a=new Date(t);return i.getFullYear()===a.getFullYear()?i.toLocaleDateString(void 0,{month:`long`,day:`numeric`}):i.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function at(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function ot(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 st(e){let t=(0,Z.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:o}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:d,attachmentId:f}=qe(),p=qe(lt),m=d===n&&f===r,h=m&&s,g=m&&c,_=m?l:0,v=m&&u>0?u:i??0,y=v>0?Math.min(_/v*100,100):0,b;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==p?(b=e=>{e.stopPropagation(),p(n,r,i)},t[0]=r,t[1]=i,t[2]=n,t[3]=p,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==p?(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),p(n,r,i))},t[5]=r,t[6]=i,t[7]=n,t[8]=p,t[9]=S):S=t[9];let C=S,w;t[10]===o?w=t[11]:(w=a(`flex items-center gap-2`,o),t[10]=o,t[11]=w);let T=h?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,E;t[12]===T?E=t[13]:(E=a(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition-colors`,T),t[12]=T,t[13]=E);let D=h?`Pause`:`Play`,O;t[14]!==g||t[15]!==h?(O=g?(0,Q.jsx)(_e,{className:`h-3.5 w-3.5 animate-spin`}):h?(0,Q.jsx)(U,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(V,{className:`h-3.5 w-3.5 ml-0.5`}),t[14]=g,t[15]=h,t[16]=O):O=t[16];let k;t[17]!==x||t[18]!==C||t[19]!==E||t[20]!==D||t[21]!==O?(k=(0,Q.jsx)(`button`,{type:`button`,onClick:x,onKeyDown:C,className:E,"aria-label":D,children:O}),t[17]=x,t[18]=C,t[19]=E,t[20]=D,t[21]=O,t[22]=k):k=t[22];let A=`${y}%`,j;t[23]===A?j=t[24]:(j=(0,Q.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:A}})}),t[23]=A,t[24]=j);let M;t[25]!==v||t[26]!==m||t[27]!==_?(M=ot(m&&_>0?_:v),t[25]=v,t[26]=m,t[27]=_,t[28]=M):M=t[28];let N;t[29]===M?N=t[30]:(N=(0,Q.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:M}),t[29]=M,t[30]=N);let P;t[31]!==j||t[32]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[j,N]}),t[31]=j,t[32]=N,t[33]=P):P=t[33];let F;return t[34]!==P||t[35]!==w||t[36]!==k?(F=(0,Q.jsxs)(`div`,{className:w,onClick:ct,children:[k,P]}),t[34]=P,t[35]=w,t[36]=k,t[37]=F):F=t[37],F}function ct(e){return e.stopPropagation()}function lt(e){return e.toggle}function ut(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function dt(e){let t=(0,Z.c)(80),{note:n,selected:r,onPress:i,onPin:o,onArchive:s,onDelete:c,labels:l,timeLabels:u}=e,d=r===void 0?!1:r,f;t[0]!==l||t[1]!==n?(f=ut(n,l),t[0]=l,t[1]=n,t[2]=f):f=t[2];let p=f,m=!n.snippet?.trim(),[h]=(0,X.useState)(ht),_;t[3]!==n.createdAt||t[4]!==h||t[5]!==u?(_=rt(n.createdAt,h,u),t[3]=n.createdAt,t[4]=h,t[5]=u,t[6]=_):_=t[6];let y=_,b,x;t[7]!==n.id||t[8]!==i?(b=()=>i(n.id),x=e=>{(e.key===`Enter`||e.key===` `)&&i(n.id)},t[7]=n.id,t[8]=i,t[9]=b,t[10]=x):(b=t[9],x=t[10]);let S=d?`bg-surface-active hover:bg-surface-active`:`bg-surface-base hover:bg-surface-hover`,C;t[11]===S?C=t[12]:(C=a(`group relative flex cursor-pointer flex-col gap-2 rounded-lg px-3 py-2.5`,`transition-colors duration-150 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,S),t[11]=S,t[12]=C);let w=d?`true`:void 0,E;t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(E=n.coverAttachmentId?(0,Q.jsx)(Qe,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,Q.jsx)(st,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-28 shrink-0`}):null,t[13]=n.coverAttachmentId,t[14]=n.id,t[15]=n.kind,t[16]=n.voiceAttachmentId,t[17]=n.voiceDurationSec,t[18]=E):E=t[18];let D;t[19]===n.title?D=t[20]:(D=n.title&&(0,Q.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[19]=n.title,t[20]=D);let O=n.title?`text-fg-muted`:m?`italic text-fg-muted`:`text-fg`,k;t[21]===O?k=t[22]:(k=a(`truncate text-sm leading-5`,O),t[21]=O,t[22]=k);let A;t[23]!==p||t[24]!==k?(A=(0,Q.jsx)(`p`,{className:k,children:p}),t[23]=p,t[24]=k,t[25]=A):A=t[25];let M;t[26]!==D||t[27]!==A?(M=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,A]}),t[26]=D,t[27]=A,t[28]=M):M=t[28];let N;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(j,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:mt,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-0 transition-opacity group-hover:opacity-100 hover:bg-surface-panel focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":`Actions`,children:(0,Q.jsx)(T,{className:`h-4 w-4`})})}),t[29]=N):N=t[29];let P;t[30]!==n.id||t[31]!==n.pinned||t[32]!==o?(P=()=>o(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=o,t[33]=P):P=t[33];let F;t[34]===n.pinned?F=t[35]:(F=n.pinned?(0,Q.jsx)(g,{className:`h-4 w-4`}):(0,Q.jsx)(Ee,{className:`h-4 w-4`}),t[34]=n.pinned,t[35]=F);let ee=n.pinned?l.unpin:l.pin,I;t[36]!==P||t[37]!==F||t[38]!==ee?(I=(0,Q.jsxs)(se,{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:P,children:[F,ee]}),t[36]=P,t[37]=F,t[38]=ee,t[39]=I):I=t[39];let L;t[40]!==n.id||t[41]!==s?(L=()=>s(n.id),t[40]=n.id,t[41]=s,t[42]=L):L=t[42];let R;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(Ie,{className:`h-4 w-4`}),t[43]=R):R=t[43];let ne;t[44]!==l.archive||t[45]!==L?(ne=(0,Q.jsxs)(se,{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,l.archive]}),t[44]=l.archive,t[45]=L,t[46]=ne):ne=t[46];let re;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(W,{className:`my-1 h-px bg-edge-subtle`}),t[47]=re):re=t[47];let z;t[48]!==n.id||t[49]!==c?(z=()=>c(n.id),t[48]=n.id,t[49]=c,t[50]=z):z=t[50];let ie;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(K,{className:`h-4 w-4`}),t[51]=ie):ie=t[51];let ae;t[52]!==l.delete||t[53]!==z?(ae=(0,Q.jsxs)(se,{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:z,children:[ie,l.delete]}),t[52]=l.delete,t[53]=z,t[54]=ae):ae=t[54];let B;t[55]!==I||t[56]!==ne||t[57]!==ae?(B=(0,Q.jsxs)(v,{children:[N,(0,Q.jsx)(ze,{children:(0,Q.jsxs)(te,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:pt,children:[I,ne,re,ae]})})]}),t[55]=I,t[56]=ne,t[57]=ae,t[58]=B):B=t[58];let V;t[59]!==M||t[60]!==B||t[61]!==E?(V=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[E,M,B]}),t[59]=M,t[60]=B,t[61]=E,t[62]=V):V=t[62];let H;t[63]===n.pinned?H=t[64]:(H=n.pinned&&(0,Q.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,Q.jsx)(Ee,{className:`h-3 w-3`})}),t[63]=n.pinned,t[64]=H);let U;t[65]===n.tags?U=t[66]:(U=n.tags?.slice(0,2).map(ft),t[65]=n.tags,t[66]=U);let oe;t[67]===y?oe=t[68]:(oe=(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:y}),t[67]=y,t[68]=oe);let ce;t[69]!==H||t[70]!==U||t[71]!==oe?(ce=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[H,U,oe]}),t[69]=H,t[70]=U,t[71]=oe,t[72]=ce):ce=t[72];let le;return t[73]!==V||t[74]!==ce||t[75]!==b||t[76]!==x||t[77]!==C||t[78]!==w?(le=(0,Q.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:b,onKeyDown:x,className:C,"aria-current":w,children:[V,ce]}),t[73]=V,t[74]=ce,t[75]=b,t[76]=x,t[77]=C,t[78]=w,t[79]=le):le=t[79],le}function ft(e){return(0,Q.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function pt(e){return e.stopPropagation()}function mt(e){return e.stopPropagation()}function ht(){return Date.now()}var gt={edit:ie,ai_edit:Y,sync:J,restore:y};function _t(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function vt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let s=o(l(e=>e.language)).notes,c=s,{data:u}=f(e?[`note-history`,e]:null,()=>B(e)),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),_=(0,X.useCallback)(async t=>{m(!0);try{await R(e,t),d({type:`success`,title:s.restoreSuccess}),g(null),i()}catch{d({type:`error`,title:s.restoreFailed})}finally{m(!1)}},[e,s.restoreSuccess,s.restoreFailed,i]),v=Date.now();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(Ce,{className:`h-4 w-4`,"aria-hidden":!0}),s.history]}),(0,Q.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,Q.jsx)(z,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:u?.length?(0,Q.jsx)(`ul`,{className:`divide-y divide-edge`,children:u.map(e=>{let r=gt[e.trigger]??ie,i=t===e.timestamp,o=h===e.timestamp;return(0,Q.jsxs)(`li`,{children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:_t(e.trigger,s)}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:rt(e.timestamp,v,c)})]}),e.snippet&&(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,Q.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:s.restoreConfirm}),(0,Q.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?`...`:s.restore}),(0,Q.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,Q.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:s.restore})})]},e.timestamp)})}):(0,Q.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:s.historyEmpty}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:s.historyEmptyDescription})]})})]})}function yt(e){let t=(0,Z.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:s,onClose:c,noteThreads:u,openingChat:d,onOpenChat:m,onOpenNewChat:h}=e,g=o(l(Et)).notes,_=p(),v=r?.aiDeep?.catalysis,y=v?.report??null,b;t[0]===n?b=t[1]:(b=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=b);let x;t[2]===n?x=t[3]:(x=()=>C(n),t[2]=n,t[3]=x);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},t[4]=S):S=t[4];let{data:w,mutate:T,isLoading:D}=f(b,x,S),O;t[5]===n?O=t[6]:(O=async e=>{try{await M(n,e)}catch{}},t[5]=n,t[6]=O);let A=O,j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(Y,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=j):j=t[7];let N;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(Re,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=N):N=t[8];let P;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Q.jsx)(L,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=P):P=t[9],(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:g.catalysisSectionTitle})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:c,"aria-label":g.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:N})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,Q.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:g.catalysisSectionDescription}),w?(0,Q.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.contextStatusTitle}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void T(()=>E(n),{revalidate:!1}),disabled:D,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:g.contextRebuild}),(0,Q.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,w.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:w.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:w.status})]}),(0,Q.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:g.contextStatusDetail.replace(`{{attachments}}`,String(w.attachments.length)).replace(`{{tokens}}`,String(w.tokenEstimate??0))}),w.attachments.length>0?(0,Q.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:w.attachments.slice(0,5).map(Tt)}):null]}):null,(0,Q.jsx)(`button`,{type:`button`,onClick:s,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?g.processing:y?g.recatalyze:g.catalyzeAction}),y?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.valueHypothesis}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:y.valueHypothesis})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.targetUsers}),(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.targetUsers.slice(0,5).map(wt)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.keyQuestions}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.keyQuestions.slice(0,3).map(Ct)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.mvpPathLabel}),(0,Q.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.mvpPath.slice(0,3).map(St)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.risks}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.risks.slice(0,3).map(xt)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.nextActions}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.nextActions.slice(0,4).map(bt)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:g.confidenceLabel.replace(`{{percent}}`,String(Math.round(y.confidence*100)))}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void A(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackHelpfulAria,children:(0,Q.jsx)(k,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void A(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackNotHelpfulAria,children:(0,Q.jsx)(I,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,Q.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:g.noCatalysisReportHint}),(0,Q.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,g.relatedThreadsTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.relatedThreadsDescription})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:m,disabled:d,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:d?g.openingChat:g.openThread}),(0,Q.jsx)(`button`,{type:`button`,onClick:h,disabled:d,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:g.newThread})]})]}),u.length>0?(0,Q.jsx)(`div`,{className:`space-y-2`,children:u.slice(0,5).map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>_(`/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,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||g.noteDiscussionFallback}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:g.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:g.noThreads})]})]})]})}function bt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,Q.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function xt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,Q.jsx)(`span`,{children:e})]},e)}function St(e,t){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,Q.jsx)(`span`,{children:e})]},e)}function Ct(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,Q.jsx)(`span`,{children:e})]},e)}function wt(e){return(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function Tt(e){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function Et(e){return e.language}var Dt=()=>i(()=>import(`./block-editor-Dhj5f4Bx.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),Ot=()=>i(()=>import(`./markdown-editor-jD1LPiP-.js`).then(e=>e.n),__vite__mapDeps([20,1,3,18,6,21])),kt=(0,X.lazy)(()=>Dt().then(e=>({default:e.BlockEditor}))),At=(0,X.lazy)(()=>Ot().then(e=>({default:e.MarkdownEditor})));function jt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,Q.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function Mt(e){let t=(0,Z.c)(14),{mode:n,onModeChange:r,labels:i}=e,o;t[0]===i.edit?o=t[1]:(o={id:`wysiwyg`,label:i.edit,Icon:De},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:de},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:ne},t[4]=i.preview,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=[o,s,c],t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,Q.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,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&Dt(),t===`source`&&Ot()},onFocus:()=>{t===`wysiwyg`&&Dt(),t===`source`&&Ot()},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,Q.jsx)(o,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=u,t[12]=r,t[13]=d):d=t[13],d}function Nt(e){let t=(0,Z.c)(15),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:s,clearHeaderOnCleanup:c,onOpenSearch:u,autoFocus:d,onAutoFocusConsumed:f}=e,p=a===void 0?!0:a,m=c===void 0?!0:c,h=d===void 0?!1:d,g=l(Pt),_;t[0]===g?_=t[1]:(_=o(g),t[0]=g,t[1]=_);let v=_.notes.lightboxClose,y;t[2]!==h||t[3]!==s||t[4]!==m||t[5]!==n||t[6]!==f||t[7]!==r||t[8]!==u||t[9]!==i||t[10]!==p?(y=(0,Q.jsx)(Ft,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:s,clearHeaderOnCleanup:m,onOpenSearch:u,autoFocus:h,onAutoFocusConsumed:f}),t[2]=h,t[3]=s,t[4]=m,t[5]=n,t[6]=f,t[7]=r,t[8]=u,t[9]=i,t[10]=p,t[11]=y):y=t[11];let b;return t[12]!==v||t[13]!==y?(b=(0,Q.jsx)(Ze,{closeLabel:v,children:y}),t[12]=v,t[13]=y,t[14]=b):b=t[14],b}function Pt(e){return e.language}function Ft({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:s=!0,onOpenSearch:c,autoFocus:m=!1,onAutoFocusConsumed:g}){let v=l(e=>e.language),y=o(v).notes,b=o(v).automations.suggestions,S=p(),C=u(e=>e.resolved)===`dark`,{openImage:w}=Ye(),[T,E]=(0,X.useState)(`wysiwyg`),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(``),[F,ee]=(0,X.useState)(360),[I,R]=(0,X.useState)(!1),[te,ne]=(0,X.useState)(!1),[re,z]=(0,X.useState)(!1),ie=(0,X.useRef)(!1),ae=(0,X.useRef)(!1),B=(0,X.useRef)(null),V=(0,X.useRef)(null),H=(0,X.useRef)(null),U=(0,X.useRef)(null),se=(0,X.useRef)(null),ue=(0,X.useRef)(null),de=(0,X.useRef)(null),fe=(0,X.useRef)(null),pe=(0,X.useRef)(null),me=he(e=>e.setPageHeader),W=he(e=>e.clearPageHeader),{data:G,mutate:K}=f(e?[`note-detail`,e]:null,()=>le(e)),{data:ge=[],mutate:_e}=f(e?[`note-threads`,e]:null,()=>Oe(e),{revalidateOnFocus:!1}),q=k!==null;(0,X.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&K()};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[K,e]),(0,X.useEffect)(()=>{ie.current=!1,P(``),A(null),O(null),ae.current=!1,pe.current=null},[e]),(0,X.useEffect)(()=>{!G||ie.current||(P(G.title??``),ie.current=!0)},[G]),(0,X.useEffect)(()=>{if(!m||!G||q||pe.current===e)return;let t=window.requestAnimationFrame(()=>{fe.current?.focus(),g?.()});return pe.current=e,()=>window.cancelAnimationFrame(t)},[m,q,G,e,g]);let J=G?new Date(G.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,ye=(0,X.useMemo)(()=>r?(0,Q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":y.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,h,i),children:(0,Q.jsx)(Re,{className:`h-4 w-4`,"aria-hidden":!0})}):null,[i,y.back,t,r]),be=(0,X.useCallback)(t=>{P(t),e&&(U.current=t,V.current&&clearTimeout(V.current),V.current=setTimeout(async()=>{let t=U.current;if(U.current=null,t!==null){M(!0);try{await oe(e,{title:t}),await K(),n?.()}catch{}finally{M(!1)}}},600))},[e,K,n]),xe=(0,X.useMemo)(()=>(0,Q.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,h),children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:N||J||void 0,children:N||J}),j?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:y.saving}):null]}),[y.saving,j,J,N]),Se=(0,X.useCallback)(async(t=!1)=>{z(!0);try{let n=await Te(e,{forceNew:t});await K(),await _e(),S(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){d({type:`error`,title:y.chatOpenFailedTitle,message:e instanceof Error?e.message:y.chatOpenFailedMessage})}finally{z(!1)}},[K,_e,S,e,y.chatOpenFailedMessage,y.chatOpenFailedTitle]),we=(0,X.useCallback)(async()=>{ne(!0);try{await ce(e),await K(),d({type:`success`,title:y.catalysisDone})}catch(e){d({type:`error`,title:y.catalysisFailed,message:e instanceof Error?e.message:y.chatOpenFailedMessage})}finally{ne(!1)}},[K,e]),Ee=(0,X.useCallback)(()=>{O(D===`breakdown`?null:`breakdown`),!G?.aiDeep?.catalysis?.report&&!te&&we()},[D,te,we,G?.aiDeep?.catalysis?.report]),De=(0,X.useMemo)(()=>(0,Q.jsxs)(`div`,{className:a(`flex items-center gap-2`,h),children:[c?(0,Q.jsx)(`button`,{type:`button`,onClick:c,"aria-label":y.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Q.jsx)(Ne,{className:`h-4 w-4`,"aria-hidden":!0})}):null,(0,Q.jsxs)(`button`,{type:`button`,onClick:Ee,disabled:te,"aria-label":y.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`,D===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,Q.jsx)(Y,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),te?y.catalyzing:y.catalyzeButton]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>Se(!1),disabled:re,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,Q.jsx)(L,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),re?y.openingChat:y.openChatButton]}),(0,Q.jsx)(Mt,{mode:T,onModeChange:E,labels:{edit:y.modeEdit,source:y.modeSource,preview:y.modePreview}}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>O(D===`history`?null:`history`),"aria-label":y.history,className:a(`rounded-lg p-1.5 transition-colors`,D===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,Q.jsx)(Ce,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[te,Ee,Se,T,y.history,y.modeEdit,y.modePreview,y.modeSource,re,D,c,y.searchDialogTitle]);(0,X.useLayoutEffect)(()=>(me({startExtra:ye,main:G?xe:null,end:G?De:null}),()=>{s&&W()}),[s,W,De,xe,ye,G,me]);let ke=(0,X.useCallback)(t=>{e&&(H.current=t,B.current&&clearTimeout(B.current),B.current=setTimeout(async()=>{let t=H.current;if(H.current=null,t!==null){M(!0);try{await oe(e,{markdown:t}),await K(),n?.()}catch(e){d({type:`error`,title:y.saveFailed,message:e instanceof Error?e.message:y.saveFailedHint})}finally{M(!1)}}},600))},[e,K,y.saveFailed,y.saveFailedHint,n]),Ae=(0,X.useCallback)(t=>{x(e,t.timestamp).then(e=>{e&&A(e)})},[e]),je=(0,X.useCallback)(()=>{O(null),A(null)},[]),Me=(0,X.useCallback)(()=>{O(null),A(null),K(),n?.()},[K,n]);if((0,X.useEffect)(()=>()=>{B.current&&clearTimeout(B.current),V.current&&clearTimeout(V.current);let t=H.current,n=U.current;H.current=null,U.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&oe(e,r)},[e]),G===void 0)return(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(G===null)return(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:y.notFoundTitle}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y.notFoundDescription}),(0,Q.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:y.back})]});let Pe=q?k.title??``:N,Fe=q?k.markdown??``:G.markdown??``,Ie=new Date(G.createdAt).getTime(),Le=Number.isFinite(Ie)&&Date.now()-Ie<3600*1e3?(0,Q.jsx)(Be,{title:b.noteCreatedTitle,description:b.noteCreatedDescription,prompt:b.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(ve,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,Q.jsx)(ve,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,Q.jsx)(`div`,{ref:se,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:q?(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Pe&&(0,Q.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Pe}),Fe?(0,Q.jsx)(_,{noteId:e,content:Fe,className:`opacity-80`}):(0,Q.jsx)(`p`,{className:`italic text-fg-muted`,children:y.emptyPreview})]}):(0,Q.jsxs)(Q.Fragment,{children:[T===`wysiwyg`&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,Q.jsx)(`input`,{ref:fe,type:`text`,value:N,onChange:e=>be(e.target.value),onCompositionStart:()=>{ae.current=!0},onCompositionEnd:()=>{ae.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!ae.current&&!t.isComposing&&(e.preventDefault(),(se.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:y.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Le]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(X.Suspense,{fallback:(0,Q.jsx)(jt,{}),children:(0,Q.jsx)(kt,{initialContent:G.markdown??``,onChange:ke,noteId:e},`wysiwyg-${e}`)})})]}),T===`source`&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,Q.jsx)(`input`,{ref:fe,type:`text`,value:N,onChange:e=>be(e.target.value),placeholder:y.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Le]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(X.Suspense,{fallback:(0,Q.jsx)(jt,{}),children:(0,Q.jsx)(At,{initialContent:G.markdown??``,onChange:ke,isDark:C},`source-${e}`)})})]}),T===`preview`&&(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&w(t.currentSrc||t.src,t.alt)},children:[N&&(0,Q.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:N}),G.markdown?(0,Q.jsx)(_,{noteId:e,content:G.markdown,className:`[&_img]:cursor-zoom-in`}):(0,Q.jsx)(`p`,{className:`italic text-fg-muted`,children:y.emptyPreview})]})]})})]}),(0,Q.jsx)(`div`,{ref:ue,className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!I&&`transition-[width] duration-300 ease-in-out`),style:{width:D?F:0},children:(0,Q.jsxs)(`div`,{ref:de,className:`flex min-h-0 flex-1 flex-col`,style:{width:F},children:[(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),R(!0);let n=e.clientX,r=F,i=e.pointerId,a=0,o=F,s=F,c=()=>{a=0,s=o,D&&ue.current?.style.setProperty(`width`,`${s}px`),de.current?.style.setProperty(`width`,`${s}px`)},l=e=>{let t=r-(e.clientX-n);o=Math.max(280,Math.min(600,Math.round(t))),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}R(!1),ee(s),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},className:a(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,I&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:D===`history`?(0,Q.jsx)(vt,{noteId:e,activeTimestamp:k?.timestamp??null,onSelect:Ae,onClose:je,onRestored:Me}):D===`breakdown`?(0,Q.jsx)(yt,{noteId:e,note:G??null,catalyzing:te,onCatalyze:we,onClose:()=>O(null),noteThreads:ge,openingChat:re,onOpenChat:()=>Se(!1),onOpenNewChat:()=>Se(!0)}):null})]})})]})}var It=3e4;function Lt(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function Rt({placeholder:e,sendLabel:t,onCapture:n,onImagePick:r,onVoiceCapture:i,recordingLabel:o=`Recording…`,imageDisabled:s=!1,voiceDisabled:c=!1}){let[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(0),[_,v]=(0,X.useState)(!1),y=(0,X.useRef)(null),b=(0,X.useRef)(null),x=(0,X.useRef)(null),S=(0,X.useRef)([]),C=(0,X.useRef)(0),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.useCallback)(()=>{w.current&&=(clearInterval(w.current),null),T.current&&=(clearTimeout(T.current),null),x.current?.getTracks().forEach(e=>e.stop()),x.current=null,b.current=null,S.current=[],m(!1),g(0)},[]);(0,X.useEffect)(()=>()=>E(),[E]);let D=(0,X.useCallback)(async()=>{let e=b.current;if(!e||e.state!==`recording`)return;v(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-C.current)/1e3)),n=e.mimeType||Lt()||`audio/webm`,r=new Blob(S.current,{type:n});if(E(),r.size>0&&i){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,a=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await i(a,t)}finally{v(!1)}return}v(!1)},[E,i]),O=(0,X.useCallback)(async()=>{if(!(!i||_||p)&&!(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`))try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=Lt(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);x.current=e,b.current=n,S.current=[],C.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&S.current.push(e.data)},n.start(),m(!0),g(0),w.current=setInterval(()=>{g(Math.round((Date.now()-C.current)/1e3))},250),T.current=setTimeout(()=>{D()},It)}catch{E()}},[E,i,p,D,_]),k=(0,X.useCallback)(()=>{if(p){D();return}O()},[p,O,D]),A=(0,X.useCallback)(async e=>{let t=l.trim();if(!(!t||d)){f(!0),u(``);try{await n(t,e)}catch{u(t)}finally{f(!1),y.current?.focus()}}},[l,d,n]),j=(0,X.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),A()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),A({navigate:!1}))},[A]),M=d||_;return(0,Q.jsxs)(`div`,{className:a(`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,Q.jsx)(`button`,{type:`button`,onClick:r,disabled:M||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,Q.jsx)(xe,{className:`h-4 w-4`})}),i&&(0,Q.jsx)(`button`,{type:`button`,onClick:k,disabled:M||c||d,className:a(`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,Q.jsx)(be,{className:`h-4 w-4 fill-current`}):(0,Q.jsx)(pe,{className:`h-4 w-4`})}),p?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:o.replace(`{{seconds}}`,String(h))}):(0,Q.jsx)(`textarea`,{ref:y,value:l,onChange:e=>u(e.target.value),onKeyDown:j,placeholder:e,rows:1,disabled:M,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,Q.jsx)(`button`,{type:`button`,disabled:!l.trim()||M||p,onClick:e=>void A({navigate:!e.shiftKey}),"aria-label":t,className:a(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,l.trim()&&!M&&!p?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,Q.jsx)(Se,{className:`h-4 w-4`})})]})}var zt={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},Bt=240,Vt=320,Ht=520,Ut=560;function Wt(e){if(globalThis.localStorage===void 0)return Vt;try{let t=globalThis.localStorage.getItem(e);if(!t)return Vt;let n=Number(t);return Number.isFinite(n)?n:Vt}catch{return Vt}}function Gt(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var Kt={thought:q,todo:je,voice:pe,media:xe,bookmark:Ae,mixed:q,task:je};function qt(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Jt(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function Yt(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function Xt({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:i=!0,listTag:c,captureTags:u=[],listTitle:g,listDescription:_,emptyText:v,emptyDescription:y,listWidthStorageKey:x=`xopc.notes.listWidth`}){let C=o(l(e=>e.language)).notes,T=!!s(e=>e.token),[E,O]=(0,X.useReducer)(S,zt),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(``),[I,L]=(0,X.useState)(0),[R,te]=(0,X.useState)(()=>Wt(x)),[ne,ie]=(0,X.useState)(!1),[B,V]=(0,X.useState)(!1),[U,se]=(0,X.useState)(!1),[ce,le]=(0,X.useState)(null),de=(0,X.useRef)(null),fe=(0,X.useRef)(null),[me]=(0,X.useState)(()=>Date.now()),W=p(),K=(0,X.useCallback)(e=>{let t=de.current?.clientWidth??window.innerWidth,n=Math.max(Bt,t-Ut);return Math.max(Bt,Math.min(Math.min(Ht,n),e))},[]),_e=(0,X.useCallback)(e=>{let t=K(e);te(t),Gt(x,t)},[K,x]);(0,X.useLayoutEffect)(()=>{te(e=>K(e))},[K]);let{data:ve,mutate:J,isLoading:be}=f((0,X.useMemo)(()=>T?[`notes-list`,c,E.statusFilter,E.kindFilter,E.pinnedOnly]:null,[T,c,E.statusFilter,E.kindFilter,E.pinnedOnly]),()=>m({status:E.statusFilter===`all`?void 0:E.statusFilter,kind:E.kindFilter===`all`?void 0:E.kindFilter,tag:c,pinned:E.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),Se=be&&!ve,Ce=ve?.items??[],Te=ve?.total??0,De=j.trim(),{data:Oe,isLoading:ke}=f(T&&k&&De?[`notes-search`,c,De]:null,()=>m({search:De,tag:c,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),Y=Oe?.items??[],Re=e?Ce.some(t=>t.id===e):!0;(0,X.useEffect)(()=>{L(0)},[De]),(0,X.useEffect)(()=>{I>=Y.length&&L(Math.max(0,Y.length-1))},[I,Y.length]),(0,X.useEffect)(()=>{let e=()=>{J()};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[J]);let ze=he(e=>e.setPageHeader),Be=he(e=>e.clearPageHeader),Z=Te>0?C.noteCount.replace(`{{count}}`,String(Te)):null,Ve=C.searchDialogTitle,$=C.searchClose,He=C.searchClear,Ue=(0,X.useMemo)(()=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),className:a(`inline-flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,h),"aria-label":Ve,children:[(0,Q.jsx)(Ne,{className:`size-4`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:Ve})]}),[Ve]);(0,X.useLayoutEffect)(()=>{if(n)return T?(ze({startExtra:null,main:(0,Q.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,h),children:[(0,Q.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:g??C.title}),Z?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Z}):null]}),end:Ue}),()=>Be()):(Be(),()=>Be())},[Be,T,Ue,g,n,C.title,Z,e,ze]);let We=(0,X.useMemo)(()=>({justNow:C.justNow,minutesAgo:C.minutesAgo,today:C.today,yesterday:C.yesterday,daysAgo:C.daysAgo}),[C.justNow,C.minutesAgo,C.today,C.yesterday,C.daysAgo]),Ge=(0,X.useMemo)(()=>[{id:`recent`,label:C.viewRecent,description:C.viewRecentDescription,icon:ee,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:C.filterInbox,description:C.viewInboxDescription,icon:ye,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:C.pinned,description:C.viewPinnedDescription,icon:Ee,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:C.viewTasks,description:C.viewTasksDescription,icon:je,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:C.kindVoice,description:C.viewVoiceDescription,icon:pe,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:C.kindMedia,description:C.viewMediaDescription,icon:xe,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:C.kindBookmark,description:C.viewBookmarksDescription,icon:Ae,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:C.filterProcessed,description:C.viewProcessedDescription,icon:Fe,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:C.filterArchived,description:C.viewArchiveDescription,icon:Ie,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[C.filterArchived,C.filterInbox,C.filterProcessed,C.kindBookmark,C.kindMedia,C.kindVoice,C.pinned,C.viewArchiveDescription,C.viewBookmarksDescription,C.viewInboxDescription,C.viewMediaDescription,C.viewPinnedDescription,C.viewProcessedDescription,C.viewRecent,C.viewRecentDescription,C.viewTasks,C.viewTasksDescription,C.viewVoiceDescription]),Ke=Ge.find(e=>Jt(E,e))??Ge[0],qe=g??Ke.label,Je=_??Ke.description,Ye=(0,X.useCallback)(async(e,n)=>{let r=u.length?await b({markdown:e,kind:`thought`,tags:u,channel:`web`}):await re(e,`web`);await J(),n?.navigate!==!1&&W(Yt(t,r.id))},[t,u,J,W]),Xe=(0,X.useCallback)(async()=>{if(!U){se(!0);try{let e=await b({markdown:``,kind:`thought`,tags:u,channel:`web`});O({type:`patch`,patch:zt}),await J(),le(e.id),W(Yt(t,e.id))}catch(e){d({type:`error`,title:C.createBlankFailed,message:e instanceof Error?e.message:C.createBlankFailedHint})}finally{se(!1)}}},[t,u,U,J,C.createBlankFailed,C.createBlankFailedHint,W]),Ze=(0,X.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let t=e.files?.[0];if(t)try{await ae(t,`web`),await J()}catch(e){d({type:`error`,title:C.imageUploadFailed,message:e instanceof Error?e.message:C.imageUploadFailedHint})}},e.click()},[J,C.imageUploadFailed,C.imageUploadFailedHint]),Qe=(0,X.useCallback)(async(e,t)=>{try{await H(e,t,`web`),await J()}catch(e){d({type:`error`,title:C.voiceUploadFailed,message:e instanceof Error?e.message:C.voiceUploadFailedHint})}},[J,C.voiceUploadFailed,C.voiceUploadFailedHint]),$e=(0,X.useCallback)(async(e,t)=>{await oe(e,{pinned:t}),await J()},[J]),et=(0,X.useCallback)(async e=>{await oe(e,{status:`archived`}),await J()},[J]),tt=(0,X.useCallback)(async e=>{await Le(e),await J()},[J]),nt=(0,X.useCallback)(e=>{W(Yt(t,e))},[t,W]),ot=(0,X.useCallback)(e=>{W(Yt(t,e)),A(!1)},[t,W]),st=(0,X.useCallback)(e=>{if(Y.length){if(e.key===`ArrowDown`)e.preventDefault(),L(e=>Math.min(Y.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),L(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=Y[I]??Y[0];t&&ot(t.id)}}},[I,ot,Y]),ct=(0,X.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=fe.current;t.setPointerCapture(e.pointerId),ie(!0);let r=de.current?.clientWidth??window.innerWidth,i=Math.max(Bt,r-Ut),a=Math.min(Ht,i),o=e=>Math.max(Bt,Math.min(a,e)),s=e.clientX,c=o(R),l=e.pointerId,u=0,d=c,f=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let p=()=>{u=0,f=d,n&&(n.style.width=`${f}px`)},m=e=>{d=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(p))},h=()=>{u!==0&&(window.cancelAnimationFrame(u),p());try{t.releasePointerCapture(l)}catch{}ie(!1),de.current?.style.setProperty(`--notes-list-width`,`${f}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),te(f),Gt(x,f),window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,h)};window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,h)},[x,R]);(0,X.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),Xe())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Xe]);let lt=(0,X.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),_e(R-16)):e.key===`ArrowRight`?(e.preventDefault(),_e(R+16)):e.key===`Home`?(e.preventDefault(),_e(Bt)):e.key===`End`&&(e.preventDefault(),_e(Ht))},[_e,R]);return T?(0,Q.jsxs)(`div`,{ref:de,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,style:{"--notes-list-width":`${R}px`},children:[(0,Q.jsxs)(`section`,{ref:fe,className:a(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden bg-surface-panel`,!ne&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,B?`lg:w-0 lg:min-w-0 lg:max-w-0 lg:pointer-events-none`:`lg:w-[var(--notes-list-width)]`,e&&`hidden lg:flex`),"aria-hidden":B?!0:void 0,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-3 border-b border-edge-subtle p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,Q.jsx)(we,{value:Ke.id,onChange:e=>{let t=Ge.find(t=>t.id===e.target.value);t&&O({type:`patch`,patch:t.patch})},className:`-ml-1 block max-w-44 truncate rounded-lg border border-transparent bg-transparent px-1 py-0.5 text-sm font-semibold text-fg transition-colors hover:border-edge hover:bg-surface-base focus:border-accent focus:bg-surface-base focus:outline-none focus:ring-1 focus:ring-accent`,"aria-label":C.libraryTitle,children:Ge.map(e=>(0,Q.jsx)(Me,{value:e.id,children:e.label},e.id))}):(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:qe}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:Z??Je})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>V(!0),className:`hidden size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":C.collapseNotesList,title:C.collapseNotesList,children:(0,Q.jsx)(N,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:Xe,disabled:U,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":C.createBlankNote,title:C.createBlankShortcut,children:(0,Q.jsx)(w,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!0),className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":C.searchDialogTitle,children:(0,Q.jsx)(Ne,{className:`h-4 w-4`,"aria-hidden":!0})})]})]}),(0,Q.jsx)(Rt,{placeholder:C.quickCapturePlaceholder,sendLabel:C.send,onCapture:Ye,onImagePick:i?Ze:void 0,onVoiceCapture:i?Qe:void 0,recordingLabel:C.recording})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:Se?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,Q.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):Ce.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-2 px-6 py-16 text-center`,children:[(0,Q.jsx)(q,{className:`h-8 w-8 text-fg-muted`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:e&&!Re?C.noteOutsideCurrentView:v??C.noNotes}),e&&!Re?null:(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:y??C.noNotesDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!Re?(0,Q.jsx)(`div`,{className:`mb-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted`,children:C.noteOutsideCurrentView}):null,Ce.map((t,n)=>{let r=n>0?at(Ce[n-1].createdAt):null;return(0,Q.jsxs)(`div`,{children:[at(t.createdAt)!==r&&(0,Q.jsx)(`div`,{className:a(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:it(t.createdAt,me,We)}),(0,Q.jsx)(dt,{note:t,selected:t.id===e,onPress:nt,onPin:$e,onArchive:et,onDelete:tt,timeLabels:We,labels:{pin:C.pin,unpin:C.unpin,archive:C.archive,delete:C.delete,imageNote:C.imageNote,noText:C.noText}})]},t.id)})]})})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":C.resizeNotesList,"aria-valuemin":Bt,"aria-valuemax":Ht,"aria-valuenow":Math.round(R),tabIndex:0,onPointerDown:ct,onDoubleClick:()=>_e(Vt),onKeyDown:lt,title:C.resizeNotesList,className:a(`group relative hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,B?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-3 lg:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-0`),children:(0,Q.jsx)(`span`,{"aria-hidden":!0,className:a(`h-8 w-1 rounded-pill opacity-0 transition-[background-color,opacity,transform] duration-150`,`bg-edge-strong/55 group-hover:opacity-100 group-focus-visible:opacity-100`,`group-hover:scale-y-110 group-focus-visible:scale-y-110`,ne&&`bg-accent opacity-100 scale-y-125`)})}),(0,Q.jsxs)(`section`,{className:a(`relative min-w-0 flex-1 bg-surface-panel`,!e&&`hidden lg:flex`),children:[B?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>V(!1),className:`absolute left-3 top-3 z-10 hidden size-8 items-center justify-center rounded-lg border border-edge bg-surface-base text-fg-muted shadow-surface transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":C.expandNotesList,title:C.expandNotesList,children:(0,Q.jsx)(N,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,Q.jsx)(Nt,{noteId:e,onBack:()=>W(t),onSaved:()=>void J(),backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>A(!0),autoFocus:e===ce,onAutoFocusConsumed:()=>le(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(q,{className:`mx-auto h-9 w-9 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:C.emptyEditorTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:C.emptyEditorDescription}),(0,Q.jsxs)(`button`,{type:`button`,onClick:Xe,disabled:U,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,Q.jsx)(w,{className:`h-4 w-4`,"aria-hidden":!0}),U?C.creatingBlankNote:C.createBlankNote]})]})})]}),(0,Q.jsx)(P,{open:k,onOpenChange:A,children:(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(F,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(G,{className:`fixed left-1/2 top-24 z-[90] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(ge,{className:`text-sm font-semibold text-fg`,children:Ve}),(0,Q.jsx)(D,{className:`sr-only`,children:C.searchPlaceholder}),(0,Q.jsx)(ue,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":$,children:(0,Q.jsx)(z,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`p-4`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Ne,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{autoFocus:!0,type:`search`,value:j,onChange:e=>M(e.target.value),onKeyDown:st,placeholder:C.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-10 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),j?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(``),className:`absolute right-2 top-1/2 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":He,children:(0,Q.jsx)(z,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:De?ke&&!Oe?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):Y.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(q,{className:`h-7 w-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:C.searchNoResults}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:C.searchNoResultsDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:C.searchResultsCount.replace(`{{count}}`,String(Oe?.total??Y.length))}),Y.map((e,t)=>{let n=Kt[e.kind]||q,r=qt(e,{imageNote:C.imageNote,noText:C.noText});return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ot(e.id),onMouseEnter:()=>L(t),className:a(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===I?`bg-surface-active`:`hover:bg-surface-hover`),children:[(0,Q.jsx)(n,{className:`mt-0.5 h-4 w-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:rt(e.updatedAt,me,We)})]}),e.title?(0,Q.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,Q.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,Q.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]})]},e.id)})]}):(0,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(Ne,{className:`h-7 w-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:C.searchEmptyTitle}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:C.searchEmptyDescription})]})})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,Q.jsx)(q,{className:`h-10 w-10 text-fg-muted`}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C.needToken})]})}export{Ye as n,qe as r,Xt as t};