@xopcai/xopc 0.0.159 → 0.0.161

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 (215) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{action-boundary-settings-panel-CaRK2vIy.js → action-boundary-settings-panel-BIVBUiNT.js} +1 -1
  4. package/dist/gateway/static/root/assets/activity-store-o7GRljfD.js +1 -0
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BeVf03hx.js → agent-avatar-dicebear-9R3szLMc.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-_qbUaYbs.js +2 -0
  7. package/dist/gateway/static/root/assets/{api-BjcBIV2O.js → api-jSTqFMq9.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-BG2ulMYw.js → app-management-settings-panel-D81cyE76.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-0Kjenr2T.js → appearance-settings-Ct6bZQCV.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-0sPqD0FK.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-ChiNnH1e.js → archive-plugin-CfD7AZKn.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-pbBlQR-g.js → attachment-load-CP_Gaxt3.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automation-suggestion-card-CTZDOyDy.js → automation-suggestion-card-BGKM_NDZ.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-page-BxWBuBsE.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-BeZGzpGF.js → binary-plugins-IPr2EVnS.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-BnDmhN5Z.js → block-editor-B6aHEGA6.js} +3 -3
  17. package/dist/gateway/static/root/assets/browser-settings-page-C499b9AH.js +8 -0
  18. package/dist/gateway/static/root/assets/{capability-presets-api-Ii36j_7v.js → capability-presets-api-CCX9-LjU.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Cl3dw4yh.js → capability-presets-settings-panel-Dva9SiPK.js} +2 -2
  20. package/dist/gateway/static/root/assets/{channel-recipient-api-CFqrSi5K.js → channel-recipient-api-MmLMLDWf.js} +1 -1
  21. package/dist/gateway/static/root/assets/channels-settings-DNAU7u9o.js +1 -0
  22. package/dist/gateway/static/root/assets/channels-status-swr-CIOH7tgn.js +1 -0
  23. package/dist/gateway/static/root/assets/check-DUBLcKHA.js +1 -0
  24. package/dist/gateway/static/root/assets/circle-alert-BEjgurr2.js +1 -0
  25. package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +1 -0
  26. package/dist/gateway/static/root/assets/{connector-logo-CiLxuZ8S.js → connector-logo-BbjzIs87.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-TwiBp8vY.js +2 -0
  28. package/dist/gateway/static/root/assets/createLucideIcon-DPHK1VkS.js +1 -0
  29. package/dist/gateway/static/root/assets/desktop-pet-CYH5ZSXy.js +1 -0
  30. package/dist/gateway/static/root/assets/desktop-pet-settings-DQLqGLc0.js +1 -0
  31. package/dist/gateway/static/root/assets/desktop-pet-sprite-DTqXSpqf.js +1 -0
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-CC2VL5Mc.js → directory-picker-path-field-ClsiXhmz.js} +1 -1
  33. package/dist/gateway/static/root/assets/{dreaming-settings-KY7ZfVsy.js → dreaming-settings-CjMPPdzg.js} +3 -3
  34. package/dist/gateway/static/root/assets/{extension-debug-page-C8KBeucs.js → extension-debug-page-57eizjhB.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-CV-5Kcyk.js → extension-page-CsbSb3u1.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-DvUtDrAu.js → extension-settings-page-DKA9-lyP.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-api-DXfVeJLc.js → gateway-config-api-DIPJuzBZ.js} +1 -1
  38. package/dist/gateway/static/root/assets/gateway-settings-CDLqAQY7.js +1 -0
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-cxQ94qMm.js → gateway-startup-retry-DrfSJtvT.js} +1 -1
  40. package/dist/gateway/static/root/assets/goal-create-dialog-Q3B0E-0s.js +1 -0
  41. package/dist/gateway/static/root/assets/goal-detail-page-C5VAK04G.js +4 -0
  42. package/dist/gateway/static/root/assets/{goals-config-api-P8VhLqYF.js → goals-config-api-lGC10UkU.js} +1 -1
  43. package/dist/gateway/static/root/assets/goals-page-BJb-5IYw.js +2 -0
  44. package/dist/gateway/static/root/assets/{goals-settings-DHXyaH_O.js → goals-settings-BWq0pdrA.js} +1 -1
  45. package/dist/gateway/static/root/assets/{heartbeat-settings-CNckP_Dv.js → heartbeat-settings-D4o8BJVv.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-CkUHH170.css +1 -0
  47. package/dist/gateway/static/root/assets/index-vq_cJZJC.js +199 -0
  48. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-jXmv1RVX.js → keyboard-shortcuts-settings-6T2QYehS.js} +1 -1
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-euH17Kvb.js +2 -0
  50. package/dist/gateway/static/root/assets/{local-apps-page-Cs5LKjtc.js → local-apps-page-DCjg2K9f.js} +1 -1
  51. package/dist/gateway/static/root/assets/{locale-store-C_M71MK9.js → locale-store-Dar-xqQr.js} +1 -1
  52. package/dist/gateway/static/root/assets/logs-page-CyYCBqym.js +7 -0
  53. package/dist/gateway/static/root/assets/{markdown-split-BFqeSNte.js → markdown-split-rt1XO43g.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-Cc8379gq.js → media-plugins-Bwo8CJuh.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-CxySDn9d.js +5 -0
  56. package/dist/gateway/static/root/assets/models-hub-panel-DObxxjc9.js +2 -0
  57. package/dist/gateway/static/root/assets/{notes-page-DlGU4ipo.js → notes-page-Dp-pkX7d.js} +1 -1
  58. package/dist/gateway/static/root/assets/notes-workbench-CCb4RXcZ.js +4 -0
  59. package/dist/gateway/static/root/assets/{page-tabs-kFOswGlG.js → page-tabs-CzZ4iKOb.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-CvjuvABg.js → preview-open-alternatives-3E_Qa-58.js} +1 -1
  61. package/dist/gateway/static/root/assets/product-delivery-BTRT9kCS.js +1 -0
  62. package/dist/gateway/static/root/assets/product-open-page-B2T48Sbt.js +1 -0
  63. package/dist/gateway/static/root/assets/project-detail-page-BvEcriRC.js +1 -0
  64. package/dist/gateway/static/root/assets/projects-page-B_e79MRJ.js +1 -0
  65. package/dist/gateway/static/root/assets/remote-access-hub-DGcqnYfR.js +1 -0
  66. package/dist/gateway/static/root/assets/{save-bar-controls-DwrD7ODx.js → save-bar-controls-CkeKasGm.js} +1 -1
  67. package/dist/gateway/static/root/assets/{schedule-field-Ba4WzTmE.js → schedule-field-TkqUL3wm.js} +1 -1
  68. package/dist/gateway/static/root/assets/{schema-form-DvydL8eF.js → schema-form-DC-iU5IG.js} +1 -1
  69. package/dist/gateway/static/root/assets/sessions-page-DQZhrDJ8.js +1 -0
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-BkdeN99Y.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-collapsible-section-LaQqGGej.js → settings-collapsible-section-Dpqth3oA.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-form-section-DruI__qO.js → settings-form-section-CNqF6IwY.js} +1 -1
  73. package/dist/gateway/static/root/assets/{settings-loading-skeleton-UvA-eDhF.js → settings-loading-skeleton-DkvwitK_.js} +1 -1
  74. package/dist/gateway/static/root/assets/{settings-page-layout-DG-XMIPu.js → settings-page-layout-DWvNgISx.js} +1 -1
  75. package/dist/gateway/static/root/assets/{settings-page-5oCGSebm.js → settings-page-qPG7I2zd.js} +1 -1
  76. package/dist/gateway/static/root/assets/setup-status-panel-lwRAh9aw.js +1 -0
  77. package/dist/gateway/static/root/assets/{share-preview-page-FLVeTrRt.js → share-preview-page-DGpSPW-n.js} +1 -1
  78. package/dist/gateway/static/root/assets/shares-settings-BGj9IVUr.js +1 -0
  79. package/dist/gateway/static/root/assets/skill-reload-api-B2UBAs5U.js +1 -0
  80. package/dist/gateway/static/root/assets/skills-page-DdjzFZ8I.js +2 -0
  81. package/dist/gateway/static/root/assets/{system-settings-panel-CeK93xVi.js → system-settings-panel-8TxxSbUw.js} +1 -1
  82. package/dist/gateway/static/root/assets/{theme-store-C8ohIHhw.js → theme-store-B5FzMWOx.js} +1 -1
  83. package/dist/gateway/static/root/assets/{typed-models-lib-D1Lr2gG0.js → typed-models-lib-DEGtSA5h.js} +1 -1
  84. package/dist/gateway/static/root/assets/{use-channel-catalog-BWzou5ar.js → use-channel-catalog-BDU6FneG.js} +1 -1
  85. package/dist/gateway/static/root/assets/user-context-page-BTTZpAGV.js +1 -0
  86. package/dist/gateway/static/root/assets/voice-api-key-field-DuDQd-WU.js +1 -0
  87. package/dist/gateway/static/root/assets/work-discovery-page-BUVkVCsW.js +1 -0
  88. package/dist/gateway/static/root/assets/work-item-detail-page-DeEPPu4n.js +1 -0
  89. package/dist/gateway/static/root/assets/work-page-DQNUyTUq.js +1 -0
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Bynqe4kV.js → workflow-run-setup-panel-Cwi8Pz7n.js} +2 -2
  91. package/dist/gateway/static/root/assets/workflows-page-BIy4wrzO.js +11 -0
  92. package/dist/gateway/static/root/index.html +12 -10
  93. package/dist/package.js +1 -1
  94. package/dist/src/automations/service/action-executor.js +1 -1
  95. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  96. package/dist/src/config/agent-profile.js +1 -1
  97. package/dist/src/gateway/agents-admin.js +1 -1
  98. package/dist/src/gateway/chat-stream/mapper.d.ts +1 -0
  99. package/dist/src/gateway/chat-stream/mapper.js +43 -7
  100. package/dist/src/gateway/hono/routes/home.js +15 -2
  101. package/dist/src/gateway/hono/routes/work-discovery.js +451 -0
  102. package/dist/src/gateway/hono/sse.d.ts +2 -0
  103. package/dist/src/gateway/hono/sse.js +10 -3
  104. package/dist/src/gateway/run-loop.js +17 -7
  105. package/dist/src/gateway/server.d.ts +1 -0
  106. package/dist/src/gateway/server.js +9 -0
  107. package/dist/src/gateway/service.d.ts +2 -0
  108. package/dist/src/gateway/service.js +27 -2
  109. package/dist/src/local-apps/preview-runtime-bridge.d.ts +1 -1
  110. package/dist/src/local-apps/preview-runtime-bridge.js +14 -11
  111. package/dist/src/mobile/notification-service.js +1 -0
  112. package/dist/src/pets/factory.js +23 -26
  113. package/dist/src/pets/manifest.d.ts +2 -1
  114. package/dist/src/pets/manifest.js +15 -8
  115. package/dist/src/pets/validator.js +8 -3
  116. package/dist/src/proactive/calendar-signals.d.ts +4 -0
  117. package/dist/src/proactive/calendar-signals.js +120 -0
  118. package/dist/src/proactive/focus-service.d.ts +62 -0
  119. package/dist/src/proactive/focus-service.js +173 -0
  120. package/dist/src/proactive/index.d.ts +7 -0
  121. package/dist/src/proactive/index.js +7 -0
  122. package/dist/src/proactive/insight-repository.d.ts +19 -0
  123. package/dist/src/proactive/insight-repository.js +106 -0
  124. package/dist/src/proactive/run-processor.d.ts +19 -0
  125. package/dist/src/proactive/run-processor.js +125 -0
  126. package/dist/src/proactive/trial-expiry-reconciler.d.ts +5 -0
  127. package/dist/src/proactive/trial-expiry-reconciler.js +30 -0
  128. package/dist/src/proactive/types.d.ts +64 -0
  129. package/dist/src/proactive/types.js +1 -0
  130. package/dist/src/proactive/watch-repository.d.ts +28 -0
  131. package/dist/src/proactive/watch-repository.js +129 -0
  132. package/dist/src/storage/sqlite/knowledge-repository.d.ts +1 -0
  133. package/dist/src/storage/sqlite/knowledge-repository.js +4 -0
  134. package/dist/src/storage/sqlite/migrations/047_work_discovery_sources.sql +16 -0
  135. package/dist/src/storage/sqlite/migrations/048_work_understanding_investigations.sql +40 -0
  136. package/dist/src/storage/sqlite/migrations/049_work_understanding_threads.sql +52 -0
  137. package/dist/src/storage/sqlite/migrations/050_work_discovery_source_refreshes.sql +15 -0
  138. package/dist/src/storage/sqlite/migrations/051_focus_watches.sql +26 -0
  139. package/dist/src/storage/sqlite/migrations/052_proactive_insights.sql +25 -0
  140. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  141. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  142. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  143. package/dist/src/storage/sqlite/schema.js +1 -1
  144. package/dist/src/work-discovery/analyzer.d.ts +12 -1
  145. package/dist/src/work-discovery/analyzer.js +126 -7
  146. package/dist/src/work-discovery/candidate-discovery.d.ts +17 -0
  147. package/dist/src/work-discovery/candidate-discovery.js +279 -0
  148. package/dist/src/work-discovery/evaluation.d.ts +11 -0
  149. package/dist/src/work-discovery/evaluation.js +17 -0
  150. package/dist/src/work-discovery/governance.d.ts +25 -0
  151. package/dist/src/work-discovery/governance.js +96 -0
  152. package/dist/src/work-discovery/incremental-repository.d.ts +13 -0
  153. package/dist/src/work-discovery/incremental-repository.js +55 -0
  154. package/dist/src/work-discovery/incremental.d.ts +2 -0
  155. package/dist/src/work-discovery/incremental.js +7 -0
  156. package/dist/src/work-discovery/index.d.ts +10 -0
  157. package/dist/src/work-discovery/index.js +13 -3
  158. package/dist/src/work-discovery/investigation-repository.d.ts +16 -0
  159. package/dist/src/work-discovery/investigation-repository.js +122 -0
  160. package/dist/src/work-discovery/investigator.d.ts +55 -0
  161. package/dist/src/work-discovery/investigator.js +358 -0
  162. package/dist/src/work-discovery/probe.d.ts +22 -0
  163. package/dist/src/work-discovery/probe.js +88 -1
  164. package/dist/src/work-discovery/service.d.ts +110 -1
  165. package/dist/src/work-discovery/service.js +578 -8
  166. package/dist/src/work-discovery/source-repository.d.ts +13 -0
  167. package/dist/src/work-discovery/source-repository.js +72 -0
  168. package/dist/src/work-discovery/thread-repository.d.ts +34 -0
  169. package/dist/src/work-discovery/thread-repository.js +112 -0
  170. package/dist/src/work-discovery/thread-service.d.ts +8 -0
  171. package/dist/src/work-discovery/thread-service.js +104 -0
  172. package/dist/src/work-discovery/types.d.ts +145 -0
  173. package/package.json +1 -1
  174. package/skills/creative/hatch-pet/SKILL.md +2 -2
  175. package/dist/gateway/static/root/assets/activity-store-C-57rvkX.js +0 -1
  176. package/dist/gateway/static/root/assets/agents-P05C4A-3.js +0 -2
  177. package/dist/gateway/static/root/assets/apps-page-DANGrBpN.js +0 -1
  178. package/dist/gateway/static/root/assets/automations-page-BXfGL_cm.js +0 -6
  179. package/dist/gateway/static/root/assets/browser-settings-page-534luV0B.js +0 -8
  180. package/dist/gateway/static/root/assets/channels-settings-M91zFJVi.js +0 -1
  181. package/dist/gateway/static/root/assets/channels-status-swr-vooEF4lG.js +0 -1
  182. package/dist/gateway/static/root/assets/check-BODqo66o.js +0 -1
  183. package/dist/gateway/static/root/assets/circle-alert-RzVebuX2.js +0 -1
  184. package/dist/gateway/static/root/assets/cn-BQ_8x0bT.js +0 -1
  185. package/dist/gateway/static/root/assets/connectors-page-CV5UulW6.js +0 -2
  186. package/dist/gateway/static/root/assets/desktop-pet-Cil2eSpW.js +0 -1
  187. package/dist/gateway/static/root/assets/desktop-pet-settings-DwsC6l5F.js +0 -1
  188. package/dist/gateway/static/root/assets/desktop-pet-sprite-DqZ6fbIj.js +0 -1
  189. package/dist/gateway/static/root/assets/gateway-settings-BpJ0v56l.js +0 -1
  190. package/dist/gateway/static/root/assets/goal-create-dialog-lMHD-2CX.js +0 -1
  191. package/dist/gateway/static/root/assets/goal-detail-page-yPmF-G7b.js +0 -4
  192. package/dist/gateway/static/root/assets/goals-page-BHTCKobG.js +0 -2
  193. package/dist/gateway/static/root/assets/index-BgZhEOkN.css +0 -1
  194. package/dist/gateway/static/root/assets/index-BuqGh2SW.js +0 -193
  195. package/dist/gateway/static/root/assets/local-app-workbench-page-zpp_wciE.js +0 -2
  196. package/dist/gateway/static/root/assets/logs-page-B4CRYqYR.js +0 -7
  197. package/dist/gateway/static/root/assets/messages-BuT0SR1R.js +0 -5
  198. package/dist/gateway/static/root/assets/models-hub-panel-1hdoAoB_.js +0 -2
  199. package/dist/gateway/static/root/assets/notes-workbench-DQEAZTA5.js +0 -4
  200. package/dist/gateway/static/root/assets/project-detail-page-Bp9bC7A6.js +0 -1
  201. package/dist/gateway/static/root/assets/projects-page-RNorFXTw.js +0 -1
  202. package/dist/gateway/static/root/assets/remote-access-hub-BqRTcM_6.js +0 -1
  203. package/dist/gateway/static/root/assets/sessions-page-B2EfW1cm.js +0 -1
  204. package/dist/gateway/static/root/assets/settings-advanced-gate-CklL85T4.js +0 -1
  205. package/dist/gateway/static/root/assets/setup-status-panel-D3my1HgB.js +0 -1
  206. package/dist/gateway/static/root/assets/shares-settings-DVxgjrsP.js +0 -1
  207. package/dist/gateway/static/root/assets/skill-reload-api-Bcu58ZaF.js +0 -1
  208. package/dist/gateway/static/root/assets/skills-page-CDd-84FE.js +0 -2
  209. package/dist/gateway/static/root/assets/sliding-segmented-uWmrxE3P.js +0 -1
  210. package/dist/gateway/static/root/assets/user-context-page-1OyJnTyR.js +0 -1
  211. package/dist/gateway/static/root/assets/voice-api-key-field-B2ncRwHS.js +0 -1
  212. package/dist/gateway/static/root/assets/work-discovery-page-BZlY4PZL.js +0 -1
  213. package/dist/gateway/static/root/assets/work-item-detail-page-DPXMrneY.js +0 -1
  214. package/dist/gateway/static/root/assets/work-page-CTERoqyv.js +0 -1
  215. package/dist/gateway/static/root/assets/workflows-page-CLgsnqFQ.js +0 -11
@@ -0,0 +1,8 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./copy-to-clipboard-HOJ79TWv.js";import{t as s}from"./messages-CxySDn9d.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Dar-xqQr.js";import{$o as p,Bl as m,Cc as h,Ds as g,Fl as _,Fs as v,Gl as y,Ja as b,Jn as x,Kc as S,Lc as C,Ls as w,Mt as T,Nt as E,Rl as D,Ss as O,Tc as k,Xl as A,Ya as j,Ys as M,Zl as N,au as P,bl as F,ds as I,ec as L,eu as R,hc as z,jt as B,nc as V,ps as H,qo as U,qr as W,rc as ee,ru as G,ts as te,wc as K,yc as ne}from"./index-vq_cJZJC.js";import{n as re,r as ie,t as ae}from"./settings-page-layout-DWvNgISx.js";import{n as oe}from"./settings-loading-skeleton-DkvwitK_.js";import{t as se}from"./settings-advanced-gate-BkdeN99Y.js";import{n as ce,t as q}from"./settings-form-section-CNqF6IwY.js";import{t as le}from"./page-tabs-CzZ4iKOb.js";import{c as ue,r as de,s as J}from"./typed-models-lib-DEGtSA5h.js";import{i as fe,l as pe,s as me,u as he}from"./gateway-config-api-DIPJuzBZ.js";var Y=e(t(),1),X=n(),Z=r();function Q(e){let t=(0,X.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 ge(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function _e(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:i,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=a(ue(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let m;t[16]===r?m=t[17]:(m=e=>r(e.target.value),t[16]=r,t[17]=m);let h=s.browserPickerTitle,g;t[18]===o?g=t[19]:(g=o.map(ve),t[18]=o,t[19]=g);let _;t[20]!==s.browserPickerTitle||t[21]!==m||t[22]!==g||t[23]!==n?(_=(0,Z.jsx)(p,{id:`browser-backend-select`,className:f,value:n,onChange:m,"aria-label":h,children:g}),t[20]=s.browserPickerTitle,t[21]=m,t[22]=g,t[23]=n,t[24]=_):_=t[24];let v=i?(0,Z.jsxs)(`button`,{type:`button`,className:a(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:s.browserGoToConfigure}),(0,Z.jsx)(P,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,y;t[25]!==v||t[26]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[_,v]}),t[25]=v,t[26]=_,t[27]=y):y=t[27],c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,y,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:a(`inline-block size-1.5 rounded-full`,ge(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=i,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function ve(e){return(0,Z.jsx)(te,{value:e.value,children:e.name},e.value)}function ye(e){return`browser-focus-${e}`}function be(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function xe(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ye(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(ce,{icon:L,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)(Q,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,m=n.desc.browserDialogPolicy,h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=ue(),t[17]=h):h=t[17];let g;t[18]===i?g=t[19]:(g=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=g);let _;t[20]===n.browserDialogPolicyMustRespond?_=t[21]:(_=(0,Z.jsx)(te,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=_);let v;t[22]===n.browserDialogPolicyAutoDismiss?v=t[23]:(v=(0,Z.jsx)(te,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=v);let y;t[24]===n.browserDialogPolicyAutoAccept?y=t[25]:(y=(0,Z.jsx)(te,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=y);let b;t[26]!==r.browserDialogPolicy||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(b=(0,Z.jsxs)(p,{className:h,value:r.browserDialogPolicy,onChange:g,children:[_,v,y]}),t[26]=r.browserDialogPolicy,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=b):b=t[31];let x;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==b?(x=(0,Z.jsx)(Q,{label:f,description:m,children:b}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=b,t[35]=x):x=t[35];let S=n.label.browserDialogTimeout,C=n.desc.browserDialogTimeout,w;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(w=J(),t[36]=w):w=t[36];let T=r.browserDialogTimeout??``,E;t[37]===i?E=t[38]:(E=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=E);let D;t[39]!==T||t[40]!==E?(D=(0,Z.jsx)(`input`,{type:`number`,className:w,min:1,value:T,placeholder:`300`,onChange:E}),t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==D?(O=(0,Z.jsx)(Q,{label:S,description:C,children:D}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=D,t[45]=O):O=t[45];let k;t[46]!==x||t[47]!==O||t[48]!==d?(k=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,x,O]}),t[46]=x,t[47]=O,t[48]=d,t[49]=k):k=t[49];let A;t[50]!==o||t[51]!==k?(A=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{children:[o,k]})}),t[50]=o,t[51]=k,t[52]=A):A=t[52];let j;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(j=ye(`security`),t[53]=j):j=t[53];let M;t[54]===n.browserSecurityShow?M=t[55]:(M=(0,Z.jsx)(ce,{icon:ee,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=M);let N;t[56]===i?N=t[57]:(N=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=N);let P;t[58]!==r.browserAllowPrivateUrls||t[59]!==N?(P=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:N}),t[58]=r.browserAllowPrivateUrls,t[59]=N,t[60]=P):P=t[60];let F;t[61]===n.browserAllowPrivateOn?F=t[62]:(F=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=F);let I;t[63]!==P||t[64]!==F?(I=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[P,F]}),t[63]=P,t[64]=F,t[65]=I):I=t[65];let R;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==I?(R=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:I}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=I,t[69]=R):R=t[69];let z=n.label.browserCommandTimeout,B=n.desc.browserCommandTimeout,V;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(V=J(),t[70]=V):V=t[70];let H=r.browserCommandTimeout??``,U;t[71]===i?U=t[72]:(U=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=U);let W;t[73]!==H||t[74]!==U?(W=(0,Z.jsx)(`input`,{type:`number`,className:V,min:5,value:H,placeholder:`30`,onChange:U}),t[73]=H,t[74]=U,t[75]=W):W=t[75];let G;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==W?(G=(0,Z.jsx)(Q,{label:z,description:B,children:W}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=W,t[79]=G):G=t[79];let K;t[80]!==R||t[81]!==G?(K=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[R,G]}),t[80]=R,t[81]=G,t[82]=K):K=t[82];let ne;t[83]!==M||t[84]!==K?(ne=(0,Z.jsx)(`div`,{id:j,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[M,K]})}),t[83]=M,t[84]=K,t[85]=ne):ne=t[85];let re;return t[86]!==A||t[87]!==ne?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[A,ne]}),t[86]=A,t[87]=ne,t[88]=re):re=t[88],re}function Se(e){let t=(0,X.c)(9),{language:n,label:r,className:i}=e,o;t[0]===n?o=t[1]:(o=U(n),t[0]=n,t[1]=o);let s;t[2]===i?s=t[3]:(s=a(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(_,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=c):c=t[4];let l;return t[5]!==r||t[6]!==o||t[7]!==s?(l=(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[5]=r,t[6]=o,t[7]=s,t[8]=l):l=t[8],l}function Ce(e){let t=(0,X.c)(27),{title:n,description:r,recommended:i,recommendedLabel:o,icon:s,onSelect:c,selectLabel:l}=e,u=`${n} — ${l}`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=a(`group flex w-full flex-col rounded-xl bg-surface-panel/80 p-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=d):d=t[0];let f;t[1]===s?f=t[2]:(f=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=s,t[2]=f);let p;t[3]===n?p=t[4]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==i||t[6]!==o?(m=i&&o?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:o}):null,t[5]=i,t[6]=o,t[7]=m):m=t[7];let h;t[8]!==p||t[9]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,m]}),t[8]=p,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]!==f||t[18]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=y):y=t[19];let b;t[20]===l?b=t[21]:(b=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:l}),t[20]=l,t[21]=b);let x;return t[22]!==c||t[23]!==u||t[24]!==y||t[25]!==b?(x=(0,Z.jsxs)(`button`,{type:`button`,onClick:c,"aria-label":u,className:d,children:[y,b]}),t[22]=c,t[23]=u,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function we(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=W(Te),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:ne,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:V,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:C,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:y,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>pe(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let c;t[12]===n.browserSetupSubtitle?c=t[13]:(c=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=c);let l;t[14]!==s||t[15]!==c?(l=(0,Z.jsxs)(`div`,{children:[s,c]}),t[14]=s,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(u=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,Z.jsx)(Ce,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=u):u=t[21];let d;return t[22]!==l||t[23]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function Te(e){return e.mode}function Ee(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function De(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Oe(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function ke(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Ae=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],je=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Me={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Ne(e){let t=(e??``).trim();return t===`behavior`?`overview`:Ae.includes(t)?t:`overview`}function Pe(e){return je.includes(e)}function Fe(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ie,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Ie,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ie(e){let t=(0,X.c)(27),{kind:n,detail:r,m:i}=e,o,s,c,l;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:G,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:w,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:S,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:R,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:N,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];o=e,s=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=a(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=o,t[7]=s,t[8]=c,t[9]=l}else o=t[6],s=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=a(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let f;t[12]!==o||t[13]!==d?(f=(0,Z.jsx)(o,{className:d}),t[12]=o,t[13]=d,t[14]=f):f=t[14];let p;t[15]===s?p=t[16]:(p=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=p);let m;t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{className:c,children:[f,p]}),t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20];let h;t[21]===r?h=t[22]:(h=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=h);let g;return t[23]!==l||t[24]!==m||t[25]!==h?(g=(0,Z.jsxs)(`span`,{className:l,children:[m,h]}),t[23]=l,t[24]=m,t[25]=h,t[26]=g):g=t[26],g}function Le(e){let t=(0,X.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,o;t[0]===i?o=t[1]:(o=a(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=o);let s;return t[2]!==r||t[3]!==o?(s=(0,Z.jsx)(`div`,{className:o,children:r}),t[2]=r,t[3]=o,t[4]=s):s=t[4],s}var Re={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function ze({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(E,Re),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:_}=c,v=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{v();let e=setInterval(()=>void v(),8e3);return()=>clearInterval(e)},[v]);let y=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(_.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await v()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[_,r,d,e.browserCdpLaunchedAtPort,n,v]),b=(0,Y.useCallback)(async e=>{await i(e),await v()},[v,i]),x=(0,Y.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Fe,{icon:K,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void y(),children:[d===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Le,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)(Q,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:_,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void b(t.port),children:[(0,Z.jsx)(M,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Fe,{icon:g,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void x(),children:[p===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(h,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),m?(0,Z.jsx)(Le,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function Be(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ve(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Be(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(He)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function He(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ue={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function We({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Y.useReducer)(E,Ue),{confirmOpen:f,installStatus:m,installMessage:h,openStatus:g,openMessage:_,runtime:v}=u,{progress:y,running:b,cancelling:C,run:w,reset:T,cancel:O}=i,k=t.kind===`ok`?t.data:null,A=k?.installed===!0,j=m===`installing`||b,M=(0,Y.useCallback)(async()=>{if(A)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,A]);(0,Y.useEffect)(()=>{if(!A){d({type:`patch`,patch:{runtime:null}});return}M();let e=setInterval(()=>void M(),8e3);return()=>clearInterval(e)},[A,M]);let N=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),T();let t=await w({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),T();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await M()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,M,T,w]),P=(0,Y.useCallback)(async()=>{if(g!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,g]),F=t.kind===`loading`?`checking`:t.kind===`error`?`error`:A?`ready`:`not_installed`,I=A&&k?.version?`v${k.version} (${k.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fe,{icon:V,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:F,statusDetail:I,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[A?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g===`pending`,onClick:()=>void P(),children:[g===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),g===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:j,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[j?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):A?(0,Z.jsx)(z,{className:`size-3.5`}):m===`installed`?(0,Z.jsx)(G,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(D,{className:`size-3.5`}),j?e.browserCloakInstalling:A?e.browserReinstall:e.browserCloakDownload]})]}),children:[b?(0,Z.jsx)(Ve,{m:e,progress:y,cancelling:C,onCancel:()=>void O()}):null,h?(0,Z.jsx)(Le,{kind:m===`failed`?`error`:`success`,message:h}):null,_?(0,Z.jsx)(Le,{kind:g===`error`?`error`:`success`,message:_}):null,A&&v?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:v.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(v.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:v.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),v.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(p,{className:ue(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(te,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(te,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4`,children:[(0,Z.jsx)(ce,{icon:V,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)(Q,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)(Q,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)(Q,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)(Q,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:Ge(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(x,{open:f,title:e.browserConfirmDownloadTitle,description:Ke(e,k),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void N(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Ge(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ke(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
2
+ `)}function qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[a,o]=(0,Y.useState)(`idle`),[c,u]=(0,Y.useState)(null),d=t.provider===`local`?`browserbase`:t.provider,f=s(l(e=>e.language)).providersSettings,m=I({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),g=(0,Y.useCallback)(()=>fe().then(e=>e.apiKey??null),[]),_=(0,Y.useCallback)(async()=>{o(`pending`),u(null);try{let n=await r(d,t.apiKey);n.reachable?(o(`ok`),u(e.browserCloudTestOk)):(o(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){o(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,d,r]);return(0,Z.jsxs)(Fe,{icon:y,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:a===`pending`,onClick:()=>void _(),children:[a===`pending`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(h,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(p,{className:ue(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(te,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(te,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(H,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:d===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:m,reveal:g,loadFailedLabel:`Failed to load key`})}),d===`browserbase`?(0,Z.jsx)(Q,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)(Q,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),c?(0,Z.jsx)(Le,{kind:a===`error`?`error`:`success`,message:c}):null]})}function Je(e){let t=(0,X.c)(48),{m:n,installed:r,extensionDir:i,connected:o,busy:s,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!i&&o,h;t[3]!==s||t[4]!==i||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(h=i?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:c,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:l,title:i,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:u,title:i,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=s,t[4]=i,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,b;t[27]===y?b=t[28]:(b=y.filter(Ye),t[27]=y,t[28]=b);let x=b.length,S=n.browserExtensionInstallGuideTitle,C;t[29]===n.browserExtensionInstallGuideTitle?C=t[30]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=C);let w;t[31]!==x||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(w=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(x)).replace(`{{total}}`,String(y.length)),t[31]=x,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=w):w=t[34];let T;t[35]===w?T=t[36]:(T=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:w}),t[35]=w,t[36]=T);let E;t[37]!==T||t[38]!==C?(E=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[C,T]}),t[37]=T,t[38]=C,t[39]=E):E=t[39];let D;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(D=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(G,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(A,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:a(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=y,t[43]=D):D=t[43];let O;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==E||t[46]!==D?(O=(0,Z.jsxs)(`div`,{"aria-label":S,className:`rounded-xl bg-surface-base p-3`,children:[E,D]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=E,t[46]=D,t[47]=O):O=t[47],O}function Ye(e){return e.done}var Xe=19820,Ze=3e4;function Qe({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:s,installArtifacts:c,refetchArtifacts:l,openExtensionChrome:u,revealExtensionFolder:d,form:f,embedded:p=!1}){let[m,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),C=f.port??Xe,w=f.host||`127.0.0.1`,T=`ws://${w}:${C}/browser-ext`,E=t.kind===`ok`&&t.data.running,O=t.kind===`ok`&&t.data.connected,A=t.kind===`ok`&&t.data.bridgeHeld===!0,j=t.kind===`ok`&&t.data.portConflict===!0,N=E||A,P=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,F=P?.installed===!0,I=P?.extensionDir,L=P?.needsChromeReload===!0,R=t.kind===`ok`?O?{icon:k,color:`text-green-500`,label:e.browserExtensionConnected}:E?{icon:h,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:v,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:v,color:`text-fg-muted`,label:`…`},z=R.icon,B=(0,Y.useCallback)(async()=>{if(!m){g(`start`),y(null);try{await i({host:w,port:C})}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[m,w,C,i]),V=(0,Y.useCallback)(async()=>{if(!m){g(`stop`),y(null);try{await a()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[m,a]),H=(0,Y.useCallback)(async()=>{if(!m){g(`disconnect`),y(null);try{await s()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[m,s]),U=(0,Y.useCallback)(async()=>{if(!m){g(`install`),y(null),x(null);try{let t=await c({force:F});t?.extensionDir?x(`${e.browserExtensionInstalled}: ${t.extensionDir}`):x(e.browserExtensionInstalled),await l()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[m,c,F,e.browserExtensionInstalled,l]),W=(0,Y.useCallback)(async()=>{if(!m){g(`open`),y(null);try{await u()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[m,u]),ee=(0,Y.useCallback)(async()=>{if(!(!I||m)){g(`path`),y(null),x(null);try{await o(I)?x(e.browserExtensionPathCopied):x(e.browserExtensionPathCopyFailed)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[m,I,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),G=(0,Y.useCallback)(async()=>{if(!(!I||m)){g(`folder`),y(null),x(null);try{await d(),x(e.browserExtensionFolderOpened)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(null)}}},[m,I,e.browserExtensionFolderOpened,d]),te=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void U(),children:[m===`install`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(D,{className:`size-3.5`}),m===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),N?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void V(),children:[m===`stop`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(M,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void B(),children:[m===`start`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(K,{className:`size-3.5`}),m===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),O?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:m!==null,onClick:()=>void H(),children:[m===`disconnect`?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(v,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Fe,{icon:ne,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:p,primaryAction:te,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1024,max:65535,value:f.port??``,placeholder:String(Xe),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:f.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1,step:1,value:f.connectionTimeoutMs==null?``:Math.round(f.connectionTimeoutMs/1e3),placeholder:String(Ze/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:T}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${R.color}`,children:[(0,Z.jsx)(z,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:R.label})]})]}),(0,Z.jsx)(Je,{m:e,installed:F,extensionDir:I,connected:O,busy:m!==null,pathBusy:m===`path`,folderBusy:m===`folder`,onOpenChrome:()=>void W(),onCopyPath:()=>void ee(),onRevealFolder:()=>void G()}),L?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,j?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(C))}):null,b?(0,Z.jsx)(Le,{kind:`success`,message:b}):null,_?(0,Z.jsx)(Le,{kind:`error`,message:_}):null]})})}function $e(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[l,u]=(0,Y.useState)(`idle`),[d,f]=(0,Y.useState)(null),{progress:p,running:m,cancelling:h,run:g,reset:_,cancel:v}=o,y;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==_||t[5]!==g?(y=async()=>{u(`installing`),f(null),_();let e=await g({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),_();return}u(`failed`),f(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),f(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=_,t[5]=g,t[6]=y):y=t[6];let b=y,x=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,w=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,T=r.kind===`ok`&&r.data.installed,E=l===`installing`||m,O;t[7]===b?O=t[8]:(O=()=>void b(),t[7]=b,t[8]=O);let k;t[9]!==T||t[10]!==E||t[11]!==l?(k=E?(0,Z.jsx)(S,{className:`size-3.5 animate-spin`}):T?(0,Z.jsx)(z,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(G,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(D,{className:`size-3.5`}),t[9]=T,t[10]=E,t[11]=l,t[12]=k):k=t[12];let A=E?n.browserPlaywrightInstalling:T?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==E||t[14]!==O||t[15]!==k||t[16]!==A?(j=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:E,onClick:O,children:[k,A]}),t[13]=E,t[14]=O,t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=N):N=t[20];let P;t[21]===M?P=t[22]:(P=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=P);let F;t[23]!==v||t[24]!==h||t[25]!==n||t[26]!==p||t[27]!==m?(F=m?(0,Z.jsx)(Ve,{m:n,progress:p,showLogs:!0,cancelling:h,onCancel:()=>void v()}):null,t[23]=v,t[24]=h,t[25]=n,t[26]=p,t[27]=m,t[28]=F):F=t[28];let I;t[29]!==d||t[30]!==l?(I=d?(0,Z.jsx)(Le,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=I):I=t[31];let L;return t[32]!==c||t[33]!==n||t[34]!==w||t[35]!==x||t[36]!==F||t[37]!==I||t[38]!==j||t[39]!==P?(L=(0,Z.jsxs)(Fe,{icon:C,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:x,statusDetail:w,m:n,embedded:c,primaryAction:j,children:[P,F,I]}),t[32]=c,t[33]=n,t[34]=w,t[35]=x,t[36]=F,t[37]=I,t[38]=j,t[39]=P,t[40]=L):L=t[40],L}async function et(e){let t=await u(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await u(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var tt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function nt(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function rt(e){let[t,n]=(0,Y.useReducer)(nt,tt),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,Y.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await et(d(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),c=(0,Y.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await et(d(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),l=(0,Y.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),f=(0,Y.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),p=(0,Y.useCallback)(async()=>et(d(`/api/browser/cloakbrowser/status`)),[]),m=(0,Y.useCallback)(async()=>$(d(`/api/browser/cloakbrowser/launch`),{}),[]),h=e.browserEnabled===!0&&e.probeExtension===!0,g=e.browserEnabled===!0&&e.probeLocal===!0,_=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:v,extensionPort:y}=e,b=(0,Y.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});v&&e.set(`host`,v),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await u(d(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[v,y]),x=(0,Y.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await et(d(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Y.useCallback)(async e=>{let t=(await $(d(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Y.useEffect)(()=>{if(!g){n({type:`playwright-idle`});return}s()},[g,s]),(0,Y.useEffect)(()=>{if(!_){n({type:`cloak-idle`});return}c()},[_,c]);let T=(0,Y.useRef)(h);T.current!==h&&(T.current=h,h||n({type:`extension-idle`})),(0,Y.useEffect)(()=>{if(!h)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[h,b,x]);let E=(0,Y.useCallback)(async e=>{await $(d(`/api/browser/extension/start`),{host:e?.host??v,port:e?.port??y}),await b()},[v,y,b]),D=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!h||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${v}:${y??19820}`;k.current!==t&&(k.current=t,E({host:v,port:y}).catch(()=>{k.current=null}))},[h,a,v,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:f,fetchCloakRuntimeStatus:p,launchCloak:m,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Y.useCallback)(async e=>$(d(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Y.useCallback)(async(e,t)=>$(d(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Y.useCallback)(async e=>$(d(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Y.useCallback)(async e=>{await $(d(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Y.useCallback)(async()=>(await et(d(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var it=`
3
+
4
+ `,at=/\r\n/g,ot={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},st={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ct=8;function lt(){return{phase:null,message:null,percent:null,lines:[]}}function ut(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>ct?r.slice(-8):r}return n}async function dt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
5
+ `)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(at,`
6
+ `);let l=a.split(it);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function ft(e){let[t,n]=(0,Y.useState)(lt),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.useCallback)(()=>{s.current||n(lt())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await u(d(st[e]),{method:`POST`}).catch(()=>{}),c.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,Y.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;c.current=r,s.current=!0,i(!0),n(lt());try{let i=await u(d(ot[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await dt(i.body,e=>{n(t=>ut(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{c.current===r&&(c.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:l,cancel:f}}function pt(e){let t=(0,X.c)(150),{a:n,form:r,update:i,activeTab:o,setActiveTab:s}=e,c=l(ht),u=W(mt),d=ft(`playwright`),f=ft(`cloakbrowser`),p=r.browserEnabled&&(o===`overview`||o===`extension`),m=r.browserEnabled&&(o===`overview`||o===`local`),h=r.browserEnabled&&(o===`overview`||o===`cloakbrowser`),_;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==h||t[7]!==p||t[8]!==m?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:h,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=h,t[7]=p,t[8]=m,t[9]=_):_=t[9];let v=rt(_),b;t[10]===v.playwright?b=t[11]:(b=Ee(v.playwright),t[10]=v.playwright,t[11]=b);let x=b,S;t[12]===v.cloak?S=t[13]:(S=Ee(v.cloak),t[12]=v.cloak,t[13]=S);let w=S,T;t[14]===v.extension?T=t[15]:(T=Oe(v.extension),t[14]=v.extension,t[15]=T);let E=T,D;t[16]!==n||t[17]!==v.extension?(D=ke(v.extension,n),t[16]=n,t[17]=v.extension,t[18]=D):D=t[18];let O=D,k;t[19]!==n||t[20]!==w||t[21]!==E||t[22]!==O||t[23]!==x||t[24]!==u?(k=[{value:`extension`,icon:ne,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:E,statusLabel:O},{value:`local`,icon:C,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:x,statusLabel:De(x,n)},{value:`cloakbrowser`,icon:V,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:w,statusLabel:De(w,n)},{value:`cdp`,icon:g,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:y,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>pe(e.value,u)),t[19]=n,t[20]=w,t[21]=E,t[22]=O,t[23]=x,t[24]=u,t[25]=k):k=t[25];let A=k,j;t[26]!==s||t[27]!==i?(j=e=>{i({browserEnabled:!0,browserBackend:e}),s(e)},t[26]=s,t[27]=i,t[28]=j):j=t[28];let M=j,N=!r.browserEnabled&&`pointer-events-none opacity-40`,P;t[29]===N?P=t[30]:(P=a(`flex flex-col gap-5 transition-opacity`,N),t[29]=N,t[30]=P);let I=!r.browserEnabled,L;t[31]!==n||t[32]!==o||t[33]!==v.disconnectExtension||t[34]!==v.extension||t[35]!==v.extensionArtifacts||t[36]!==v.installExtensionArtifacts||t[37]!==v.openExtensionChrome||t[38]!==v.refetchExtensionArtifacts||t[39]!==v.revealExtensionFolder||t[40]!==v.startExtensionBridge||t[41]!==v.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==i?(L=o===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Qe,{embedded:!0,m:n,probe:v.extension,artifacts:v.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>i({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:v.startExtensionBridge,stopBridge:v.stopExtensionBridge,disconnectExtension:v.disconnectExtension,installArtifacts:v.installExtensionArtifacts,refetchArtifacts:v.refetchExtensionArtifacts,openExtensionChrome:v.openExtensionChrome,revealExtensionFolder:v.revealExtensionFolder})}):null,t[31]=n,t[32]=o,t[33]=v.disconnectExtension,t[34]=v.extension,t[35]=v.extensionArtifacts,t[36]=v.installExtensionArtifacts,t[37]=v.openExtensionChrome,t[38]=v.refetchExtensionArtifacts,t[39]=v.revealExtensionFolder,t[40]=v.startExtensionBridge,t[41]=v.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=i,t[46]=L):L=t[46];let R;t[47]!==n||t[48]!==o||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==d?(R=o===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=o,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=d,t[53]=R):R=t[53];let z;t[54]!==n||t[55]!==o||t[56]!==f||t[57]!==v.applyCloakDoctor||t[58]!==v.cloak||t[59]!==v.fetchCloakRuntimeStatus||t[60]!==v.launchCloak||t[61]!==v.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==i?(z=o===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(We,{embedded:!0,m:n,doctor:v.cloak,refetch:v.refetchCloak,applyDoctor:v.applyCloakDoctor,installStream:f,fetchRuntimeStatus:v.fetchCloakRuntimeStatus,launchCloak:v.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>i({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=o,t[56]=f,t[57]=v.applyCloakDoctor,t[58]=v.cloak,t[59]=v.fetchCloakRuntimeStatus,t[60]=v.launchCloak,t[61]=v.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=i,t[74]=z):z=t[74];let B;t[75]!==n||t[76]!==o||t[77]!==v.launchCdp||t[78]!==v.listCdpInstances||t[79]!==v.pingCdp||t[80]!==v.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==i?(B=o===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(ze,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>i({browserCdpUrl:e}),launch:v.launchCdp,stop:v.stopCdp,listInstances:v.listCdpInstances,ping:v.pingCdp})}):null,t[75]=n,t[76]=o,t[77]=v.launchCdp,t[78]=v.listCdpInstances,t[79]=v.pingCdp,t[80]=v.stopCdp,t[81]=r.browserCdpUrl,t[82]=i,t[83]=B):B=t[83];let H;t[84]!==n||t[85]!==o||t[86]!==v.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==i?(H=o===`cloud`?(0,Z.jsx)(q,{children:(0,Z.jsx)(qe,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>i({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:v.testCloud})}):null,t[84]=n,t[85]=o,t[86]=v.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=i,t[92]=H):H=t[92];let U;t[93]!==L||t[94]!==R||t[95]!==z||t[96]!==B||t[97]!==H||t[98]!==P||t[99]!==I?(U=(0,Z.jsxs)(`div`,{className:P,"aria-hidden":I,children:[L,R,z,B,H]}),t[93]=L,t[94]=R,t[95]=z,t[96]=B,t[97]=H,t[98]=P,t[99]=I,t[100]=U):U=t[100];let ee=U;if(o===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==M?(e=r.browserEnabled?null:(0,Z.jsx)(we,{m:n,onStart:M}),t[101]=n,t[102]=r.browserEnabled,t[103]=M,t[104]=e):e=t[104];let o;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(F,{className:`size-4`,strokeWidth:1.75})}),t[105]=o):o=t[105];let l;t[106]===i?l=t[107]:(l=e=>i({browserEnabled:e.target.checked}),t[106]=i,t[107]=l);let u;t[108]!==r.browserEnabled||t[109]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:l}),t[108]=r.browserEnabled,t[109]=l,t[110]=u):u=t[110];let d;t[111]===n.browserEnabledOn?d=t[112]:(d=(0,Z.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=d);let f;t[113]!==u||t[114]!==d?(f=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[u,d]}),t[113]=u,t[114]=d,t[115]=f):f=t[115];let p;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[o,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Q,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=p):p=t[119];let m;t[120]!==n.browserDocsLink||t[121]!==c?(m=(0,Z.jsx)(Se,{language:c,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=c,t[122]=m):m=t[122];let h;t[123]!==p||t[124]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[123]=p,t[124]=m,t[125]=h):h=t[125];let g;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==A||t[130]!==s||t[131]!==i?(g=r.browserEnabled?(0,Z.jsx)(`div`,{id:ye(`connection`),className:a(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(_e,{m:n,value:r.browserBackend,onChange:e=>i({browserBackend:e}),onOpenConfig:s,options:A})}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=A,t[130]=s,t[131]=i,t[132]=g):g=t[132];let _;t[133]!==h||t[134]!==g?(_=(0,Z.jsx)(q,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,g]})}),t[133]=h,t[134]=g,t[135]=_):_=t[135];let v=!r.browserEnabled&&`pointer-events-none opacity-40`,y;t[136]===v?y=t[137]:(y=a(`transition-opacity`,v),t[136]=v,t[137]=y);let b=!r.browserEnabled,x;t[138]!==n||t[139]!==r||t[140]!==i?(x=(0,Z.jsx)(xe,{a:n,form:r,update:i}),t[138]=n,t[139]=r,t[140]=i,t[141]=x):x=t[141];let S;t[142]!==y||t[143]!==b||t[144]!==x?(S=(0,Z.jsx)(se,{children:(0,Z.jsx)(`div`,{className:y,"aria-hidden":b,children:x})}),t[142]=y,t[143]=b,t[144]=x,t[145]=S):S=t[145];let C;return t[146]!==e||t[147]!==_||t[148]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,_,S]}),t[146]=e,t[147]=_,t[148]=S,t[149]=C):C=t[149],C}return Pe(o)?ee:null}function mt(e){return e.mode}function ht(e){return e.language}function gt(e){let t=(0,X.c)(54),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,c=o===void 0?!1:o,u=l(_t),d;t[0]===u?d=t[1]:(d=s(u),t[0]=u,t[1]=d);let f=d,p=f.agentSettings,h=f.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(m,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===h?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:h}),t[3]=h,t[4]=n);let r;t[5]===p.needToken?r=t[6]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:p.needToken}),t[5]=p.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,Z.jsx)(ie,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,Z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ie,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(oe,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??p.loadError,n;t[11]===e?n=t[12]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==f.logs.refresh||t[16]!==r?(a=(0,Z.jsx)(O,{type:`button`,variant:`secondary`,onClick:r,children:f.logs.refresh}),t[15]=f.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,Z.jsxs)(ie,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let g=c?void 0:r,_;t[21]===p.sectionDesc?_=t[22]:(_=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:p.sectionDesc}),t[21]=p.sectionDesc,t[22]=_);let v;t[23]!==p.saved||t[24]!==i.dirty||t[25]!==i.saveOk?(v=i.saveOk&&!i.dirty?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,role:`status`,children:p.saved}):null,t[23]=p.saved,t[24]=i.dirty,t[25]=i.saveOk,t[26]=v):v=t[26];let y=!i.dirty||i.saving,b;t[27]!==p.discard||t[28]!==y||t[29]!==i.discard?(b=(0,Z.jsx)(O,{type:`button`,variant:`secondary`,disabled:y,onClick:i.discard,children:p.discard}),t[27]=p.discard,t[28]=y,t[29]=i.discard,t[30]=b):b=t[30];let x=!i.dirty||i.saving,S;t[31]===i?S=t[32]:(S=()=>void i.save(),t[31]=i,t[32]=S);let C=i.saving?p.saving:p.save,w;t[33]!==x||t[34]!==S||t[35]!==C?(w=(0,Z.jsx)(O,{type:`button`,variant:`primary`,disabled:x,onClick:S,children:C}),t[33]=x,t[34]=S,t[35]=C,t[36]=w):w=t[36];let T;t[37]!==w||t[38]!==v||t[39]!==b?(T=(0,Z.jsxs)(Z.Fragment,{children:[v,b,w]}),t[37]=w,t[38]=v,t[39]=b,t[40]=T):T=t[40];let E;t[41]!==h||t[42]!==T||t[43]!==g||t[44]!==_?(E=(0,Z.jsx)(re,{title:h,subtitle:g,meta:_,actions:T}),t[41]=h,t[42]=T,t[43]=g,t[44]=_,t[45]=E):E=t[45];let D;t[46]===i.error?D=t[47]:(D=i.error?(0,Z.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[46]=i.error,t[47]=D);let k;t[48]===a?k=t[49]:(k=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[48]=a,t[49]=k);let A;return t[50]!==E||t[51]!==D||t[52]!==k?(A=(0,Z.jsxs)(ie,{gap:`gap-6`,children:[E,D,k]}),t[50]=E,t[51]=D,t[52]=k,t[53]=A):A=t[53],A}function _t(e){return e.language}var vt={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},yt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},bt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},xt={summaryModel:``},St={model:``,maxLength:void 0};function Ct(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function wt(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function Tt(e){return e===!0||e===`true`||e===1}function Et(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=Tt(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=Tt(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset==="default"?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
7
+ `):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Dt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...vt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:vt.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):vt.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:vt.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):vt.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):vt.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:vt.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):vt.retentionWindow}}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...yt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:yt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):yt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:yt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:yt.tailKeepRatio}}function kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:bt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:bt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:bt.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function At(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function jt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...St};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Mt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function Nt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Pt(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Ft(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function It(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Lt(e){let t={},n=t.models&&typeof t.models==`object`&&!Array.isArray(t.models)?t.models:{},r=n.chat,i=t.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:wt(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:wt(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:wt(t.imageGenerationModel),u=Et((e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser),d=typeof t.maxTaskDurationMs==`number`&&Number.isFinite(t.maxTaskDurationMs)?t.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:Ct(r),modelFallbacks:a,imageModel:Ct(t.imageModel),imageModelFallbacks:s,imageGenerationModel:Ct(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:Ft(t),imageGenerationModelAutoProviderFallback:It(t),mediaMaxMb:typeof t.mediaMaxMb==`number`&&!Number.isNaN(t.mediaMaxMb)?t.mediaMaxMb:void 0,maxTokens:typeof t.maxTokens==`number`?t.maxTokens:8192,temperature:typeof t.temperature==`number`?t.temperature:.7,maxToolIterations:typeof t.maxToolIterations==`number`?t.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof t.maxRequestsPerTurn==`number`?t.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof t.maxToolFailuresPerTurn==`number`?t.maxToolFailuresPerTurn:3,workspace:typeof t.workspace==`string`?t.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof t.thinkingDefault==`string`?t.thinkingDefault:`medium`,reasoningDefault:typeof t.reasoningDefault==`string`?t.reasoningDefault:`stream`,verboseDefault:typeof t.verboseDefault==`string`?t.verboseDefault:`full`,compaction:Dt(t.compaction),pruning:Ot(t.pruning),memory:kt(t.memory),sessionSearch:At(t.sessionSearch),webExtract:jt(t.webExtract),delegate:Mt(t.delegate,!1),executeCode:Mt(t.executeCode,!1),systemPromptOverride:typeof t.systemPromptOverride==`string`?t.systemPromptOverride:``,skillsAllowlist:Nt(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return Nt(n)})(),typedModels:de(n),paramsJson:Pt(t.params)}}function Rt(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
8
+ `).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function zt(e){await f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Rt(e)})}),b()}var Bt=B();function Vt(e,t={}){let n=!!c(e=>e.token),[r,i]=(0,Y.useReducer)(Bt,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!1),h=(0,Y.useRef)(null),{data:g,error:_,isLoading:v,mutate:y}=j(n);T({enabled:n,parsed:(0,Y.useMemo)(()=>g?.payload?.config===void 0?null:Lt(g.payload.config),[g]),dirty:m.current,trackedParsedRef:h,dispatch:i,onResetDirty:()=>{m.current=!1}});let b=!!(n&&v&&g===void 0&&!_),x=_ instanceof Error?_.message:_?String(_):null,S=(0,Y.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);return{hasToken:n,loading:b,fetchError:x,form:a,update:(0,Y.useCallback)(e=>{m.current=!0,p(!1),i({type:`patch`,patch:e})},[]),dirty:S,saving:s,saveOk:f,error:u,setError:d,save:(0,Y.useCallback)(async()=>{if(!a||s)return!1;l(!0),d(null),p(!1);try{return await zt(a),m.current=!1,i({type:`saved`,value:a}),p(!0),y(),!0}catch(t){return d(t instanceof Error?t.message:e.saveError),!1}finally{l(!1)}},[e.saveError,a,y,s]),discard:(0,Y.useCallback)(()=>{m.current=!1,i({type:`discard`}),p(!1),d(null)},[]),mutate:y}}function Ht(e,t){return e.browserTabs[t]}function Ut(){let e=(0,X.c)(43),t=l(Gt),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,a=r.agentSettings,o=r.chat,c=W(Wt),u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u={saveScope:`browser`},e[2]=u):u=e[2];let d=Vt(a,u),[f,p]=i(),m;e[3]===c?m=e[4]:(m=he(Ae,c),e[3]=c,e[4]=m);let h=m,g;e[5]===f?g=e[6]:(g=be(f.get(`focus`)),e[5]=f,e[6]=g);let _=g,v;e[7]!==_||e[8]!==f?(v=_?Me[_]??Ne(f.get(`tab`)):Ne(f.get(`tab`)),e[7]=_,e[8]=f,e[9]=v):v=e[9];let y=v,b;bb0:{if(!d.form){b=null;break bb0}let t;e[10]!==a||e[11]!==o||e[12]!==d.form||e[13]!==d.update?(t={form:d.form,update:d.update,a,chat:o},e[10]=a,e[11]=o,e[12]=d.form,e[13]=d.update,e[14]=t):t=e[14],b=t}let x=b,S;e[15]===p?S=e[16]:(S=e=>{p(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[15]=p,e[16]=S);let C=S;me(y,C);let w,T;e[17]!==_||e[18]!==f||e[19]!==p?(w=()=>{if(!_)return;let e=Me[_]??Ne(f.get(`tab`));p(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=_===`runtime`||_===`security`?ye(_):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},T=[_,f,p],e[17]=_,e[18]=f,e[19]=p,e[20]=w,e[21]=T):(w=e[20],T=e[21]),(0,Y.useEffect)(w,T);let E;if(e[22]!==a||e[23]!==h){let t;e[25]===a?t=e[26]:(t=e=>({id:e,label:Ht(a,e)}),e[25]=a,e[26]=t),E=h.map(t),e[22]=a,e[23]=h,e[24]=E}else E=e[24];let D=E,O;e[27]!==y||e[28]!==a.browserTabsAria||e[29]!==C||e[30]!==D?(O=(0,Z.jsx)(le,{items:D,activeTab:y,onChange:C,ariaLabel:a.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[27]=y,e[28]=a.browserTabsAria,e[29]=C,e[30]=D,e[31]=O):O=e[31];let k;e[32]!==y||e[33]!==x||e[34]!==C?(k=x?(0,Z.jsx)(pt,{...x,activeTab:y,setActiveTab:C}):null,e[32]=y,e[33]=x,e[34]=C,e[35]=k):k=e[35];let A;e[36]!==y||e[37]!==k?(A=(0,Z.jsx)(ae,{id:y,activeTab:y,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:k}),e[36]=y,e[37]=k,e[38]=A):A=e[38];let j;return e[39]!==O||e[40]!==A||e[41]!==d?(j=(0,Z.jsxs)(gt,{sectionId:`agent-browser`,intro:``,vm:d,tabbed:!0,children:[O,A]}),e[39]=O,e[40]=A,e[41]=d,e[42]=j):j=e[42],j}function Wt(e){return e.mode}function Gt(e){return e.language}export{Ut as AgentBrowserSettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-C_M71MK9.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{$n as o,It as s,Qn as c,hc as l,js as u,ms as d}from"./index-BuqGh2SW.js";import{s as f}from"./typed-models-lib-D1Lr2gG0.js";var p=[{key:`code-intelligence`,toolIds:[`code_search`,`code_read_symbol`,`code_trace`,`code_impact`,`code_architecture`]},{key:`workspace`,toolIds:[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`exec_command`,`execute_code`]},{key:`messaging`,toolIds:[`send_message`,`send_media`,`text_to_speech`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`,`read_media`,`create_share`]},{key:`web`,toolIds:[`web_search`,`web_fetch`,`web_extract`,`browser_use`]},{key:`misc`,toolIds:[`session_status`,`dreaming`,`tool_manual`,`clarify`,`todo`,`update_plan`,`automation`,`workflow`,`delegate_task`]},{key:`unknown`,toolIds:[`skills_list`,`skill_view`,`skill_manage`]},{key:`extensions`,toolIds:[`extensions`]},{key:`mcp`,toolIds:[`bundle-mcp`]}],m=new Set(p.flatMap(e=>[...e.toolIds].map(e=>String(e))));function h(e){return e.filter(e=>e&&!m.has(e)).sort((e,t)=>e.localeCompare(t))}var g=e(t(),1),_=n(),v=[`deep`,`fast`,`cheap`,`code`,`review`];function y(e){return v.includes(e)}function b(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:p,labels:m}=e,{data:h=[]}=a(c,o,{revalidateOnFocus:!1}),b=(0,g.useMemo)(()=>new Set(h.filter(e=>e.vision===!0).map(e=>e.id)),[h]),x=(0,g.useRef)([]),S=(0,g.useRef)(0);for(;x.current.length<t.length;)x.current.push(`typed-model-row-${S.current++}`);x.current.length>t.length&&(x.current.length=t.length);let C=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},w=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,C(e,{fallbacks:a})},T=e=>{let n=t[e];n&&C(e,{fallbacks:[...n.fallbacks??[],``]})},E=(e,n)=>{let r=t[e];r&&C(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},D=e=>{x.current.splice(e,1),n(t.filter((t,n)=>n!==e))},O=e=>{x.current.push(`typed-model-row-${S.current++}`),n([...t,e])},k=t.find(e=>e.model.trim())?.model??``,A=t.map((e,t)=>({row:e,index:t})),j=v.map(e=>A.find(t=>t.row.id===e)).filter(e=>!!e),M=A.filter(e=>!y(e.row.id)),N=v.filter(e=>!t.some(t=>t.id===e)),P=(e,t)=>{let{row:n,index:a}=e,o=n.id===i,c=[n.model,...n.fallbacks??[]].some(e=>b.has(e.trim())),h=y(n.id)?m.roleNames[n.id]:m.id,g=y(n.id)?m.roleDescriptions[n.id]:``;return(0,_.jsxs)(`div`,{className:`grid gap-3 rounded-lg bg-surface-panel/70 p-3 shadow-surface lg:grid-cols-[minmax(0,11rem)_minmax(0,1fr)_auto] lg:items-start`,children:[t.recommended?(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:h}),o?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.defaultBadge}):null,c?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.visionBadge}):null]}),(0,_.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:n.id}),g?(0,_.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:g}):null]}):(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,_.jsx)(`span`,{children:m.id}),c?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.visionBadge}):null]}),(0,_.jsx)(`input`,{type:`text`,className:f(),value:n.id,disabled:r,placeholder:m.idPlaceholder,"aria-label":m.id,onChange:e=>C(a,{id:e.target.value.toLowerCase()})})]}),(0,_.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,_.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.primaryModel}),(0,_.jsx)(s,{value:n.model,disabled:r,placeholder:p.modelPlaceholder,searchPlaceholder:p.modelSearchPlaceholder,noMatches:p.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>C(a,{model:e})}),c?(0,_.jsx)(`div`,{className:`text-xs leading-relaxed text-fg-muted`,children:m.visionAutoHint}):null]}),(0,_.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.fallbackModels}),(0,_.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>T(a),children:[(0,_.jsx)(l,{className:`size-3.5`,strokeWidth:1.75}),m.addFallback]})]}),(n.fallbacks??[]).length>0?(0,_.jsx)(`div`,{className:`grid gap-1.5`,children:(n.fallbacks??[]).map((e,t)=>(0,_.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,_.jsx)(s,{value:e,disabled:r,placeholder:m.fallbackPlaceholder,searchPlaceholder:p.modelSearchPlaceholder,noMatches:p.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>w(a,t,e)}),(0,_.jsx)(d,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":m.removeFallback,onClick:()=>E(a,t),children:(0,_.jsx)(u,{className:`size-4`,strokeWidth:1.75})})]},`${x.current[a]??a}-fallback-${t}`))}):(0,_.jsx)(`div`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:m.fallbackEmptyHint})]}),(0,_.jsx)(`input`,{type:`text`,className:f(),value:n.description,disabled:r,placeholder:m.descriptionPlaceholder,"aria-label":m.description,onChange:e=>C(a,{description:e.target.value})})]}),(0,_.jsx)(d,{type:`button`,variant:`secondary`,className:`shrink-0 sm:mt-0`,disabled:r||o,"aria-label":m.remove,onClick:()=>D(a),children:(0,_.jsx)(u,{className:`size-4`,strokeWidth:1.75})})]},x.current[a]??`typed-model-row-${a}`)};return(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-fg-muted`,children:m.recommendedTitle}),j.map(e=>P(e,{recommended:!0})),N.length>0?(0,_.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-1`,children:N.map(e=>(0,_.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 rounded-lg px-2.5 text-xs`,disabled:r,onClick:()=>O({id:e,description:m.roleDescriptions[e],model:k,fallbacks:[]}),children:[(0,_.jsx)(l,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),m.addPurpose.replace(`{name}`,m.roleNames[e])]},e))}):null]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-fg-muted`,children:m.customTitle}),M.length>0?M.map(e=>P(e,{recommended:!1})):(0,_.jsx)(`div`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:m.noCustomRoles})]}),(0,_.jsxs)(d,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,disabled:r,onClick:()=>O({id:``,description:``,model:k,fallbacks:[]}),children:[(0,_.jsx)(l,{className:`size-4 shrink-0`,strokeWidth:1.75}),m.add]})]})}async function x(){let e=await i(r(`/api/capability-presets`));if(!Array.isArray(e.payload?.presets)||typeof e.payload.defaultPresetId!=`string`||!Array.isArray(e.payload.agents)||!Array.isArray(e.payload.builtinToolIds))throw Error(`Invalid /api/capability-presets response`);return e.payload}async function S(e){let t=await i(r(`/api/capability-presets`),{method:`POST`,body:JSON.stringify(e)}),n=t.payload?.presetId,a=t.payload?.presets;if(!n||!a||typeof a.defaultPresetId!=`string`||!Array.isArray(a.presets)||!Array.isArray(a.agents)||!Array.isArray(a.builtinToolIds))throw Error(`Invalid create capability preset response`);return{presetId:n,presets:a}}async function C(e,t){let n=await i(r(`/api/capability-presets/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)});if(!Array.isArray(n.payload?.presets)||typeof n.payload.defaultPresetId!=`string`||!Array.isArray(n.payload.agents)||!Array.isArray(n.payload.builtinToolIds))throw Error(`Invalid update capability preset response`);return n.payload}async function w(e){let t=await i(r(`/api/capability-presets/${encodeURIComponent(e)}`),{method:`DELETE`});if(!Array.isArray(t.payload?.presets)||typeof t.payload.defaultPresetId!=`string`||!Array.isArray(t.payload.agents)||!Array.isArray(t.payload.builtinToolIds))throw Error(`Invalid delete capability preset response`);return t.payload}export{b as a,C as i,w as n,p as o,x as r,h as s,S as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-Dar-xqQr.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{It as o,Rs as s,Sc as c,Ss as l,Un as u,Wn as d}from"./index-vq_cJZJC.js";import{s as f}from"./typed-models-lib-DEGtSA5h.js";var p=[{key:`code-intelligence`,toolIds:[`code_search`,`code_read_symbol`,`code_trace`,`code_impact`,`code_architecture`]},{key:`workspace`,toolIds:[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`exec_command`,`execute_code`]},{key:`messaging`,toolIds:[`send_message`,`send_media`,`text_to_speech`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`,`read_media`,`create_share`]},{key:`web`,toolIds:[`web_search`,`web_fetch`,`web_extract`,`browser_use`]},{key:`misc`,toolIds:[`session_status`,`dreaming`,`tool_manual`,`clarify`,`todo`,`update_plan`,`automation`,`workflow`,`delegate_task`]},{key:`unknown`,toolIds:[`skills_list`,`skill_view`,`skill_manage`]},{key:`extensions`,toolIds:[`extensions`]},{key:`mcp`,toolIds:[`bundle-mcp`]}],m=new Set(p.flatMap(e=>[...e.toolIds].map(e=>String(e))));function h(e){return e.filter(e=>e&&!m.has(e)).sort((e,t)=>e.localeCompare(t))}var g=e(t(),1),_=n(),v=[`deep`,`fast`,`cheap`,`code`,`review`];function y(e){return v.includes(e)}function b(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:p,labels:m}=e,{data:h=[]}=a(u,d,{revalidateOnFocus:!1}),b=(0,g.useMemo)(()=>new Set(h.filter(e=>e.vision===!0).map(e=>e.id)),[h]),x=(0,g.useRef)([]),S=(0,g.useRef)(0);for(;x.current.length<t.length;)x.current.push(`typed-model-row-${S.current++}`);x.current.length>t.length&&(x.current.length=t.length);let C=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},w=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,C(e,{fallbacks:a})},T=e=>{let n=t[e];n&&C(e,{fallbacks:[...n.fallbacks??[],``]})},E=(e,n)=>{let r=t[e];r&&C(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},D=e=>{x.current.splice(e,1),n(t.filter((t,n)=>n!==e))},O=e=>{x.current.push(`typed-model-row-${S.current++}`),n([...t,e])},k=t.find(e=>e.model.trim())?.model??``,A=t.map((e,t)=>({row:e,index:t})),j=v.map(e=>A.find(t=>t.row.id===e)).filter(e=>!!e),M=A.filter(e=>!y(e.row.id)),N=v.filter(e=>!t.some(t=>t.id===e)),P=(e,t)=>{let{row:n,index:a}=e,u=n.id===i,d=[n.model,...n.fallbacks??[]].some(e=>b.has(e.trim())),h=y(n.id)?m.roleNames[n.id]:m.id,g=y(n.id)?m.roleDescriptions[n.id]:``;return(0,_.jsxs)(`div`,{className:`grid gap-3 rounded-lg bg-surface-panel/70 p-3 shadow-surface lg:grid-cols-[minmax(0,11rem)_minmax(0,1fr)_auto] lg:items-start`,children:[t.recommended?(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:h}),u?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.defaultBadge}):null,d?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.visionBadge}):null]}),(0,_.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:n.id}),g?(0,_.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:g}):null]}):(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,_.jsx)(`span`,{children:m.id}),d?(0,_.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/25 bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:m.visionBadge}):null]}),(0,_.jsx)(`input`,{type:`text`,className:f(),value:n.id,disabled:r,placeholder:m.idPlaceholder,"aria-label":m.id,onChange:e=>C(a,{id:e.target.value.toLowerCase()})})]}),(0,_.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,_.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.primaryModel}),(0,_.jsx)(o,{value:n.model,disabled:r,placeholder:p.modelPlaceholder,searchPlaceholder:p.modelSearchPlaceholder,noMatches:p.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>C(a,{model:e})}),d?(0,_.jsx)(`div`,{className:`text-xs leading-relaxed text-fg-muted`,children:m.visionAutoHint}):null]}),(0,_.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:m.fallbackModels}),(0,_.jsxs)(l,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>T(a),children:[(0,_.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),m.addFallback]})]}),(n.fallbacks??[]).length>0?(0,_.jsx)(`div`,{className:`grid gap-1.5`,children:(n.fallbacks??[]).map((e,t)=>(0,_.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,_.jsx)(o,{value:e,disabled:r,placeholder:m.fallbackPlaceholder,searchPlaceholder:p.modelSearchPlaceholder,noMatches:p.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>w(a,t,e)}),(0,_.jsx)(l,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":m.removeFallback,onClick:()=>E(a,t),children:(0,_.jsx)(s,{className:`size-4`,strokeWidth:1.75})})]},`${x.current[a]??a}-fallback-${t}`))}):(0,_.jsx)(`div`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:m.fallbackEmptyHint})]}),(0,_.jsx)(`input`,{type:`text`,className:f(),value:n.description,disabled:r,placeholder:m.descriptionPlaceholder,"aria-label":m.description,onChange:e=>C(a,{description:e.target.value})})]}),(0,_.jsx)(l,{type:`button`,variant:`secondary`,className:`shrink-0 sm:mt-0`,disabled:r||u,"aria-label":m.remove,onClick:()=>D(a),children:(0,_.jsx)(s,{className:`size-4`,strokeWidth:1.75})})]},x.current[a]??`typed-model-row-${a}`)};return(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-fg-muted`,children:m.recommendedTitle}),j.map(e=>P(e,{recommended:!0})),N.length>0?(0,_.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-1`,children:N.map(e=>(0,_.jsxs)(l,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 rounded-lg px-2.5 text-xs`,disabled:r,onClick:()=>O({id:e,description:m.roleDescriptions[e],model:k,fallbacks:[]}),children:[(0,_.jsx)(c,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),m.addPurpose.replace(`{name}`,m.roleNames[e])]},e))}):null]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,_.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-fg-muted`,children:m.customTitle}),M.length>0?M.map(e=>P(e,{recommended:!1})):(0,_.jsx)(`div`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:m.noCustomRoles})]}),(0,_.jsxs)(l,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,disabled:r,onClick:()=>O({id:``,description:``,model:k,fallbacks:[]}),children:[(0,_.jsx)(c,{className:`size-4 shrink-0`,strokeWidth:1.75}),m.add]})]})}async function x(){let e=await i(r(`/api/capability-presets`));if(!Array.isArray(e.payload?.presets)||typeof e.payload.defaultPresetId!=`string`||!Array.isArray(e.payload.agents)||!Array.isArray(e.payload.builtinToolIds))throw Error(`Invalid /api/capability-presets response`);return e.payload}async function S(e){let t=await i(r(`/api/capability-presets`),{method:`POST`,body:JSON.stringify(e)}),n=t.payload?.presetId,a=t.payload?.presets;if(!n||!a||typeof a.defaultPresetId!=`string`||!Array.isArray(a.presets)||!Array.isArray(a.agents)||!Array.isArray(a.builtinToolIds))throw Error(`Invalid create capability preset response`);return{presetId:n,presets:a}}async function C(e,t){let n=await i(r(`/api/capability-presets/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)});if(!Array.isArray(n.payload?.presets)||typeof n.payload.defaultPresetId!=`string`||!Array.isArray(n.payload.agents)||!Array.isArray(n.payload.builtinToolIds))throw Error(`Invalid update capability preset response`);return n.payload}async function w(e){let t=await i(r(`/api/capability-presets/${encodeURIComponent(e)}`),{method:`DELETE`});if(!Array.isArray(t.payload?.presets)||typeof t.payload.defaultPresetId!=`string`||!Array.isArray(t.payload.agents)||!Array.isArray(t.payload.builtinToolIds))throw Error(`Invalid delete capability preset response`);return t.payload}export{b as a,C as i,w as n,p as o,x as r,h as s,S as t};
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-BuT0SR1R.js";import{l as s,n as c}from"./locale-store-C_M71MK9.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{$c as u,Ao as d,Dl as f,Fo as p,Go as m,Jo as h,Mo as g,No as _,Pl as v,Po as y,Xo as b,Yo as x,fc as S,hc as C,ic as w,jo as T,js as E,ko as D,lu as O,ms as k,qo as A,qr as j,qs as M,ss as N,vs as ee,ys as P}from"./index-BuqGh2SW.js";import{n as te,r as ne}from"./settings-page-layout-DG-XMIPu.js";import{n as re,r as F}from"./settings-loading-skeleton-UvA-eDhF.js";import{n as I,t as L}from"./settings-form-section-DruI__qO.js";import{a as ie,i as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./capability-presets-api-Ii36j_7v.js";import{a as de,i as fe,o as R,t as z}from"./typed-models-lib-D1Lr2gG0.js";var B=e(t(),1),V=n(),H=r();function pe(e){let t=(0,V.c)(34),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===c.inheritanceTitle?d=t[3]:(d=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,H.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,H.jsxs)(`span`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,H.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,H.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(0,H.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,H.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,H.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,H.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function U(e){return e.name||e.directoryId}function me(e){let t=(0,V.c)(56),{mode:n,selected:r,catalog:i,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(U).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,H.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=_);let v;t[8]===h?v=t[9]:(v=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=v);let y;t[10]!==_||t[11]!==v?(y=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]===u.modeLabel?b=t[14]:(b=(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=b);let x;t[15]===u.modeInherit?x=t[16]:(x=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=x);let S;t[17]===u.modeAll?S=t[18]:(S=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=S);let C;t[19]===u.modeAllowlist?C=t[20]:(C=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=C);let w;t[21]===u.modeDenylist?w=t[22]:(w=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=w);let T;t[23]===u.modeOff?T=t[24]:(T=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=T);let E;t[25]!==w||t[26]!==T||t[27]!==x||t[28]!==S||t[29]!==C?(E=[x,S,C,w,T],t[25]=w,t[26]=T,t[27]=x,t[28]=S,t[29]=C,t[30]=E):E=t[30];let D=E,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==D?(A=(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:D.map(e=>{let[t,r]=e;return(0,H.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=D,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==b?(j=(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,A]}),t[36]=A,t[37]=b,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==o||t[48]!==l||t[49]!==d||t[50]!==r?(M=d?(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:s||o||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),o?(0,H.jsx)(F,{rows:3}):i.length===0?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,H.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=U(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,o=i||u.noDescription;return(0,H.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,H.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,H.jsx)(`p`,{className:a(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=o,t[48]=l,t[49]=d,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==y?(N=(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,j,M]}),t[52]=j,t[53]=M,t[54]=y,t[55]=N):N=t[55],N}var W=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],G=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],K=[`send_message`,`send_media`,`text_to_speech`,`create_share`],he=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],ge=[...W,...K],q=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],_e=[`send_message`,`send_media`];function ve(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function ye(e){let t=(0,V.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:o,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==r?(f=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(be),t[2]=d,t[3]=r,t[4]=f):f=t[4];let p=f,h;if(t[5]!==d||t[6]!==n){h=[];for(let e of se){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=le(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=d,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==i||t[13]!==r?(_=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=_):_=t[14];let v=_,y;t[15]!==i||t[16]!==r?(y=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=y):y=t[17];let b=y,x;t[18]!==d||t[19]!==i?(x=e=>{i(ve(d,e))},t[18]=d,t[19]=i,t[20]=x):x=t[20];let S=x;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let C;t[23]===l.quickActionsLabel?C=t[24]:(C=(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=C);let w;t[25]===i?w=t[26]:(w=()=>i({}),t[25]=i,t[26]=w);let T;t[27]!==o||t[28]!==l.quickClearOverrides||t[29]!==w?(T=(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:w,children:l.quickClearOverrides}),t[27]=o,t[28]=l.quickClearOverrides,t[29]=w,t[30]=T):T=t[30];let E;t[31]===S?E=t[32]:(E=()=>S([[W,`deny`]]),t[31]=S,t[32]=E);let D;t[33]!==o||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:E,children:l.quickReadOnlyWorkspace}),t[33]=o,t[34]=l.quickReadOnlyWorkspace,t[35]=E,t[36]=D):D=t[36];let O;t[37]===S?O=t[38]:(O=()=>S([[G,`deny`]]),t[37]=S,t[38]=O);let j;t[39]!==o||t[40]!==l.quickHighRiskOff||t[41]!==O?(j=(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:O,children:l.quickHighRiskOff}),t[39]=o,t[40]=l.quickHighRiskOff,t[41]=O,t[42]=j):j=t[42];let M;t[43]===S?M=t[44]:(M=()=>S([[K,`deny`]]),t[43]=S,t[44]=M);let N;t[45]!==o||t[46]!==l.quickNoOutbound||t[47]!==M?(N=(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:M,children:l.quickNoOutbound}),t[45]=o,t[46]=l.quickNoOutbound,t[47]=M,t[48]=N):N=t[48];let ee;t[49]===S?ee=t[50]:(ee=()=>S([[he,`allow`],[ge,`deny`]]),t[49]=S,t[50]=ee);let P;t[51]!==o||t[52]!==l.quickResearchMode||t[53]!==ee?(P=(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:ee,children:l.quickResearchMode}),t[51]=o,t[52]=l.quickResearchMode,t[53]=ee,t[54]=P):P=t[54];let te;t[55]===S?te=t[56]:(te=()=>S([[q,`allow`],[_e,`deny`]]),t[55]=S,t[56]=te);let ne;t[57]!==o||t[58]!==l.quickCodingMode||t[59]!==te?(ne=(0,H.jsx)(k,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:te,children:l.quickCodingMode}),t[57]=o,t[58]=l.quickCodingMode,t[59]=te,t[60]=ne):ne=t[60];let re;t[61]!==j||t[62]!==N||t[63]!==P||t[64]!==ne||t[65]!==T||t[66]!==D?(re=(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,j,N,P,ne]}),t[61]=j,t[62]=N,t[63]=P,t[64]=ne,t[65]=T,t[66]=D,t[67]=re):re=t[67];let F;t[68]!==re||t[69]!==C?(F=(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[C,re]}),t[68]=re,t[69]=C,t[70]=F):F=t[70];let I;t[71]===l.overrideSummaryTitle?I=t[72]:(I=(0,H.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=I);let L;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==p?(L=p.length>0?(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,H.jsxs)(`span`,{className:a(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,H.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=p,t[78]=L):L=t[78];let ie;t[79]!==I||t[80]!==L?(ie=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[I,L]}),t[79]=I,t[80]=L,t[81]=ie):ie=t[81];let ae;t[82]!==o||t[83]!==c||t[84]!==s||t[85]!==g||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==v||t[98]!==r||t[99]!==b?(ae=(0,H.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,H.jsxs)(`li`,{className:a(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,H.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,H.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,H.jsx)(`button`,{type:`button`,className:a(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>v(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,H.jsxs)(m,{value:n.scope??``,disabled:o,onChange:t=>b(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,H.jsx)(A,{value:``,children:l.scopeInherit}),(0,H.jsx)(A,{value:`readonly`,children:l.scopeReadonly}),(0,H.jsx)(A,{value:`workspace`,children:l.scopeWorkspace}),(0,H.jsx)(A,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,H.jsx)(J,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:o,onChange:t=>b(e,e=>xe(e,`maxCallsPerTurn`,t))}),(0,H.jsx)(J,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:o,onChange:t=>b(e,e=>xe(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=o,t[83]=c,t[84]=s,t[85]=g,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=v,t[98]=r,t[99]=b,t[100]=ae):ae=t[100];let oe;return t[101]!==F||t[102]!==ie||t[103]!==ae?(oe=(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,ie,ae]}),t[101]=F,t[102]=ie,t[103]=ae,t[104]=oe):oe=t[104],oe}function be(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function xe(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function J(e){let t=(0,V.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,H.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Se=[{id:`overview`,icon:v},{id:`models`,icon:u},{id:`tools`,icon:P},{id:`skills`,icon:S},{id:`advanced`,icon:M},{id:`impact`,icon:f}];function Ce(e){return fe(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Y(e){return structuredClone(e?.tools?.builtin??{})}function we(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Te(){return{primary:``,fallbacks:``,timeoutMs:``,autoProviderFallback:``}}function Ee(e){return{primary:e?.primary??``,fallbacks:e?.fallbacks?.join(`
2
- `)??``,timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function X(){return{imageModel:Te(),imageGenerationModel:Te(),allowFallbacks:``,maxCostTier:``}}function Z(e){return{imageModel:Ee(e?.models?.imageModel),imageGenerationModel:Ee(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Q(e){return e===void 0?``:JSON.stringify(e,null,2)}function De(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Oe(e){return{mcp:Q(e?.tools?.mcp),workflows:Q(e?.workflows),boundaries:Q(e?.boundaries),runtime:Q(e?.runtime),locks:Q(e?.locks)}}function ke(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Ce(e),modelAdvanced:Z(e),toolPolicies:Y(e),skillMode:e?.skills?.mode??`inherit`,skillPick:we(e),extendsIds:[...e?.extends??[]],jsonFields:Oe(e)}}function Ae(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function je(e,t){let n=z(e.modelRows),r=Ae(e.modelAdvanced.imageModel),i=Ae(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function Me(e){return e.trim()?JSON.parse(e):void 0}function $(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ne(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=Me(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Pe(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Fe(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function Ie(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:je(e,t),tools:{builtin:Pe(e.toolPolicies),mcp:$(e.jsonFields.mcp)},skills:Fe(e),extends:[...e.extendsIds].toSorted(),workflows:$(e.jsonFields.workflows),boundaries:$(e.jsonFields.boundaries),runtime:$(e.jsonFields.runtime),locks:$(e.jsonFields.locks)}}function Le(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Pe(e.tools?.builtin),mcp:$(Q(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:$(Q(e.workflows)),boundaries:$(Q(e.boundaries)),runtime:$(Q(e.runtime)),locks:$(Q(e.locks))}:null}function Re(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function ze(){return{modelAdvanced:X(),extendsIds:[],jsonFields:De()}}function Be(e,t){return{extends:[...e.extendsIds],models:je(e,t)??void 0,tools:Ne(e)??void 0,skills:Fe(e)??void 0,workflows:Me(e.jsonFields.workflows),boundaries:Me(e.jsonFields.boundaries),runtime:Me(e.jsonFields.runtime),locks:Me(e.jsonFields.locks)}}function Ve(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...ze()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...ze()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...ze()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...ze()}}function He(){let e=o(c(e=>e.language)),t=e.capabilityPresetsSettings,n=!!s(e=>e.token),{data:r,error:m,isLoading:O,mutate:A}=l(n?`settings-capability-presets`:null,ce,{revalidateOnFocus:!1}),{data:F=[],isLoading:se}=l(n?`settings-capability-presets-skills-catalog`:null,j,{revalidateOnFocus:!1}),[le,fe]=i(),[R,z]=(0,B.useState)(``),[V,U]=(0,B.useState)(`overview`),[W,G]=(0,B.useState)(()=>Ve(`blank`,t)),[K,he]=(0,B.useState)(!1),[ge,q]=(0,B.useState)(null),[_e,ve]=(0,B.useState)(null),be=r?.presets??[],xe=r?.defaultPresetId??`default`,J=be.find(e=>e.id===xe)??null,Ce=be.filter(e=>e.id!==xe),Y=(0,B.useMemo)(()=>be.find(e=>e.id===R)??be[0]??null,[be,R]),we=!Y||W.id.trim()!==Y.id,Te=!!(Y&&Y.id===xe),Ee=JSON.stringify(Ie(W,Y))!==JSON.stringify(Le(Y)),X=Ie(W,Y),Z=Le(Y),Q=[X.id!==Z?.id||X.name!==Z?.name||X.description!==Z?.description?t.tabs.overview:``,JSON.stringify(X.models)===JSON.stringify(Z?.models)?``:t.tabs.models,JSON.stringify(X.tools)===JSON.stringify(Z?.tools)?``:t.tabs.tools,JSON.stringify(X.skills)===JSON.stringify(Z?.skills)?``:t.tabs.skills,JSON.stringify({extends:X.extends,workflows:X.workflows,boundaries:X.boundaries,runtime:X.runtime,locks:X.locks})===JSON.stringify({extends:Z?.extends,workflows:Z?.workflows,boundaries:Z?.boundaries,runtime:Z?.runtime,locks:Z?.locks})?``:t.tabs.advanced].filter(Boolean),De=ge??(m instanceof Error?m.message:null),Oe=le.get(`action`)===`new`||!!le.get(`preset`),Ae=we?t.newPreset:Y?.name??t.editorTitle,je=t=>e.agentsSettings.toolsDisableGroups[t],$=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,B.useEffect)(()=>{if(!r||K)return;if(le.get(`action`)===`new`){let e=le.get(`starter`);z(``),G(Ve(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`,t)),U(`overview`);return}let e=le.get(`preset`)?.trim(),n=e?r.presets.find(t=>t.id===e):null;if(n){z(n.id),G(ke(n)),U(le.get(`tab`)??`overview`);return}Y&&(z(Y.id),G(e=>e.id===Y.id?e:ke(Y)))},[K,r,le,Y]);function Ne(e){z(e.id),G(ke(e)),fe({preset:e.id},{replace:!0}),U(`overview`)}function Pe(e){let n=Ve(e,t);z(``),G(n),q(null),fe(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),U(`overview`)}function Fe(){Ee&&!window.confirm(t.discardConfirm)||(fe({},{replace:!0}),q(null),G(ke(Y)),U(`overview`))}async function ze(){let e=de(W.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){q(e),U(`models`);return}for(let e of[W.modelAdvanced.imageModel,W.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks.split(/\r?\n|,/)].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){q(t.invalidModelRef),U(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){q(t.advancedPositiveIntegerError),U(`models`);return}}for(let e of Object.values(W.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){q(t.advancedPositiveIntegerError),U(`tools`);return}for(let e of Object.keys(W.jsonFields))try{Me(W.jsonFields[e])}catch{q(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),U(`advanced`);return}he(!0),q(null);try{let e=Be(W,Y);if(we){let t=await ue({id:W.id.trim(),name:W.name.trim(),...W.description.trim()?{description:W.description.trim()}:{},...e});await A(t.presets,{revalidate:!1}),z(t.presetId),fe({preset:t.presetId},{replace:!0})}else Y&&await A(await ae(Y.id,{name:W.name.trim(),description:W.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){q(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function He(){if(Y&&window.confirm(t.deleteConfirm.replace(`{{name}}`,Y.name))){he(!0),q(null);try{let e=await oe(Y.id);await A(e,{revalidate:!1});let t=e.presets[0]??null;z(t?.id??``),G(ke(t)),fe(t?{preset:t.id}:{},{replace:!0})}catch(e){q(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}}return n?(0,H.jsxs)(ne,{gap:`gap-5`,className:`pb-24`,children:[(0,H.jsx)(te,{title:t.title,subtitle:t.subtitle,actions:(0,H.jsxs)(k,{type:`button`,onClick:()=>Pe(`blank`),disabled:K,children:[(0,H.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),De?(0,H.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,O?(0,H.jsx)(re,{sections:2}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:C,title:t.newPreset,subtitle:t.editorHint}),(0,H.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,H.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-sm text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Pe(e),children:[(0,H.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,H.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),J?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:u,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Ne(J),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:J.name}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:J.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),J.description?(0,H.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:J.description}):null,(0,H.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Re(J,t)})]})]}):null,(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:u,title:t.listTitle,subtitle:t.listHint}),Ce.length===0?(0,H.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:t.empty}):(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Ce.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Ne(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,H.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,H.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:Re(e,t)})]},e.id))})]})]}),(0,H.jsx)(D,{open:Oe,onOpenChange:e=>{e||Fe()},children:(0,H.jsxs)(y,{children:[(0,H.jsx)(_,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,b)}),(0,H.jsx)(T,{ref:ve,className:a(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,x),onOpenAutoFocus:e=>e.preventDefault(),children:(0,H.jsxs)(h,{layer:`modal`,portalContainer:_e,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(p,{className:`truncate text-base font-semibold text-fg`,children:Ae}),(0,H.jsx)(g,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:we?t.editorHint:W.id})]}),(0,H.jsx)(d,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:a(N,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,H.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}),De?(0,H.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,(0,H.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:Se.map(({id:e,icon:n})=>(0,H.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,V===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>U(e),children:[(0,H.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[V===`overview`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:v,title:t.overviewTitle,subtitle:t.overviewHint}),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.id,disabled:K||!we,onChange:e=>G(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!we&&Y?(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,H.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String(Y.version))})]}):null,(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.name,disabled:K,onChange:e=>G(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,H.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.description,disabled:K,onChange:e=>G(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,H.jsx)(Ue,{icon:u,label:t.modelsTitle,value:String(W.modelRows.length)}),(0,H.jsx)(Ue,{icon:P,label:t.toolsTitle,value:String(Object.keys(W.toolPolicies).length)}),(0,H.jsx)(Ue,{icon:S,label:t.skillsTitle,value:t.skillModeLabels[W.skillMode]})]})]}):null,V===`models`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:u,title:t.modelsTitle,subtitle:t.modelsHint}),(0,H.jsx)(ie,{rows:W.modelRows,onChange:e=>G(t=>({...t,modelRows:e})),disabled:K,defaultRole:Y?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,visionBadge:t.modelVisionBadge,visionAutoHint:t.modelVisionAutoHint,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,H.jsx)(We,{value:W.modelAdvanced,onChange:e=>G(t=>({...t,modelAdvanced:e})),disabled:K,cp:t})]}):null,V===`tools`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:P,title:t.toolsTitle,subtitle:t.toolsHint}),(0,H.jsx)(ye,{builtinToolIds:r?.builtinToolIds??[],toolPolicies:W.toolPolicies,onChange:e=>G(t=>({...t,toolPolicies:e})),disabled:K,getToolDescription:$,getGroupTitle:je,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,V===`skills`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:S,title:t.skillsTitle,subtitle:t.skillsHint}),(0,H.jsx)(me,{mode:W.skillMode,selected:W.skillPick,catalog:F,loading:se,disabled:K,onModeChange:e=>G(t=>({...t,skillMode:e})),onSelectedChange:e=>G(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,V===`advanced`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:M,title:t.advancedTitle,subtitle:t.advancedHint}),(0,H.jsx)(pe,{extendsIds:W.extendsIds,onExtendsChange:e=>G(t=>({...t,extendsIds:e})),presetOptions:be.filter(e=>e.id!==Y?.id&&e.id!==xe),jsonFields:W.jsonFields,onJsonFieldsChange:e=>G(t=>({...t,jsonFields:e})),disabled:K,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,V===`impact`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:f,title:t.usageTitle,subtitle:t.usageHint}),(0,H.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Q.length>0?t.changePreviewSections.replace(`{{sections}}`,Q.join(`、`)):t.changePreviewEmpty})]}),Y?.usage.length?(0,H.jsx)(`div`,{className:`grid gap-2`,children:Y.usage.map(e=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,H.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,H.jsx)(`div`,{className:`font-medium text-fg`,children:Ee?t.unsavedTitle:t.noUnsavedTitle}),(0,H.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ee?(Y?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String(Y?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee?(0,H.jsx)(k,{type:`button`,variant:`secondary`,disabled:K,onClick:()=>G(ke(Y)),children:t.discard}):null,Y&&!Te?(0,H.jsxs)(k,{type:`button`,variant:`secondary`,disabled:K,onClick:()=>void He(),children:[(0,H.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,H.jsxs)(k,{type:`button`,disabled:K||!W.id.trim()||!W.name.trim()||!Ee,onClick:()=>void ze(),children:[(0,H.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,H.jsxs)(ne,{gap:`gap-3`,children:[(0,H.jsx)(te,{title:t.title}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function Ue(e){let t=(0,V.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,H.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,H.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function We(e){let t=(0,V.c)(77),{value:n,onChange:r,disabled:i,cp:a}=e,o;t[0]!==r||t[1]!==n?(o=(e,t)=>{r({...n,[e]:t})},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]===a.modelAdvancedTitle?c=t[4]:(c=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[3]=a.modelAdvancedTitle,t[4]=c);let l;t[5]===a.modelAdvancedHint?l=t[6]:(l=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[5]=a.modelAdvancedHint,t[6]=l);let u;t[7]===s?u=t[8]:(u=e=>s(`imageModel`,e),t[7]=s,t[8]=u);let d;t[9]!==a||t[10]!==i||t[11]!==u||t[12]!==n.imageModel?(d=(0,H.jsx)(Ge,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:u,disabled:i,cp:a}),t[9]=a,t[10]=i,t[11]=u,t[12]=n.imageModel,t[13]=d):d=t[13];let f;t[14]===s?f=t[15]:(f=e=>s(`imageGenerationModel`,e),t[14]=s,t[15]=f);let p;t[16]!==a||t[17]!==i||t[18]!==f||t[19]!==n.imageGenerationModel?(p=(0,H.jsx)(Ge,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:f,disabled:i,cp:a}),t[16]=a,t[17]=i,t[18]=f,t[19]=n.imageGenerationModel,t[20]=p):p=t[20];let h;t[21]!==d||t[22]!==p?(h=(0,H.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[d,p]}),t[21]=d,t[22]=p,t[23]=h):h=t[23];let g;t[24]===a.modelAllowFallbacksLabel?g=t[25]:(g=(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[24]=a.modelAllowFallbacksLabel,t[25]=g);let _;t[26]!==r||t[27]!==n?(_=e=>r({...n,allowFallbacks:e.target.value}),t[26]=r,t[27]=n,t[28]=_):_=t[28];let v;t[29]===a.policyInherit?v=t[30]:(v=(0,H.jsx)(A,{value:``,children:a.policyInherit}),t[29]=a.policyInherit,t[30]=v);let y;t[31]===a.policyEnabled?y=t[32]:(y=(0,H.jsx)(A,{value:`true`,children:a.policyEnabled}),t[31]=a.policyEnabled,t[32]=y);let b;t[33]===a.policyDisabled?b=t[34]:(b=(0,H.jsx)(A,{value:`false`,children:a.policyDisabled}),t[33]=a.policyDisabled,t[34]=b);let x;t[35]!==i||t[36]!==v||t[37]!==y||t[38]!==b||t[39]!==_||t[40]!==n.allowFallbacks?(x=(0,H.jsxs)(m,{value:n.allowFallbacks,disabled:i,onChange:_,children:[v,y,b]}),t[35]=i,t[36]=v,t[37]=y,t[38]=b,t[39]=_,t[40]=n.allowFallbacks,t[41]=x):x=t[41];let S;t[42]!==x||t[43]!==g?(S=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[g,x]}),t[42]=x,t[43]=g,t[44]=S):S=t[44];let C;t[45]===a.modelMaxCostTierLabel?C=t[46]:(C=(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[45]=a.modelMaxCostTierLabel,t[46]=C);let w;t[47]!==r||t[48]!==n?(w=e=>r({...n,maxCostTier:e.target.value}),t[47]=r,t[48]=n,t[49]=w):w=t[49];let T;t[50]===a.policyInherit?T=t[51]:(T=(0,H.jsx)(A,{value:``,children:a.policyInherit}),t[50]=a.policyInherit,t[51]=T);let E;t[52]===a.costTierLow?E=t[53]:(E=(0,H.jsx)(A,{value:`low`,children:a.costTierLow}),t[52]=a.costTierLow,t[53]=E);let D;t[54]===a.costTierMedium?D=t[55]:(D=(0,H.jsx)(A,{value:`medium`,children:a.costTierMedium}),t[54]=a.costTierMedium,t[55]=D);let O;t[56]===a.costTierHigh?O=t[57]:(O=(0,H.jsx)(A,{value:`high`,children:a.costTierHigh}),t[56]=a.costTierHigh,t[57]=O);let k;t[58]!==i||t[59]!==w||t[60]!==T||t[61]!==E||t[62]!==D||t[63]!==O||t[64]!==n.maxCostTier?(k=(0,H.jsxs)(m,{value:n.maxCostTier,disabled:i,onChange:w,children:[T,E,D,O]}),t[58]=i,t[59]=w,t[60]=T,t[61]=E,t[62]=D,t[63]=O,t[64]=n.maxCostTier,t[65]=k):k=t[65];let j;t[66]!==C||t[67]!==k?(j=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[C,k]}),t[66]=C,t[67]=k,t[68]=j):j=t[68];let M;t[69]!==S||t[70]!==j?(M=(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-panel/70 p-3 shadow-surface sm:grid-cols-2`,children:[S,j]}),t[69]=S,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==c||t[73]!==l||t[74]!==M||t[75]!==h?(N=(0,H.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-5 dark:border-edge`,children:[c,l,h,M]}),t[72]=c,t[73]=l,t[74]=M,t[75]=h,t[76]=N):N=t[76],N}function Ge(e){let t=(0,V.c)(64),{title:n,value:r,onChange:i,disabled:o,cp:s}=e,c;t[0]===n?c=t[1]:(c=(0,H.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=c);let l=s.modelToolPrimaryLabel,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]!==i||t[4]!==r?(d=e=>i({...r,primary:e.target.value}),t[3]=i,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==o||t[7]!==d||t[8]!==r.primary?(f=(0,H.jsx)(`input`,{className:u,value:r.primary,disabled:o,placeholder:`provider/model`,onChange:d}),t[6]=o,t[7]=d,t[8]=r.primary,t[9]=f):f=t[9];let p;t[10]!==s.modelToolPrimaryLabel||t[11]!==f?(p=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l,f]}),t[10]=s.modelToolPrimaryLabel,t[11]=f,t[12]=p):p=t[12];let h=s.modelToolFallbacksLabel,g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`min-h-20 resize-y font-mono text-xs`),t[13]=g):g=t[13];let _;t[14]!==i||t[15]!==r?(_=e=>i({...r,fallbacks:e.target.value}),t[14]=i,t[15]=r,t[16]=_):_=t[16];let v;t[17]!==s.modelToolFallbacksPlaceholder||t[18]!==o||t[19]!==_||t[20]!==r.fallbacks?(v=(0,H.jsx)(`textarea`,{className:g,value:r.fallbacks,disabled:o,placeholder:s.modelToolFallbacksPlaceholder,onChange:_}),t[17]=s.modelToolFallbacksPlaceholder,t[18]=o,t[19]=_,t[20]=r.fallbacks,t[21]=v):v=t[21];let y;t[22]!==s.modelToolFallbacksLabel||t[23]!==v?(y=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[h,v]}),t[22]=s.modelToolFallbacksLabel,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==i||t[26]!==r?(b=e=>i({...r,timeoutMs:e.target.value}),t[25]=i,t[26]=r,t[27]=b):b=t[27];let x;t[28]!==o||t[29]!==b||t[30]!==r.timeoutMs?(x=(0,H.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:o,onChange:b}),t[28]=o,t[29]=b,t[30]=r.timeoutMs,t[31]=x):x=t[31];let S;t[32]!==s.toolTimeoutLabel||t[33]!==x?(S=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.toolTimeoutLabel,x]}),t[32]=s.toolTimeoutLabel,t[33]=x,t[34]=S):S=t[34];let C;t[35]!==i||t[36]!==r?(C=e=>i({...r,autoProviderFallback:e.target.value}),t[35]=i,t[36]=r,t[37]=C):C=t[37];let w;t[38]===s.policyInherit?w=t[39]:(w=(0,H.jsx)(A,{value:``,children:s.policyInherit}),t[38]=s.policyInherit,t[39]=w);let T;t[40]===s.policyEnabled?T=t[41]:(T=(0,H.jsx)(A,{value:`true`,children:s.policyEnabled}),t[40]=s.policyEnabled,t[41]=T);let E;t[42]===s.policyDisabled?E=t[43]:(E=(0,H.jsx)(A,{value:`false`,children:s.policyDisabled}),t[42]=s.policyDisabled,t[43]=E);let D;t[44]!==o||t[45]!==C||t[46]!==w||t[47]!==T||t[48]!==E||t[49]!==r.autoProviderFallback?(D=(0,H.jsxs)(m,{value:r.autoProviderFallback,disabled:o,onChange:C,children:[w,T,E]}),t[44]=o,t[45]=C,t[46]=w,t[47]=T,t[48]=E,t[49]=r.autoProviderFallback,t[50]=D):D=t[50];let O;t[51]!==s.modelAutoProviderFallbackLabel||t[52]!==D?(O=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.modelAutoProviderFallbackLabel,D]}),t[51]=s.modelAutoProviderFallbackLabel,t[52]=D,t[53]=O):O=t[53];let k;t[54]!==S||t[55]!==O?(k=(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[S,O]}),t[54]=S,t[55]=O,t[56]=k):k=t[56];let j;t[57]!==y||t[58]!==k||t[59]!==p?(j=(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[p,y,k]}),t[57]=y,t[58]=k,t[59]=p,t[60]=j):j=t[60];let M;return t[61]!==c||t[62]!==j?(M=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 p-3 shadow-surface`,children:[c,j]}),t[61]=c,t[62]=j,t[63]=M):M=t[63],M}export{He as CapabilityPresetsSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-CxySDn9d.js";import{l as s,n as c}from"./locale-store-Dar-xqQr.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{$o as u,Bo as d,Es as f,Ho as p,Pl as m,Ro as h,Rr as g,Rs as _,Sc as v,Ss as y,Ts as b,Uo as x,Vl as S,Vo as C,Wo as w,dc as T,ec as E,gu as D,hs as O,is as k,ns as A,ol as j,rs as M,ts as N,yc as P,zo as ee}from"./index-vq_cJZJC.js";import{n as te,r as ne}from"./settings-page-layout-DWvNgISx.js";import{n as re,r as F}from"./settings-loading-skeleton-DkvwitK_.js";import{n as I,t as L}from"./settings-form-section-CNqF6IwY.js";import{a as ie,i as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./capability-presets-api-CCX9-LjU.js";import{a as de,i as fe,o as R,t as z}from"./typed-models-lib-DEGtSA5h.js";var B=e(t(),1),V=n(),H=r();function pe(e){let t=(0,V.c)(34),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===c.inheritanceTitle?d=t[3]:(d=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,H.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,H.jsxs)(`span`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,H.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,H.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(0,H.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,H.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,H.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,H.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,H.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function U(e){return e.name||e.directoryId}function me(e){let t=(0,V.c)(56),{mode:n,selected:r,catalog:i,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(U).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,H.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=_);let v;t[8]===h?v=t[9]:(v=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=v);let b;t[10]!==_||t[11]!==v?(b=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=b):b=t[12];let x;t[13]===u.modeLabel?x=t[14]:(x=(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=x);let S;t[15]===u.modeInherit?S=t[16]:(S=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=S);let C;t[17]===u.modeAll?C=t[18]:(C=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=C);let w;t[19]===u.modeAllowlist?w=t[20]:(w=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=w);let T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let E;t[23]===u.modeOff?E=t[24]:(E=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=E);let O;t[25]!==T||t[26]!==E||t[27]!==S||t[28]!==C||t[29]!==w?(O=[S,C,w,T,E],t[25]=T,t[26]=E,t[27]=S,t[28]=C,t[29]=w,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,H.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==x?(j=(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,A]}),t[36]=A,t[37]=x,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==o||t[48]!==l||t[49]!==d||t[50]!==r?(M=d?(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:s||o||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),o?(0,H.jsx)(F,{rows:3}):i.length===0?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,H.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=U(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,o=i||u.noDescription;return(0,H.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,H.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,H.jsx)(`p`,{className:a(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=o,t[48]=l,t[49]=d,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==b?(N=(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[b,j,M]}),t[52]=j,t[53]=M,t[54]=b,t[55]=N):N=t[55],N}var W=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],G=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],K=[`send_message`,`send_media`,`text_to_speech`,`create_share`],he=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],ge=[...W,...K],q=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],_e=[`send_message`,`send_media`];function ve(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function ye(e){let t=(0,V.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:o,getToolDescription:s,getGroupTitle:c,labels:l}=e,d;t[0]===n?d=t[1]:(d=new Set(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(be),t[2]=f,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==f||t[6]!==n){h=[];for(let e of se){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=le(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=f,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==i||t[13]!==r?(_=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=_):_=t[14];let v=_,b;t[15]!==i||t[16]!==r?(b=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=b):b=t[17];let x=b,S;t[18]!==f||t[19]!==i?(S=e=>{i(ve(f,e))},t[18]=f,t[19]=i,t[20]=S):S=t[20];let C=S;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let w;t[23]===l.quickActionsLabel?w=t[24]:(w=(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=w);let T;t[25]===i?T=t[26]:(T=()=>i({}),t[25]=i,t[26]=T);let E;t[27]!==o||t[28]!==l.quickClearOverrides||t[29]!==T?(E=(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:T,children:l.quickClearOverrides}),t[27]=o,t[28]=l.quickClearOverrides,t[29]=T,t[30]=E):E=t[30];let D;t[31]===C?D=t[32]:(D=()=>C([[W,`deny`]]),t[31]=C,t[32]=D);let O;t[33]!==o||t[34]!==l.quickReadOnlyWorkspace||t[35]!==D?(O=(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:D,children:l.quickReadOnlyWorkspace}),t[33]=o,t[34]=l.quickReadOnlyWorkspace,t[35]=D,t[36]=O):O=t[36];let k;t[37]===C?k=t[38]:(k=()=>C([[G,`deny`]]),t[37]=C,t[38]=k);let A;t[39]!==o||t[40]!==l.quickHighRiskOff||t[41]!==k?(A=(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:k,children:l.quickHighRiskOff}),t[39]=o,t[40]=l.quickHighRiskOff,t[41]=k,t[42]=A):A=t[42];let j;t[43]===C?j=t[44]:(j=()=>C([[K,`deny`]]),t[43]=C,t[44]=j);let M;t[45]!==o||t[46]!==l.quickNoOutbound||t[47]!==j?(M=(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:j,children:l.quickNoOutbound}),t[45]=o,t[46]=l.quickNoOutbound,t[47]=j,t[48]=M):M=t[48];let P;t[49]===C?P=t[50]:(P=()=>C([[he,`allow`],[ge,`deny`]]),t[49]=C,t[50]=P);let ee;t[51]!==o||t[52]!==l.quickResearchMode||t[53]!==P?(ee=(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:P,children:l.quickResearchMode}),t[51]=o,t[52]=l.quickResearchMode,t[53]=P,t[54]=ee):ee=t[54];let te;t[55]===C?te=t[56]:(te=()=>C([[q,`allow`],[_e,`deny`]]),t[55]=C,t[56]=te);let ne;t[57]!==o||t[58]!==l.quickCodingMode||t[59]!==te?(ne=(0,H.jsx)(y,{type:`button`,variant:`secondary`,className:R,disabled:o,onClick:te,children:l.quickCodingMode}),t[57]=o,t[58]=l.quickCodingMode,t[59]=te,t[60]=ne):ne=t[60];let re;t[61]!==A||t[62]!==M||t[63]!==ee||t[64]!==ne||t[65]!==E||t[66]!==O?(re=(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[E,O,A,M,ee,ne]}),t[61]=A,t[62]=M,t[63]=ee,t[64]=ne,t[65]=E,t[66]=O,t[67]=re):re=t[67];let F;t[68]!==re||t[69]!==w?(F=(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,re]}),t[68]=re,t[69]=w,t[70]=F):F=t[70];let I;t[71]===l.overrideSummaryTitle?I=t[72]:(I=(0,H.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=I);let L;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==m?(L=m.length>0?(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,H.jsxs)(`span`,{className:a(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,H.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=m,t[78]=L):L=t[78];let ie;t[79]!==I||t[80]!==L?(ie=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[I,L]}),t[79]=I,t[80]=L,t[81]=ie):ie=t[81];let ae;t[82]!==o||t[83]!==c||t[84]!==s||t[85]!==g||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==v||t[98]!==r||t[99]!==x?(ae=(0,H.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,H.jsxs)(`li`,{className:a(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,H.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,H.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,H.jsx)(`button`,{type:`button`,className:a(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>v(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,H.jsxs)(u,{value:n.scope??``,disabled:o,onChange:t=>x(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,H.jsx)(N,{value:``,children:l.scopeInherit}),(0,H.jsx)(N,{value:`readonly`,children:l.scopeReadonly}),(0,H.jsx)(N,{value:`workspace`,children:l.scopeWorkspace}),(0,H.jsx)(N,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,H.jsx)(J,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:o,onChange:t=>x(e,e=>xe(e,`maxCallsPerTurn`,t))}),(0,H.jsx)(J,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:o,onChange:t=>x(e,e=>xe(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=o,t[83]=c,t[84]=s,t[85]=g,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=v,t[98]=r,t[99]=x,t[100]=ae):ae=t[100];let oe;return t[101]!==F||t[102]!==ie||t[103]!==ae?(oe=(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,ie,ae]}),t[101]=F,t[102]=ie,t[103]=ae,t[104]=oe):oe=t[104],oe}function be(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function xe(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function J(e){let t=(0,V.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,H.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Se=[{id:`overview`,icon:S},{id:`models`,icon:j},{id:`tools`,icon:f},{id:`skills`,icon:P},{id:`advanced`,icon:E},{id:`impact`,icon:m}];function Ce(e){return fe(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Y(e){return structuredClone(e?.tools?.builtin??{})}function we(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Te(){return{primary:``,fallbacks:``,timeoutMs:``,autoProviderFallback:``}}function Ee(e){return{primary:e?.primary??``,fallbacks:e?.fallbacks?.join(`
2
+ `)??``,timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function X(){return{imageModel:Te(),imageGenerationModel:Te(),allowFallbacks:``,maxCostTier:``}}function Z(e){return{imageModel:Ee(e?.models?.imageModel),imageGenerationModel:Ee(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Q(e){return e===void 0?``:JSON.stringify(e,null,2)}function De(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Oe(e){return{mcp:Q(e?.tools?.mcp),workflows:Q(e?.workflows),boundaries:Q(e?.boundaries),runtime:Q(e?.runtime),locks:Q(e?.locks)}}function ke(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Ce(e),modelAdvanced:Z(e),toolPolicies:Y(e),skillMode:e?.skills?.mode??`inherit`,skillPick:we(e),extendsIds:[...e?.extends??[]],jsonFields:Oe(e)}}function Ae(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function je(e,t){let n=z(e.modelRows),r=Ae(e.modelAdvanced.imageModel),i=Ae(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function Me(e){return e.trim()?JSON.parse(e):void 0}function $(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ne(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=Me(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Pe(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Fe(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function Ie(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:je(e,t),tools:{builtin:Pe(e.toolPolicies),mcp:$(e.jsonFields.mcp)},skills:Fe(e),extends:[...e.extendsIds].toSorted(),workflows:$(e.jsonFields.workflows),boundaries:$(e.jsonFields.boundaries),runtime:$(e.jsonFields.runtime),locks:$(e.jsonFields.locks)}}function Le(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Pe(e.tools?.builtin),mcp:$(Q(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:$(Q(e.workflows)),boundaries:$(Q(e.boundaries)),runtime:$(Q(e.runtime)),locks:$(Q(e.locks))}:null}function Re(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function ze(){return{modelAdvanced:X(),extendsIds:[],jsonFields:De()}}function Be(e,t){return{extends:[...e.extendsIds],models:je(e,t)??void 0,tools:Ne(e)??void 0,skills:Fe(e)??void 0,workflows:Me(e.jsonFields.workflows),boundaries:Me(e.jsonFields.boundaries),runtime:Me(e.jsonFields.runtime),locks:Me(e.jsonFields.locks)}}function Ve(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...ze()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...ze()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...ze()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...ze()}}function He(){let e=o(c(e=>e.language)),t=e.capabilityPresetsSettings,n=!!s(e=>e.token),{data:r,error:u,isLoading:D,mutate:N}=l(n?`settings-capability-presets`:null,ce,{revalidateOnFocus:!1}),{data:F=[],isLoading:se}=l(n?`settings-capability-presets-skills-catalog`:null,g,{revalidateOnFocus:!1}),[le,fe]=i(),[R,z]=(0,B.useState)(``),[V,U]=(0,B.useState)(`overview`),[W,G]=(0,B.useState)(()=>Ve(`blank`,t)),[K,he]=(0,B.useState)(!1),[ge,q]=(0,B.useState)(null),[_e,ve]=(0,B.useState)(null),be=r?.presets??[],xe=r?.defaultPresetId??`default`,J=be.find(e=>e.id===xe)??null,Ce=be.filter(e=>e.id!==xe),Y=(0,B.useMemo)(()=>be.find(e=>e.id===R)??be[0]??null,[be,R]),we=!Y||W.id.trim()!==Y.id,Te=!!(Y&&Y.id===xe),Ee=JSON.stringify(Ie(W,Y))!==JSON.stringify(Le(Y)),X=Ie(W,Y),Z=Le(Y),Q=[X.id!==Z?.id||X.name!==Z?.name||X.description!==Z?.description?t.tabs.overview:``,JSON.stringify(X.models)===JSON.stringify(Z?.models)?``:t.tabs.models,JSON.stringify(X.tools)===JSON.stringify(Z?.tools)?``:t.tabs.tools,JSON.stringify(X.skills)===JSON.stringify(Z?.skills)?``:t.tabs.skills,JSON.stringify({extends:X.extends,workflows:X.workflows,boundaries:X.boundaries,runtime:X.runtime,locks:X.locks})===JSON.stringify({extends:Z?.extends,workflows:Z?.workflows,boundaries:Z?.boundaries,runtime:Z?.runtime,locks:Z?.locks})?``:t.tabs.advanced].filter(Boolean),De=ge??(u instanceof Error?u.message:null),Oe=le.get(`action`)===`new`||!!le.get(`preset`),Ae=we?t.newPreset:Y?.name??t.editorTitle,je=t=>e.agentsSettings.toolsDisableGroups[t],$=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,B.useEffect)(()=>{if(!r||K)return;if(le.get(`action`)===`new`){let e=le.get(`starter`);z(``),G(Ve(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`,t)),U(`overview`);return}let e=le.get(`preset`)?.trim(),n=e?r.presets.find(t=>t.id===e):null;if(n){z(n.id),G(ke(n)),U(le.get(`tab`)??`overview`);return}Y&&(z(Y.id),G(e=>e.id===Y.id?e:ke(Y)))},[K,r,le,Y]);function Ne(e){z(e.id),G(ke(e)),fe({preset:e.id},{replace:!0}),U(`overview`)}function Pe(e){let n=Ve(e,t);z(``),G(n),q(null),fe(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),U(`overview`)}function Fe(){Ee&&!window.confirm(t.discardConfirm)||(fe({},{replace:!0}),q(null),G(ke(Y)),U(`overview`))}async function ze(){let e=de(W.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){q(e),U(`models`);return}for(let e of[W.modelAdvanced.imageModel,W.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks.split(/\r?\n|,/)].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){q(t.invalidModelRef),U(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){q(t.advancedPositiveIntegerError),U(`models`);return}}for(let e of Object.values(W.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){q(t.advancedPositiveIntegerError),U(`tools`);return}for(let e of Object.keys(W.jsonFields))try{Me(W.jsonFields[e])}catch{q(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),U(`advanced`);return}he(!0),q(null);try{let e=Be(W,Y);if(we){let t=await ue({id:W.id.trim(),name:W.name.trim(),...W.description.trim()?{description:W.description.trim()}:{},...e});await N(t.presets,{revalidate:!1}),z(t.presetId),fe({preset:t.presetId},{replace:!0})}else Y&&await N(await ae(Y.id,{name:W.name.trim(),description:W.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){q(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function He(){if(Y&&window.confirm(t.deleteConfirm.replace(`{{name}}`,Y.name))){he(!0),q(null);try{let e=await oe(Y.id);await N(e,{revalidate:!1});let t=e.presets[0]??null;z(t?.id??``),G(ke(t)),fe(t?{preset:t.id}:{},{replace:!0})}catch(e){q(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}}return n?(0,H.jsxs)(ne,{gap:`gap-5`,className:`pb-24`,children:[(0,H.jsx)(te,{title:t.title,subtitle:t.subtitle,actions:(0,H.jsxs)(y,{type:`button`,onClick:()=>Pe(`blank`),disabled:K,children:[(0,H.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),De?(0,H.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,D?(0,H.jsx)(re,{sections:2}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:v,title:t.newPreset,subtitle:t.editorHint}),(0,H.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,H.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-sm text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Pe(e),children:[(0,H.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,H.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),J?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:j,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Ne(J),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:J.name}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:J.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),J.description?(0,H.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:J.description}):null,(0,H.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Re(J,t)})]})]}):null,(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:j,title:t.listTitle,subtitle:t.listHint}),Ce.length===0?(0,H.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:t.empty}):(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Ce.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Ne(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,H.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,H.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:Re(e,t)})]},e.id))})]})]}),(0,H.jsx)(h,{open:Oe,onOpenChange:e=>{e||Fe()},children:(0,H.jsxs)(x,{children:[(0,H.jsx)(p,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,k)}),(0,H.jsx)(d,{ref:ve,className:a(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,M),onOpenAutoFocus:e=>e.preventDefault(),children:(0,H.jsxs)(A,{layer:`modal`,portalContainer:_e,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(w,{className:`truncate text-base font-semibold text-fg`,children:Ae}),(0,H.jsx)(C,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:we?t.editorHint:W.id})]}),(0,H.jsx)(ee,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:a(O,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,H.jsx)(b,{className:`size-4`,"aria-hidden":!0})})})]}),De?(0,H.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:De}):null,(0,H.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:Se.map(({id:e,icon:n})=>(0,H.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,V===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>U(e),children:[(0,H.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[V===`overview`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:S,title:t.overviewTitle,subtitle:t.overviewHint}),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.id,disabled:K||!we,onChange:e=>G(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!we&&Y?(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,H.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String(Y.version))})]}):null,(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,H.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.name,disabled:K,onChange:e=>G(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,H.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.description,disabled:K,onChange:e=>G(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,H.jsx)(Ue,{icon:j,label:t.modelsTitle,value:String(W.modelRows.length)}),(0,H.jsx)(Ue,{icon:f,label:t.toolsTitle,value:String(Object.keys(W.toolPolicies).length)}),(0,H.jsx)(Ue,{icon:P,label:t.skillsTitle,value:t.skillModeLabels[W.skillMode]})]})]}):null,V===`models`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:j,title:t.modelsTitle,subtitle:t.modelsHint}),(0,H.jsx)(ie,{rows:W.modelRows,onChange:e=>G(t=>({...t,modelRows:e})),disabled:K,defaultRole:Y?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,visionBadge:t.modelVisionBadge,visionAutoHint:t.modelVisionAutoHint,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,H.jsx)(We,{value:W.modelAdvanced,onChange:e=>G(t=>({...t,modelAdvanced:e})),disabled:K,cp:t})]}):null,V===`tools`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:f,title:t.toolsTitle,subtitle:t.toolsHint}),(0,H.jsx)(ye,{builtinToolIds:r?.builtinToolIds??[],toolPolicies:W.toolPolicies,onChange:e=>G(t=>({...t,toolPolicies:e})),disabled:K,getToolDescription:$,getGroupTitle:je,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,V===`skills`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:P,title:t.skillsTitle,subtitle:t.skillsHint}),(0,H.jsx)(me,{mode:W.skillMode,selected:W.skillPick,catalog:F,loading:se,disabled:K,onModeChange:e=>G(t=>({...t,skillMode:e})),onSelectedChange:e=>G(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,V===`advanced`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:E,title:t.advancedTitle,subtitle:t.advancedHint}),(0,H.jsx)(pe,{extendsIds:W.extendsIds,onExtendsChange:e=>G(t=>({...t,extendsIds:e})),presetOptions:be.filter(e=>e.id!==Y?.id&&e.id!==xe),jsonFields:W.jsonFields,onJsonFieldsChange:e=>G(t=>({...t,jsonFields:e})),disabled:K,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,V===`impact`?(0,H.jsxs)(L,{children:[(0,H.jsx)(I,{icon:m,title:t.usageTitle,subtitle:t.usageHint}),(0,H.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Q.length>0?t.changePreviewSections.replace(`{{sections}}`,Q.join(`、`)):t.changePreviewEmpty})]}),Y?.usage.length?(0,H.jsx)(`div`,{className:`grid gap-2`,children:Y.usage.map(e=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,H.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,H.jsx)(`div`,{className:`font-medium text-fg`,children:Ee?t.unsavedTitle:t.noUnsavedTitle}),(0,H.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ee?(Y?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String(Y?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ee?(0,H.jsx)(y,{type:`button`,variant:`secondary`,disabled:K,onClick:()=>G(ke(Y)),children:t.discard}):null,Y&&!Te?(0,H.jsxs)(y,{type:`button`,variant:`secondary`,disabled:K,onClick:()=>void He(),children:[(0,H.jsx)(_,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,H.jsxs)(y,{type:`button`,disabled:K||!W.id.trim()||!W.name.trim()||!Ee,onClick:()=>void ze(),children:[(0,H.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,H.jsxs)(ne,{gap:`gap-3`,children:[(0,H.jsx)(te,{title:t.title}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function Ue(e){let t=(0,V.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,H.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,H.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function We(e){let t=(0,V.c)(77),{value:n,onChange:r,disabled:i,cp:a}=e,o;t[0]!==r||t[1]!==n?(o=(e,t)=>{r({...n,[e]:t})},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]===a.modelAdvancedTitle?c=t[4]:(c=(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[3]=a.modelAdvancedTitle,t[4]=c);let l;t[5]===a.modelAdvancedHint?l=t[6]:(l=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[5]=a.modelAdvancedHint,t[6]=l);let d;t[7]===s?d=t[8]:(d=e=>s(`imageModel`,e),t[7]=s,t[8]=d);let f;t[9]!==a||t[10]!==i||t[11]!==d||t[12]!==n.imageModel?(f=(0,H.jsx)(Ge,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:d,disabled:i,cp:a}),t[9]=a,t[10]=i,t[11]=d,t[12]=n.imageModel,t[13]=f):f=t[13];let p;t[14]===s?p=t[15]:(p=e=>s(`imageGenerationModel`,e),t[14]=s,t[15]=p);let m;t[16]!==a||t[17]!==i||t[18]!==p||t[19]!==n.imageGenerationModel?(m=(0,H.jsx)(Ge,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:p,disabled:i,cp:a}),t[16]=a,t[17]=i,t[18]=p,t[19]=n.imageGenerationModel,t[20]=m):m=t[20];let h;t[21]!==f||t[22]!==m?(h=(0,H.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[f,m]}),t[21]=f,t[22]=m,t[23]=h):h=t[23];let g;t[24]===a.modelAllowFallbacksLabel?g=t[25]:(g=(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[24]=a.modelAllowFallbacksLabel,t[25]=g);let _;t[26]!==r||t[27]!==n?(_=e=>r({...n,allowFallbacks:e.target.value}),t[26]=r,t[27]=n,t[28]=_):_=t[28];let v;t[29]===a.policyInherit?v=t[30]:(v=(0,H.jsx)(N,{value:``,children:a.policyInherit}),t[29]=a.policyInherit,t[30]=v);let y;t[31]===a.policyEnabled?y=t[32]:(y=(0,H.jsx)(N,{value:`true`,children:a.policyEnabled}),t[31]=a.policyEnabled,t[32]=y);let b;t[33]===a.policyDisabled?b=t[34]:(b=(0,H.jsx)(N,{value:`false`,children:a.policyDisabled}),t[33]=a.policyDisabled,t[34]=b);let x;t[35]!==i||t[36]!==v||t[37]!==y||t[38]!==b||t[39]!==_||t[40]!==n.allowFallbacks?(x=(0,H.jsxs)(u,{value:n.allowFallbacks,disabled:i,onChange:_,children:[v,y,b]}),t[35]=i,t[36]=v,t[37]=y,t[38]=b,t[39]=_,t[40]=n.allowFallbacks,t[41]=x):x=t[41];let S;t[42]!==x||t[43]!==g?(S=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[g,x]}),t[42]=x,t[43]=g,t[44]=S):S=t[44];let C;t[45]===a.modelMaxCostTierLabel?C=t[46]:(C=(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[45]=a.modelMaxCostTierLabel,t[46]=C);let w;t[47]!==r||t[48]!==n?(w=e=>r({...n,maxCostTier:e.target.value}),t[47]=r,t[48]=n,t[49]=w):w=t[49];let T;t[50]===a.policyInherit?T=t[51]:(T=(0,H.jsx)(N,{value:``,children:a.policyInherit}),t[50]=a.policyInherit,t[51]=T);let E;t[52]===a.costTierLow?E=t[53]:(E=(0,H.jsx)(N,{value:`low`,children:a.costTierLow}),t[52]=a.costTierLow,t[53]=E);let D;t[54]===a.costTierMedium?D=t[55]:(D=(0,H.jsx)(N,{value:`medium`,children:a.costTierMedium}),t[54]=a.costTierMedium,t[55]=D);let O;t[56]===a.costTierHigh?O=t[57]:(O=(0,H.jsx)(N,{value:`high`,children:a.costTierHigh}),t[56]=a.costTierHigh,t[57]=O);let k;t[58]!==i||t[59]!==w||t[60]!==T||t[61]!==E||t[62]!==D||t[63]!==O||t[64]!==n.maxCostTier?(k=(0,H.jsxs)(u,{value:n.maxCostTier,disabled:i,onChange:w,children:[T,E,D,O]}),t[58]=i,t[59]=w,t[60]=T,t[61]=E,t[62]=D,t[63]=O,t[64]=n.maxCostTier,t[65]=k):k=t[65];let A;t[66]!==C||t[67]!==k?(A=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[C,k]}),t[66]=C,t[67]=k,t[68]=A):A=t[68];let j;t[69]!==S||t[70]!==A?(j=(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-panel/70 p-3 shadow-surface sm:grid-cols-2`,children:[S,A]}),t[69]=S,t[70]=A,t[71]=j):j=t[71];let M;return t[72]!==c||t[73]!==l||t[74]!==j||t[75]!==h?(M=(0,H.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-5 dark:border-edge`,children:[c,l,h,j]}),t[72]=c,t[73]=l,t[74]=j,t[75]=h,t[76]=M):M=t[76],M}function Ge(e){let t=(0,V.c)(64),{title:n,value:r,onChange:i,disabled:o,cp:s}=e,c;t[0]===n?c=t[1]:(c=(0,H.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=c);let l=s.modelToolPrimaryLabel,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=a(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`font-mono text-xs`),t[2]=d):d=t[2];let f;t[3]!==i||t[4]!==r?(f=e=>i({...r,primary:e.target.value}),t[3]=i,t[4]=r,t[5]=f):f=t[5];let p;t[6]!==o||t[7]!==f||t[8]!==r.primary?(p=(0,H.jsx)(`input`,{className:d,value:r.primary,disabled:o,placeholder:`provider/model`,onChange:f}),t[6]=o,t[7]=f,t[8]=r.primary,t[9]=p):p=t[9];let m;t[10]!==s.modelToolPrimaryLabel||t[11]!==p?(m=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l,p]}),t[10]=s.modelToolPrimaryLabel,t[11]=p,t[12]=m):m=t[12];let h=s.modelToolFallbacksLabel,g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`min-h-20 resize-y font-mono text-xs`),t[13]=g):g=t[13];let _;t[14]!==i||t[15]!==r?(_=e=>i({...r,fallbacks:e.target.value}),t[14]=i,t[15]=r,t[16]=_):_=t[16];let v;t[17]!==s.modelToolFallbacksPlaceholder||t[18]!==o||t[19]!==_||t[20]!==r.fallbacks?(v=(0,H.jsx)(`textarea`,{className:g,value:r.fallbacks,disabled:o,placeholder:s.modelToolFallbacksPlaceholder,onChange:_}),t[17]=s.modelToolFallbacksPlaceholder,t[18]=o,t[19]=_,t[20]=r.fallbacks,t[21]=v):v=t[21];let y;t[22]!==s.modelToolFallbacksLabel||t[23]!==v?(y=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[h,v]}),t[22]=s.modelToolFallbacksLabel,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==i||t[26]!==r?(b=e=>i({...r,timeoutMs:e.target.value}),t[25]=i,t[26]=r,t[27]=b):b=t[27];let x;t[28]!==o||t[29]!==b||t[30]!==r.timeoutMs?(x=(0,H.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:o,onChange:b}),t[28]=o,t[29]=b,t[30]=r.timeoutMs,t[31]=x):x=t[31];let S;t[32]!==s.toolTimeoutLabel||t[33]!==x?(S=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.toolTimeoutLabel,x]}),t[32]=s.toolTimeoutLabel,t[33]=x,t[34]=S):S=t[34];let C;t[35]!==i||t[36]!==r?(C=e=>i({...r,autoProviderFallback:e.target.value}),t[35]=i,t[36]=r,t[37]=C):C=t[37];let w;t[38]===s.policyInherit?w=t[39]:(w=(0,H.jsx)(N,{value:``,children:s.policyInherit}),t[38]=s.policyInherit,t[39]=w);let T;t[40]===s.policyEnabled?T=t[41]:(T=(0,H.jsx)(N,{value:`true`,children:s.policyEnabled}),t[40]=s.policyEnabled,t[41]=T);let E;t[42]===s.policyDisabled?E=t[43]:(E=(0,H.jsx)(N,{value:`false`,children:s.policyDisabled}),t[42]=s.policyDisabled,t[43]=E);let D;t[44]!==o||t[45]!==C||t[46]!==w||t[47]!==T||t[48]!==E||t[49]!==r.autoProviderFallback?(D=(0,H.jsxs)(u,{value:r.autoProviderFallback,disabled:o,onChange:C,children:[w,T,E]}),t[44]=o,t[45]=C,t[46]=w,t[47]=T,t[48]=E,t[49]=r.autoProviderFallback,t[50]=D):D=t[50];let O;t[51]!==s.modelAutoProviderFallbackLabel||t[52]!==D?(O=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.modelAutoProviderFallbackLabel,D]}),t[51]=s.modelAutoProviderFallbackLabel,t[52]=D,t[53]=O):O=t[53];let k;t[54]!==S||t[55]!==O?(k=(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[S,O]}),t[54]=S,t[55]=O,t[56]=k):k=t[56];let A;t[57]!==y||t[58]!==k||t[59]!==m?(A=(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[m,y,k]}),t[57]=y,t[58]=k,t[59]=m,t[60]=A):A=t[60];let j;return t[61]!==c||t[62]!==A?(j=(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 p-3 shadow-surface`,children:[c,A]}),t[61]=c,t[62]=A,t[63]=j):j=t[63],j}export{He as CapabilityPresetsSettingsPanel};
@@ -1 +1 @@
1
- import{r as e,s as t}from"./locale-store-C_M71MK9.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await t(e(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await t(e(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}export{i as n,a as r,r as t};
1
+ import{r as e,s as t}from"./locale-store-Dar-xqQr.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await t(e(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await t(e(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}export{i as n,a as r,r as t};