@xopcai/xopc 0.0.120 → 0.0.121

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 (239) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/dashscope/src/image-generation-provider.d.ts +6 -5
  3. package/dist/extensions/dashscope/src/image-generation-provider.js +40 -64
  4. package/dist/extensions/dashscope/src/image-generation-provider.js.map +1 -1
  5. package/dist/extensions/dashscope/src/index.d.ts +1 -1
  6. package/dist/extensions/dashscope/src/index.js +2 -2
  7. package/dist/extensions/dashscope/xopc.extension.json +3 -2
  8. package/dist/extensions/minimax/src/image-generation-provider.d.ts +7 -5
  9. package/dist/extensions/minimax/src/image-generation-provider.js +43 -37
  10. package/dist/extensions/minimax/src/image-generation-provider.js.map +1 -1
  11. package/dist/extensions/minimax/src/index.d.ts +1 -1
  12. package/dist/extensions/minimax/src/index.js +2 -2
  13. package/dist/extensions/minimax/xopc.extension.json +1 -1
  14. package/dist/extensions/telegram/xopc.extension.json +1 -1
  15. package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +41 -0
  16. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-APTlX9Sq.js → agent-avatar-dicebear-4AW4JgSU.js} +1 -1
  17. package/dist/gateway/static/root/assets/agents-2SVUUPlp.js +2 -0
  18. package/dist/gateway/static/root/assets/{app-management-settings-panel-DTKc5HHT.js → app-management-settings-panel-CE6GkGU2.js} +1 -1
  19. package/dist/gateway/static/root/assets/{appearance-settings-BTciFrE9.js → appearance-settings-BmaUjghw.js} +1 -1
  20. package/dist/gateway/static/root/assets/{apps-page-DT52OrbM.js → apps-page-BWeQ1I49.js} +1 -1
  21. package/dist/gateway/static/root/assets/{archive-plugin-CiHaUMII.js → archive-plugin-CX4_KWut.js} +1 -1
  22. package/dist/gateway/static/root/assets/{attachment-load-t4gSrNjL.js → attachment-load-jf-PIIUU.js} +1 -1
  23. package/dist/gateway/static/root/assets/{automation-suggestion-card-CtysjSoQ.js → automation-suggestion-card-BHk5rtJz.js} +1 -1
  24. package/dist/gateway/static/root/assets/automations-page-QHotl53D.js +1 -0
  25. package/dist/gateway/static/root/assets/{binary-plugins-BAbSldW5.js → binary-plugins-DG9XQikd.js} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-BNr_82xl.js → block-editor-Up_VIxLJ.js} +6 -6
  27. package/dist/gateway/static/root/assets/browser-settings-page-Cmwi6IIQ.js +8 -0
  28. package/dist/gateway/static/root/assets/{capability-presets-api-tzD702Gg.js → capability-presets-api-CGM4OyMw.js} +1 -1
  29. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-AGhTueAc.js → capability-presets-settings-panel-CzWt0LBb.js} +1 -1
  30. package/dist/gateway/static/root/assets/{channel-recipient-api-DL_KzwGE.js → channel-recipient-api-BEByL4_o.js} +1 -1
  31. package/dist/gateway/static/root/assets/channels-settings-BOMCUe2J.js +1 -0
  32. package/dist/gateway/static/root/assets/connectors-page-C-Dexk_F.js +2 -0
  33. package/dist/gateway/static/root/assets/dist-Mys7eFJ5.js +1 -0
  34. package/dist/gateway/static/root/assets/dist-wO9a2_ID.js +1 -0
  35. package/dist/gateway/static/root/assets/{dreaming-settings-BEwWA1yf.js → dreaming-settings-WPEj8pir.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-debug-page-Dl2kO0Sf.js → extension-debug-page-DZxa_j7-.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-DmbLPsx_.js → extension-page-CseziW53.js} +1 -1
  38. package/dist/gateway/static/root/assets/extension-settings-page-B_9J-xyo.js +1 -0
  39. package/dist/gateway/static/root/assets/{fetch-B3ME5Eri.js → fetch-Cs4ck8zA.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-config-api-DI9_BBTo.js → gateway-config-api-Dl223a7r.js} +1 -1
  41. package/dist/gateway/static/root/assets/gateway-settings-DdzbtW9R.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-startup-retry-CSZQTz6K.js → gateway-startup-retry-IvePwjFE.js} +1 -1
  43. package/dist/gateway/static/root/assets/goal-detail-page-Dxldogms.js +1 -0
  44. package/dist/gateway/static/root/assets/{goals-config-api-Bhzqrp2w.js → goals-config-api-CUCP6yCl.js} +1 -1
  45. package/dist/gateway/static/root/assets/goals-page-DU5Nd6Xp.js +2 -0
  46. package/dist/gateway/static/root/assets/goals-settings-Dj87qPxv.js +1 -0
  47. package/dist/gateway/static/root/assets/heartbeat-settings-Cgm5JmwH.js +1 -0
  48. package/dist/gateway/static/root/assets/index-BU1pvxmS.js +191 -0
  49. package/dist/gateway/static/root/assets/index-l54WfSqe.css +1 -0
  50. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-kMp08SlX.js → keyboard-shortcuts-settings-DJgYw0nB.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-C10aS4XO.js +2 -0
  52. package/dist/gateway/static/root/assets/{markdown-split-Bc0w40vz.js → markdown-split-gnQ_EiGo.js} +1 -1
  53. package/dist/gateway/static/root/assets/{media-plugins-DJ_HvgIy.js → media-plugins-CQV-mgJn.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-C6Kc4Jhf.js +3 -0
  55. package/dist/gateway/static/root/assets/models-hub-panel-B35CAfg6.js +2 -0
  56. package/dist/gateway/static/root/assets/note-detail-page-Brlwse8x.js +2 -0
  57. package/dist/gateway/static/root/assets/{note-image-lightbox-4zntqpZq.js → note-image-lightbox-BthwKjLA.js} +1 -1
  58. package/dist/gateway/static/root/assets/{notes-page-VocWOjoK.js → notes-page-CoAwRc7L.js} +1 -1
  59. package/dist/gateway/static/root/assets/{preview-open-alternatives-BbA7sRd_.js → preview-open-alternatives-BPMXC-2u.js} +1 -1
  60. package/dist/gateway/static/root/assets/remote-access-hub-B36RQ05h.js +1 -0
  61. package/dist/gateway/static/root/assets/{save-bar-controls-Dividh61.js → save-bar-controls-BEHqwZjz.js} +1 -1
  62. package/dist/gateway/static/root/assets/schedule-field-CMY25m97.js +1 -0
  63. package/dist/gateway/static/root/assets/schema-form-CxjxsFfg.js +1 -0
  64. package/dist/gateway/static/root/assets/sessions-page-73THChnj.js +1 -0
  65. package/dist/gateway/static/root/assets/settings-advanced-gate-CR9VsY-R.js +1 -0
  66. package/dist/gateway/static/root/assets/{settings-collapsible-section-BMCOfuE_.js → settings-collapsible-section-s-kiLAxP.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-form-section-DBkGwpIN.js → settings-form-section-CIxIEYxU.js} +1 -1
  68. package/dist/gateway/static/root/assets/settings-page-BJ1AhfKI.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-page-layout-NxoW5Y57.js → settings-page-layout--6qT7ZJa.js} +1 -1
  70. package/dist/gateway/static/root/assets/setup-status-panel-C1TtS1vJ.js +1 -0
  71. package/dist/gateway/static/root/assets/{share-preview-page-B0suFCfj.js → share-preview-page-BZADSbS1.js} +1 -1
  72. package/dist/gateway/static/root/assets/shares-settings-gqC8Rmhy.js +1 -0
  73. package/dist/gateway/static/root/assets/skill-reload-api-C9P-WYvS.js +1 -0
  74. package/dist/gateway/static/root/assets/skills-page-CEpSvOhF.js +2 -0
  75. package/dist/gateway/static/root/assets/{system-settings-panel-CrmEnyX4.js → system-settings-panel-Czjf0kLJ.js} +1 -1
  76. package/dist/gateway/static/root/assets/{typed-models-lib-BAsGn25g.js → typed-models-lib-Cmt8SYdI.js} +1 -1
  77. package/dist/gateway/static/root/assets/{use-channel-catalog-C7vcAoGb.js → use-channel-catalog-DyM-ckEQ.js} +1 -1
  78. package/dist/gateway/static/root/assets/user-profile-settings-panel-BygLv8vm.js +1 -0
  79. package/dist/gateway/static/root/assets/{utils-Dl9efgnV.js → utils-CloW8coB.js} +1 -1
  80. package/dist/gateway/static/root/assets/voice-api-key-field-BsoqJba6.js +1 -0
  81. package/dist/gateway/static/root/assets/{voice-player-store-CMC5NOJp.js → voice-player-store-DduWlJYV.js} +1 -1
  82. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CcQeX6l5.js +3 -0
  83. package/dist/gateway/static/root/assets/workflows-page-CeA8A9Ef.js +18 -0
  84. package/dist/gateway/static/root/index.html +7 -8
  85. package/dist/package.js +1 -1
  86. package/dist/src/agent/embedded/xopc-auth-storage.d.ts +1 -5
  87. package/dist/src/agent/embedded/xopc-auth-storage.js +2 -8
  88. package/dist/src/agent/embedded/xopc-auth-storage.js.map +1 -1
  89. package/dist/src/agent/embedded/xopc-tools-bridge.js +23 -0
  90. package/dist/src/agent/embedded/xopc-tools-bridge.js.map +1 -1
  91. package/dist/src/agent/goals/checklist-judge.js +1 -1
  92. package/dist/src/agent/goals/checklist-judge.js.map +1 -1
  93. package/dist/src/agent/goals/judge.js +1 -1
  94. package/dist/src/agent/goals/judge.js.map +1 -1
  95. package/dist/src/agent/image/tool-model-config.d.ts +2 -0
  96. package/dist/src/agent/image/tool-model-config.js +2 -2
  97. package/dist/src/agent/image/tool-model-config.js.map +1 -1
  98. package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
  99. package/dist/src/agent/image/understanding/pi-ai-provider.js.map +1 -1
  100. package/dist/src/agent/memory/compaction.d.ts +1 -1
  101. package/dist/src/agent/memory/compaction.js +1 -1
  102. package/dist/src/agent/memory/compaction.js.map +1 -1
  103. package/dist/src/agent/middleware/self-verify.d.ts +3 -0
  104. package/dist/src/agent/middleware/self-verify.js +18 -0
  105. package/dist/src/agent/middleware/self-verify.js.map +1 -1
  106. package/dist/src/agent/orchestration/agent-event-handler.js +28 -3
  107. package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
  108. package/dist/src/agent/prompt/sections/tooling.js +21 -5
  109. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  110. package/dist/src/agent/prompt/service-prompt-builder.js +1 -0
  111. package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
  112. package/dist/src/agent/prompt/system-prompt.d.ts +1 -0
  113. package/dist/src/agent/prompt/system-prompt.js +13 -1
  114. package/dist/src/agent/prompt/system-prompt.js.map +1 -1
  115. package/dist/src/agent/sandbox/path-policy.js +30 -6
  116. package/dist/src/agent/sandbox/path-policy.js.map +1 -1
  117. package/dist/src/agent/service/btw-query.js +1 -1
  118. package/dist/src/agent/service/btw-query.js.map +1 -1
  119. package/dist/src/agent/starter-agents.js +16 -16
  120. package/dist/src/agent/starter-agents.js.map +1 -1
  121. package/dist/src/agent/tools/image-generate-tool.js +12 -1
  122. package/dist/src/agent/tools/image-generate-tool.js.map +1 -1
  123. package/dist/src/agent/tools/session-search-tool.js +1 -1
  124. package/dist/src/agent/tools/session-search-tool.js.map +1 -1
  125. package/dist/src/agent/tools/web-extract.js +1 -1
  126. package/dist/src/agent/tools/web-extract.js.map +1 -1
  127. package/dist/src/agent-manifest/index.js +2 -2
  128. package/dist/src/agent-manifest/schema.d.ts +66 -0
  129. package/dist/src/agent-manifest/schema.js +28 -2
  130. package/dist/src/agent-manifest/schema.js.map +1 -1
  131. package/dist/src/automations/draft/automation-draft-service.js +1 -1
  132. package/dist/src/automations/draft/automation-draft-service.js.map +1 -1
  133. package/dist/src/cli/commands/agent.js +2 -2
  134. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  135. package/dist/src/cli/commands/models.js +1 -1
  136. package/dist/src/cli/commands/onboard/model.js +161 -11
  137. package/dist/src/cli/commands/onboard/model.js.map +1 -1
  138. package/dist/src/cli/commands/onboard.js +1 -1
  139. package/dist/src/cli/commands/profile.js +1 -1
  140. package/dist/src/cli/commands/tunnel.js +1 -1
  141. package/dist/src/cli/commands/update.js +1 -1
  142. package/dist/src/cli/extension-cli-register.js +1 -1
  143. package/dist/src/config/agent-profile.js +1 -1
  144. package/dist/src/config/default-model.d.ts +11 -0
  145. package/dist/src/config/default-model.js +19 -0
  146. package/dist/src/config/default-model.js.map +1 -0
  147. package/dist/src/config/index.js +3 -3
  148. package/dist/src/config/schema.d.ts +71 -11
  149. package/dist/src/config/schema.js +57 -22
  150. package/dist/src/config/schema.js.map +1 -1
  151. package/dist/src/connectors/registries/smithery.js +10 -9
  152. package/dist/src/connectors/registries/smithery.js.map +1 -1
  153. package/dist/src/daemon/install-plan.js +2 -1
  154. package/dist/src/daemon/install-plan.js.map +1 -1
  155. package/dist/src/gateway/agents-admin.js +1 -1
  156. package/dist/src/gateway/global-defaults-admin.js +6 -16
  157. package/dist/src/gateway/global-defaults-admin.js.map +1 -1
  158. package/dist/src/gateway/hono/lib/config-payload.d.ts +24 -0
  159. package/dist/src/gateway/hono/routes/agents.js +1 -79
  160. package/dist/src/gateway/hono/routes/agents.js.map +1 -1
  161. package/dist/src/gateway/hono/routes/models.js +132 -14
  162. package/dist/src/gateway/hono/routes/models.js.map +1 -1
  163. package/dist/src/gateway/hono/routes/voice.js +1 -1
  164. package/dist/src/gateway/hono/routes/voice.js.map +1 -1
  165. package/dist/src/gateway/image-capabilities.d.ts +11 -1
  166. package/dist/src/gateway/image-capabilities.js +32 -43
  167. package/dist/src/gateway/image-capabilities.js.map +1 -1
  168. package/dist/src/gateway/run-loop.js +1 -1
  169. package/dist/src/gateway/workspace-editor-path.js +9 -1
  170. package/dist/src/gateway/workspace-editor-path.js.map +1 -1
  171. package/dist/src/generated/bundled-image-generation-providers.d.ts +4 -2
  172. package/dist/src/generated/bundled-image-generation-providers.js +6 -4
  173. package/dist/src/generated/bundled-image-generation-providers.js.map +1 -1
  174. package/dist/src/mcp/channel-bridge.js +1 -1
  175. package/dist/src/media/paths.js +3 -4
  176. package/dist/src/media/paths.js.map +1 -1
  177. package/dist/src/notes/service.js +1 -1
  178. package/dist/src/notes/service.js.map +1 -1
  179. package/dist/src/providers/domestic-presets.d.ts +615 -0
  180. package/dist/src/providers/domestic-presets.js +834 -0
  181. package/dist/src/providers/domestic-presets.js.map +1 -0
  182. package/dist/src/providers/env-keys.js +29 -5
  183. package/dist/src/providers/env-keys.js.map +1 -1
  184. package/dist/src/providers/extension-stream-bridge.js +1 -1
  185. package/dist/src/providers/extension-stream-bridge.js.map +1 -1
  186. package/dist/src/providers/index.d.ts +5 -5
  187. package/dist/src/providers/index.js +101 -21
  188. package/dist/src/providers/index.js.map +1 -1
  189. package/dist/src/providers/model-discovery.d.ts +17 -0
  190. package/dist/src/providers/model-discovery.js +61 -0
  191. package/dist/src/providers/model-discovery.js.map +1 -0
  192. package/dist/src/providers/model-registry.d.ts +1 -1
  193. package/dist/src/providers/model-registry.js +1 -1
  194. package/dist/src/providers/model-registry.js.map +1 -1
  195. package/dist/src/providers/presentation.js +185 -14
  196. package/dist/src/providers/presentation.js.map +1 -1
  197. package/dist/src/session/session-title.js +1 -1
  198. package/dist/src/session/session-title.js.map +1 -1
  199. package/dist/src/tui/xopc-tui-keybindings.d.ts +1 -1
  200. package/dist/src/voice/tts/summarize.js +1 -1
  201. package/dist/src/voice/tts/summarize.js.map +1 -1
  202. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  203. package/dist/src/workflows/draft/workflow-draft-service.js.map +1 -1
  204. package/package.json +6 -6
  205. package/dist/gateway/static/root/assets/Combination-BzaXOLd9.js +0 -41
  206. package/dist/gateway/static/root/assets/agents-CFW_FS_V.js +0 -2
  207. package/dist/gateway/static/root/assets/automations-page-B2YvT3ES.js +0 -1
  208. package/dist/gateway/static/root/assets/browser-settings-page-BQEXPhDU.js +0 -8
  209. package/dist/gateway/static/root/assets/channels-settings-DRTutLlN.js +0 -1
  210. package/dist/gateway/static/root/assets/connectors-page-DneJVuge.js +0 -2
  211. package/dist/gateway/static/root/assets/dist-By6Rh2ee.js +0 -1
  212. package/dist/gateway/static/root/assets/dist-CkobR7mk.js +0 -1
  213. package/dist/gateway/static/root/assets/dist-DokQNVMQ.js +0 -1
  214. package/dist/gateway/static/root/assets/extension-settings-page-BS2rx40e.js +0 -1
  215. package/dist/gateway/static/root/assets/gateway-settings-DAFI_T0W.js +0 -1
  216. package/dist/gateway/static/root/assets/goal-detail-page-DLuz4jC9.js +0 -1
  217. package/dist/gateway/static/root/assets/goals-page-DTAfv9Ft.js +0 -2
  218. package/dist/gateway/static/root/assets/goals-settings-CWN2iirQ.js +0 -1
  219. package/dist/gateway/static/root/assets/heartbeat-settings-CkkkHvOi.js +0 -1
  220. package/dist/gateway/static/root/assets/index-CnjzMw5i.js +0 -191
  221. package/dist/gateway/static/root/assets/index-E1QinYKp.css +0 -1
  222. package/dist/gateway/static/root/assets/logs-page-CDXDlS_W.js +0 -2
  223. package/dist/gateway/static/root/assets/messages-CISb1HLv.js +0 -3
  224. package/dist/gateway/static/root/assets/models-hub-panel-BTwxMIgZ.js +0 -2
  225. package/dist/gateway/static/root/assets/note-detail-page-BBfOeB0m.js +0 -2
  226. package/dist/gateway/static/root/assets/remote-access-hub-CXwjuD_Q.js +0 -1
  227. package/dist/gateway/static/root/assets/schedule-field-pRheF2CO.js +0 -1
  228. package/dist/gateway/static/root/assets/schema-form-D6PiPxfr.js +0 -1
  229. package/dist/gateway/static/root/assets/sessions-page-CpcVySQK.js +0 -1
  230. package/dist/gateway/static/root/assets/settings-advanced-gate-BVy_TawT.js +0 -1
  231. package/dist/gateway/static/root/assets/settings-page-CZpNyCWn.js +0 -1
  232. package/dist/gateway/static/root/assets/setup-status-panel-MVHLLu_a.js +0 -1
  233. package/dist/gateway/static/root/assets/shares-settings-C6DBbQGo.js +0 -1
  234. package/dist/gateway/static/root/assets/skill-reload-api-6hJmhwSn.js +0 -1
  235. package/dist/gateway/static/root/assets/skills-page-Im1MA0Iw.js +0 -2
  236. package/dist/gateway/static/root/assets/user-profile-settings-panel-QAQWGelF.js +0 -1
  237. package/dist/gateway/static/root/assets/voice-api-key-field-D-6XueTv.js +0 -1
  238. package/dist/gateway/static/root/assets/workflow-run-setup-panel-DVPllR4k.js +0 -3
  239. package/dist/gateway/static/root/assets/workflows-page-B94WISTW.js +0 -18
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CISb1HLv.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-B3ME5Eri.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Aa as p,At as m,Ba as h,Ds as g,Dt as _,Et as v,Ft as y,Go as b,It as x,Ji as S,Lo as C,Lt as w,Mi as T,Mt as E,Ni as D,Nt as O,Oi as k,Ot as A,Pi as j,Pt as M,Qn as N,Qs as P,Rt as F,So as I,Tt as L,Ua as R,Ui as z,Va as B,Xi as V,Zn as H,aa as U,ba as ee,bo as te,ct as ne,ea as re,f as ie,fa as W,go as ae,ia as G,ji as oe,jt as se,ki as ce,la as le,li as ue,ni as de,no as fe,oa as K,ot as pe,qi as me,qs as he,ro as ge,sa as q,so as _e,st as ve,ta as J,ti as ye,to as be,ts as xe,ws as Se,zs as Ce}from"./index-CnjzMw5i.js";import{a as we,c as Te,d as Ee,f as De,l as Oe,n as ke,o as Ae,r as je,s as Me,t as Ne,u as Pe}from"./voice-api-key-field-D-6XueTv.js";import{t as Fe}from"./settings-advanced-gate-BVy_TawT.js";import{t as Ie}from"./settings-collapsible-section-BMCOfuE_.js";import{n as Le,t as Re}from"./settings-form-section-DBkGwpIN.js";import{i as ze,n as Be,t as Ve}from"./settings-page-layout-NxoW5Y57.js";import{n as He,t as Ue}from"./save-bar-controls-Dividh61.js";var Y=n(),X=e(t(),1),Z=r(),We=()=>c(De);function Ge(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 Ke={saving:!1,savedFlash:!1,error:void 0};function qe(){let e=o(e=>e.language),t=a(e),n=t.imageModelsSettings,r=!!s(e=>e.token),[i,c]=(0,X.useReducer)(ne,Ke),{saving:l,error:u}=i,p=ue(),m=(0,X.useMemo)(()=>new Set(p.map(e=>e.id)),[p]),{data:h=[],isLoading:g}=f(r?We():null,Ee,{revalidateOnFocus:!1}),_=h.some(e=>e.configured),v=Oe(h),y=v.credDirty;(0,X.useEffect)(()=>{if(!y)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[y]),He({id:`image-models`,dirty:y,saving:l,save:(0,X.useCallback)(async()=>{c({type:`patch`,patch:{saving:!0,error:void 0}});try{v.credDirty&&await v.saveCredentials(n.credentialsSaveError),c({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:n.saved})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{saving:!1}})}},[v,n.credentialsSaveError,n.saved]),discard:(0,X.useCallback)(()=>{v.credDirty&&v.onDiscardCredentials(),c({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[v])});let b=(0,X.useMemo)(()=>Ge(n),[n]),x=(0,X.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]);return r?g?(0,Z.jsxs)(`div`,{className:`flex w-full items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(I,{className:`size-4 animate-spin`}),` Loading…`]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u?(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:u}):null,(0,Z.jsx)(Ie,{advancedOnly:!0,icon:B,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:_,children:h.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Z.jsx)(Pe,{summaries:h,credDraft:v.credDraft,credBaseline:v.credBaseline,credDirty:v.credDirty,credSaving:v.credSaving,credError:v.credError,credSavedFlash:v.credSavedFlash,credNoopFlash:v.credNoopFlash,updateCredRow:v.updateCredRow,onDiscardCredentials:v.onDiscardCredentials,onSaveCredentials:()=>void v.saveCredentials(n.credentialsSaveError),extensionIds:m,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:x,messages:b})})]}):(0,Z.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Q=G;function Je(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Ye(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Xe(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,K,`dark:border-edge`)}function Ze(){return i(U,G)}function Qe(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function $e(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 et=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],tt=[{id:`whisper-1`,name:`Whisper-1`}],nt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],rt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],it=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],at=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],ot=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],st=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],ct=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],lt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],ut=[{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 dt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function ft(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function pt(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 mt(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 ht(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function gt(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function _t(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 vt(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 yt(){let e=a(o(e=>e.language)).voiceSettings,t=!!s(e=>e.token),[n,r]=(0,X.useReducer)(vt,{form:null,baseline:null}),i=n.form,l=n.baseline,[u,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}=de(t),{data:w,error:T,isLoading:E,mutate:D}=f(t?c(`/api/voice/models`):null,ke,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=f(t?c(`/api/voice/providers`):null,je,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=f(t?c(`/api/voice/stt-providers`):null,we,{revalidateOnFocus:!1}),P=(0,X.useMemo)(()=>O?.providers??[],[O]),F=(0,X.useMemo)(()=>j?.providers??[],[j]),L=(0,X.useMemo)(()=>b?.payload?.config===void 0?null:Ae(b.payload.config),[b]),R=(0,X.useMemo)(()=>!i||!l?!1:JSON.stringify(i)!==JSON.stringify(l),[i,l]);t?L!==null&&w!==void 0&&!v.current&&(y.current.parsed!==L||y.current.models!==w)&&(y.current={parsed:L,models:w},r({type:`sync`,value:L}),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 z=!!(t&&(L===null||w===void 0||O===void 0||j===void 0)&&(S||E||A||N)),B=x instanceof Error?x.message:x?String(x):T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):M instanceof Error?M.message:M?String(M):null,V=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),H=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),U=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),ee=(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}}}}})},[]),te=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ne=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),re=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),ie=(0,X.useCallback)(e=>{v.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),W=(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(He({id:`voice`,dirty:R,saving:m,save:(0,X.useCallback)(async()=>{if(!(!i||m)){h(!0),_(null);try{await Me(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)(()=>{l&&(v.current=!1,r({type:`discard`}),_(null))},[l])}),!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(z)return(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(I,{className:`size-4 animate-spin`}),e.loading]})});if(!i||u===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??B??e.loadError}),(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:e.retry})]});let G=i.stt,oe=i.tts,se=ht(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)(bt,{v:e,stt:G,tts:oe}),(0,Z.jsx)(St,{v:e,apiKeyLabels:se,stt:G,models:u,sttProviders:F,updateStt:V,updateSttAlibaba:H,updateSttOpenai:U,updateSttFallback:ee}),(0,Z.jsx)(Dt,{v:e,apiKeyLabels:se,tts:oe,models:u,ttsProviders:P,updateTts:te,updateTtsAlibaba:ne,updateTtsOpenai:re,updateTtsEdge:ie,updateTtsMinimax:W,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 bt(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} · ${dt(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)(xt,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?pt(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)(xt,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${ft(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)(xt,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,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 xt(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 border border-edge bg-surface-panel px-3 py-2.5`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function St(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:et,p=o?.stt?.openai?.length?o.stt.openai:tt,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(Et),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)(ae,{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)(Ot,{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`,Q),children:[(0,Z.jsx)($,{children:n.stt.provider}),(0,Z.jsx)(`select`,{className:Ze(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[dt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,Z.jsx)(`select`,{className:Ze(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(Tt)}):a.provider===`openai`?(0,Z.jsx)(`select`,{className:Ze(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(wt)}):a.provider===`groq`?(0,Z.jsx)(`select`,{className:Ze(),value:m||nt[0].id,onChange:e=>w({model:e.target.value}),children:nt.map(Ct)}):(0,Z.jsx)(`input`,{className:Xe(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.apiKey}),(0,Z.jsx)(Ne,{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,Je(a.provider)?` ${Je(a.provider)}`:``]})]})]}),S.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Z.jsx)(kt,{field:e,value:gt(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Q},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 Ct(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function wt(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Tt(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Et(e){return e.key!==`apiKey`&&e.key!==`model`}function Dt({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:rt,m=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:it,h=r?.tts?.alibaba?.length?r.tts.alibaba:at,g=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:ot,_=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:st,v=r?.tts?.minimax?.length?r.tts.minimax:ct,y=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:lt,[b,x]=(0,X.useState)(e.tts.test.sampleText),[S,C]=(0,X.useState)({status:`idle`}),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.useCallback)(()=>{w.current?.pause(),w.current=null,T.current&&=(URL.revokeObjectURL(T.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,L=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}),C({status:`idle`})},[o]),z=(0,X.useCallback)(async()=>{let t=b.trim();if(!t){C({status:`error`,message:e.tts.test.emptyText});return}E(),C({status:`loading`});try{let r=await Te({text:t,provider:n.provider,providerConfig:A,...F?{model:F}:{},...L?{voice:L}:{}}),i=$e(r.audio,r.mimeType);T.current=i;let a=new Audio(i);w.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Qe(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>C({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>C({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),C({status:`playing`,summary:o})}catch(e){E(),C({status:`error`,message:e instanceof Error?e.message:String(e)})}},[F,L,A,E,b,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]),V=(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)(W,{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)(Ot,{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} ${ft(n.provider,e)}${L?` · ${L}`:``}`:`${e.tts.statusNeedsSetup} ${ft(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`,Q),children:[(0,Z.jsx)($,{children:e.tts.trigger}),(0,Z.jsxs)(`select`,{className:Ze(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`off`,children:e.tts.triggerOff}),(0,Z.jsx)(`option`,{value:`inbound`,children:e.tts.triggerInbound}),(0,Z.jsx)(`option`,{value:`tagged`,children:e.tts.triggerTagged}),(0,Z.jsx)(`option`,{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`,Q),children:[(0,Z.jsx)($,{children:e.tts.provider}),(0,Z.jsx)(`select`,{className:Ze(),value:n.provider,onChange:e=>R(e.target.value),children:D.map(t=>(0,Z.jsx)(`option`,{value:t.id,children:ft(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??mt(n.provider,e)]})]})]}),(0,Z.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,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`,Q),children:[(0,Z.jsx)($,{children:e.stt.apiKey}),(0,Z.jsx)(Ne,{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,Ye(n.provider)?` ${Ye(n.provider)}`:``]})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.stt.model}),(0,Z.jsx)(`select`,{className:Ze(),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`?h:v).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(`select`,{className:Ze(),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`?m:n.provider===`alibaba`?g:y).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(`select`,{className:Ze(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:_.map(e=>(0,Z.jsx)(`option`,{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)(`select`,{className:Ze(),value:``,onChange:e=>{let t=ut.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Z.jsx)(`option`,{value:``,children:e.tts.localCli.presetPlaceholder}),ut.map(e=>(0,Z.jsx)(`option`,{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(Xe(),`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(Xe(),`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)(`select`,{className:Ze(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`wav`,children:`wav`}),(0,Z.jsx)(`option`,{value:`mp3`,children:`mp3`}),(0,Z.jsx)(`option`,{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:Xe(),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)(kt,{field:e,value:gt(A,e),onChange:t=>V(e,t),className:e.type===`textarea`?`sm:col-span-2`:Q},e.key))}):null]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,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:S.status===`loading`,className:`h-9`,children:[S.status===`loading`?(0,Z.jsx)(I,{className:`size-4 animate-spin`}):(0,Z.jsx)(ge,{className:`size-4`}),S.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,onClick:()=>{E(),C(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:S.status!==`playing`,className:`h-9`,children:[(0,Z.jsx)(p,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Z.jsx)(`textarea`,{className:i(Xe(),`mt-3 min-h-20 resize-y`),value:b,onChange:e=>x(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:[b.length,`/1000`]}),S.status===`playing`||S.status===`done`?(0,Z.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[S.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,S.summary]}):null,S.status===`error`?(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:S.message}):null]})]})]}):null]})]})}function Ot(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?`border-accent/45 bg-accent/10 text-fg shadow-surface dark:bg-accent/15`:`border-edge bg-surface-panel text-fg hover:border-accent/35 hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl border px-4 py-3 text-left transition-colors`,K,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 kt(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(_t(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)(`select`,{id:s,className:Ze(),value:l,required:n.required,onChange:e=>a(_t(n,e.target.value)),children:(n.options??[]).map(At)}):n.type===`textarea`?(0,Z.jsx)(`textarea`,{id:s,className:i(Xe(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(_t(n,e.target.value))}):n.type===`password`?(0,Z.jsx)(V,{id:s,className:o,value:l,onChange:e=>a(_t(n,e)),placeholder:n.placeholder,labels:me}):(0,Z.jsx)(`input`,{id:s,className:Xe(),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(_t(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 At(e){return(0,Z.jsx)(`option`,{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 jt(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 Mt(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),ye()}async function Nt(e){let t=await l(c(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Pt(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 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`,K,`dark:border-edge`)}function It(){return i(U,G)}var Lt=[`brave`,`tavily`,`bing`,`searxng`];function Rt(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var zt=pe();function Bt(){let e=a(o(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!s(e=>e.token),[c,l]=(0,X.useReducer)(zt,{form:null,baseline:null}),u=c.form,f=c.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:C}=de(r);ve({enabled:r,parsed:(0,X.useMemo)(()=>y?.payload?.config===void 0?null:jt(y.payload.config),[y]),dirty:_.current,trackedParsedRef:v,dispatch:l,onResetDirty:()=>{_.current=!1}});let w=!!(r&&x&&y===void 0&&!b),T=b instanceof Error?b.message:b?String(b):null,E=(0,X.useMemo)(()=>!u||!f?!1:JSON.stringify(u)!==JSON.stringify(f),[u,f]),D=(0,X.useCallback)(e=>{_.current=!0,l({type:`patch`,patch:e})},[]);return He({id:`search`,dirty:E,saving:p,save:(0,X.useCallback)(async()=>{if(!(!u||p)){m(!0),g(null);try{await Mt(u),_.current=!1,l({type:`saved`,value:u}),d({type:`success`,title:t.saved})}catch(e){g(e instanceof Error?e.message:t.saveError)}finally{m(!1)}}},[u,p,t.saveError]),discard:(0,X.useCallback)(()=>{f&&(_.current=!1,l({type:`discard`}),g(null))},[f])}),r?w?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Z.jsx)(I,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading})]}):u?(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)(Re,{children:[(0,Z.jsx)(Le,{icon:R,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Z.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Z.jsx)(Pt,{label:t.regionLabel,description:t.regionDesc,children:(0,Z.jsxs)(`select`,{className:It(),value:u.regionMode,onChange:e=>D({regionMode:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`auto`,children:t.regionAuto}),(0,Z.jsx)(`option`,{value:`cn`,children:t.regionCn}),(0,Z.jsx)(`option`,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Z.jsx)(Fe,{children:(0,Z.jsxs)(Re,{children:[(0,Z.jsx)(Le,{icon:Ce,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:u.blocklistEnabled,onChange:e=>D({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)(Pt,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Z.jsx)(`textarea`,{className:i(Ft(),`min-h-[6rem] font-mono text-xs`),value:u.blocklistDomains.join(`
2
- `),placeholder:t.blocklistDomainsPlaceholder,disabled:!u.blocklistEnabled,onChange:e=>{D({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Z.jsxs)(Re,{children:[(0,Z.jsx)(Le,{icon:R,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Z.jsx)(Pt,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:50,className:Ft(),value:u.maxResults,onChange:e=>D({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}),u.providers.map((n,r)=>(0,Z.jsx)(Vt,{row:n,providerIndex:r,labels:t,secretLabels:S(e.providersSettings),onChange:e=>{let t=[...u.providers];t[r]=e,D({providers:t})},onRemove:()=>{D({providers:u.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:()=>D({providers:[...u.providers,Rt()]}),children:[(0,Z.jsx)(be,{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??T??t.loadError}),(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void C(),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 Vt(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=()=>Nt(r).then(Ht),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(It(),`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=Lt.map(e=>(0,Z.jsx)(`option`,{value:e,children:a.providerTypes[e]},e)),t[6]=a.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,Z.jsx)(`select`,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==n?(g=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,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)(ee,{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)(Pt,{label:a.urlLabel,description:a.urlDesc,children:(0,Z.jsx)(`input`,{type:`url`,className:Ft(),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)(V,{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)(Pt,{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 border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=D):D=t[53],D}function Ht(e){return e.apiKey??null}var Ut=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function Wt(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function Gt(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function Kt(){let e=await u(c(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(Wt(t)||`HTTP ${e.status}`);return{...t.payload,config:Gt(t.payload.config)}}async function qt(e){let t=await u(c(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(Wt(n)||`HTTP ${t.status}`);return await x(),n.payload}function Jt(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}function Yt(){let e=(0,Y.c)(31),t=s(en),n=!!t,{data:r,isLoading:i}=de(n),a;e[0]===n?a=e[1]:(a=n?c(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},e[4]=l):l=e[4];let{data:u,isLoading:d}=f(a,o,l),p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[5]=p):p=e[5];let{data:m,isLoading:h}=f(n?w:null,$t,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:b}=f(n?y:null,Qt,v),x;bb0:{if(!u||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],x=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==u||e[12]!==_?(t=se(u,O(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=u,e[12]=_,e[13]=t):t=e[13],x=t}let S=x,C;bb1:{if(!b){C=null;break bb1}let t;e[14]===b.config?t=e[15]:(t=Gt(b.config),e[14]=b.config,e[15]=t),C=t}let T=C,E;if(e[16]!==S||e[17]!==T||e[18]!==u||e[19]!==_){E=[];let t=new Set((u??[]).filter(Zt).map(Xt)),n;e[21]===T?n=e[22]:(n=new Set(T?Object.keys(T.providers):[]),e[21]=T,e[22]=n);let r=n;for(let e of S){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?T.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;E.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(T){let t;e[23]===T.providers?t=e[24]:(t=Object.entries(T.providers),e[23]=T.providers,e[24]=t);for(let[e,n]of t)E.some(t=>t.id===e)||E.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=S,e[17]=T,e[18]=u,e[19]=_,e[20]=E}else E=e[20];let D=E,k=i||d||h,A;return e[25]!==S||e[26]!==D||e[27]!==T||e[28]!==k||e[29]!==_?(A={cards:D,loading:k,builtinRows:S,customConfig:T,allModels:_},e[25]=S,e[26]=D,e[27]=T,e[28]=k,e[29]=_,e[30]=A):A=e[30],A}function Xt(e){return e.id}function Zt(e){return e.configured}function Qt(){return Kt()}function $t(){return F()}function en(e){return e.token}function tn(e){let t=(0,Y.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=Yt();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-surface-hover`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(rn)})]}),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(nn),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)(be,{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 border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,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)(be,{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)(an,{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 nn(e){return e.configured}function rn(e){return(0,Z.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function an(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 border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,J.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)(Se,{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)(h,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let g;t[19]===r.manage?g=t[20]:(g=(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]=g);let _;t[21]!==g||t[22]!==p?(_=(0,Z.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,g]}),t[21]=g,t[22]=p,t[23]=_):_=t[23];let v;return t[24]!==a||t[25]!==_||t[26]!==d?(v=(0,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 on(e){let t=await u(c(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function sn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function cn(e,t){let n=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function ln(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function un(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function dn(e){let t=await u(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var fn=[`common`,`specialty`,`enterprise`,`oauth`,`extension`];function pn(e){let t=new Map;for(let e of fn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}var mn={ollama:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`},lmstudio:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`},openrouter:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``},zhipuCn:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`},zaiGeneral:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`}};function hn(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var gn=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function _n(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,K,`dark:border-edge`)}function vn(){return i(U,G)}function yn(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function bn(e){return e===`text,image`?[`text`,`image`]:[`text`]}function xn(e){let t=(0,Y.c)(21),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,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)(oe,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,N)}),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`,H),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.providerId||t[15]!==d.type?(x=(0,Z.jsxs)(T,{children:[y,(0,Z.jsx)(ce,{className:b,children:d.type===`pick`?(0,Z.jsx)(Cn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>f({type:`builtin`,providerId:e}),onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Z.jsx)(wn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v}):(0,Z.jsx)(Dn,{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.providerId,t[15]=d.type,t[16]=x):x=t[16];let S;return t[17]!==g||t[18]!==n||t[19]!==x?(S=(0,Z.jsx)(D,{open:n,onOpenChange:g,children:x}),t[17]=g,t[18]=n,t[19]=x,t[20]=S):S=t[20],S}function Sn(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`,J.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(le,{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)(k,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function Cn(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=L[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=pn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,Z.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=h);let _;t[11]===o.close?_=t[12]:(_=(0,Z.jsx)(Sn,{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)(R,{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 x;t[17]===a?x=t[18]:(x=e=>a(e.target.value),t[17]=a,t[18]=x);let S=o.searchPlaceholder,C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,K),t[19]=C):C=t[19];let w;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==x?(w=(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:x,placeholder:S,autoComplete:`off`,autoFocus:!0,className:C})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=x,t[23]=w):w=t[23];let T;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(T=u?null:(0,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`,J.press),children:[(0,Z.jsx)(b,{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)(g,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=o.addCustom,t[25]=o.customDescription,t[26]=c,t[27]=u,t[28]=T):T=t[28];let E;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(E=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:fn.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`,J.press),children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Z.jsx)(Se,{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]=E):E=t[34];let D;t[35]!==T||t[36]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=D):D=t[37];let O;return t[38]!==w||t[39]!==D||t[40]!==v?(O=(0,Z.jsxs)(Z.Fragment,{children:[v,w,D]}),t[38]=w,t[39]=D,t[40]=v,t[41]=O):O=t[41],O}function wn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=L[e],[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),[y,b]=(0,X.useState)(!1),x=(0,X.useRef)(null),C=a(r).providersSettings,w=S(C),T=(0,X.useMemo)(()=>v(e,r),[e,r]),D=c?.supportsApiKey!==!1,O=c?.supportsOAuth===!0,[k,A]=(0,X.useState)(null),[M,N]=(0,X.useState)(null),[P,F]=(0,X.useState)(`idle`),[R,z]=(0,X.useState)(null),[B,H]=(0,X.useState)(null),[U,ee]=(0,X.useState)(``),te=P===`waiting`||P===`waiting_code`;(0,X.useEffect)(()=>{if(!k||!te)return;let e=window.setInterval(()=>{(async()=>{try{let t=await sn(k);t.status===`waiting_auth`||t.status===`waiting_code`?(F(t.status===`waiting_code`?`waiting_code`:`waiting`),N(t.message??null),z(t.authUrl??null),H(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),F(`success`),N(t.message??C.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),F(`error`),N(t.error??t.message??C.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[k,te,s,C.revokeFailed,C.saved]),(0,X.useEffect)(()=>()=>{k&&un(k).catch(()=>{})},[k]);let ne=async()=>{F(`waiting`),N(C.oauthStarting),h(null);try{A((await on(e)).sessionId)}catch(e){F(`error`),N(e instanceof Error?e.message:C.revokeFailed)}},re=async()=>{if(k){try{await ln(k)}catch{}F(`idle`),N(null),A(null),z(null),H(null)}},ie=async()=>{if(!(!k||!U.trim()))try{await cn(k,U.trim()),ee(``),N(C.oauthProcessingCode)}catch(e){F(`error`),N(e instanceof Error?e.message:C.revokeFailed)}},W=async()=>{let t=u.trim();if(!(!t||!D)){p(!0),h(null);try{await E({[e]:t}),b(!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`,J.press),"aria-label":n.back,children:(0,Z.jsx)(g,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Z.jsx)(Sn,{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,D?(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)(V,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:w,inputRef:x,onKeyDown:e=>{e.key===`Enter`&&W()}})]}):null,O?(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:C.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:C.oauthHint})]}),(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:te,onClick:()=>void ne(),children:[te?(0,Z.jsx)(I,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,C.oauth]})]}),M?(0,Z.jsx)(`p`,{className:i(`text-xs`,P===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:M}):null,P===`waiting`||P===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[R?(0,Z.jsxs)(`a`,{href:R,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:[C.openAuthPage,(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void re(),children:C.cancelOAuth})]}):null,B?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:B}):null,P===`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=>ee(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ie(),placeholder:C.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`,K)}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,onClick:()=>void ie(),children:C.submitCode})]}):null]}):null,T.length>0&&D?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.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:[_(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}),D?(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!u.trim()||f||y,onClick:()=>void W(),children:y?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(Se,{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)(I,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Tn(e=`custom`){if(e!==`custom`&&mn[e]){let t=mn[e];return{preset:e,providerId:hn(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function En(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:mn[t.key]?{...Tn(t.key),modelIds:e.modelIds}:e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Dn({customConfig:e,labels:t,language:n,onBack:r,onSaved:o}){let[s,c]=(0,X.useReducer)(En,void 0,()=>Tn()),[l,u]=(0,X.useState)(!1),d=S(a(n).providersSettings),{preset:f,providerId:p,baseUrl:m,api:h,apiKey:_,modelIds:v,error:y}=s,b=async()=>{let n=p.trim(),r=m.trim();if(!n){c({type:`setError`,value:t.providerIdRequired});return}if(!r){c({type:`setError`,value:t.baseUrlRequired});return}let i=v.map(e=>e.trim()).filter(Boolean);u(!0),c({type:`setError`,value:null});try{let t=e?.providers??{},a={baseUrl:r,api:h,apiKey:_.trim()||void 0,models:i.map(e=>({id:e}))};await qt({providers:{...t,[n]:a}}),o()}catch(e){c({type:`setError`,value:e instanceof Error?e.message:t.saveError})}finally{u(!1)}},x=p.trim()&&m.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:r,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,J.press),"aria-label":t.back,children:(0,Z.jsx)(g,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:t.step2CustomTitle}),(0,Z.jsx)(Sn,{label:t.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:t.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:t.presetLabel}),(0,Z.jsxs)(`select`,{id:`custom-preset`,value:f,onChange:e=>c({type:`applyPreset`,key:e.target.value}),className:vn(),children:[(0,Z.jsx)(`option`,{value:`custom`,children:t.presetCustom}),(0,Z.jsx)(`option`,{value:`ollama`,children:t.presetOllama}),(0,Z.jsx)(`option`,{value:`lmstudio`,children:t.presetLmStudio}),(0,Z.jsx)(`option`,{value:`openrouter`,children:t.presetOpenRouter}),(0,Z.jsx)(`option`,{value:`zhipuCn`,children:t.presetZhipuCn}),(0,Z.jsx)(`option`,{value:`zaiGeneral`,children:t.presetZaiGeneral})]})]}),(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:t.providerIdLabel}),(0,Z.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:p,onChange:e=>c({type:`setProviderId`,value:e.target.value}),placeholder:t.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,K)})]}),(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:t.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:m,onChange:e=>c({type:`setBaseUrl`,value:e.target.value}),placeholder:t.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,K)})]}),(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:t.apiTypeLabel}),(0,Z.jsx)(`select`,{id:`custom-api-type`,value:h,onChange:e=>c({type:`setApi`,value:e.target.value}),className:vn(),children:Ut.map(e=>(0,Z.jsx)(`option`,{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:t.apiKeyLabel}),(0,Z.jsx)(V,{id:`custom-api-key`,value:_,onChange:e=>c({type:`setApiKey`,value:e}),placeholder:t.apiKeyPlaceholder,labels:d})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.modelIdLabel}),v.map((e,n)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>c({type:`updateModelId`,index:n,value:e.target.value}),placeholder:t.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,K)}),v.length>1?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c({type:`removeModelSlot`,index:n}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,J.press),children:(0,Z.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${n}`)),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>c({type:`addModelSlot`}),children:[(0,Z.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}),t.addModel]})]}),y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):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:r,children:t.cancel}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!x||l,onClick:()=>void b(),children:l?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(I,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t.saving]}):t.save})]})]})}function On(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}:Jt(``),t[0]=n,t[1]=l);let[u,d]=(0,X.useState)(l),[f,p]=(0,X.useState)(kn),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=yn(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)(j,{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(re,`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)(le,{className:`size-4`}),t[25]=O):O=t[25];let A;t[26]===c.close?A=t[27]:(A=(0,Z.jsx)(k,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:D,"aria-label":c.close,children:O})}),t[26]=c.close,t[27]=A);let M;t[28]!==E||t[29]!==A?(M=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[E,A]}),t[28]=E,t[29]=A,t[30]=M):M=t[30];let N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=N):N=t[31];let P;t[32]===c.modelId?P=t[33]:(P=(0,Z.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,N]}),t[32]=c.modelId,t[33]=P);let F;t[34]===f?F=t[35]:(F=i(_n(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=F);let I=u.id||``,L;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>h(`id`,e.target.value),t[36]=L):L=t[36];let R=!r,z;t[37]!==F||t[38]!==I||t[39]!==R?(z=(0,Z.jsx)(`input`,{className:F,value:I,onChange:L,placeholder:`e.g. llama3.1:8b`,disabled:R}),t[37]=F,t[38]=I,t[39]=R,t[40]=z):z=t[40];let B;t[41]===f?B=t[42]:(B=f.has(`id`)?(0,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]=B);let V;t[43]!==P||t[44]!==z||t[45]!==B?(V=(0,Z.jsxs)(`div`,{children:[P,z,B]}),t[43]=P,t[44]=z,t[45]=B,t[46]=V):V=t[46];let H;t[47]===c.displayName?H=t[48]:(H=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=H);let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=_n(),t[49]=U):U=t[49];let ee=u.name||``,te;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>h(`name`,e.target.value),t[50]=te):te=t[50];let ne;t[51]===ee?ne=t[52]:(ne=(0,Z.jsx)(`input`,{className:U,value:ee,onChange:te}),t[51]=ee,t[52]=ne);let ie;t[53]!==H||t[54]!==ne?(ie=(0,Z.jsxs)(`div`,{children:[H,ne]}),t[53]=H,t[54]=ne,t[55]=ie):ie=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 ae;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ae=vn(),t[58]=ae):ae=t[58];let G;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>h(`input`,bn(e.target.value)),t[59]=G):G=t[59];let oe;t[60]===c?oe=t[61]:(oe=gn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=oe);let se;t[62]!==S||t[63]!==oe?(se=(0,Z.jsx)(`select`,{className:ae,value:S,onChange:G,children:oe}),t[62]=S,t[63]=oe,t[64]=se):se=t[64];let ce;t[65]!==W||t[66]!==se?(ce=(0,Z.jsxs)(`div`,{children:[W,se]}),t[65]=W,t[66]=se,t[67]=ce):ce=t[67];let ue=u.reasoning||!1,de;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>h(`reasoning`,e.target.checked),t[68]=de):de=t[68];let fe;t[69]===ue?fe=t[70]:(fe=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ue,onChange:de}),t[69]=ue,t[70]=fe);let K;t[71]!==c.reasoning||t[72]!==fe?(K=(0,Z.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fe,c.reasoning]}),t[71]=c.reasoning,t[72]=fe,t[73]=K):K=t[73];let pe;t[74]!==ce||t[75]!==K?(pe=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,K]}),t[74]=ce,t[75]=K,t[76]=pe):pe=t[76];let me;t[77]===c.contextWindow?me=t[78]:(me=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=me);let he;t[79]===f?he=t[80]:(he=i(_n(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=he);let ge=u.contextWindow??128e3,_e;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=_e):_e=t[81];let ve;t[82]!==he||t[83]!==ge?(ve=(0,Z.jsx)(`input`,{type:`number`,min:1,className:he,value:ge,onChange:_e}),t[82]=he,t[83]=ge,t[84]=ve):ve=t[84];let J;t[85]===f?J=t[86]:(J=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]=J);let ye;t[87]!==me||t[88]!==ve||t[89]!==J?(ye=(0,Z.jsxs)(`div`,{children:[me,ve,J]}),t[87]=me,t[88]=ve,t[89]=J,t[90]=ye):ye=t[90];let be;t[91]===c.maxOutputTokens?be=t[92]:(be=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=be);let xe;t[93]===f?xe=t[94]:(xe=i(_n(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=xe);let Se=u.maxTokens??16384,Ce;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Ce):Ce=t[95];let we;t[96]!==xe||t[97]!==Se?(we=(0,Z.jsx)(`input`,{type:`number`,min:1,className:xe,value:Se,onChange:Ce}),t[96]=xe,t[97]=Se,t[98]=we):we=t[98];let Te;t[99]===f?Te=t[100]:(Te=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]=Te);let Ee;t[101]!==be||t[102]!==we||t[103]!==Te?(Ee=(0,Z.jsxs)(`div`,{children:[be,we,Te]}),t[101]=be,t[102]=we,t[103]=Te,t[104]=Ee):Ee=t[104];let De;t[105]!==ye||t[106]!==Ee?(De=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ye,Ee]}),t[105]=ye,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]===c.costSection?Oe=t[109]:(Oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Oe);let ke;t[110]===c.costInput?ke=t[111]:(ke=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=ke);let Ae;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=_n(),t[112]=Ae):Ae=t[112];let je=u.cost?.input??0,Me;t[113]===u.cost?Me=t[114]:(Me=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]=Me);let Ne;t[115]!==je||t[116]!==Me?(Ne=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ae,value:je,onChange:Me}),t[115]=je,t[116]=Me,t[117]=Ne):Ne=t[117];let Pe;t[118]!==ke||t[119]!==Ne?(Pe=(0,Z.jsxs)(`div`,{children:[ke,Ne]}),t[118]=ke,t[119]=Ne,t[120]=Pe):Pe=t[120];let Fe;t[121]===c.costOutput?Fe=t[122]:(Fe=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Fe);let Ie;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=_n(),t[123]=Ie):Ie=t[123];let Le=u.cost?.output??0,Re;t[124]===u.cost?Re=t[125]:(Re=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]=Re);let ze;t[126]!==Le||t[127]!==Re?(ze=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[126]=Le,t[127]=Re,t[128]=ze):ze=t[128];let Be;t[129]!==Fe||t[130]!==ze?(Be=(0,Z.jsxs)(`div`,{children:[Fe,ze]}),t[129]=Fe,t[130]=ze,t[131]=Be):Be=t[131];let Ve;t[132]!==Pe||t[133]!==Be?(Ve=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Pe,Be]}),t[132]=Pe,t[133]=Be,t[134]=Ve):Ve=t[134];let He;t[135]!==Oe||t[136]!==Ve?(He=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Oe,Ve]}),t[135]=Oe,t[136]=Ve,t[137]=He):He=t[137];let Ue;t[138]!==V||t[139]!==ie||t[140]!==pe||t[141]!==De||t[142]!==He?(Ue=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[V,ie,pe,De,He]}),t[138]=V,t[139]=ie,t[140]=pe,t[141]=De,t[142]=He,t[143]=Ue):Ue=t[143];let We;t[144]===c.cancel?We=t[145]:(We=(0,Z.jsx)(k,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=We);let Ge=r?c.addModelConfirm:c.saveModelConfirm,Ke;t[146]!==y||t[147]!==Ge?(Ke=(0,Z.jsx)(q,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:Ge}),t[146]=y,t[147]=Ge,t[148]=Ke):Ke=t[148];let qe;t[149]!==We||t[150]!==Ke?(qe=(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[We,Ke]}),t[149]=We,t[150]=Ke,t[151]=qe):qe=t[151];let Q;return t[152]!==M||t[153]!==Ue||t[154]!==qe?(Q=(0,Z.jsxs)(Z.Fragment,{children:[M,Ue,qe]}),t[152]=M,t[153]=Ue,t[154]=qe,t[155]=Q):Q=t[155],Q}function kn(){return new Map}function An(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)(oe,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,N)}),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`,H,`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)(On,{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)(T,{children:[u,(0,Z.jsx)(ce,{className:d,onOpenAutoFocus:jn,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 jn(e){return e.preventDefault()}function Mn(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=()=>M(n).then(Nn),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)(V,{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 Nn(e){return e.apiKey??null}function Pn(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)(oe,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,N)}),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`,H),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)(T,{children:[p,(0,Z.jsx)(ce,{className:m,children:o?(0,Z.jsx)(In,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Z.jsx)(Fn,{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 Fn({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=L[e],d=n.filter(t=>t.provider===e),[f,p]=(0,X.useState)(l?.apiKey??``),[h,g]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(!1),T=a(o).providersSettings,D=l?.supportsApiKey!==!1,O=l?.supportsOAuth===!0,M=l?.authMode===`oauth`&&l.authStatus===`connected`,N=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[P,F]=(0,X.useState)(null),[R,z]=(0,X.useState)(null),[B,V]=(0,X.useState)(`idle`),[H,U]=(0,X.useState)(null),[ne,re]=(0,X.useState)(null),[W,ae]=(0,X.useState)(``),G=B===`waiting`||B===`waiting_code`,oe=(0,X.useMemo)(()=>v(e,o),[e,o]),se=f!==(l?.apiKey??``),ce=async()=>{let t=f.trim();if(!(!t||!D||m(t))){g(!0),S(null);try{await E({[e]:t}),b(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){S(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}};(0,X.useEffect)(()=>{if(!P||!G)return;let e=window.setInterval(()=>{(async()=>{try{let t=await sn(P);t.status===`waiting_auth`||t.status===`waiting_code`?(V(t.status===`waiting_code`?`waiting_code`:`waiting`),z(t.message??null),U(t.authUrl??null),re(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),V(`success`),z(t.message??T.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),V(`error`),z(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,G,s,c,T.revokeFailed,T.saved]),(0,X.useEffect)(()=>()=>{P&&un(P).catch(()=>{})},[P]);let ue=async()=>{try{await A(e),c(),s()}catch{}},de=async()=>{V(`waiting`),z(T.oauthStarting),S(null);try{F((await on(e)).sessionId)}catch(e){V(`error`),z(e instanceof Error?e.message:T.revokeFailed)}},fe=async()=>{if(P){try{await ln(P)}catch{}V(`idle`),z(null),F(null),U(null),re(null)}},pe=async()=>{if(!(!P||!W.trim()))try{await cn(P,W.trim()),ae(``),z(T.oauthProcessingCode)}catch(e){V(`error`),z(e instanceof Error?e.message:T.revokeFailed)}},me=async()=>{try{await dn(e),c(),s()}catch(e){S(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)(j,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,Z.jsx)(k,{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`,J.press),children:(0,Z.jsx)(le,{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,D?(0,Z.jsx)(Mn,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{p(e),b(!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)(he,{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)(xe,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,O?(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:M?T.sourceOauth:T.oauthHint})]}),M?(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:G,onClick:()=>void de(),children:[G?(0,Z.jsx)(I,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),R?(0,Z.jsx)(`p`,{className:i(`text-xs`,B===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:R}):null,B===`waiting`||B===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[H?(0,Z.jsxs)(`a`,{href:H,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)(xe,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:T.cancelOAuth})]}):null,ne?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}):null,B===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:W,onChange:e=>ae(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`,K)}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,onClick:()=>void pe(),children:T.submitCode})]}):null]}):null,oe.length>0&&D?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oe.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:[_(e,r),(0,Z.jsx)(xe,{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}),x?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(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)(ee,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:D&&se&&!m(f.trim())?(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!f.trim()||h||y,onClick:()=>void ce(),children:y?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(I,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Z.jsx)(ie,{open:C,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ue(),onCancel:()=>w(!1)})]})}function In({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,g]=(0,X.useState)(l?.models??[]),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(null),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),A=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:m(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},M=async()=>{let e=A({models:h});if(e){v(!0),b(null);try{await qt(e),s(),o()}catch(e){b(e instanceof Error?e.message:n.saveError)}finally{v(!1)}}},N=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await qt({providers:r}),s(),o()}catch{}},P=(e,t)=>{O({model:e,isNew:t}),E(!0)},F=async e=>{if(!D)return;let t=D.isNew?[...h,e]:h.map(t=>t.id===e.id?e:t);g(t);let r=A({models:t});if(r)try{await qt(r),s()}catch(e){b(e instanceof Error?e.message:n.saveError)}},L=async e=>{let t=h.filter(t=>t.id!==e);g(t),w(null);let r=A({models:t});if(r)try{await qt(r),s()}catch(e){b(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)(j,{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)(k,{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`,J.press),children:(0,Z.jsx)(le,{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`,K)})]}),(0,Z.jsx)(Mn,{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:()=>P(null,!0),children:[(0,Z.jsx)(be,{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`,J.press),onClick:()=>P(e,!1),"aria-label":c.editModel,children:(0,Z.jsx)(_e,{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`,J.press),onClick:()=>w(e.id),"aria-label":c.removeModel,children:(0,Z.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):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:()=>S(!0),children:[(0,Z.jsx)(ee,{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:_,onClick:()=>void M(),children:_?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(I,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Z.jsx)(ie,{open:x,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void N(),onCancel:()=>S(!1)}),(0,Z.jsx)(ie,{open:C!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,C??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{C&&L(C)},onCancel:()=>w(null)}),(0,Z.jsx)(An,{open:T,onOpenChange:e=>{E(e),e||O(null)},providerId:e,model:D?.model??null,isNew:D?.isNew??!1,onSave:e=>void F(e),m:c})]})}var Ln=[`services`,`image-models`,`voice`,`search`];function Rn(e){let t=(e??``).trim();return Ln.includes(t)?t:`services`}function zn(){let e=(0,Y.c)(59),t=o(Vn),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.modelsHub,[s,c]=P(),l;e[2]===s?l=e[3]:(l=Rn(s.get(`tab`)),e[2]=s,e[3]=l);let u=l,[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=Yt(),g;e[4]!==i.servicesHint||e[5]!==i.tabs.services?(g={id:`services`,icon:fe,label:i.tabs.services,hint:i.servicesHint},e[4]=i.servicesHint,e[5]=i.tabs.services,e[6]=g):g=e[6];let _;e[7]!==i.imageModelsHint||e[8]!==i.tabs.imageModels?(_={id:`image-models`,icon:C,label:i.tabs.imageModels,hint:i.imageModelsHint},e[7]=i.imageModelsHint,e[8]=i.tabs.imageModels,e[9]=_):_=e[9];let v;e[10]!==i.tabs.voice||e[11]!==i.voiceHint?(v={id:`voice`,icon:ae,label:i.tabs.voice,hint:i.voiceHint},e[10]=i.tabs.voice,e[11]=i.voiceHint,e[12]=v):v=e[12];let y;e[13]!==i.searchHint||e[14]!==i.tabs.search?(y={id:`search`,icon:R,label:i.tabs.search,hint:i.searchHint},e[13]=i.searchHint,e[14]=i.tabs.search,e[15]=y):y=e[15];let b;e[16]!==g||e[17]!==_||e[18]!==v||e[19]!==y?(b=[g,_,v,y],e[16]=g,e[17]=_,e[18]=v,e[19]=y,e[20]=b):b=e[20];let x=b,S;e[21]===c?S=e[22]:(S=e=>{c(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=c,e[22]=S);let w=S,T=Bn,E=r.settingsSections.credentials,D=i.subtitle,O;e[23]===t?O=e[24]:(O=z(t,`configuration`),e[23]=t,e[24]=O);let k;e[25]!==i.docsLink||e[26]!==i.subtitle||e[27]!==r.settingsSections.credentials||e[28]!==O?(k=(0,Z.jsx)(Be,{title:E,subtitle:D,docsLink:O,docsLabel:i.docsLink}),e[25]=i.docsLink,e[26]=i.subtitle,e[27]=r.settingsSections.credentials,e[28]=O,e[29]=k):k=e[29];let A;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Ue,{}),e[30]=A):A=e[30];let j;e[31]!==u||e[32]!==i.tabsAria||e[33]!==w||e[34]!==x?(j=(0,Z.jsx)(ze,{items:x,activeTab:u,onChange:w,ariaLabel:i.tabsAria,tabIdPrefix:`hub-tab`,panelIdPrefix:`hub-panel`}),e[31]=u,e[32]=i.tabsAria,e[33]=w,e[34]=x,e[35]=j):j=e[35];let M;e[36]!==u||e[37]!==i.connectedProviders||e[38]!==x?(M=x.map(e=>(0,Z.jsx)(Un,{id:e.id,activeTab:u,hint:e.hint,children:e.id===`services`?(0,Z.jsx)(tn,{labels:i.connectedProviders,onAdd:()=>f(!0),onManage:(e,t)=>m({providerId:e,isCustom:t})}):(0,Z.jsx)(Hn,{tab:e.id})},e.id)),e[36]=u,e[37]=i.connectedProviders,e[38]=x,e[39]=M):M=e[39];let N;e[40]!==d||e[41]!==i.addProviderDialog||e[42]!==t||e[43]!==h.builtinRows||e[44]!==h.customConfig?(N=(0,Z.jsx)(xn,{open:d,onOpenChange:f,builtinRows:h.builtinRows,customConfig:h.customConfig,labels:i.addProviderDialog,language:t,onSaved:T}),e[40]=d,e[41]=i.addProviderDialog,e[42]=t,e[43]=h.builtinRows,e[44]=h.customConfig,e[45]=N):N=e[45];let F;e[46]!==i.manageProviderDialog||e[47]!==t||e[48]!==p||e[49]!==h.allModels||e[50]!==h.builtinRows||e[51]!==h.customConfig?(F=p?(0,Z.jsx)(Pn,{open:!0,onOpenChange:e=>{e||m(null)},providerId:p.providerId,isCustom:p.isCustom,builtinRows:h.builtinRows,customConfig:h.customConfig,allModels:h.allModels,labels:i.manageProviderDialog,language:t,onSaved:T}):null,e[46]=i.manageProviderDialog,e[47]=t,e[48]=p,e[49]=h.allModels,e[50]=h.builtinRows,e[51]=h.customConfig,e[52]=F):F=e[52];let I;return e[53]!==k||e[54]!==j||e[55]!==M||e[56]!==N||e[57]!==F?(I=(0,Z.jsxs)(Ve,{children:[k,A,j,M,N,F]}),e[53]=k,e[54]=j,e[55]=M,e[56]=N,e[57]=F,e[58]=I):I=e[58],I}function Bn(){x()}function Vn(e){return e.language}function Hn(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)(qe,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(yt,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Bt,{}),t[2]=e):e=t[2],e}}}function Un({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 border border-edge 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{zn as ModelsHubPanel};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-BNr_82xl.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-CnjzMw5i.js","assets/preload-helper-zJ_50EbN.js","assets/dist-CkobR7mk.js","assets/Combination-BzaXOLd9.js","assets/dist-DokQNVMQ.js","assets/vendor-react-BOUWij0V.js","assets/cn-BQ_8x0bT.js","assets/vendor-swr-BIWyz7Rc.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-Ba72bFmP.js","assets/config-reload-event-Bjh2zoKp.js","assets/messages-CISb1HLv.js","assets/fetch-B3ME5Eri.js","assets/gateway-startup-retry-CSZQTz6K.js","assets/toast-z0toXu32.js","assets/theme-store-Bt6vAkSB.js","assets/index-E1QinYKp.css","assets/vendor-codemirror-CNP1wPe7.js","assets/note-image-lightbox-4zntqpZq.js","assets/voice-player-store-CMC5NOJp.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-AssmZFx4.js","assets/code-editor-dZTY2dRW.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-CISb1HLv.js";import{n as s}from"./locale-store-Ba72bFmP.js";import{i as c}from"./theme-store-Bt6vAkSB.js";import{r as l}from"./toast-z0toXu32.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$t as d,Bo as f,Bt as p,Gt as m,Ht as h,Jt as g,Kt as ee,Na as _,Qt as te,Sa as v,Us as y,Ut as ne,Vi as b,Vs as re,Wt as x,Xs as S,Ya as C,Zo as w,Zs as T,ds as E,en as D,es as O,i as k,la as A,rn as j,so as M,tn as N,xa as P,yo as ie,zi as ae}from"./index-CnjzMw5i.js";import{n as oe,t as se}from"./note-image-lightbox-4zntqpZq.js";import{t as ce}from"./automation-suggestion-card-CtysjSoQ.js";import{r as F}from"./note-time-hm6JO_Wi.js";var I=n(),L=e(t(),1),R=r(),z={edit:M,ai_edit:_,sync:C,restore:y};function B(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function le({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let c=o(s(e=>e.language)).notes,d=c,{data:p}=u(e?[`note-history`,e]:null,()=>m(e)),[h,g]=(0,L.useState)(!1),[ee,_]=(0,L.useState)(null),te=(0,L.useCallback)(async t=>{g(!0);try{await D(e,t),l({type:`success`,title:c.restoreSuccess}),_(null),i()}catch{l({type:`error`,title:c.restoreFailed})}finally{g(!1)}},[e,c.restoreSuccess,c.restoreFailed,i]),v=Date.now();return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,R.jsx)(f,{className:`h-4 w-4`,"aria-hidden":!0}),c.history]}),(0,R.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,R.jsx)(A,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:p?.length?(0,R.jsx)(`ul`,{className:`divide-y divide-edge`,children:p.map(e=>{let r=z[e.trigger]??M,i=t===e.timestamp,o=ee===e.timestamp;return(0,R.jsxs)(`li`,{children:[(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:B(e.trigger,c)}),(0,R.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:F(e.timestamp,v,d)})]}),e.snippet&&(0,R.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,R.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:c.restoreConfirm}),(0,R.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),te(e.timestamp)},disabled:h,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:h?`...`:c.restore}),(0,R.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),_(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,R.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),_(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:c.restore})})]},e.timestamp)})}):(0,R.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:c.historyEmpty}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:c.historyEmptyDescription})]})})]})}function ue(e){let t=(0,I.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:l,noteThreads:f,openingChat:p,onOpenChat:m,onOpenNewChat:h}=e,g=o(s(q)).notes,ee=S(),y=r?.aiDeep?.catalysis,b=y?.report??null,x;t[0]===n?x=t[1]:(x=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=x);let C;t[2]===n?C=t[3]:(C=()=>ne(n),t[2]=n,t[3]=C);let w;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},t[4]=w):w=t[4];let{data:T,mutate:E,isLoading:D}=u(x,C,w),O;t[5]===n?O=t[6]:(O=async e=>{try{await d(n,e)}catch{}},t[5]=n,t[6]=O);let k=O,A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,R.jsx)(_,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=A):A=t[7];let j;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,R.jsx)(re,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=j):j=t[8];let M;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,R.jsx)(ie,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=M):M=t[9],(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,(0,R.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:g.catalysisSectionTitle})]}),(0,R.jsx)(`button`,{type:`button`,onClick:l,"aria-label":g.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:j})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,R.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:g.catalysisSectionDescription}),T?(0,R.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.contextStatusTitle}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void E(()=>te(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,R.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,T.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:T.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:T.status})]}),(0,R.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:g.contextStatusDetail.replace(`{{attachments}}`,String(T.attachments.length)).replace(`{{tokens}}`,String(T.tokenEstimate??0))}),T.attachments.length>0?(0,R.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:T.attachments.slice(0,5).map(K)}):null]}):null,(0,R.jsx)(`button`,{type:`button`,onClick:c,disabled:i,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:i?g.processing:b?g.recatalyze:g.catalyzeAction}),b?(0,R.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.valueHypothesis}),(0,R.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:b.valueHypothesis})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.targetUsers}),(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:b.targetUsers.slice(0,5).map(G)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.keyQuestions}),(0,R.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.keyQuestions.slice(0,3).map(W)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.mvpPathLabel}),(0,R.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.mvpPath.slice(0,3).map(U)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.risks}),(0,R.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.risks.slice(0,3).map(H)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.nextActions}),(0,R.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.nextActions.slice(0,4).map(V)})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,R.jsx)(`span`,{className:`text-xs text-fg-muted`,children:g.confidenceLabel.replace(`{{percent}}`,String(Math.round(b.confidence*100)))}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>void k(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,y?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackHelpfulAria,children:(0,R.jsx)(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void k(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,y?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackNotHelpfulAria,children:(0,R.jsx)(v,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,R.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,R.jsxs)(`section`,{className:`mt-6 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[M,g.relatedThreadsTitle]}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.relatedThreadsDescription})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:m,disabled:p,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:p?g.openingChat:g.openThread}),(0,R.jsx)(`button`,{type:`button`,onClick:h,disabled:p,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})]})]}),f.length>0?(0,R.jsx)(`div`,{className:`space-y-2`,children:f.slice(0,5).map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ee(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||g.noteDiscussionFallback}),(0,R.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:g.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,R.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 V(e){return(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,R.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function H(e){return(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,R.jsx)(`span`,{children:e})]},e)}function U(e,t){return(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,R.jsx)(`span`,{children:e})]},e)}function W(e){return(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,R.jsx)(`span`,{children:e})]},e)}function G(e){return(0,R.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function K(e){return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,R.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function q(e){return e.language}var J=()=>i(()=>import(`./block-editor-BNr_82xl.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])),Y=()=>i(()=>import(`./markdown-editor-AssmZFx4.js`).then(e=>e.n),__vite__mapDeps([23,1,3,19,7,24])),de=(0,L.lazy)(()=>J().then(e=>({default:e.BlockEditor}))),fe=(0,L.lazy)(()=>Y().then(e=>({default:e.MarkdownEditor})));function pe(){let e=(0,I.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,R.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,R.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,R.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,R.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function me(e){let t=(0,I.c)(14),{mode:n,onModeChange:r,labels:i}=e,o;t[0]===i.edit?o=t[1]:(o={id:`wysiwyg`,label:i.edit,Icon:w},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:E},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:O},t[4]=i.preview,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=[o,s,c],t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,R.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,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&J(),t===`source`&&Y()},onFocus:()=>{t===`wysiwyg`&&J(),t===`source`&&Y()},className:a(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,R.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 X(e){let t=(0,I.c)(9),{noteId:n,onBack:r,onSaved:i}=e,a=s(he),c;t[0]===a?c=t[1]:(c=o(a),t[0]=a,t[1]=c);let l=c.notes.lightboxClose,u;t[2]!==n||t[3]!==r||t[4]!==i?(u=(0,R.jsx)(Z,{noteId:n,onBack:r,onSaved:i}),t[2]=n,t[3]=r,t[4]=i,t[5]=u):u=t[5];let d;return t[6]!==l||t[7]!==u?(d=(0,R.jsx)(se,{closeLabel:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8],d}function he(e){return e.language}function Z({noteId:e,onBack:t,onSaved:n}){let r=s(e=>e.language),i=o(r).notes,d=o(r).automations.suggestions,m=S(),te=c(e=>e.resolved)===`dark`,{openImage:v}=oe(),[y,ne]=(0,L.useState)(`wysiwyg`),[C,w]=(0,L.useState)(null),[T,E]=(0,L.useState)(null),[D,O]=(0,L.useState)(!1),[A,M]=(0,L.useState)(``),[P,se]=(0,L.useState)(360),[F,I]=(0,L.useState)(!1),[z,B]=(0,L.useState)(!1),[V,H]=(0,L.useState)(!1),U=(0,L.useRef)(!1),W=(0,L.useRef)(!1),G=(0,L.useRef)(null),K=(0,L.useRef)(null),q=(0,L.useRef)(null),J=(0,L.useRef)(null),Y=(0,L.useRef)(null),X=ae(e=>e.setPageHeader),he=ae(e=>e.clearPageHeader),{data:Z,mutate:Q}=u(e?[`note-detail`,e]:null,()=>h(e)),{data:ge=[],mutate:_e}=u(e?[`note-threads`,e]:null,()=>ee(e),{revalidateOnFocus:!1});(0,L.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&Q()};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[Q,e]),(0,L.useEffect)(()=>{U.current=!1,M(``),E(null),w(null),W.current=!1},[e]),(0,L.useEffect)(()=>{!Z||U.current||(M(Z.title??``),U.current=!0)},[Z]);let ve=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,ye=(0,L.useMemo)(()=>(0,R.jsx)(`button`,{type:`button`,onClick:t,"aria-label":i.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,b),children:(0,R.jsx)(re,{className:`h-4 w-4`,"aria-hidden":!0})}),[i.back,t]),be=(0,L.useCallback)(t=>{M(t),e&&(J.current=t,K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let t=J.current;if(J.current=null,t!==null){O(!0);try{await N(e,{title:t}),await Q(),n?.()}catch{}finally{O(!1)}}},600))},[e,Q,n]),xe=(0,L.useMemo)(()=>(0,R.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,b),children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:A||ve||void 0,children:A||ve}),D?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:i.saving}):null]}),[i.saving,D,ve,A]),$=(0,L.useCallback)(async(t=!1)=>{H(!0);try{let n=await g(e,{forceNew:t});await Q(),await _e(),m(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){l({type:`error`,title:i.chatOpenFailedTitle,message:e instanceof Error?e.message:i.chatOpenFailedMessage})}finally{H(!1)}},[Q,_e,m,e,i.chatOpenFailedMessage,i.chatOpenFailedTitle]),Se=(0,L.useCallback)(async()=>{B(!0);try{await p(e),await Q(),l({type:`success`,title:i.catalysisDone})}catch(e){l({type:`error`,title:i.catalysisFailed,message:e instanceof Error?e.message:i.chatOpenFailedMessage})}finally{B(!1)}},[Q,e]),Ce=(0,L.useCallback)(()=>{w(C===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!z&&Se()},[C,z,Se,Z?.aiDeep?.catalysis?.report]),we=(0,L.useMemo)(()=>(0,R.jsxs)(`div`,{className:a(`flex items-center gap-2`,b),children:[(0,R.jsxs)(`button`,{type:`button`,onClick:Ce,disabled:z,"aria-label":i.catalysisSectionTitle,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,C===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,R.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),z?i.catalyzing:i.catalyzeButton]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>$(!1),disabled:V,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,R.jsx)(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),V?i.openingChat:i.openChatButton]}),(0,R.jsx)(me,{mode:y,onModeChange:ne,labels:{edit:i.modeEdit,source:i.modeSource,preview:i.modePreview}}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>w(C===`history`?null:`history`),"aria-label":i.history,className:a(`rounded-lg p-1.5 transition-colors`,C===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,R.jsx)(f,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[z,Ce,$,y,i.history,i.modeEdit,i.modePreview,i.modeSource,V,C]);(0,L.useLayoutEffect)(()=>(X({startExtra:ye,main:Z?xe:null,end:Z?we:null}),()=>he()),[he,we,xe,ye,Z,X]);let Te=(0,L.useCallback)(t=>{e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){O(!0);try{await N(e,{markdown:t}),await Q(),n?.()}catch(e){l({type:`error`,title:i.saveFailed,message:e instanceof Error?e.message:i.saveFailedHint})}finally{O(!1)}}},600))},[e,Q,i.saveFailed,i.saveFailedHint,n]),Ee=(0,L.useCallback)(t=>{x(e,t.timestamp).then(e=>{e&&E(e)})},[e]),De=(0,L.useCallback)(()=>{w(null),E(null)},[]),Oe=(0,L.useCallback)(()=>{w(null),E(null),Q(),n?.()},[Q,n]);if((0,L.useEffect)(()=>()=>{G.current&&clearTimeout(G.current),K.current&&clearTimeout(K.current);let t=q.current,n=J.current;q.current=null,J.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&N(e,r)},[e]),Z===void 0)return(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,R.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(Z===null)return(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:i.notFoundTitle}),(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.notFoundDescription}),(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:i.back})]});let ke=T!==null,Ae=ke?T.title??``:A,je=ke?T.markdown??``:Z.markdown??``,Me=new Date(Z.createdAt).getTime(),Ne=Number.isFinite(Me)&&Date.now()-Me<3600*1e3;return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(k,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,R.jsx)(k,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),Ne?(0,R.jsx)(ce,{title:d.noteCreatedTitle,description:d.noteCreatedDescription,prompt:d.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},className:`mb-3 shrink-0`}):null,(0,R.jsx)(`div`,{ref:Y,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:ke?(0,R.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Ae&&(0,R.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Ae}),je?(0,R.jsx)(j,{noteId:e,content:je,className:`opacity-80`}):(0,R.jsx)(`p`,{className:`italic text-fg-muted`,children:i.emptyPreview})]}):(0,R.jsxs)(R.Fragment,{children:[y===`wysiwyg`&&(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,R.jsx)(`input`,{type:`text`,value:A,onChange:e=>be(e.target.value),onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!W.current&&!t.isComposing&&(e.preventDefault(),(Y.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:i.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(pe,{}),children:(0,R.jsx)(de,{initialContent:Z.markdown??``,onChange:Te,noteId:e},`wysiwyg-${e}`)})})]}),y===`source`&&(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,R.jsx)(`input`,{type:`text`,value:A,onChange:e=>be(e.target.value),placeholder:i.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(pe,{}),children:(0,R.jsx)(fe,{initialContent:Z.markdown??``,onChange:Te,isDark:te},`source-${e}`)})})]}),y===`preview`&&(0,R.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&v(t.currentSrc||t.src,t.alt)},children:[A&&(0,R.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:A}),Z.markdown?(0,R.jsx)(j,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,R.jsx)(`p`,{className:`italic text-fg-muted`,children:i.emptyPreview})]})]})})]}),(0,R.jsx)(`div`,{className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!F&&`transition-[width] duration-300 ease-in-out`),style:{width:C?P:0},children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{width:P},children:[(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),I(!0);let n=e.clientX,r=P,i=e.pointerId,a=e=>{let t=r-(e.clientX-n);se(Math.max(280,Math.min(600,t)))},o=()=>{try{t.releasePointerCapture(i)}catch{}I(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},className:a(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,F&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:C===`history`?(0,R.jsx)(le,{noteId:e,activeTimestamp:T?.timestamp??null,onSelect:Ee,onClose:De,onRestored:Oe}):C===`breakdown`?(0,R.jsx)(ue,{noteId:e,note:Z??null,catalyzing:z,onCatalyze:Se,onClose:()=>w(null),noteThreads:ge,openingChat:V,onOpenChat:()=>$(!1),onOpenNewChat:()=>$(!0)}):null})]})})]})}function Q(){let e=(0,I.c)(5),{noteId:t}=T(),n=S(),r;e[0]===n?r=e[1]:(r=()=>{n(`/notes`)},e[0]=n,e[1]=r);let i=r;if(!t)return null;let a;return e[2]!==i||e[3]!==t?(a=(0,R.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,R.jsx)(X,{noteId:t,onBack:i})}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}export{Q as NoteDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CISb1HLv.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,c,i as l,n as u,o as d,t as f}from"./fetch-B3ME5Eri.js";import{a as p,i as m}from"./vendor-swr-BIWyz7Rc.js";import{Ai as h,As as g,At as _,Bn as v,Ca as y,Di as b,Ds as x,Gi as S,Gn as C,Go as w,Hn as T,Ia as E,In as D,Jn as O,Kn as k,Ln as A,Mi as j,Ni as M,Pa as N,Pi as P,Po as F,Qn as I,Qs as L,Rn as R,So as z,Un as B,Va as V,Vn as H,Wn as U,Xi as ee,Ya as te,Zi as W,Zn as G,_s as K,ct as ne,eo as q,f as re,fo as J,ji as Y,ki as ie,ni as ae,oa as oe,qn as se,qs as ce,sa as X,ss as le,ti as ue,ts as de,ur as fe,ya as pe,zn as me}from"./index-CnjzMw5i.js";import{t as he}from"./settings-collapsible-section-BMCOfuE_.js";import{n as ge,r as _e,t as ve}from"./settings-form-section-DBkGwpIN.js";import{t as ye}from"./browser-BLJWD7WI.js";import{i as be,n as xe,r as Se,t as Ce}from"./settings-page-layout-NxoW5Y57.js";var Z=n(),Q=e(t(),1);function we(e,t){let{mutate:n}=p(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),ue()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await v();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await D();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await A(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await R():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function Te(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,oe,`dark:border-edge`)}function Ee(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:s,lanOnly:c,onRefreshQr:l}=e,u=s===void 0?!1:s,d=c===void 0?!1:c,f=o(ke),p;t[0]===f?p=t[1]:(p=a(f),t[0]=f,t[1]=p);let m=p,h=m.tunnelSettings,g=d?m.remoteAccess.lan:null,_;t[2]!==m.clipboard.copyFailed||t[3]!==h.pairCopied||t[4]!==h.pairCopyLink?(_={copy:h.pairCopyLink,copied:h.pairCopied,copyFailed:m.clipboard.copyFailed},t[2]=m.clipboard.copyFailed,t[3]=h.pairCopied,t[4]=h.pairCopyLink,t[5]=_):_=t[5];let v=_,{tunnelActive:y,tunnelStatus:b,tunnelQr:x,pairContext:S,pairBaseUrl:C,setPairBaseUrl:w,applySuggestedPairUrl:T,applyCandidateUrl:E,resetPairBaseFromContext:D,baseOk:O,localhostWarn:k,pairingBlocked:A,deepLink:j,qrPayload:M,qrDataUrl:P,qrGenFailed:F,encoding:I}=n,L;t[6]===D?L=t[7]:(L=e=>{D(e.recommended.url)},t[6]=D,t[7]=L);let R=we(r,L),B,V,H,U,ee;if(t[8]!==E||t[9]!==T||t[10]!==O||t[11]!==R||t[12]!==r||t[13]!==g||t[14]!==d||t[15]!==k||t[16]!==l||t[17]!==C||t[18]!==S?.candidates||t[19]!==S?.recommended||t[20]!==A||t[21]!==w||t[22]!==u||t[23]!==h.pairBaseUrlHint||t[24]!==h.pairBaseUrlLabel||t[25]!==h.pairBaseUrlPlaceholder||t[26]!==h.pairBlockedLoopbackBody||t[27]!==h.pairBlockedNextSteps||t[28]!==h.pairBlockedTitle||t[29]!==h.pairCandidatesTitle||t[30]!==h.pairEnableLanButton||t[31]!==h.pairEnableLanEnabling||t[32]!==h.pairEnableLanSecurityAuditLink||t[33]!==h.pairInvalidBaseUrl||t[34]!==h.pairLocalhostWarning||t[35]!==h.pairSelectCandidateHint||t[36]!==h.pairSelectCandidateTitle||t[37]!==h.pairSubtitle||t[38]!==h.pairSuggestedLanLabel||t[39]!==h.pairTitle||t[40]!==h.pairTunnelActive||t[41]!==h.pairTunnelLanUrl||t[42]!==h.pairTunnelPublicUrl||t[43]!==h.pairUseSuggestedUrl||t[44]!==h.pairWaitingForTunnel||t[45]!==h.refreshQr||t[46]!==y||t[47]!==x||t[48]!==b?.publicUrl){ee=Symbol.for(`react.early_return_sentinel`);bb0:{let e=S?.candidates.filter(Oe)??[],n=d?(e.find(De)?.url??e[0]?.url??``).trim():S?.recommended.url?.trim()??``,a=(d||!y)&&e.length>1,o=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:i(`text-xs font-medium`,r),children:a?h.pairSelectCandidateTitle:h.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:i(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,C.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>E(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),a?(0,$.jsx)(`p`,{className:i(`mt-1 text-[11px] leading-relaxed`,r),children:h.pairSelectCandidateHint}):null]})};if(B=u&&!d,B&&!y){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(N,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===h.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,h.pairTitle]}),t[55]=h.pairTitle,t[56]=n);let r;t[57]===h.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.pairWaitingForTunnel}),t[57]=h.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(ve,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],ee=i;break bb0}let s=g?.pairTitle??h.pairTitle,c=d?g?.pairSubtitle??h.pairSubtitle:y?h.pairTunnelActive:h.pairSubtitle,f=!!(l&&(d||u&&y)),p=B?`mb-2`:`mb-3`,m;t[62]===p?m=t[63]:(m=i(`flex flex-wrap items-start justify-between gap-2`,p),t[62]=p,t[63]=m);let _;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(N,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=_):_=t[64];let v;t[65]===s?v=t[66]:(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[_,s]}),t[65]=s,t[66]=v);let D;t[67]!==B||t[68]!==c||t[69]!==h.pairSubtitle?(D=B?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:h.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c}),t[67]=B,t[68]=c,t[69]=h.pairSubtitle,t[70]=D):D=t[70];let j;t[71]!==v||t[72]!==D?(j=(0,$.jsxs)(`div`,{children:[v,D]}),t[71]=v,t[72]=D,t[73]=j):j=t[73];let M;t[74]!==l||t[75]!==f||t[76]!==h.refreshQr?(M=f?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void l(),children:[(0,$.jsx)(te,{className:`size-4`}),h.refreshQr]}):null,t[74]=l,t[75]=f,t[76]=h.refreshQr,t[77]=M):M=t[77],t[78]!==m||t[79]!==j||t[80]!==M?(V=(0,$.jsxs)(`div`,{className:m,children:[j,M]}),t[78]=m,t[79]=j,t[80]=M,t[81]=V):V=t[81],H=A?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:h.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:h.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:h.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:T,children:h.pairUseSuggestedUrl})]}):null,e.length>0?o(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(X,{type:`button`,className:`w-full sm:w-auto`,disabled:R.busy||!r,onClick:()=>R.setConfirmOpen(!0),children:[R.busy?(0,$.jsx)(z,{className:`size-3.5 animate-spin`}):null,R.busy?h.pairEnableLanEnabling:h.pairEnableLanButton]})}),R.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:R.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?g?.pairBlockedNextSteps??h.pairBlockedNextSteps:h.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ce,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:h.pairEnableLanSecurityAuditLink}),d&&g?.pairPublicTabLink?(0,$.jsx)(ce,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairPublicTabLink}):null]})]}):null,U=y&&!d?B?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg border border-edge bg-surface-panel px-3 py-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:b?.publicUrl})]}),x?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:x.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:h.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:i(Te(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||h.pairBaseUrlPlaceholder,value:C,onChange:e=>w(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:h.pairBaseUrlHint}),!O&&C.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:h.pairInvalidBaseUrl}):null,k?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:h.pairLocalhostWarning}):null,a?o(`neutral`):null]})}t[8]=E,t[9]=T,t[10]=O,t[11]=R,t[12]=r,t[13]=g,t[14]=d,t[15]=k,t[16]=l,t[17]=C,t[18]=S?.candidates,t[19]=S?.recommended,t[20]=A,t[21]=w,t[22]=u,t[23]=h.pairBaseUrlHint,t[24]=h.pairBaseUrlLabel,t[25]=h.pairBaseUrlPlaceholder,t[26]=h.pairBlockedLoopbackBody,t[27]=h.pairBlockedNextSteps,t[28]=h.pairBlockedTitle,t[29]=h.pairCandidatesTitle,t[30]=h.pairEnableLanButton,t[31]=h.pairEnableLanEnabling,t[32]=h.pairEnableLanSecurityAuditLink,t[33]=h.pairInvalidBaseUrl,t[34]=h.pairLocalhostWarning,t[35]=h.pairSelectCandidateHint,t[36]=h.pairSelectCandidateTitle,t[37]=h.pairSubtitle,t[38]=h.pairSuggestedLanLabel,t[39]=h.pairTitle,t[40]=h.pairTunnelActive,t[41]=h.pairTunnelLanUrl,t[42]=h.pairTunnelPublicUrl,t[43]=h.pairUseSuggestedUrl,t[44]=h.pairWaitingForTunnel,t[45]=h.refreshQr,t[46]=y,t[47]=x,t[48]=b?.publicUrl,t[49]=B,t[50]=V,t[51]=H,t[52]=U,t[53]=ee}else B=t[49],V=t[50],H=t[51],U=t[52],ee=t[53];if(ee!==Symbol.for(`react.early_return_sentinel`))return ee;let W;t[82]===h.pairSecurityNote?W=t[83]:(W=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:h.pairSecurityNote}),t[82]=h.pairSecurityNote,t[83]=W);let G;t[84]!==v||t[85]!==j||t[86]!==I||t[87]!==A||t[88]!==P||t[89]!==F||t[90]!==h.pairEncoding||t[91]!==h.pairImageError||t[92]!==h.pairQrDisabled?(G=j?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[P&&!F?(0,$.jsx)(`img`,{src:P,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,I?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairEncoding}):null,F?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:h.pairImageError}):null,(0,$.jsx)(fe,{text:j,labels:v})]}):A?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairQrDisabled}):null,t[84]=v,t[85]=j,t[86]=I,t[87]=A,t[88]=P,t[89]=F,t[90]=h.pairEncoding,t[91]=h.pairImageError,t[92]=h.pairQrDisabled,t[93]=G):G=t[93];let K;t[94]!==B||t[95]!==M||t[96]!==h.deeplinkTitle?(K=M&&!B?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:h.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:M})]}):null,t[94]=B,t[95]=M,t[96]=h.deeplinkTitle,t[97]=K):K=t[97];let ne;t[98]!==B||t[99]!==h.pairMobileProbeHint||t[100]!==h.pairSchemeHint?(ne=B?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:h.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:h.pairMobileProbeHint})]}),t[98]=B,t[99]=h.pairMobileProbeHint,t[100]=h.pairSchemeHint,t[101]=ne):ne=t[101];let q,J;t[102]===R?(q=t[103],J=t[104]):(q=()=>void R.runEnableLanPairing(),J=()=>{R.busy||R.setConfirmOpen(!1)},t[102]=R,t[103]=q,t[104]=J);let Y;t[105]!==R.confirmOpen||t[106]!==h.consentCancel||t[107]!==h.pairEnableLanButton||t[108]!==h.pairEnableLanConfirmBody||t[109]!==h.pairEnableLanConfirmTitle||t[110]!==q||t[111]!==J?(Y=(0,$.jsx)(re,{open:R.confirmOpen,title:h.pairEnableLanConfirmTitle,description:h.pairEnableLanConfirmBody,confirmLabel:h.pairEnableLanButton,cancelLabel:h.consentCancel,onConfirm:q,onCancel:J}),t[105]=R.confirmOpen,t[106]=h.consentCancel,t[107]=h.pairEnableLanButton,t[108]=h.pairEnableLanConfirmBody,t[109]=h.pairEnableLanConfirmTitle,t[110]=q,t[111]=J,t[112]=Y):Y=t[112];let ie;return t[113]!==W||t[114]!==G||t[115]!==K||t[116]!==ne||t[117]!==Y||t[118]!==V||t[119]!==H||t[120]!==U?(ie=(0,$.jsx)(ve,{children:(0,$.jsxs)($.Fragment,{children:[V,H,U,W,G,K,ne,Y]})}),t[113]=W,t[114]=G,t[115]=K,t[116]=ne,t[117]=Y,t[118]=V,t[119]=H,t[120]=U,t[121]=ie):ie=t[121],ie}function De(e){return e.reachable}function Oe(e){return e.kind===`lan`}function ke(e){return e.language}function Ae(e){let t=(0,Z.c)(40),{open:n,title:r,intro:a,bullets:o,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Y,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,I)}),t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=i(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,G),t[3]=_):_=t[3];let v;t[4]===r?v=t[5]:(v=(0,$.jsx)(P,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=v);let y;t[6]===a?y=t[7]:(y=(0,$.jsx)(h,{className:`mt-2 text-sm text-fg-muted`,children:a}),t[6]=a,t[7]=y);let b;t[8]===o?b=t[9]:(b=o.map(je),t[8]=o,t[9]=b);let x;t[10]===b?x=t[11]:(x=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:b}),t[10]=b,t[11]=x);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===s?w=t[16]:(w=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=w);let T;t[17]!==w||t[18]!==C?(T=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=T):T=t[19];let E;t[20]!==l||t[21]!==d?(E=(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=E):E=t[22];let D=!f,O;t[23]!==c||t[24]!==u||t[25]!==D?(O=(0,$.jsx)(X,{type:`button`,disabled:D,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==E||t[28]!==O?(k=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[E,O]}),t[27]=E,t[28]=O,t[29]=k):k=t[29];let A;t[30]!==T||t[31]!==k||t[32]!==v||t[33]!==y||t[34]!==x?(A=(0,$.jsxs)(j,{children:[g,(0,$.jsxs)(ie,{className:_,onOpenAutoFocus:Me,children:[v,y,x,T,k]})]}),t[30]=T,t[31]=k,t[32]=v,t[33]=y,t[34]=x,t[35]=A):A=t[35];let N;return t[36]!==n||t[37]!==m||t[38]!==A?(N=(0,$.jsx)(M,{open:n,onOpenChange:m,children:A}),t[36]=n,t[37]=m,t[38]=A,t[39]=N):N=t[39],N}function je(e){return(0,$.jsx)(`li`,{children:e},e)}function Me(e){return e.preventDefault()}function Ne(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Pe=[`preparing_frpc`,`registering`,`starting_frpc`];function Fe(e){return e?e===`reconnecting_frpc`?Pe.indexOf(`starting_frpc`):Pe.indexOf(e):-1}function Ie(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Pe.indexOf(e),i=Fe(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Le(e,t,n){let r=n.startProgress;return Ie(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Re(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function ze(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Be(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,a]=(0,Q.useState)(0),o;t[0]!==a||t[1]!==n.state?(o=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>a(Ve),1e3);return()=>window.clearInterval(e)},t[0]=a,t[1]=n.state,t[2]=o):o=t[2];let s=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==s?(c=[n.state,s],t[3]=n.state,t[4]=s,t[5]=c):c=t[5],(0,Q.useEffect)(o,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,d,f,p;if(t[6]!==n||t[7]!==r){let e=ze(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3`;let a;t[13]===r.startProgressTitle?a=t[14]:(a=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=a);let o;t[15]===r.startProgressHint?o=t[16]:(o=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=o),t[17]!==a||t[18]!==o?(d=(0,$.jsxs)(`div`,{children:[a,o]}),t[17]=a,t[18]=o,t[19]=d):d=t[19];let s=Pe.map(e=>{let t=Ie(e,n),a=Le(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(g,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(z,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(K,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:i(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Re(r,e)}),a?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:a}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:i(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Ne(n.frpcDownload.bytesReceived),` /`,` `,Ne(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===s?f=t[21]:(f=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=f),p=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12];let m;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(m=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==u||t[26]!==d||t[27]!==f||t[28]!==p||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f,p,m]}),t[25]=u,t[26]=d,t[27]=f,t[28]=p,t[29]=m,t[30]=h):h=t[30],h}function Ve(e){return e+1}function He(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Ue(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function We(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Ge(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ke(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:a,statusErr:o,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,b,x,S,C;t[0]!==r||t[1]!==s?(C=Ue(r),_=r.enabled||s,v=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(_e(),`space-y-4`),t[9]=S):S=t[9],x=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=i(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,We(C)),t[0]=r,t[1]=s,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=x,t[7]=S,t[8]=C):(_=t[2],v=t[3],y=t[4],b=t[5],x=t[6],S=t[7],C=t[8]);let T=C===`connected`&&`bg-emerald-500`,E=C===`progress`&&`bg-amber-500 animate-pulse`,D=C===`error`&&`bg-red-500`,O=C===`off`&&`bg-fg-subtle`,k;t[10]!==T||t[11]!==E||t[12]!==D||t[13]!==O?(k=i(`size-1.5 rounded-full`,T,E,D,O),t[10]=T,t[11]=E,t[12]=D,t[13]=O,t[14]=k):k=t[14];let A;t[15]===k?A=t[16]:(A=(0,$.jsx)(`span`,{className:k,"aria-hidden":!0}),t[15]=k,t[16]=A);let j;t[17]!==a||t[18]!==r||t[19]!==n?(j=a&&!r.enabled?n.loading:He(n,r),t[17]=a,t[18]=r,t[19]=n,t[20]=j):j=t[20];let M;t[21]!==A||t[22]!==j||t[23]!==y?(M=(0,$.jsxs)(`span`,{className:y,children:[A,j]}),t[21]=A,t[22]=j,t[23]=y,t[24]=M):M=t[24];let N;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(N=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ge(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=N):N=t[28];let P;t[29]!==M||t[30]!==N||t[31]!==b?(P=(0,$.jsxs)(`div`,{className:b,children:[M,N]}),t[29]=M,t[30]=N,t[31]=b,t[32]=P):P=t[32];let F;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(w,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=F):F=t[33];let I;t[34]!==P||t[35]!==x?(I=(0,$.jsxs)(`div`,{className:x,children:[P,F]}),t[34]=P,t[35]=x,t[36]=I):I=t[36];let L;t[37]===o?L=t[38]:(L=o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o instanceof Error?o.message:String(o)}):null,t[37]=o,t[38]=L);let R;t[39]!==l||t[40]!==n.consentExpiredBanner?(R=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=R):R=t[41];let B;t[42]!==_||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(B=_?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,$.jsx)(fe,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Be,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(z,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(X,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(z,{className:`size-4 animate-spin`}):(0,$.jsx)(q,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(pe,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(X,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(z,{className:`size-4 animate-spin`}):(0,$.jsx)(q,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=u,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=B):B=t[54];let V;return t[55]!==I||t[56]!==L||t[57]!==R||t[58]!==B||t[59]!==S?(V=(0,$.jsxs)(`section`,{className:S,children:[I,L,R,B]}),t[55]=I,t[56]=L,t[57]=R,t[58]=B,t[59]=S,t[60]=V):V=t[60],V}var qe=`https://console.xopc.ai/keys/tunnel`,Je={reconfiguring:!1};function Ye(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:a,brokerSecretConfiguredInConfig:o,brokerSecretMaskedValue:s,brokerSecretDraft:c,savingBrokerSecret:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:p,onClear:m,sectionRef:h}=e,v=(0,Q.useId)(),y=a&&!r,b=!y,[x,S]=(0,Q.useReducer)(ne,Je),{reconfiguring:C}=x,w;t[0]!==o||t[1]!==c||t[2]!==r||t[3]!==C?(w=o&&!r&&!C&&!c.trim(),t[0]=o,t[1]=c,t[2]=r,t[3]=C,t[4]=w):w=t[4];let T=w,E;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(E={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=E):E=t[9];let D=E,O;t[10]===c?O=t[11]:(O=c.trim().length>0&&!_(c.trim()),t[10]=c,t[11]=O);let k=O,A;t[12]===f?A=t[13]:(A=()=>{S({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[12]=f,t[13]=A);let j=A,M=y&&`ring-1 ring-amber-500/30`,N;t[14]===M?N=t[15]:(N=i(M),t[14]=M,t[15]=N);let P=b?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:y?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,I;t[16]===P?I=t[17]:(I=i(`flex size-9 shrink-0 items-center justify-center rounded-lg`,P),t[16]=P,t[17]=I);let L;t[18]===b?L=t[19]:(L=b?(0,$.jsx)(g,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(F,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=b,t[19]=L);let R;t[20]!==I||t[21]!==L?(R=(0,$.jsx)(`span`,{className:I,children:L}),t[20]=I,t[21]=L,t[22]=R):R=t[22];let B=b?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,V;t[23]===B?V=t[24]:(V=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:B}),t[23]=B,t[24]=V);let H=b?n.brokerSecretReadyHint:n.brokerSecretHint,U;t[25]===H?U=t[26]:(U=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:H}),t[25]=H,t[26]=U);let te;t[27]!==y||t[28]!==n.brokerSecretMissingHint?(te=y?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=y,t[28]=n.brokerSecretMissingHint,t[29]=te):te=t[29];let W;t[30]!==V||t[31]!==U||t[32]!==te?(W=(0,$.jsxs)(`div`,{children:[V,U,te]}),t[30]=V,t[31]=U,t[32]=te,t[33]=W):W=t[33];let G;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(de,{className:`size-3`,"aria-hidden":!0}),t[34]=G):G=t[34];let K;t[35]===n.brokerSecretConsoleLink?K=t[36]:(K=(0,$.jsxs)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,G]}),t[35]=n.brokerSecretConsoleLink,t[36]=K);let q;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(q=r?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-muted`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=q):q=t[39];let re;t[40]!==o||t[41]!==c||t[42]!==r||t[43]!==s||t[44]!==k||t[45]!==j||t[46]!==d||t[47]!==v||t[48]!==y||t[49]!==m||t[50]!==f||t[51]!==p||t[52]!==C||t[53]!==l||t[54]!==D||t[55]!==T||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(re=T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:v,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:v,value:s,labels:D,reveal:Xe,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>{S({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:v,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:v,value:c,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:D,disabled:l}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(X,{type:`button`,disabled:l||!k,onClick:p,children:[l?(0,$.jsx)(z,{className:`size-4 animate-spin`}):null,y?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),o||r?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear}):null,C?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:l,onClick:j,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=o,t[41]=c,t[42]=r,t[43]=s,t[44]=k,t[45]=j,t[46]=d,t[47]=v,t[48]=y,t[49]=m,t[50]=f,t[51]=p,t[52]=C,t[53]=l,t[54]=D,t[55]=T,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=re):re=t[66];let J;t[67]===u?J=t[68]:(J=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[67]=u,t[68]=J);let Y;t[69]!==W||t[70]!==K||t[71]!==q||t[72]!==re||t[73]!==J?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[W,K,q,re,J]}),t[69]=W,t[70]=K,t[71]=q,t[72]=re,t[73]=J,t[74]=Y):Y=t[74];let ie;t[75]!==R||t[76]!==Y?(ie=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[R,Y]}),t[75]=R,t[76]=Y,t[77]=ie):ie=t[77];let ae;t[78]!==ie||t[79]!==N?(ae=(0,$.jsx)(ve,{className:N,children:ie}),t[78]=ie,t[79]=N,t[80]=ae):ae=t[80];let oe;return t[81]!==h||t[82]!==ae?(oe=(0,$.jsx)(`div`,{ref:h,id:`tunnel-broker-secret-setup`,children:ae}),t[81]=h,t[82]=ae,t[83]=oe):oe=t[83],oe}function Xe(){return k().then(Ze)}function Ze(e){return e.registrationSecret??null}function Qe(e){let t=(0,Z.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=S(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=i(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(de,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var $e=e(ye(),1),et={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function tt(e){return $e.toDataURL(e,et)}function nt(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function rt(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function it(e,t){return e?t?nt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function at(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=p(),a=(0,Q.useRef)(!1),{data:o}=m(r?`tunnel-status`:null,B,{refreshInterval:6e4}),{data:c,mutate:l}=m(r?`tunnel-pair-context`:null,H,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let u=o?.state===`connected`&&!!o.publicUrl?.trim(),f=u&&!n,{data:h,mutate:g}=m(f&&r?`tunnel-qr`:null,T,{refreshInterval:4*6e4}),{data:_,mutate:v}=m(!f&&r&&c?.pairingReady?`tunnel-pair`:null,me,{refreshInterval:4*6e4}),[y,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(``),[w,E]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(c!==w.pairContext||n!==w.preferLan)){E({pairContext:c,preferLan:n});let e=it(c,n);y!==e&&x(e)}let D=(0,Q.useCallback)(e=>{a.current=!0,x(e)},[]),O=(0,Q.useCallback)(()=>{let e=it(c,n);e&&(a.current=!0,x(e))},[c,n]),k=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,x(t))},[]),A=(0,Q.useCallback)(e=>{a.current=!1,x(e?.trim()||it(c,n))},[c,n]),j=y.trim(),M=(0,Q.useMemo)(()=>{try{let e=new URL(j);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[j]),N=M&&d(j),P=!f&&!!(c&&!c.pairingReady&&c.blockReason===`GATEWAY_LOOPBACK_ONLY`),F=!f&&M&&!N&&!!_?.pairingSecret&&(c?.pairingReady===!0||!P),I=(0,Q.useMemo)(()=>{let e=nt(c);return n?e||(j&&!rt(c,j)?j:``):j},[c,n,j]),L=(0,Q.useMemo)(()=>{if(!e)return``;if(S.trim())return S.trim();if(f&&h?.qrPayload?.trim())return h.qrPayload.trim();if(!F||!_?.pairingSecret)return``;let t=c?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=c?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?I:t?.url??j;return i?s({baseUrl:i,pairingSecret:_.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,I,_?.pairingSecret,F,S,n,j,f,h?.qrPayload,c?.candidates]),R=b(()=>tt(L),[L],{enabled:!!L,initial:null,errorData:null}),z=L?R.data:null,V=!!(L&&R.error!==null&&!R.loading);return{tunnelActive:u,tunnelStatus:o,tunnelQr:h,pairContext:c,pairBaseUrl:y,setPairBaseUrl:D,applySuggestedPairUrl:O,applyCandidateUrl:k,baseOk:M,localhostWarn:N,pairingBlocked:P,deepLink:L,qrPayload:L,qrDataUrl:z,qrGenFailed:V,encoding:!!(L&&!z&&!V),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){C(e.trim()),g({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:h?.lanUrl??null},!1);return}C(``),await l(),f?await g():c?.pairingReady&&await v()},[v,l,g,c?.pairingReady,h?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:A}}var ot={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function st({embedded:e=!1}){let t=o(e=>e.language),n=a(t).tunnelSettings,r=c(e=>e.token),s=!!r,[l,u]=(0,Q.useReducer)(ne,ot),{actionError:d,starting:f,stopping:p,savingAutoStart:h,consentOpen:g,autoStartConfirmOpen:v,releaseConfirmOpen:y,releasing:b,brokerSecretDraft:x,savingBrokerSecret:S,brokerSecretNotice:T}=l,E=(0,Q.useRef)(null),D=at(r??``),{data:k}=ae(s),{data:A,error:j,isLoading:M,mutate:N}=m(s?`tunnel-status`:null,B,{refreshInterval:e=>f?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),P=(0,Q.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return A?.config?.autoStart===!0},[k,A?.config?.autoStart]),F=(0,Q.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[k]),I=_(F),L=A?.registrationSecret?.source===`env`,R=A?.registrationSecret?.source===`missing`,V=A?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{N()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[N]);let H=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),ee=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{starting:!0}});try{let e=await se();await N(),ue(),await D.refreshQr(e.qrPayload)}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{starting:!1}})}},[N,D.refreshQr]),te=(0,Q.useCallback)(()=>{if(!V){u({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),E.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(A?.consentRequired){u({type:`patch`,patch:{consentOpen:!0}});return}ee()},[V,A?.consentRequired,ee,n.brokerSecretRequiredBeforeStart]),W=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{consentOpen:!1}}),u({type:`patch`,patch:{actionError:null}});try{await C(),await Promise.all([N(),ee()])}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[N,ee]),G=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{stopping:!0}});try{await O(),await Promise.all([D.refreshQr(),N()]),ue()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{stopping:!1}})}},[N,D.refreshQr]),K=(0,Q.useCallback)(async e=>{u({type:`patch`,patch:{savingAutoStart:!0}}),u({type:`patch`,patch:{actionError:null}});try{await U({autoStart:e}),ue()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Q.useCallback)(()=>{if(P){K(!1);return}if(A?.consentRequired){u({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!A?.canAutoStart){u({type:`patch`,patch:{actionError:n.autoStartHint}});return}u({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,A?.canAutoStart,A?.consentRequired,n,P]),J=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await U({registrationSecret:e}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),ue(),await N(),u({type:`patch`,patch:{actionError:null}})}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[x,N,n.brokerSecretSaved]),Y=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await U({registrationSecret:null}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),ue(),await N()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}},[N,n.brokerSecretCleared]),ie=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await O({release:!0}),await Promise.all([D.refreshQr(),N()]),ue()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{releasing:!1}})}},[N,D.refreshQr]),oe=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!s)return(0,$.jsx)(`div`,{className:e?void 0:`mx-auto w-full max-w-app-main px-4 py-8`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let ce=A??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:P,brokerUrl:`https://frp.xopc.ai/api`}},le=A?.consentRequired&&(ce.enabled||P||A?.consent?.acceptedAt),de=(0,$.jsx)(Ye,{t:n,brokerSecretFromEnv:L,brokerSecretMissing:R,brokerSecretConfiguredInConfig:I,brokerSecretMaskedValue:I?F:``,brokerSecretDraft:x,savingBrokerSecret:S,brokerSecretNotice:T,copyFailedLabel:a(t).clipboard.copyFailed,onDraftChange:e=>u({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void J(),onClear:()=>void Y(),sectionRef:E}),fe=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:H,checkboxLabel:n.consentCheckbox,confirmLabel:le?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void W(),onCancel:()=>u({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(re,{open:v,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{u({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>u({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(re,{open:y,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ie(),onCancel:()=>u({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(Ke,{t:n,status:ce,isLoading:M,statusErr:j,starting:f,stopping:p,showConsentExpired:!!le,copyLabels:oe,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:te,onStop:()=>void G()}),(0,$.jsx)(Ee,{pairQr:D,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void D.refreshQr()}),(0,$.jsxs)(he,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!P&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:h||!P&&!A?.canAutoStart,onChange:q}),n.autoStart]}),!A?.canAutoStart&&!P?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,ce.subdomain||ce.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:b||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(z,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(he,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Qe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),fe]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(Ke,{t:n,status:ce,isLoading:M,statusErr:j,starting:f,stopping:p,showConsentExpired:!!le,copyLabels:oe,startDisabled:!V,startDisabledReason:V?void 0:n.brokerSecretRequiredBeforeStart,onStart:te,onStop:()=>void G()}),(0,$.jsx)(Ee,{pairQr:D,gatewayToken:r??``}),ce.subdomain||ce.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:b||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(z,{className:`size-4 animate-spin`}):null,n.release]})}):null,ce.subdomain||ce.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ve,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!P&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:P,disabled:h||!P&&!A?.canAutoStart,onChange:q}),n.autoStart]}),!A?.canAutoStart&&!P?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Qe,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),fe]})}async function ct(){let e=await f(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function lt(e=`serve`){let t=await f(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function ut(){let e=await f(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var dt=`https://tailscale.com/download`;function ft(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:dt,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function pt({embedded:e=!1}){let t=o(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.token),[s,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),{data:f,mutate:p,isLoading:h}=m(i?`exposure-status`:null,ct,{refreshInterval:3e4}),g=f?.tailscale.hostname,_=f?.tailscale.active===!0,v=f?.tailscale.cliAvailable!==!1,y=g?`https://${g}/`:null,b=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await lt(`serve`),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]),x=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await ut(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]);if(!i)return null;let S=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(ft,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&f?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(ft,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,h&&!f?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ve,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(fe,{text:y,labels:r})}):null,u?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void x(),children:[s?(0,$.jsx)(z,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(X,{type:`button`,disabled:s||!v,onClick:()=>void b(),children:[s?(0,$.jsx)(z,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(q,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(Qe,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?S:(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:w,title:n.title,subtitle:n.subtitle}),S]})}function mt(){let e=(0,Z.c)(26),t=o(gt),n=c(ht),r;e[0]===t?r=e[1]:(r=a(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={preferLan:!0},e[2]=s):s=e[2];let l=at(n??``,s),u;e[3]!==i.subtitle||e[4]!==i.title?(u=(0,$.jsx)(ge,{icon:V,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=u):u=e[5];let d;e[6]===i.body?d=e[7]:(d=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=d);let f;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),e[8]=f):f=e[8];let p;e[9]===i.link?p=e[10]:(p=(0,$.jsxs)(ce,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,f]}),e[9]=i.link,e[10]=p);let m;e[11]!==d||e[12]!==p?(m=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[d,p]}),e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;e[14]!==u||e[15]!==m?(h=(0,$.jsxs)(ve,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=h):h=e[16];let g=n??``,_;e[17]===l?_=e[18]:(_=()=>void l.refreshQr(),e[17]=l,e[18]=_);let v;e[19]!==l||e[20]!==g||e[21]!==_?(v=(0,$.jsx)(Ee,{pairQr:l,gatewayToken:g,lanOnly:!0,onRefreshQr:_}),e[19]=l,e[20]=g,e[21]=_,e[22]=v):v=e[22];let y;return e[23]!==v||e[24]!==h?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,v]}),e[23]=v,e[24]=h,e[25]=y):y=e[25],y}function ht(e){return e.token}function gt(e){return e.language}function _t(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=o(vt),s;t[0]===i?s=t[1]:(s=a(i),t[0]=i,t[1]=s);let c=s.remoteAccess.ssh,[l,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await W(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=p):p=t[3];let m,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>void f(),h=(0,$.jsx)(le,{className:`mr-1 h-4 w-4`}),t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=l?c.copied:c.copy,_;t[6]===g?_=t[7]:(_=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:m,children:[h,g]})}),t[6]=g,t[7]=_);let v;t[8]!==r||t[9]!==c.hint?(v=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c.hint}):null,t[8]=r,t[9]=c.hint,t[10]=v):v=t[10];let b;t[11]!==_||t[12]!==v?(b=(0,$.jsxs)($.Fragment,{children:[p,_,v]}),t[11]=_,t[12]=v,t[13]=b):b=t[13];let x=b;if(r){let e;t[14]!==c.subtitle||t[15]!==c.title?(e=(0,$.jsx)(ge,{icon:y,title:c.title,subtitle:c.subtitle}),t[14]=c.subtitle,t[15]=c.title,t[16]=e):e=t[16];let n;t[17]===x?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:x}),t[17]=x,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ve,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let S;t[22]!==c.subtitle||t[23]!==c.title?(S=(0,$.jsx)(ge,{icon:y,title:c.title,subtitle:c.subtitle}),t[22]=c.subtitle,t[23]=c.title,t[24]=S):S=t[24];let C;t[25]===x?C=t[26]:(C=(0,$.jsx)(`div`,{className:`mt-4`,children:x}),t[25]=x,t[26]=C);let w;return t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(ve,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function vt(e){return e.language}function yt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(_t,{embedded:!0}),e[0]=t):t=e[0],t}function bt(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function xt(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,a;t[0]===r?a=t[1]:(a=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,bt(r)),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function St(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=o(Tt),s;t[0]===r?s=t[1]:(s=a(r),t[0]=r,t[1]=s);let l=s.remoteAccess.guide,u=!!c(wt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,ct,d),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:15e3},t[3]=p):p=t[3];let{data:h}=m(u?`tunnel-status`:null,B,p),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g={refreshInterval:6e4},t[4]=g):g=t[4];let{data:_}=m(u?`tunnel-pair-context`:null,H,g);if(!u)return null;let v=f?.tailscale.active===!0,b=h?.state,x=h?.enabled&&b===`connected`,S=h?.enabled&&(b===`connecting`||b===`reconnecting`||!!h?.startProgress||!!h?.frpcDownload),C=(_?.candidates??[]).some(Ct),T=v?`active`:`off`,D=v?l.statusActive:l.statusOff,O;t[5]!==l.tailscaleCardTitle||t[6]!==T||t[7]!==D?(O={tab:`tailscale`,icon:w,title:l.tailscaleCardTitle,kind:T,statusLabel:D},t[5]=l.tailscaleCardTitle,t[6]=T,t[7]=D,t[8]=O):O=t[8];let k=x?`active`:S?`connecting`:`off`,A=x?l.statusActive:S?l.statusConnecting:l.statusOff,j;t[9]!==l.publicCardTitle||t[10]!==k||t[11]!==A?(j={tab:`public`,icon:J,title:l.publicCardTitle,kind:k,statusLabel:A},t[9]=l.publicCardTitle,t[10]=k,t[11]=A,t[12]=j):j=t[12];let M=C?`active`:`off`,N=C?l.statusActive:l.statusOff,P;t[13]!==l.reverseProxyCardTitle||t[14]!==M||t[15]!==N?(P={tab:`reverse-proxy`,icon:E,title:l.reverseProxyCardTitle,kind:M,statusLabel:N},t[13]=l.reverseProxyCardTitle,t[14]=M,t[15]=N,t[16]=P):P=t[16];let F;t[17]!==l.sshCardStatus||t[18]!==l.sshCardTitle?(F={tab:`ssh`,icon:y,title:l.sshCardTitle,kind:`off`,statusLabel:l.sshCardStatus},t[17]=l.sshCardStatus,t[18]=l.sshCardTitle,t[19]=F):F=t[19];let I;t[20]!==l.lanCardStatus||t[21]!==l.lanCardTitle?(I={tab:`lan`,icon:V,title:l.lanCardTitle,kind:`off`,statusLabel:l.lanCardStatus},t[20]=l.lanCardStatus,t[21]=l.lanCardTitle,t[22]=I):I=t[22];let L;t[23]!==j||t[24]!==P||t[25]!==F||t[26]!==I||t[27]!==O?(L=[O,j,P,F,I],t[23]=j,t[24]=P,t[25]=F,t[26]=I,t[27]=O,t[28]=L):L=t[28];let R=L,z;return t[29]!==R||t[30]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:R.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:i(`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-2.5 text-left transition-colors`,`hover:border-edge hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(xt,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=R,t[30]=n,t[31]=z):z=t[31],z}function Ct(e){return e.kind===`reverse-proxy`}function wt(e){return e.token}function Tt(e){return e.language}function Et(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:a,icon:o,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-2xl bg-surface-base px-4 py-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==a||t[6]!==l?(p=a&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=a,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Dt(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=o(At),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let s=i.remoteAccess,l=s.guide,u=!!c(kt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,ct,d),p;t[3]===f?.conflicts?p=t[4]:(p=f?.conflicts??[],t[3]=f?.conflicts,t[4]=p);let h=p;if(!u){let e;return t[5]===l.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.needToken}),t[5]=l.needToken,t[6]=e),e}let g;t[7]===n?g=t[8]:(g=(0,$.jsx)(St,{onOpenTab:n}),t[7]=n,t[8]=g);let _;t[9]!==h||t[10]!==l.conflictsHint||t[11]!==l.conflictsTitle?(_=h.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:l.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:l.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:h.map(Ot)})]}):null,t[9]=h,t[10]=l.conflictsHint,t[11]=l.conflictsTitle,t[12]=_):_=t[12];let v;t[13]===l.pickMethod?v=t[14]:(v=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.pickMethod}),t[13]=l.pickMethod,t[14]=v);let b;t[15]===n?b=t[16]:(b=()=>n(`tailscale`),t[15]=n,t[16]=b);let x;t[17]!==l.configure||t[18]!==l.recommended||t[19]!==l.tailscaleCardDesc||t[20]!==l.tailscaleCardTitle||t[21]!==b?(x=(0,$.jsx)(Et,{icon:w,title:l.tailscaleCardTitle,description:l.tailscaleCardDesc,recommended:!0,recommendedLabel:l.recommended,openLabel:l.configure,onOpen:b}),t[17]=l.configure,t[18]=l.recommended,t[19]=l.tailscaleCardDesc,t[20]=l.tailscaleCardTitle,t[21]=b,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=()=>n(`public`),t[23]=n,t[24]=S);let C;t[25]!==l.configure||t[26]!==l.publicCardDesc||t[27]!==l.publicCardTitle||t[28]!==S?(C=(0,$.jsx)(Et,{icon:J,title:l.publicCardTitle,description:l.publicCardDesc,openLabel:l.configure,onOpen:S}),t[25]=l.configure,t[26]=l.publicCardDesc,t[27]=l.publicCardTitle,t[28]=S,t[29]=C):C=t[29];let T;t[30]===n?T=t[31]:(T=()=>n(`reverse-proxy`),t[30]=n,t[31]=T);let D;t[32]!==l.configure||t[33]!==l.reverseProxyCardDesc||t[34]!==l.reverseProxyCardTitle||t[35]!==T?(D=(0,$.jsx)(Et,{icon:E,title:l.reverseProxyCardTitle,description:l.reverseProxyCardDesc,openLabel:l.configure,onOpen:T}),t[32]=l.configure,t[33]=l.reverseProxyCardDesc,t[34]=l.reverseProxyCardTitle,t[35]=T,t[36]=D):D=t[36];let O;t[37]===n?O=t[38]:(O=()=>n(`ssh`),t[37]=n,t[38]=O);let k;t[39]!==l.configure||t[40]!==l.sshCardDesc||t[41]!==l.sshCardTitle||t[42]!==O?(k=(0,$.jsx)(Et,{icon:y,title:l.sshCardTitle,description:l.sshCardDesc,openLabel:l.configure,onOpen:O}),t[39]=l.configure,t[40]=l.sshCardDesc,t[41]=l.sshCardTitle,t[42]=O,t[43]=k):k=t[43];let A;t[44]===n?A=t[45]:(A=()=>n(`lan`),t[44]=n,t[45]=A);let j;t[46]!==l.configure||t[47]!==l.lanCardDesc||t[48]!==l.lanCardTitle||t[49]!==A?(j=(0,$.jsx)(Et,{icon:V,title:l.lanCardTitle,description:l.lanCardDesc,openLabel:l.configure,onOpen:A}),t[46]=l.configure,t[47]=l.lanCardDesc,t[48]=l.lanCardTitle,t[49]=A,t[50]=j):j=t[50];let M;t[51]!==C||t[52]!==D||t[53]!==k||t[54]!==j||t[55]!==x?(M=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[x,C,D,k,j]}),t[51]=C,t[52]=D,t[53]=k,t[54]=j,t[55]=x,t[56]=M):M=t[56];let N;t[57]!==M||t[58]!==v?(N=(0,$.jsxs)(`div`,{children:[v,M]}),t[57]=M,t[58]=v,t[59]=N):N=t[59];let P;t[60]===l.oneAtATimeHint?P=t[61]:(P=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:l.oneAtATimeHint}),t[60]=l.oneAtATimeHint,t[61]=P);let F;t[62]===s.advanced.proxyTitle?F=t[63]:(F=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.advanced.proxyTitle}),t[62]=s.advanced.proxyTitle,t[63]=F);let I;t[64]===s.advanced.proxyBody?I=t[65]:(I=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.advanced.proxyBody}),t[64]=s.advanced.proxyBody,t[65]=I);let L;t[66]!==r||t[67]!==s.advanced.proxyDocs?(L=(0,$.jsx)(Qe,{language:r,label:s.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=s.advanced.proxyDocs,t[68]=L):L=t[68];let R;t[69]!==F||t[70]!==I||t[71]!==L?(R=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-4 py-3`,children:[F,I,L]}),t[69]=F,t[70]=I,t[71]=L,t[72]=R):R=t[72];let z;t[73]!==l.docsLink||t[74]!==r?(z=(0,$.jsx)(Qe,{language:r,label:l.docsLink}),t[73]=l.docsLink,t[74]=r,t[75]=z):z=t[75];let B;return t[76]!==N||t[77]!==P||t[78]!==R||t[79]!==z||t[80]!==g||t[81]!==_?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[g,_,N,P,R,z]}),t[76]=N,t[77]=P,t[78]=R,t[79]=z,t[80]=g,t[81]=_,t[82]=B):B=t[82],B}function Ot(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function kt(e){return e.token}function At(e){return e.language}async function jt(e){let t=await f(l(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Mt(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Nt(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Pt(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||Nt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Ft(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,oe,`dark:border-edge`)}function It(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Lt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Rt(){let e=o(e=>e.language),t=a(e).remoteAccess.reverseProxy,n=!!c(e=>e.token),r=Pt(),{mutate:l}=p(),{data:u,mutate:d}=m(n?`tunnel-pair-context`:null,H,{refreshInterval:6e4}),f=It(u),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)({busy:!1,result:null}),[y,x]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{h||(f?g(f):r&&g(r))},[f,r,h]);let S=(0,Q.useMemo)(()=>h.trim()||(f??r??``),[f,r,h]),C=!f&&!!r&&S===r,T=Lt(u),{data:E,mutate:D}=m(n&&S?[`reverse-proxy-pair`,S]:null,()=>me(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),O=(0,Q.useMemo)(()=>!S||!E?.pairingSecret?``:s({baseUrl:S,pairingSecret:E.pairingSecret,lanUrl:T}),[S,T,E?.pairingSecret]),k=b(()=>tt(O),[O],{enabled:!!O,initial:null,errorData:null}),A=(0,Q.useCallback)(async()=>{let e=h.trim()||S;if(e){v({busy:!0,result:null});try{v({busy:!1,result:await jt(e)})}catch(e){v({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[h,S]),j=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){x({busy:!0,error:null});try{await Mt(e),await d(),await l(`tunnel-pair-context`),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[S,l,d]),M=(0,Q.useCallback)(async()=>{x({busy:!0,error:null});try{await Mt(null),await d(),await l(`tunnel-pair-context`),g(``),v({busy:!1,result:null}),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}},[l,d]),N=(0,Q.useCallback)(async()=>{await D()},[D]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:w,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:i(Ft(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:h,onChange:e=>{g(e.target.value),v({busy:!1,result:null})}}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void A(),disabled:_.busy||!h.trim(),children:[_.busy?(0,$.jsx)(z,{className:`size-3.5 animate-spin`}):null,_.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),C&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,_.result?(0,$.jsx)(zt,{result:_.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[S&&f!==S?(0,$.jsxs)(X,{type:`button`,onClick:()=>void j(),disabled:y.busy,children:[y.busy?(0,$.jsx)(z,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,f?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>void M(),disabled:y.busy,children:t.clear}):null]}),y.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:y.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(ve,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),O?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void N(),children:[(0,$.jsx)(te,{className:`size-4`}),t.refreshQr]}):null]}),S?E?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,S,T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,T]}):null]}),k.data?(0,$.jsx)(`img`,{src:k.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):k.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(fe,{text:O,labels:{copy:t.copyLink,copied:t.copied,copyFailed:a(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function zt(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Bt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Vt(e){return e&&Bt.includes(e)?e:`guide`}function Ht(e,t){return e.tabs[t]}function Ut(e,t){return e.tabIntro[t]}function Wt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Gt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Dt,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(st,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Rt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yt,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(mt,{}),t[6]=e):e=t[6],e}}}function Kt(){let e=(0,Z.c)(2),t=o(Jt),n=a(t).remoteAccess,r=!!c(qt),[i,s]=L(),l=Vt(i.get(`tab`)),u;e[0]===s?u=e[1]:(u=e=>{s(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=s,e[1]=u);let d=u,f=Ut(n,l),p=Bt.map(e=>({id:e,label:Ht(n,e)}));return(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)(Qe,{language:t,label:n.docsLink,section:Wt(l),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{items:p,activeTab:l,onChange:d,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(Se,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Ht(n,l),hint:l===`public`?void 0:f,children:(0,$.jsx)(Gt,{tab:l,onOpenTab:d})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function qt(e){return e.token}function Jt(e){return e.language}export{Kt as RemoteAccessHub};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{aa as a,ra as o,sa as s}from"./index-CnjzMw5i.js";import{n as c,t as l}from"./cron-expression-B3B1eqnr.js";var u=n(),d=e(t(),1),f=r(),p=Array.from({length:60},(e,t)=>t),m=i(a,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),h=i(`h-9 min-w-[6.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,o,`dark:bg-surface-panel`),g=i(`h-9 min-w-[9.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,o),_=i(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,o),v=i(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,o);function y(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function b(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function x(e,t){switch(t.type){case`reset`:return y(t.state);case`replace`:return t.state}}function S({value:e,onChange:t,labels:n,disabled:r,showHeading:a=!0}){let o=(0,d.useMemo)(()=>c(e),[e]),[s,u]=(0,d.useReducer)(x,o,y),S=(0,d.useRef)(e);S.current!==e&&(S.current=e,u({type:`reset`,state:o}));let C=(0,d.useCallback)(e=>{let n={...s,...e};u({type:`replace`,state:n});let r=b(n),i=b(s);Object.keys(r).some(e=>r[e]!==i[e])&&t(l(r))},[t,s]),{mode:w,intervalKind:T,onceDate:E,intervalMinutes:D,intervalHours:O,minute:k,hour:A,weekDays:j,dayOfMonth:M,rawCron:N,intervalMinutesDraft:P,intervalHoursDraft:F}=s,I=`${String(A).padStart(2,`0`)}:${String(k).padStart(2,`0`)}`,L=e=>{let t=e.target.value;if(!t)return;let[n,r]=t.split(`:`).map(e=>parseInt(e,10));Number.isNaN(n)||Number.isNaN(r)||C({minute:r,hour:n})},R=(0,f.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,f.jsxs)(`select`,{className:m,disabled:r,value:w,onChange:e=>{let t=e.target.value;C({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,f.jsx)(`option`,{value:`no_repeat`,children:n.modeNoRepeat}),(0,f.jsx)(`option`,{value:`interval`,children:n.modeInterval}),(0,f.jsx)(`option`,{value:`hourly`,children:n.modeHourly}),(0,f.jsx)(`option`,{value:`daily`,children:n.modeDaily}),(0,f.jsx)(`option`,{value:`weekly`,children:n.modeWeekly}),(0,f.jsx)(`option`,{value:`monthly`,children:n.modeMonthly}),(0,f.jsx)(`option`,{value:`custom`,children:n.modeCustom})]}),w===`no_repeat`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{type:`date`,disabled:r,className:g,value:E,onChange:e=>{C({onceDate:e.target.value})},"aria-label":n.modeNoRepeat}),(0,f.jsx)(`input`,{type:`time`,step:60,disabled:r,className:h,value:I,onChange:L,"aria-label":n.scheduleTimeLabel})]}),w===`interval`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`select`,{className:i(m,`w-auto min-w-[5rem]`),disabled:r,value:T,onChange:e=>{let t=e.target.value;C({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,f.jsx)(`option`,{value:`minutes`,children:n.intervalKindMinutes}),(0,f.jsx)(`option`,{value:`hours`,children:n.intervalKindHours})]}),T===`minutes`?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:_,value:P??String(D),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),C(r)},onBlur:()=>{if(P===null)return;let e=parseInt(P,10);C({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,f.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:_,value:F??String(O),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),C(r)},onBlur:()=>{if(F===null)return;let e=parseInt(F,10);C({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,f.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,f.jsx)(`select`,{className:i(m,`w-auto min-w-[4rem]`),disabled:r,value:k,onChange:e=>{C({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:p.map(e=>(0,f.jsx)(`option`,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,f.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),w===`daily`&&(0,f.jsx)(`input`,{type:`time`,step:60,disabled:r,className:h,value:I,onChange:L,"aria-label":n.scheduleTimeLabel}),w===`weekly`&&(0,f.jsx)(`input`,{type:`time`,step:60,disabled:r,className:h,value:I,onChange:L,"aria-label":n.scheduleTimeLabel}),w===`monthly`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`select`,{className:i(m,`w-auto min-w-[4.5rem]`),disabled:r,value:M,onChange:e=>{C({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,f.jsx)(`option`,{value:e,children:e},e))}),(0,f.jsx)(`input`,{type:`time`,step:60,disabled:r,className:h,value:I,onChange:L,"aria-label":n.scheduleTimeLabel})]}),w===`hourly`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`select`,{className:i(m,`w-auto min-w-[4rem]`),disabled:r,value:k,onChange:e=>{C({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:p.map(e=>(0,f.jsx)(`option`,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,f.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),z=w===`weekly`?(0,f.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=j[t];return(0,f.jsx)(`button`,{type:`button`,disabled:r,className:i(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...j];e[t]=!e[t],C({weekDays:e})},children:e},e)})}):null,B=w===`custom`?(0,f.jsxs)(`div`,{className:`pt-1`,children:[(0,f.jsx)(`textarea`,{disabled:r,className:v,rows:2,spellCheck:!1,value:N,placeholder:`*/5 * * * *`,onChange:e=>{C({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,f.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,f.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,R,z,B]})}var C=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5],w=new Set(C),T=i(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,o),E=i(a,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function D(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function O({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=C,minSeconds:a=1}){let o=(0,d.useMemo)(()=>new Set(i),[i]),s=(0,d.useMemo)(()=>o.has(e)?String(e):``,[o,e]),[c,l]=(0,d.useState)(null),u=(0,d.useRef)(e);u.current!==e&&(u.current=e,l(null));let p=Math.max(a,Math.round(e/1e3)),m=c===null?String(p):c;return(0,f.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(`input`,{type:`number`,min:a,step:1,disabled:r,className:T,value:m,onChange:e=>{let n=e.target.value;l(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=a&&t(r*1e3)},onBlur:()=>{if(c===null)return;let e=parseInt(c,10);t(!Number.isFinite(e)||e<a?a*1e3:e*1e3),l(null)}}),(0,f.jsxs)(`select`,{className:E,disabled:r,value:s,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),l(null))},children:[(0,f.jsx)(`option`,{value:``,children:n.presets.custom}),i.map(e=>(0,f.jsx)(`option`,{value:String(e),children:D(e,n.presets)},e))]})]})]})}var k=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,o),A=()=>({start:`09:00`,end:`22:00`,timezone:``});function j(e){let t=(0,u.c)(55),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(A()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,f.jsx)(s,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let c;t[8]!==r||t[9]!==n?(c=e=>r({...n,start:e.target.value}),t[8]=r,t[9]=n,t[10]=c):c=t[10];let l;t[11]!==a||t[12]!==c||t[13]!==n.start?(l=(0,f.jsx)(`input`,{type:`time`,step:60,disabled:a,className:k,value:n.start,onChange:c}),t[11]=a,t[12]=c,t[13]=n.start,t[14]=l):l=t[14];let d;t[15]!==o||t[16]!==l?(d=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[o,l]}),t[15]=o,t[16]=l,t[17]=d):d=t[17];let p;t[18]===i.end?p=t[19]:(p=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[18]=i.end,t[19]=p);let m;t[20]!==r||t[21]!==n?(m=e=>r({...n,end:e.target.value}),t[20]=r,t[21]=n,t[22]=m):m=t[22];let h;t[23]!==a||t[24]!==m||t[25]!==n.end?(h=(0,f.jsx)(`input`,{type:`time`,step:60,disabled:a,className:k,value:n.end,onChange:m}),t[23]=a,t[24]=m,t[25]=n.end,t[26]=h):h=t[26];let g;t[27]!==p||t[28]!==h?(g=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[p,h]}),t[27]=p,t[28]=h,t[29]=g):g=t[29];let _;t[30]===i.timezone?_=t[31]:(_=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[30]=i.timezone,t[31]=_);let v;t[32]!==r||t[33]!==n?(v=e=>r({...n,timezone:e.target.value}),t[32]=r,t[33]=n,t[34]=v):v=t[34];let y;t[35]!==a||t[36]!==v||t[37]!==n.timezone?(y=(0,f.jsx)(`input`,{type:`text`,disabled:a,className:k,value:n.timezone,onChange:v,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[35]=a,t[36]=v,t[37]=n.timezone,t[38]=y):y=t[38];let b;t[39]!==y||t[40]!==_?(b=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[_,y]}),t[39]=y,t[40]=_,t[41]=b):b=t[41];let x;t[42]!==b||t[43]!==d||t[44]!==g?(x=(0,f.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[d,g,b]}),t[42]=b,t[43]=d,t[44]=g,t[45]=x):x=t[45];let S;t[46]===r?S=t[47]:(S=()=>r(null),t[46]=r,t[47]=S);let C;t[48]!==a||t[49]!==i.clear||t[50]!==S?(C=(0,f.jsx)(s,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:S,children:i.clear}),t[48]=a,t[49]=i.clear,t[50]=S,t[51]=C):C=t[51];let w;return t[52]!==x||t[53]!==C?(w=(0,f.jsxs)(`div`,{className:`space-y-2`,children:[x,C]}),t[52]=x,t[53]=C,t[54]=w):w=t[54],w}function M(e){let t=(0,u.c)(34),{disabled:n,label:r,hint:a,className:o}=e,s;t[0]===o?s=t[1]:(s=i(`flex flex-col gap-2`,o),t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,f.jsx)(S,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let d;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(d=e.kind===`interval`?(0,f.jsx)(O,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??C,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=d):d=t[18];let p;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(p=e.kind===`active-hours`?(0,f.jsx)(j,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=p):p=t[24];let m;t[25]===a?m=t[26]:(m=a?(0,f.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[25]=a,t[26]=m);let h;return t[27]!==s||t[28]!==c||t[29]!==l||t[30]!==d||t[31]!==p||t[32]!==m?(h=(0,f.jsxs)(`div`,{className:s,children:[c,l,d,p,m]}),t[27]=s,t[28]=c,t[29]=l,t[30]=d,t[31]=p,t[32]=m,t[33]=h):h=t[33],h}export{w as n,M as t};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{Xi as i,qi as a}from"./index-CnjzMw5i.js";var o=t();e();var s=n();function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function u(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function d(e){return e[`x-hidden`]===!0}function f(e){let t=e.properties;if(!c(t))return[];let n=[];for(let[e,r]of Object.entries(t))c(r)&&(d(r)||n.push({key:e,sub:r,order:l(r),group:u(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function p(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function m(e){let t=(0,o.c)(38),{name:n,s:r,value:c,onChange:l,disabled:u}=e,d=typeof r.description==`string`?r.description:void 0,f=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||d,p=r.format;if(Array.isArray(r.enum)&&r.enum.every(g)){let e;t[0]===d?e=t[1]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[0]=d,t[1]=e);let i;t[2]===l?i=t[3]:(i=e=>l(e.target.value),t[2]=l,t[3]=i);let a;t[4]===r.enum?a=t[5]:(a=r.enum.map(h),t[4]=r.enum,t[5]=a);let o;t[6]!==u||t[7]!==n||t[8]!==i||t[9]!==a||t[10]!==c?(o=(0,s.jsx)(`select`,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:c,disabled:u,onChange:i,children:a}),t[6]=u,t[7]=n,t[8]=i,t[9]=a,t[10]=c,t[11]=o):o=t[11];let f;return t[12]!==e||t[13]!==o?(f=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,o]}),t[12]=e,t[13]=o,t[14]=f):f=t[14],f}if(p===`password`){let e;t[15]===d?e=t[16]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[15]=d,t[16]=e);let n;t[17]!==u||t[18]!==l||t[19]!==f||t[20]!==c?(n=(0,s.jsx)(i,{value:c,onChange:l,placeholder:f,labels:a,disabled:u,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=u,t[18]=l,t[19]=f,t[20]=c,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let m;t[25]===d?m=t[26]:(m=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[25]=d,t[26]=m);let _;t[27]===l?_=t[28]:(_=e=>l(e.target.value),t[27]=l,t[28]=_);let v;t[29]!==u||t[30]!==n||t[31]!==f||t[32]!==_||t[33]!==c?(v=(0,s.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:c,placeholder:f,disabled:u,onChange:_}),t[29]=u,t[30]=n,t[31]=f,t[32]=_,t[33]=c,t[34]=v):v=t[34];let y;return t[35]!==m||t[36]!==v?(y=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,v]}),t[35]=m,t[36]=v,t[37]=y):y=t[37],y}function h(e){return(0,s.jsx)(`option`,{value:e,children:e},e)}function g(e){return typeof e==`string`}function _(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,c=typeof n.description==`string`?n.description:void 0,l;t[0]===c?l=t[1]:(l=c?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:c}):null,t[0]=c,t[1]=l);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,s.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==l||t[9]!==f?(p=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,f]}),t[8]=l,t[9]=f,t[10]=p):p=t[10],p}function v(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:c}=e,l=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:c?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,s.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,s.jsx)(`span`,{children:l}),t[6]=l,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,s.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function y(e){let t=(0,o.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:l}=e,u=typeof n.description==`string`?n.description:void 0,d=n.items,f=c(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=l?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==u||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===u?_=t[12]:(_=u?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:u}):null,t[11]=u,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,s.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=u,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,s.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=l?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,s.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,s.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function b(e){let t=(0,o.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:l,labels:u}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,o;t[2]===a?o=t[3]:(o=e=>a(e),t[2]=a,t[3]=o);let c;t[4]!==l||t[5]!==u||t[6]!==r||t[7]!==n||t[8]!==o?(c=(0,s.jsx)(v,{s:r,value:n,disabled:l,onChange:o,labels:u}),t[4]=l,t[5]=u,t[6]=r,t[7]=n,t[8]=o,t[9]=c):c=t[9];let d;return t[10]!==e||t[11]!==c?(d=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[10]=e,t[11]=c,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,o;t[15]!==l||t[16]!==a||t[17]!==r||t[18]!==n?(o=(0,s.jsx)(_,{s:r,value:n,disabled:l,onChange:a}),t[15]=l,t[16]=a,t[17]=r,t[18]=n,t[19]=o):o=t[19];let c;return t[20]!==e||t[21]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[20]=e,t[21]=o,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let o=typeof i==`string`?i:``,c;t[25]!==l||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==o?(c=(0,s.jsx)(m,{name:n,s:r,value:o,disabled:l,onChange:a}),t[25]=l,t[26]=n,t[27]=a,t[28]=r,t[29]=o,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=c(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(x)?i.map(String):[],t[36]=i,t[37]=n);let o;t[38]!==l||t[39]!==u||t[40]!==a||t[41]!==r||t[42]!==n?(o=(0,s.jsx)(y,{s:r,value:n,disabled:l,onChange:a,labels:u}),t[38]=l,t[39]=u,t[40]=a,t[41]=r,t[42]=n,t[43]=o):o=t[43];let c;return t[44]!==e||t[45]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[44]=e,t[45]=o,t[46]=c):c=t[46],c}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=c(i)?i:{},t[47]=i,t[48]=e);let n=e,o;t[49]===f?o=t[50]:(o=(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=o);let d;t[51]!==l||t[52]!==u||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,s.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,s.jsx)(S,{schema:r,values:n,onChange:a,disabled:l,labels:u})}),t[51]=l,t[52]=u,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==o||t[58]!==d?(p=(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[o,d]}),t[57]=o,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==u||t[61]!==d||t[62]!==f?(p=u?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=u,t[61]=d,t[62]=f,t[63]=p):p=t[63];let h;return t[64]===p?h=t[65]:(h=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=h),h}function x(e){return typeof e==`string`||typeof e==`number`}function S(e){let t=(0,o.c)(28),{schema:n,values:i,onChange:a,disabled:l,className:u,labels:d}=e,m=l===void 0?!1:l,h;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],h=e;break bb0}let e;t[1]===n?e=t[2]:(e=f(n),t[1]=n,t[2]=e),h=e}let g=h,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=p(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let x=y;if(n.type!==`object`||!c(n.properties)||g.length===0)return null;let S,w;if(t[9]!==u||t[10]!==m||t[11]!==v||t[12]!==d||t[13]!==x||t[14]!==i){let e=Array.from(v.keys()).sort(C);t[17]===u?S=t[18]:(S=r(`flex flex-col gap-4`,u),t[17]=u,t[18]=S);let n;t[19]!==m||t[20]!==v||t[21]!==d||t[22]!==x||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,s.jsx)(b,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>x(e.key,t),disabled:m,labels:d},e.key));return e===``?(0,s.jsx)(`div`,{children:t},`default`):(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,s.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=m,t[20]=v,t[21]=d,t[22]=x,t[23]=i,t[24]=n):n=t[24],w=e.map(n),t[9]=u,t[10]=m,t[11]=v,t[12]=d,t[13]=x,t[14]=i,t[15]=S,t[16]=w}else S=t[15],w=t[16];let T;return t[25]!==S||t[26]!==w?(T=(0,s.jsx)(`div`,{className:S,children:w}),t[25]=S,t[26]=w,t[27]=T):T=t[27],T}function C(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{S as t};