@withbuddi/buddi 0.1.0-pre.20 → 0.1.0-pre.21

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 (400) hide show
  1. package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
  2. package/node_modules/@buddi/cli/dist/args.d.ts +6 -0
  3. package/node_modules/@buddi/cli/dist/args.d.ts.map +1 -1
  4. package/node_modules/@buddi/cli/dist/args.js +15 -0
  5. package/node_modules/@buddi/cli/dist/args.js.map +1 -1
  6. package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
  7. package/node_modules/@buddi/cli/dist/commands.js +17 -0
  8. package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
  9. package/node_modules/@buddi/cli/dist/main.d.ts.map +1 -1
  10. package/node_modules/@buddi/cli/dist/main.js +7 -0
  11. package/node_modules/@buddi/cli/dist/main.js.map +1 -1
  12. package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
  13. package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
  14. package/node_modules/@buddi/core/dist/host/build.js +33 -16
  15. package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
  16. package/node_modules/@buddi/core/dist/host/types.d.ts +17 -0
  17. package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
  18. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  19. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js +1 -0
  20. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js.map +1 -1
  21. package/node_modules/@buddi/core/dist/pages.d.ts +74 -0
  22. package/node_modules/@buddi/core/dist/pages.d.ts.map +1 -1
  23. package/node_modules/@buddi/core/dist/pages.js +27 -1
  24. package/node_modules/@buddi/core/dist/pages.js.map +1 -1
  25. package/node_modules/@buddi/core/dist/plugin/index.d.ts +2 -2
  26. package/node_modules/@buddi/core/dist/plugin/index.d.ts.map +1 -1
  27. package/node_modules/@buddi/core/dist/plugin/version.d.ts +1 -1
  28. package/node_modules/@buddi/core/dist/plugin/version.js +1 -1
  29. package/node_modules/@buddi/core/dist/provider-accounts.d.ts +8 -0
  30. package/node_modules/@buddi/core/dist/provider-accounts.d.ts.map +1 -1
  31. package/node_modules/@buddi/core/dist/provider-accounts.js +8 -0
  32. package/node_modules/@buddi/core/dist/provider-accounts.js.map +1 -1
  33. package/node_modules/@buddi/core/dist/surfaces.d.ts +11 -0
  34. package/node_modules/@buddi/core/dist/surfaces.d.ts.map +1 -1
  35. package/node_modules/@buddi/core/dist/surfaces.js +4 -0
  36. package/node_modules/@buddi/core/dist/surfaces.js.map +1 -1
  37. package/node_modules/@buddi/core/migrations/048_surface_chat_voice.sql +13 -0
  38. package/node_modules/@buddi/core/migrations/049_surface_chat_voice_form.sql +8 -0
  39. package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
  40. package/node_modules/@buddi/gateway/dist/agents-cli.d.ts +2 -0
  41. package/node_modules/@buddi/gateway/dist/agents-cli.d.ts.map +1 -1
  42. package/node_modules/@buddi/gateway/dist/agents-cli.js +5 -3
  43. package/node_modules/@buddi/gateway/dist/agents-cli.js.map +1 -1
  44. package/node_modules/@buddi/gateway/dist/chat/session.d.ts.map +1 -1
  45. package/node_modules/@buddi/gateway/dist/chat/session.js +2 -2
  46. package/node_modules/@buddi/gateway/dist/chat/session.js.map +1 -1
  47. package/node_modules/@buddi/gateway/dist/chat/usage.d.ts +16 -0
  48. package/node_modules/@buddi/gateway/dist/chat/usage.d.ts.map +1 -1
  49. package/node_modules/@buddi/gateway/dist/chat/usage.js +53 -11
  50. package/node_modules/@buddi/gateway/dist/chat/usage.js.map +1 -1
  51. package/node_modules/@buddi/gateway/dist/index.d.ts +1 -0
  52. package/node_modules/@buddi/gateway/dist/index.d.ts.map +1 -1
  53. package/node_modules/@buddi/gateway/dist/index.js +1 -0
  54. package/node_modules/@buddi/gateway/dist/index.js.map +1 -1
  55. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts +4 -0
  56. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
  57. package/node_modules/@buddi/gateway/dist/provider-accounts.js +3 -1
  58. package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
  59. package/node_modules/@buddi/gateway/dist/speech-cli.d.ts +43 -0
  60. package/node_modules/@buddi/gateway/dist/speech-cli.d.ts.map +1 -0
  61. package/node_modules/@buddi/gateway/dist/speech-cli.js +105 -0
  62. package/node_modules/@buddi/gateway/dist/speech-cli.js.map +1 -0
  63. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts +10 -0
  64. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts.map +1 -1
  65. package/node_modules/@buddi/gateway/dist/telegram/api.js +12 -0
  66. package/node_modules/@buddi/gateway/dist/telegram/api.js.map +1 -1
  67. package/node_modules/@buddi/gateway/dist/telegram/browser-view.d.ts +2 -1
  68. package/node_modules/@buddi/gateway/dist/telegram/browser-view.d.ts.map +1 -1
  69. package/node_modules/@buddi/gateway/dist/telegram/browser-view.js +4 -2
  70. package/node_modules/@buddi/gateway/dist/telegram/browser-view.js.map +1 -1
  71. package/node_modules/@buddi/gateway/dist/telegram/main.d.ts.map +1 -1
  72. package/node_modules/@buddi/gateway/dist/telegram/main.js +10 -2
  73. package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
  74. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +25 -0
  75. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
  76. package/node_modules/@buddi/gateway/dist/telegram/surface.js +212 -10
  77. package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
  78. package/node_modules/@buddi/gateway/dist/telegram/voice.d.ts +112 -0
  79. package/node_modules/@buddi/gateway/dist/telegram/voice.d.ts.map +1 -0
  80. package/node_modules/@buddi/gateway/dist/telegram/voice.js +220 -0
  81. package/node_modules/@buddi/gateway/dist/telegram/voice.js.map +1 -0
  82. package/node_modules/@buddi/gateway/dist/web/chat.d.ts +31 -8
  83. package/node_modules/@buddi/gateway/dist/web/chat.d.ts.map +1 -1
  84. package/node_modules/@buddi/gateway/dist/web/chat.js +3 -2
  85. package/node_modules/@buddi/gateway/dist/web/chat.js.map +1 -1
  86. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +13 -2
  87. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
  88. package/node_modules/@buddi/gateway/dist/web/onboarding.js +24 -3
  89. package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
  90. package/node_modules/@buddi/gateway/dist/web/read.d.ts +15 -12
  91. package/node_modules/@buddi/gateway/dist/web/read.d.ts.map +1 -1
  92. package/node_modules/@buddi/gateway/dist/web/read.js +9 -10
  93. package/node_modules/@buddi/gateway/dist/web/read.js.map +1 -1
  94. package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
  95. package/node_modules/@buddi/gateway/dist/web/server.js +13 -0
  96. package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
  97. package/node_modules/@buddi/gateway/dist/web/speech.d.ts +47 -0
  98. package/node_modules/@buddi/gateway/dist/web/speech.d.ts.map +1 -0
  99. package/node_modules/@buddi/gateway/dist/web/speech.js +83 -0
  100. package/node_modules/@buddi/gateway/dist/web/speech.js.map +1 -0
  101. package/node_modules/@buddi/gateway/dist/web/stream.d.ts +0 -24
  102. package/node_modules/@buddi/gateway/dist/web/stream.d.ts.map +1 -1
  103. package/node_modules/@buddi/gateway/dist/web/stream.js +26 -2
  104. package/node_modules/@buddi/gateway/dist/web/stream.js.map +1 -1
  105. package/node_modules/@buddi/gateway/dist/web/usage-view.d.ts +15 -0
  106. package/node_modules/@buddi/gateway/dist/web/usage-view.d.ts.map +1 -0
  107. package/node_modules/@buddi/gateway/dist/web/usage-view.js +20 -0
  108. package/node_modules/@buddi/gateway/dist/web/usage-view.js.map +1 -0
  109. package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
  110. package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
  111. package/node_modules/@buddi/runtime/dist/anthropic.d.ts +18 -0
  112. package/node_modules/@buddi/runtime/dist/anthropic.d.ts.map +1 -1
  113. package/node_modules/@buddi/runtime/dist/anthropic.js +65 -13
  114. package/node_modules/@buddi/runtime/dist/anthropic.js.map +1 -1
  115. package/node_modules/@buddi/runtime/dist/codex-direct.d.ts.map +1 -1
  116. package/node_modules/@buddi/runtime/dist/codex-direct.js +11 -3
  117. package/node_modules/@buddi/runtime/dist/codex-direct.js.map +1 -1
  118. package/node_modules/@buddi/runtime/dist/context-window.d.ts.map +1 -1
  119. package/node_modules/@buddi/runtime/dist/context-window.js +13 -4
  120. package/node_modules/@buddi/runtime/dist/context-window.js.map +1 -1
  121. package/node_modules/@buddi/runtime/dist/loop.d.ts.map +1 -1
  122. package/node_modules/@buddi/runtime/dist/loop.js +6 -0
  123. package/node_modules/@buddi/runtime/dist/loop.js.map +1 -1
  124. package/node_modules/@buddi/runtime/dist/openai.d.ts +16 -4
  125. package/node_modules/@buddi/runtime/dist/openai.d.ts.map +1 -1
  126. package/node_modules/@buddi/runtime/dist/openai.js +23 -4
  127. package/node_modules/@buddi/runtime/dist/openai.js.map +1 -1
  128. package/node_modules/@buddi/runtime/dist/provider-models.d.ts.map +1 -1
  129. package/node_modules/@buddi/runtime/dist/provider-models.js +5 -1
  130. package/node_modules/@buddi/runtime/dist/provider-models.js.map +1 -1
  131. package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
  132. package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
  133. package/node_modules/@buddi/tool-browser/dist/computer.d.ts +53 -1
  134. package/node_modules/@buddi/tool-browser/dist/computer.d.ts.map +1 -1
  135. package/node_modules/@buddi/tool-browser/dist/computer.js +154 -5
  136. package/node_modules/@buddi/tool-browser/dist/computer.js.map +1 -1
  137. package/node_modules/@buddi/tool-browser/dist/controller.d.ts +20 -3
  138. package/node_modules/@buddi/tool-browser/dist/controller.d.ts.map +1 -1
  139. package/node_modules/@buddi/tool-browser/dist/controller.js +170 -5
  140. package/node_modules/@buddi/tool-browser/dist/controller.js.map +1 -1
  141. package/node_modules/@buddi/tool-browser/dist/index.d.ts.map +1 -1
  142. package/node_modules/@buddi/tool-browser/dist/index.js +9 -1
  143. package/node_modules/@buddi/tool-browser/dist/index.js.map +1 -1
  144. package/node_modules/@buddi/tool-browser/dist/service.d.ts +14 -1
  145. package/node_modules/@buddi/tool-browser/dist/service.d.ts.map +1 -1
  146. package/node_modules/@buddi/tool-browser/dist/service.js +28 -5
  147. package/node_modules/@buddi/tool-browser/dist/service.js.map +1 -1
  148. package/node_modules/@buddi/tool-browser/dist/types.d.ts +11 -0
  149. package/node_modules/@buddi/tool-browser/dist/types.d.ts.map +1 -1
  150. package/node_modules/@buddi/tool-browser/dist/types.js +16 -3
  151. package/node_modules/@buddi/tool-browser/dist/types.js.map +1 -1
  152. package/node_modules/@buddi/tool-browser/package.json +1 -1
  153. package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
  154. package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
  155. package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
  156. package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
  157. package/node_modules/imapflow/CHANGELOG.md +29 -0
  158. package/node_modules/imapflow/dist/cjs/commands/append.js +12 -12
  159. package/node_modules/imapflow/dist/cjs/commands/authenticate.d.ts +3 -8
  160. package/node_modules/imapflow/dist/cjs/commands/close.js +2 -1
  161. package/node_modules/imapflow/dist/cjs/commands/copy.js +4 -4
  162. package/node_modules/imapflow/dist/cjs/commands/create.js +2 -3
  163. package/node_modules/imapflow/dist/cjs/commands/delete.js +4 -4
  164. package/node_modules/imapflow/dist/cjs/commands/expunge.js +8 -5
  165. package/node_modules/imapflow/dist/cjs/commands/fetch.js +12 -10
  166. package/node_modules/imapflow/dist/cjs/commands/idle.js +6 -2
  167. package/node_modules/imapflow/dist/cjs/commands/list.js +22 -18
  168. package/node_modules/imapflow/dist/cjs/commands/move.js +11 -6
  169. package/node_modules/imapflow/dist/cjs/commands/namespace.js +1 -1
  170. package/node_modules/imapflow/dist/cjs/commands/quota.js +10 -9
  171. package/node_modules/imapflow/dist/cjs/commands/rename.js +4 -4
  172. package/node_modules/imapflow/dist/cjs/commands/search.js +7 -8
  173. package/node_modules/imapflow/dist/cjs/commands/select.js +12 -9
  174. package/node_modules/imapflow/dist/cjs/commands/status.js +11 -11
  175. package/node_modules/imapflow/dist/cjs/commands/store.js +5 -5
  176. package/node_modules/imapflow/dist/cjs/commands/subscribe.js +2 -17
  177. package/node_modules/imapflow/dist/cjs/commands/subscription.d.ts +10 -0
  178. package/node_modules/imapflow/dist/cjs/commands/subscription.js +29 -0
  179. package/node_modules/imapflow/dist/cjs/commands/unsubscribe.js +2 -17
  180. package/node_modules/imapflow/dist/cjs/download.d.ts +22 -0
  181. package/node_modules/imapflow/dist/cjs/download.js +588 -0
  182. package/node_modules/imapflow/dist/cjs/errors.d.ts +50 -1
  183. package/node_modules/imapflow/dist/cjs/errors.js +53 -1
  184. package/node_modules/imapflow/dist/cjs/handler/imap-compiler.js +1 -1
  185. package/node_modules/imapflow/dist/cjs/handler/imap-stream.d.ts +13 -2
  186. package/node_modules/imapflow/dist/cjs/handler/imap-stream.js +51 -30
  187. package/node_modules/imapflow/dist/cjs/handler/parser-instance.js +2 -2
  188. package/node_modules/imapflow/dist/cjs/handler/token-parser.js +15 -9
  189. package/node_modules/imapflow/dist/cjs/imap-flow.d.ts +30 -84
  190. package/node_modules/imapflow/dist/cjs/imap-flow.js +282 -734
  191. package/node_modules/imapflow/dist/cjs/jp-decoder.js +1 -1
  192. package/node_modules/imapflow/dist/cjs/package-info.d.ts +1 -1
  193. package/node_modules/imapflow/dist/cjs/package-info.js +3 -3
  194. package/node_modules/imapflow/dist/cjs/search-compiler.js +5 -12
  195. package/node_modules/imapflow/dist/cjs/tools.d.ts +52 -11
  196. package/node_modules/imapflow/dist/cjs/tools.js +86 -23
  197. package/node_modules/imapflow/dist/cjs/types.d.ts +30 -16
  198. package/node_modules/imapflow/dist/esm/commands/append.js +13 -13
  199. package/node_modules/imapflow/dist/esm/commands/authenticate.d.ts +3 -8
  200. package/node_modules/imapflow/dist/esm/commands/close.js +2 -1
  201. package/node_modules/imapflow/dist/esm/commands/copy.js +5 -5
  202. package/node_modules/imapflow/dist/esm/commands/create.js +3 -4
  203. package/node_modules/imapflow/dist/esm/commands/delete.js +5 -5
  204. package/node_modules/imapflow/dist/esm/commands/expunge.js +9 -6
  205. package/node_modules/imapflow/dist/esm/commands/fetch.js +13 -11
  206. package/node_modules/imapflow/dist/esm/commands/idle.js +7 -3
  207. package/node_modules/imapflow/dist/esm/commands/list.js +22 -18
  208. package/node_modules/imapflow/dist/esm/commands/move.js +12 -7
  209. package/node_modules/imapflow/dist/esm/commands/namespace.js +2 -2
  210. package/node_modules/imapflow/dist/esm/commands/quota.js +11 -10
  211. package/node_modules/imapflow/dist/esm/commands/rename.js +5 -5
  212. package/node_modules/imapflow/dist/esm/commands/search.js +8 -9
  213. package/node_modules/imapflow/dist/esm/commands/select.js +13 -10
  214. package/node_modules/imapflow/dist/esm/commands/status.js +12 -12
  215. package/node_modules/imapflow/dist/esm/commands/store.js +6 -6
  216. package/node_modules/imapflow/dist/esm/commands/subscribe.js +2 -17
  217. package/node_modules/imapflow/dist/esm/commands/subscription.d.ts +10 -0
  218. package/node_modules/imapflow/dist/esm/commands/subscription.js +26 -0
  219. package/node_modules/imapflow/dist/esm/commands/unsubscribe.js +2 -17
  220. package/node_modules/imapflow/dist/esm/download.d.ts +22 -0
  221. package/node_modules/imapflow/dist/esm/download.js +581 -0
  222. package/node_modules/imapflow/dist/esm/errors.d.ts +50 -1
  223. package/node_modules/imapflow/dist/esm/errors.js +52 -0
  224. package/node_modules/imapflow/dist/esm/handler/imap-compiler.js +1 -1
  225. package/node_modules/imapflow/dist/esm/handler/imap-stream.d.ts +13 -2
  226. package/node_modules/imapflow/dist/esm/handler/imap-stream.js +51 -30
  227. package/node_modules/imapflow/dist/esm/handler/parser-instance.js +2 -2
  228. package/node_modules/imapflow/dist/esm/handler/token-parser.js +15 -9
  229. package/node_modules/imapflow/dist/esm/imap-flow.d.ts +30 -84
  230. package/node_modules/imapflow/dist/esm/imap-flow.js +282 -735
  231. package/node_modules/imapflow/dist/esm/jp-decoder.js +1 -1
  232. package/node_modules/imapflow/dist/esm/package-info.d.ts +1 -1
  233. package/node_modules/imapflow/dist/esm/package-info.js +3 -3
  234. package/node_modules/imapflow/dist/esm/search-compiler.js +5 -12
  235. package/node_modules/imapflow/dist/esm/tools.d.ts +52 -11
  236. package/node_modules/imapflow/dist/esm/tools.js +79 -21
  237. package/node_modules/imapflow/dist/esm/types.d.ts +30 -16
  238. package/node_modules/imapflow/package.json +4 -4
  239. package/package.json +2 -2
  240. package/packages/cli/dist/.tsbuildinfo +1 -1
  241. package/packages/cli/dist/args.d.ts +6 -0
  242. package/packages/cli/dist/args.d.ts.map +1 -1
  243. package/packages/cli/dist/args.js +15 -0
  244. package/packages/cli/dist/args.js.map +1 -1
  245. package/packages/cli/dist/commands.d.ts.map +1 -1
  246. package/packages/cli/dist/commands.js +17 -0
  247. package/packages/cli/dist/commands.js.map +1 -1
  248. package/packages/cli/dist/main.d.ts.map +1 -1
  249. package/packages/cli/dist/main.js +7 -0
  250. package/packages/cli/dist/main.js.map +1 -1
  251. package/packages/core/dist/.tsbuildinfo +1 -1
  252. package/packages/core/dist/host/build.d.ts.map +1 -1
  253. package/packages/core/dist/host/build.js +33 -16
  254. package/packages/core/dist/host/build.js.map +1 -1
  255. package/packages/core/dist/host/types.d.ts +17 -0
  256. package/packages/core/dist/host/types.d.ts.map +1 -1
  257. package/packages/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  258. package/packages/core/dist/pages/__fixtures__/demo.js +1 -0
  259. package/packages/core/dist/pages/__fixtures__/demo.js.map +1 -1
  260. package/packages/core/dist/pages.d.ts +74 -0
  261. package/packages/core/dist/pages.d.ts.map +1 -1
  262. package/packages/core/dist/pages.js +27 -1
  263. package/packages/core/dist/pages.js.map +1 -1
  264. package/packages/core/dist/plugin/index.d.ts +2 -2
  265. package/packages/core/dist/plugin/index.d.ts.map +1 -1
  266. package/packages/core/dist/plugin/version.d.ts +1 -1
  267. package/packages/core/dist/plugin/version.js +1 -1
  268. package/packages/core/dist/provider-accounts.d.ts +8 -0
  269. package/packages/core/dist/provider-accounts.d.ts.map +1 -1
  270. package/packages/core/dist/provider-accounts.js +8 -0
  271. package/packages/core/dist/provider-accounts.js.map +1 -1
  272. package/packages/core/dist/surfaces.d.ts +11 -0
  273. package/packages/core/dist/surfaces.d.ts.map +1 -1
  274. package/packages/core/dist/surfaces.js +4 -0
  275. package/packages/core/dist/surfaces.js.map +1 -1
  276. package/packages/core/migrations/048_surface_chat_voice.sql +13 -0
  277. package/packages/core/migrations/049_surface_chat_voice_form.sql +8 -0
  278. package/packages/gateway/dist/.tsbuildinfo +1 -1
  279. package/packages/gateway/dist/agents-cli.d.ts +2 -0
  280. package/packages/gateway/dist/agents-cli.d.ts.map +1 -1
  281. package/packages/gateway/dist/agents-cli.js +5 -3
  282. package/packages/gateway/dist/agents-cli.js.map +1 -1
  283. package/packages/gateway/dist/chat/session.d.ts.map +1 -1
  284. package/packages/gateway/dist/chat/session.js +2 -2
  285. package/packages/gateway/dist/chat/session.js.map +1 -1
  286. package/packages/gateway/dist/chat/usage.d.ts +16 -0
  287. package/packages/gateway/dist/chat/usage.d.ts.map +1 -1
  288. package/packages/gateway/dist/chat/usage.js +53 -11
  289. package/packages/gateway/dist/chat/usage.js.map +1 -1
  290. package/packages/gateway/dist/index.d.ts +1 -0
  291. package/packages/gateway/dist/index.d.ts.map +1 -1
  292. package/packages/gateway/dist/index.js +1 -0
  293. package/packages/gateway/dist/index.js.map +1 -1
  294. package/packages/gateway/dist/provider-accounts.d.ts +4 -0
  295. package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
  296. package/packages/gateway/dist/provider-accounts.js +3 -1
  297. package/packages/gateway/dist/provider-accounts.js.map +1 -1
  298. package/packages/gateway/dist/speech-cli.d.ts +43 -0
  299. package/packages/gateway/dist/speech-cli.d.ts.map +1 -0
  300. package/packages/gateway/dist/speech-cli.js +105 -0
  301. package/packages/gateway/dist/speech-cli.js.map +1 -0
  302. package/packages/gateway/dist/telegram/api.d.ts +10 -0
  303. package/packages/gateway/dist/telegram/api.d.ts.map +1 -1
  304. package/packages/gateway/dist/telegram/api.js +12 -0
  305. package/packages/gateway/dist/telegram/api.js.map +1 -1
  306. package/packages/gateway/dist/telegram/browser-view.d.ts +2 -1
  307. package/packages/gateway/dist/telegram/browser-view.d.ts.map +1 -1
  308. package/packages/gateway/dist/telegram/browser-view.js +4 -2
  309. package/packages/gateway/dist/telegram/browser-view.js.map +1 -1
  310. package/packages/gateway/dist/telegram/main.d.ts.map +1 -1
  311. package/packages/gateway/dist/telegram/main.js +10 -2
  312. package/packages/gateway/dist/telegram/main.js.map +1 -1
  313. package/packages/gateway/dist/telegram/surface.d.ts +25 -0
  314. package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
  315. package/packages/gateway/dist/telegram/surface.js +212 -10
  316. package/packages/gateway/dist/telegram/surface.js.map +1 -1
  317. package/packages/gateway/dist/telegram/voice.d.ts +112 -0
  318. package/packages/gateway/dist/telegram/voice.d.ts.map +1 -0
  319. package/packages/gateway/dist/telegram/voice.js +220 -0
  320. package/packages/gateway/dist/telegram/voice.js.map +1 -0
  321. package/packages/gateway/dist/web/chat.d.ts +31 -8
  322. package/packages/gateway/dist/web/chat.d.ts.map +1 -1
  323. package/packages/gateway/dist/web/chat.js +3 -2
  324. package/packages/gateway/dist/web/chat.js.map +1 -1
  325. package/packages/gateway/dist/web/onboarding.d.ts +13 -2
  326. package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
  327. package/packages/gateway/dist/web/onboarding.js +24 -3
  328. package/packages/gateway/dist/web/onboarding.js.map +1 -1
  329. package/packages/gateway/dist/web/read.d.ts +15 -12
  330. package/packages/gateway/dist/web/read.d.ts.map +1 -1
  331. package/packages/gateway/dist/web/read.js +9 -10
  332. package/packages/gateway/dist/web/read.js.map +1 -1
  333. package/packages/gateway/dist/web/server.d.ts.map +1 -1
  334. package/packages/gateway/dist/web/server.js +13 -0
  335. package/packages/gateway/dist/web/server.js.map +1 -1
  336. package/packages/gateway/dist/web/speech.d.ts +47 -0
  337. package/packages/gateway/dist/web/speech.d.ts.map +1 -0
  338. package/packages/gateway/dist/web/speech.js +83 -0
  339. package/packages/gateway/dist/web/speech.js.map +1 -0
  340. package/packages/gateway/dist/web/stream.d.ts +0 -24
  341. package/packages/gateway/dist/web/stream.d.ts.map +1 -1
  342. package/packages/gateway/dist/web/stream.js +26 -2
  343. package/packages/gateway/dist/web/stream.js.map +1 -1
  344. package/packages/gateway/dist/web/usage-view.d.ts +15 -0
  345. package/packages/gateway/dist/web/usage-view.d.ts.map +1 -0
  346. package/packages/gateway/dist/web/usage-view.js +20 -0
  347. package/packages/gateway/dist/web/usage-view.js.map +1 -0
  348. package/packages/install/dist/.tsbuildinfo +1 -1
  349. package/packages/runtime/dist/.tsbuildinfo +1 -1
  350. package/packages/runtime/dist/anthropic.d.ts +18 -0
  351. package/packages/runtime/dist/anthropic.d.ts.map +1 -1
  352. package/packages/runtime/dist/anthropic.js +65 -13
  353. package/packages/runtime/dist/anthropic.js.map +1 -1
  354. package/packages/runtime/dist/codex-direct.d.ts.map +1 -1
  355. package/packages/runtime/dist/codex-direct.js +11 -3
  356. package/packages/runtime/dist/codex-direct.js.map +1 -1
  357. package/packages/runtime/dist/context-window.d.ts.map +1 -1
  358. package/packages/runtime/dist/context-window.js +13 -4
  359. package/packages/runtime/dist/context-window.js.map +1 -1
  360. package/packages/runtime/dist/loop.d.ts.map +1 -1
  361. package/packages/runtime/dist/loop.js +6 -0
  362. package/packages/runtime/dist/loop.js.map +1 -1
  363. package/packages/runtime/dist/openai.d.ts +16 -4
  364. package/packages/runtime/dist/openai.d.ts.map +1 -1
  365. package/packages/runtime/dist/openai.js +23 -4
  366. package/packages/runtime/dist/openai.js.map +1 -1
  367. package/packages/runtime/dist/provider-models.d.ts.map +1 -1
  368. package/packages/runtime/dist/provider-models.js +5 -1
  369. package/packages/runtime/dist/provider-models.js.map +1 -1
  370. package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
  371. package/packages/tools/browser/dist/.tsbuildinfo +1 -1
  372. package/packages/tools/browser/dist/computer.d.ts +53 -1
  373. package/packages/tools/browser/dist/computer.d.ts.map +1 -1
  374. package/packages/tools/browser/dist/computer.js +154 -5
  375. package/packages/tools/browser/dist/computer.js.map +1 -1
  376. package/packages/tools/browser/dist/controller.d.ts +20 -3
  377. package/packages/tools/browser/dist/controller.d.ts.map +1 -1
  378. package/packages/tools/browser/dist/controller.js +170 -5
  379. package/packages/tools/browser/dist/controller.js.map +1 -1
  380. package/packages/tools/browser/dist/index.d.ts.map +1 -1
  381. package/packages/tools/browser/dist/index.js +9 -1
  382. package/packages/tools/browser/dist/index.js.map +1 -1
  383. package/packages/tools/browser/dist/service.d.ts +14 -1
  384. package/packages/tools/browser/dist/service.d.ts.map +1 -1
  385. package/packages/tools/browser/dist/service.js +28 -5
  386. package/packages/tools/browser/dist/service.js.map +1 -1
  387. package/packages/tools/browser/dist/types.d.ts +11 -0
  388. package/packages/tools/browser/dist/types.d.ts.map +1 -1
  389. package/packages/tools/browser/dist/types.js +16 -3
  390. package/packages/tools/browser/dist/types.js.map +1 -1
  391. package/packages/tools/browser/package.json +1 -1
  392. package/packages/tools/email/dist/.tsbuildinfo +1 -1
  393. package/packages/tools/host/dist/.tsbuildinfo +1 -1
  394. package/packages/tools/memory/dist/.tsbuildinfo +1 -1
  395. package/packages/tools/web/dist/.tsbuildinfo +1 -1
  396. package/packages/web/dist/assets/index-D5cRFcgm.css +1 -0
  397. package/packages/web/dist/assets/index-GCFB1vBV.js +125 -0
  398. package/packages/web/dist/index.html +2 -2
  399. package/packages/web/dist/assets/index-BRc5auXm.js +0 -123
  400. package/packages/web/dist/assets/index-DwUpotTR.css +0 -1
@@ -1,123 +0,0 @@
1
- var bg=e=>{throw TypeError(e)};var kg=(e,t,n)=>t.has(e)||bg("Cannot "+n);var Mt=(e,t,n)=>(kg(e,t,"read from private field"),n?n.call(e):t.get(e)),Sg=(e,t,n)=>t.has(e)?bg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Pu=(e,t,n,r)=>(kg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function O1(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function D1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yj={exports:{}},Fc={},wj={exports:{}},Ne={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var xl=Symbol.for("react.element"),L1=Symbol.for("react.portal"),F1=Symbol.for("react.fragment"),U1=Symbol.for("react.strict_mode"),z1=Symbol.for("react.profiler"),B1=Symbol.for("react.provider"),W1=Symbol.for("react.context"),H1=Symbol.for("react.forward_ref"),V1=Symbol.for("react.suspense"),K1=Symbol.for("react.memo"),G1=Symbol.for("react.lazy"),Ng=Symbol.iterator;function Y1(e){return e===null||typeof e!="object"?null:(e=Ng&&e[Ng]||e["@@iterator"],typeof e=="function"?e:null)}var bj={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},kj=Object.assign,Sj={};function qi(e,t,n){this.props=e,this.context=t,this.refs=Sj,this.updater=n||bj}qi.prototype.isReactComponent={};qi.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};qi.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Nj(){}Nj.prototype=qi.prototype;function Wh(e,t,n){this.props=e,this.context=t,this.refs=Sj,this.updater=n||bj}var Hh=Wh.prototype=new Nj;Hh.constructor=Wh;kj(Hh,qi.prototype);Hh.isPureReactComponent=!0;var Cg=Array.isArray,Cj=Object.prototype.hasOwnProperty,Vh={current:null},Ej={key:!0,ref:!0,__self:!0,__source:!0};function Aj(e,t,n){var r,i={},o=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(o=""+t.key),t)Cj.call(t,r)&&!Ej.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){for(var c=Array(a),u=0;u<a;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)i[r]===void 0&&(i[r]=a[r]);return{$$typeof:xl,type:e,key:o,ref:l,props:i,_owner:Vh.current}}function q1(e,t){return{$$typeof:xl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Kh(e){return typeof e=="object"&&e!==null&&e.$$typeof===xl}function Q1(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Eg=/\/+/g;function Iu(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Q1(""+e.key):t.toString(36)}function Ea(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var l=!1;if(e===null)l=!0;else switch(o){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case xl:case L1:l=!0}}if(l)return l=e,i=i(l),e=r===""?"."+Iu(l,0):r,Cg(i)?(n="",e!=null&&(n=e.replace(Eg,"$&/")+"/"),Ea(i,t,n,"",function(u){return u})):i!=null&&(Kh(i)&&(i=q1(i,n+(!i.key||l&&l.key===i.key?"":(""+i.key).replace(Eg,"$&/")+"/")+e)),t.push(i)),1;if(l=0,r=r===""?".":r+":",Cg(e))for(var a=0;a<e.length;a++){o=e[a];var c=r+Iu(o,a);l+=Ea(o,t,n,c,i)}else if(c=Y1(e),typeof c=="function")for(e=c.call(e),a=0;!(o=e.next()).done;)o=o.value,c=r+Iu(o,a++),l+=Ea(o,t,n,c,i);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return l}function zl(e,t,n){if(e==null)return e;var r=[],i=0;return Ea(e,r,"","",function(o){return t.call(n,o,i++)}),r}function J1(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Gt={current:null},Aa={transition:null},X1={ReactCurrentDispatcher:Gt,ReactCurrentBatchConfig:Aa,ReactCurrentOwner:Vh};function Tj(){throw Error("act(...) is not supported in production builds of React.")}Ne.Children={map:zl,forEach:function(e,t,n){zl(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return zl(e,function(){t++}),t},toArray:function(e){return zl(e,function(t){return t})||[]},only:function(e){if(!Kh(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ne.Component=qi;Ne.Fragment=F1;Ne.Profiler=z1;Ne.PureComponent=Wh;Ne.StrictMode=U1;Ne.Suspense=V1;Ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X1;Ne.act=Tj;Ne.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=kj({},e.props),i=e.key,o=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,l=Vh.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(c in t)Cj.call(t,c)&&!Ej.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&a!==void 0?a[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){a=Array(c);for(var u=0;u<c;u++)a[u]=arguments[u+2];r.children=a}return{$$typeof:xl,type:e.type,key:i,ref:o,props:r,_owner:l}};Ne.createContext=function(e){return e={$$typeof:W1,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:B1,_context:e},e.Consumer=e};Ne.createElement=Aj;Ne.createFactory=function(e){var t=Aj.bind(null,e);return t.type=e,t};Ne.createRef=function(){return{current:null}};Ne.forwardRef=function(e){return{$$typeof:H1,render:e}};Ne.isValidElement=Kh;Ne.lazy=function(e){return{$$typeof:G1,_payload:{_status:-1,_result:e},_init:J1}};Ne.memo=function(e,t){return{$$typeof:K1,type:e,compare:t===void 0?null:t}};Ne.startTransition=function(e){var t=Aa.transition;Aa.transition={};try{e()}finally{Aa.transition=t}};Ne.unstable_act=Tj;Ne.useCallback=function(e,t){return Gt.current.useCallback(e,t)};Ne.useContext=function(e){return Gt.current.useContext(e)};Ne.useDebugValue=function(){};Ne.useDeferredValue=function(e){return Gt.current.useDeferredValue(e)};Ne.useEffect=function(e,t){return Gt.current.useEffect(e,t)};Ne.useId=function(){return Gt.current.useId()};Ne.useImperativeHandle=function(e,t,n){return Gt.current.useImperativeHandle(e,t,n)};Ne.useInsertionEffect=function(e,t){return Gt.current.useInsertionEffect(e,t)};Ne.useLayoutEffect=function(e,t){return Gt.current.useLayoutEffect(e,t)};Ne.useMemo=function(e,t){return Gt.current.useMemo(e,t)};Ne.useReducer=function(e,t,n){return Gt.current.useReducer(e,t,n)};Ne.useRef=function(e){return Gt.current.useRef(e)};Ne.useState=function(e){return Gt.current.useState(e)};Ne.useSyncExternalStore=function(e,t,n){return Gt.current.useSyncExternalStore(e,t,n)};Ne.useTransition=function(){return Gt.current.useTransition()};Ne.version="18.3.1";wj.exports=Ne;var d=wj.exports;const Z1=D1(d),Qi=O1({__proto__:null,default:Z1},[d]);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var eN=d,tN=Symbol.for("react.element"),nN=Symbol.for("react.fragment"),sN=Object.prototype.hasOwnProperty,rN=eN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,iN={key:!0,ref:!0,__self:!0,__source:!0};function Rj(e,t,n){var r,i={},o=null,l=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(l=t.ref);for(r in t)sN.call(t,r)&&!iN.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:tN,type:e,key:o,ref:l,props:i,_owner:rN.current}}Fc.Fragment=nN;Fc.jsx=Rj;Fc.jsxs=Rj;yj.exports=Fc;var s=yj.exports,Pj={exports:{}},vn={},Ij={exports:{}},Mj={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t(M,B){var $=M.length;M.push(B);e:for(;0<$;){var Z=$-1>>>1,V=M[Z];if(0<i(V,B))M[Z]=B,M[$]=V,$=Z;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var B=M[0],$=M.pop();if($!==B){M[0]=$;e:for(var Z=0,V=M.length,de=V>>>1;Z<de;){var ge=2*(Z+1)-1,je=M[ge],ne=ge+1,xe=M[ne];if(0>i(je,$))ne<V&&0>i(xe,je)?(M[Z]=xe,M[ne]=$,Z=ne):(M[Z]=je,M[ge]=$,Z=ge);else if(ne<V&&0>i(xe,$))M[Z]=xe,M[ne]=$,Z=ne;else break e}}return B}function i(M,B){var $=M.sortIndex-B.sortIndex;return $!==0?$:M.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,a=l.now();e.unstable_now=function(){return l.now()-a}}var c=[],u=[],p=1,f=null,h=3,v=!1,j=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(M){for(var B=n(u);B!==null;){if(B.callback===null)r(u);else if(B.startTime<=M)r(u),B.sortIndex=B.expirationTime,t(c,B);else break;B=n(u)}}function m(M){if(w=!1,y(M),!j)if(n(c)!==null)j=!0,Q(S);else{var B=n(u);B!==null&&Y(m,B.startTime-M)}}function S(M,B){j=!1,w&&(w=!1,x(C),C=-1),v=!0;var $=h;try{for(y(B),f=n(c);f!==null&&(!(f.expirationTime>B)||M&&!O());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,h=f.priorityLevel;var V=Z(f.expirationTime<=B);B=e.unstable_now(),typeof V=="function"?f.callback=V:f===n(c)&&r(c),y(B)}else r(c);f=n(c)}if(f!==null)var de=!0;else{var ge=n(u);ge!==null&&Y(m,ge.startTime-B),de=!1}return de}finally{f=null,h=$,v=!1}}var k=!1,N=null,C=-1,P=5,E=-1;function O(){return!(e.unstable_now()-E<P)}function F(){if(N!==null){var M=e.unstable_now();E=M;var B=!0;try{B=N(!0,M)}finally{B?D():(k=!1,N=null)}}else k=!1}var D;if(typeof g=="function")D=function(){g(F)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,z=T.port2;T.port1.onmessage=F,D=function(){z.postMessage(null)}}else D=function(){b(F,0)};function Q(M){N=M,k||(k=!0,D())}function Y(M,B){C=b(function(){M(e.unstable_now())},B)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){j||v||(j=!0,Q(S))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(M){switch(h){case 1:case 2:case 3:var B=3;break;default:B=h}var $=h;h=B;try{return M()}finally{h=$}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,B){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var $=h;h=M;try{return B()}finally{h=$}},e.unstable_scheduleCallback=function(M,B,$){var Z=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?Z+$:Z):$=Z,M){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=$+V,M={id:p++,callback:B,priorityLevel:M,startTime:$,expirationTime:V,sortIndex:-1},$>Z?(M.sortIndex=$,t(u,M),n(c)===null&&M===n(u)&&(w?(x(C),C=-1):w=!0,Y(m,$-Z))):(M.sortIndex=V,t(c,M),j||v||(j=!0,Q(S))),M},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(M){var B=h;return function(){var $=h;h=B;try{return M.apply(this,arguments)}finally{h=$}}}})(Mj);Ij.exports=Mj;var oN=Ij.exports;/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var lN=d,xn=oN;function J(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var $j=new Set,Wo={};function Br(e,t){Pi(e,t),Pi(e+"Capture",t)}function Pi(e,t){for(Wo[e]=t,e=0;e<t.length;e++)$j.add(t[e])}var Ss=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yd=Object.prototype.hasOwnProperty,aN=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Ag={},Tg={};function cN(e){return Yd.call(Tg,e)?!0:Yd.call(Ag,e)?!1:aN.test(e)?Tg[e]=!0:(Ag[e]=!0,!1)}function uN(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function dN(e,t,n,r){if(t===null||typeof t>"u"||uN(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Yt(e,t,n,r,i,o,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=l}var Rt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Rt[e]=new Yt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Rt[t]=new Yt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Rt[e]=new Yt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Rt[e]=new Yt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Rt[e]=new Yt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Rt[e]=new Yt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Rt[e]=new Yt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Rt[e]=new Yt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Rt[e]=new Yt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Gh=/[\-:]([a-z])/g;function Yh(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Gh,Yh);Rt[t]=new Yt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Gh,Yh);Rt[t]=new Yt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Gh,Yh);Rt[t]=new Yt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Rt[e]=new Yt(e,1,!1,e.toLowerCase(),null,!1,!1)});Rt.xlinkHref=new Yt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Rt[e]=new Yt(e,1,!1,e.toLowerCase(),null,!0,!0)});function qh(e,t,n,r){var i=Rt.hasOwnProperty(t)?Rt[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(dN(t,n,i,r)&&(n=null),r||i===null?cN(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Ms=lN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Bl=Symbol.for("react.element"),ai=Symbol.for("react.portal"),ci=Symbol.for("react.fragment"),Qh=Symbol.for("react.strict_mode"),qd=Symbol.for("react.profiler"),_j=Symbol.for("react.provider"),Oj=Symbol.for("react.context"),Jh=Symbol.for("react.forward_ref"),Qd=Symbol.for("react.suspense"),Jd=Symbol.for("react.suspense_list"),Xh=Symbol.for("react.memo"),zs=Symbol.for("react.lazy"),Dj=Symbol.for("react.offscreen"),Rg=Symbol.iterator;function po(e){return e===null||typeof e!="object"?null:(e=Rg&&e[Rg]||e["@@iterator"],typeof e=="function"?e:null)}var et=Object.assign,Mu;function Eo(e){if(Mu===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Mu=t&&t[1]||""}return`
34
- `+Mu+e}var $u=!1;function _u(e,t){if(!e||$u)return"";$u=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(`
35
- `),o=r.stack.split(`
36
- `),l=i.length-1,a=o.length-1;1<=l&&0<=a&&i[l]!==o[a];)a--;for(;1<=l&&0<=a;l--,a--)if(i[l]!==o[a]){if(l!==1||a!==1)do if(l--,a--,0>a||i[l]!==o[a]){var c=`
37
- `+i[l].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=l&&0<=a);break}}}finally{$u=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Eo(e):""}function fN(e){switch(e.tag){case 5:return Eo(e.type);case 16:return Eo("Lazy");case 13:return Eo("Suspense");case 19:return Eo("SuspenseList");case 0:case 2:case 15:return e=_u(e.type,!1),e;case 11:return e=_u(e.type.render,!1),e;case 1:return e=_u(e.type,!0),e;default:return""}}function Xd(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ci:return"Fragment";case ai:return"Portal";case qd:return"Profiler";case Qh:return"StrictMode";case Qd:return"Suspense";case Jd:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Oj:return(e.displayName||"Context")+".Consumer";case _j:return(e._context.displayName||"Context")+".Provider";case Jh:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Xh:return t=e.displayName||null,t!==null?t:Xd(e.type)||"Memo";case zs:t=e._payload,e=e._init;try{return Xd(e(t))}catch{}}return null}function hN(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Xd(t);case 8:return t===Qh?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ir(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Lj(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function pN(e){var t=Lj(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(l){r=""+l,o.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Wl(e){e._valueTracker||(e._valueTracker=pN(e))}function Fj(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Lj(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Xa(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Zd(e,t){var n=t.checked;return et({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Pg(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ir(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Uj(e,t){t=t.checked,t!=null&&qh(e,"checked",t,!1)}function ef(e,t){Uj(e,t);var n=ir(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?tf(e,t.type,n):t.hasOwnProperty("defaultValue")&&tf(e,t.type,ir(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ig(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function tf(e,t,n){(t!=="number"||Xa(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ao=Array.isArray;function wi(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+ir(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function nf(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(J(91));return et({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Mg(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(J(92));if(Ao(n)){if(1<n.length)throw Error(J(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:ir(n)}}function zj(e,t){var n=ir(t.value),r=ir(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function $g(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Bj(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function sf(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Bj(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Hl,Wj=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Hl=Hl||document.createElement("div"),Hl.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Hl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ho(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Po={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},mN=["Webkit","ms","Moz","O"];Object.keys(Po).forEach(function(e){mN.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Po[t]=Po[e]})});function Hj(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Po.hasOwnProperty(e)&&Po[e]?(""+t).trim():t+"px"}function Vj(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Hj(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var gN=et({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function rf(e,t){if(t){if(gN[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(J(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(J(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(J(61))}if(t.style!=null&&typeof t.style!="object")throw Error(J(62))}}function of(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var lf=null;function Zh(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var af=null,bi=null,ki=null;function _g(e){if(e=yl(e)){if(typeof af!="function")throw Error(J(280));var t=e.stateNode;t&&(t=Hc(t),af(e.stateNode,e.type,t))}}function Kj(e){bi?ki?ki.push(e):ki=[e]:bi=e}function Gj(){if(bi){var e=bi,t=ki;if(ki=bi=null,_g(e),t)for(e=0;e<t.length;e++)_g(t[e])}}function Yj(e,t){return e(t)}function qj(){}var Ou=!1;function Qj(e,t,n){if(Ou)return e(t,n);Ou=!0;try{return Yj(e,t,n)}finally{Ou=!1,(bi!==null||ki!==null)&&(qj(),Gj())}}function Vo(e,t){var n=e.stateNode;if(n===null)return null;var r=Hc(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(J(231,t,typeof n));return n}var cf=!1;if(Ss)try{var mo={};Object.defineProperty(mo,"passive",{get:function(){cf=!0}}),window.addEventListener("test",mo,mo),window.removeEventListener("test",mo,mo)}catch{cf=!1}function xN(e,t,n,r,i,o,l,a,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var Io=!1,Za=null,ec=!1,uf=null,vN={onError:function(e){Io=!0,Za=e}};function jN(e,t,n,r,i,o,l,a,c){Io=!1,Za=null,xN.apply(vN,arguments)}function yN(e,t,n,r,i,o,l,a,c){if(jN.apply(this,arguments),Io){if(Io){var u=Za;Io=!1,Za=null}else throw Error(J(198));ec||(ec=!0,uf=u)}}function Wr(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Jj(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Og(e){if(Wr(e)!==e)throw Error(J(188))}function wN(e){var t=e.alternate;if(!t){if(t=Wr(e),t===null)throw Error(J(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return Og(i),e;if(o===r)return Og(i),t;o=o.sibling}throw Error(J(188))}if(n.return!==r.return)n=i,r=o;else{for(var l=!1,a=i.child;a;){if(a===n){l=!0,n=i,r=o;break}if(a===r){l=!0,r=i,n=o;break}a=a.sibling}if(!l){for(a=o.child;a;){if(a===n){l=!0,n=o,r=i;break}if(a===r){l=!0,r=o,n=i;break}a=a.sibling}if(!l)throw Error(J(189))}}if(n.alternate!==r)throw Error(J(190))}if(n.tag!==3)throw Error(J(188));return n.stateNode.current===n?e:t}function Xj(e){return e=wN(e),e!==null?Zj(e):null}function Zj(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Zj(e);if(t!==null)return t;e=e.sibling}return null}var ey=xn.unstable_scheduleCallback,Dg=xn.unstable_cancelCallback,bN=xn.unstable_shouldYield,kN=xn.unstable_requestPaint,ot=xn.unstable_now,SN=xn.unstable_getCurrentPriorityLevel,ep=xn.unstable_ImmediatePriority,ty=xn.unstable_UserBlockingPriority,tc=xn.unstable_NormalPriority,NN=xn.unstable_LowPriority,ny=xn.unstable_IdlePriority,Uc=null,ts=null;function CN(e){if(ts&&typeof ts.onCommitFiberRoot=="function")try{ts.onCommitFiberRoot(Uc,e,void 0,(e.current.flags&128)===128)}catch{}}var Fn=Math.clz32?Math.clz32:TN,EN=Math.log,AN=Math.LN2;function TN(e){return e>>>=0,e===0?32:31-(EN(e)/AN|0)|0}var Vl=64,Kl=4194304;function To(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function nc(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,l=n&268435455;if(l!==0){var a=l&~i;a!==0?r=To(a):(o&=l,o!==0&&(r=To(o)))}else l=n&~i,l!==0?r=To(l):o!==0&&(r=To(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Fn(t),i=1<<n,r|=e[n],t&=~i;return r}function RN(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function PN(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes;0<o;){var l=31-Fn(o),a=1<<l,c=i[l];c===-1?(!(a&n)||a&r)&&(i[l]=RN(a,t)):c<=t&&(e.expiredLanes|=a),o&=~a}}function df(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function sy(){var e=Vl;return Vl<<=1,!(Vl&4194240)&&(Vl=64),e}function Du(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Fn(t),e[t]=n}function IN(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-Fn(n),o=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~o}}function tp(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Fn(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var Le=0;function ry(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var iy,np,oy,ly,ay,ff=!1,Gl=[],Ys=null,qs=null,Qs=null,Ko=new Map,Go=new Map,Ws=[],MN="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Lg(e,t){switch(e){case"focusin":case"focusout":Ys=null;break;case"dragenter":case"dragleave":qs=null;break;case"mouseover":case"mouseout":Qs=null;break;case"pointerover":case"pointerout":Ko.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Go.delete(t.pointerId)}}function go(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=yl(t),t!==null&&np(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function $N(e,t,n,r,i){switch(t){case"focusin":return Ys=go(Ys,e,t,n,r,i),!0;case"dragenter":return qs=go(qs,e,t,n,r,i),!0;case"mouseover":return Qs=go(Qs,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return Ko.set(o,go(Ko.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,Go.set(o,go(Go.get(o)||null,e,t,n,r,i)),!0}return!1}function cy(e){var t=Nr(e.target);if(t!==null){var n=Wr(t);if(n!==null){if(t=n.tag,t===13){if(t=Jj(n),t!==null){e.blockedOn=t,ay(e.priority,function(){oy(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ta(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=hf(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);lf=r,n.target.dispatchEvent(r),lf=null}else return t=yl(n),t!==null&&np(t),e.blockedOn=n,!1;t.shift()}return!0}function Fg(e,t,n){Ta(e)&&n.delete(t)}function _N(){ff=!1,Ys!==null&&Ta(Ys)&&(Ys=null),qs!==null&&Ta(qs)&&(qs=null),Qs!==null&&Ta(Qs)&&(Qs=null),Ko.forEach(Fg),Go.forEach(Fg)}function xo(e,t){e.blockedOn===t&&(e.blockedOn=null,ff||(ff=!0,xn.unstable_scheduleCallback(xn.unstable_NormalPriority,_N)))}function Yo(e){function t(i){return xo(i,e)}if(0<Gl.length){xo(Gl[0],e);for(var n=1;n<Gl.length;n++){var r=Gl[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Ys!==null&&xo(Ys,e),qs!==null&&xo(qs,e),Qs!==null&&xo(Qs,e),Ko.forEach(t),Go.forEach(t),n=0;n<Ws.length;n++)r=Ws[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ws.length&&(n=Ws[0],n.blockedOn===null);)cy(n),n.blockedOn===null&&Ws.shift()}var Si=Ms.ReactCurrentBatchConfig,sc=!0;function ON(e,t,n,r){var i=Le,o=Si.transition;Si.transition=null;try{Le=1,sp(e,t,n,r)}finally{Le=i,Si.transition=o}}function DN(e,t,n,r){var i=Le,o=Si.transition;Si.transition=null;try{Le=4,sp(e,t,n,r)}finally{Le=i,Si.transition=o}}function sp(e,t,n,r){if(sc){var i=hf(e,t,n,r);if(i===null)Gu(e,t,r,rc,n),Lg(e,r);else if($N(i,e,t,n,r))r.stopPropagation();else if(Lg(e,r),t&4&&-1<MN.indexOf(e)){for(;i!==null;){var o=yl(i);if(o!==null&&iy(o),o=hf(e,t,n,r),o===null&&Gu(e,t,r,rc,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else Gu(e,t,r,null,n)}}var rc=null;function hf(e,t,n,r){if(rc=null,e=Zh(r),e=Nr(e),e!==null)if(t=Wr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Jj(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return rc=e,null}function uy(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(SN()){case ep:return 1;case ty:return 4;case tc:case NN:return 16;case ny:return 536870912;default:return 16}default:return 16}}var Vs=null,rp=null,Ra=null;function dy(){if(Ra)return Ra;var e,t=rp,n=t.length,r,i="value"in Vs?Vs.value:Vs.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var l=n-e;for(r=1;r<=l&&t[n-r]===i[o-r];r++);return Ra=i.slice(e,1<r?1-r:void 0)}function Pa(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Yl(){return!0}function Ug(){return!1}function jn(e){function t(n,r,i,o,l){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=l,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Yl:Ug,this.isPropagationStopped=Ug,this}return et(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Yl)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Yl)},persist:function(){},isPersistent:Yl}),t}var Ji={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ip=jn(Ji),jl=et({},Ji,{view:0,detail:0}),LN=jn(jl),Lu,Fu,vo,zc=et({},jl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:op,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==vo&&(vo&&e.type==="mousemove"?(Lu=e.screenX-vo.screenX,Fu=e.screenY-vo.screenY):Fu=Lu=0,vo=e),Lu)},movementY:function(e){return"movementY"in e?e.movementY:Fu}}),zg=jn(zc),FN=et({},zc,{dataTransfer:0}),UN=jn(FN),zN=et({},jl,{relatedTarget:0}),Uu=jn(zN),BN=et({},Ji,{animationName:0,elapsedTime:0,pseudoElement:0}),WN=jn(BN),HN=et({},Ji,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),VN=jn(HN),KN=et({},Ji,{data:0}),Bg=jn(KN),GN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},YN={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},qN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function QN(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=qN[e])?!!t[e]:!1}function op(){return QN}var JN=et({},jl,{key:function(e){if(e.key){var t=GN[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Pa(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?YN[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:op,charCode:function(e){return e.type==="keypress"?Pa(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Pa(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),XN=jn(JN),ZN=et({},zc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wg=jn(ZN),eC=et({},jl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:op}),tC=jn(eC),nC=et({},Ji,{propertyName:0,elapsedTime:0,pseudoElement:0}),sC=jn(nC),rC=et({},zc,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),iC=jn(rC),oC=[9,13,27,32],lp=Ss&&"CompositionEvent"in window,Mo=null;Ss&&"documentMode"in document&&(Mo=document.documentMode);var lC=Ss&&"TextEvent"in window&&!Mo,fy=Ss&&(!lp||Mo&&8<Mo&&11>=Mo),Hg=" ",Vg=!1;function hy(e,t){switch(e){case"keyup":return oC.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function py(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ui=!1;function aC(e,t){switch(e){case"compositionend":return py(t);case"keypress":return t.which!==32?null:(Vg=!0,Hg);case"textInput":return e=t.data,e===Hg&&Vg?null:e;default:return null}}function cC(e,t){if(ui)return e==="compositionend"||!lp&&hy(e,t)?(e=dy(),Ra=rp=Vs=null,ui=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return fy&&t.locale!=="ko"?null:t.data;default:return null}}var uC={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Kg(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!uC[e.type]:t==="textarea"}function my(e,t,n,r){Kj(r),t=ic(t,"onChange"),0<t.length&&(n=new ip("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var $o=null,qo=null;function dC(e){Cy(e,0)}function Bc(e){var t=hi(e);if(Fj(t))return e}function fC(e,t){if(e==="change")return t}var gy=!1;if(Ss){var zu;if(Ss){var Bu="oninput"in document;if(!Bu){var Gg=document.createElement("div");Gg.setAttribute("oninput","return;"),Bu=typeof Gg.oninput=="function"}zu=Bu}else zu=!1;gy=zu&&(!document.documentMode||9<document.documentMode)}function Yg(){$o&&($o.detachEvent("onpropertychange",xy),qo=$o=null)}function xy(e){if(e.propertyName==="value"&&Bc(qo)){var t=[];my(t,qo,e,Zh(e)),Qj(dC,t)}}function hC(e,t,n){e==="focusin"?(Yg(),$o=t,qo=n,$o.attachEvent("onpropertychange",xy)):e==="focusout"&&Yg()}function pC(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Bc(qo)}function mC(e,t){if(e==="click")return Bc(t)}function gC(e,t){if(e==="input"||e==="change")return Bc(t)}function xC(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zn=typeof Object.is=="function"?Object.is:xC;function Qo(e,t){if(zn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Yd.call(t,i)||!zn(e[i],t[i]))return!1}return!0}function qg(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Qg(e,t){var n=qg(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=qg(n)}}function vy(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?vy(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jy(){for(var e=window,t=Xa();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Xa(e.document)}return t}function ap(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function vC(e){var t=jy(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&vy(n.ownerDocument.documentElement,n)){if(r!==null&&ap(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=Qg(n,o);var l=Qg(n,r);i&&l&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var jC=Ss&&"documentMode"in document&&11>=document.documentMode,di=null,pf=null,_o=null,mf=!1;function Jg(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;mf||di==null||di!==Xa(r)||(r=di,"selectionStart"in r&&ap(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_o&&Qo(_o,r)||(_o=r,r=ic(pf,"onSelect"),0<r.length&&(t=new ip("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=di)))}function ql(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var fi={animationend:ql("Animation","AnimationEnd"),animationiteration:ql("Animation","AnimationIteration"),animationstart:ql("Animation","AnimationStart"),transitionend:ql("Transition","TransitionEnd")},Wu={},yy={};Ss&&(yy=document.createElement("div").style,"AnimationEvent"in window||(delete fi.animationend.animation,delete fi.animationiteration.animation,delete fi.animationstart.animation),"TransitionEvent"in window||delete fi.transitionend.transition);function Wc(e){if(Wu[e])return Wu[e];if(!fi[e])return e;var t=fi[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in yy)return Wu[e]=t[n];return e}var wy=Wc("animationend"),by=Wc("animationiteration"),ky=Wc("animationstart"),Sy=Wc("transitionend"),Ny=new Map,Xg="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function fr(e,t){Ny.set(e,t),Br(t,[e])}for(var Hu=0;Hu<Xg.length;Hu++){var Vu=Xg[Hu],yC=Vu.toLowerCase(),wC=Vu[0].toUpperCase()+Vu.slice(1);fr(yC,"on"+wC)}fr(wy,"onAnimationEnd");fr(by,"onAnimationIteration");fr(ky,"onAnimationStart");fr("dblclick","onDoubleClick");fr("focusin","onFocus");fr("focusout","onBlur");fr(Sy,"onTransitionEnd");Pi("onMouseEnter",["mouseout","mouseover"]);Pi("onMouseLeave",["mouseout","mouseover"]);Pi("onPointerEnter",["pointerout","pointerover"]);Pi("onPointerLeave",["pointerout","pointerover"]);Br("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Br("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Br("onBeforeInput",["compositionend","keypress","textInput","paste"]);Br("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Br("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Br("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ro="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),bC=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ro));function Zg(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,yN(r,t,void 0,e),e.currentTarget=null}function Cy(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var l=r.length-1;0<=l;l--){var a=r[l],c=a.instance,u=a.currentTarget;if(a=a.listener,c!==o&&i.isPropagationStopped())break e;Zg(i,a,u),o=c}else for(l=0;l<r.length;l++){if(a=r[l],c=a.instance,u=a.currentTarget,a=a.listener,c!==o&&i.isPropagationStopped())break e;Zg(i,a,u),o=c}}}if(ec)throw e=uf,ec=!1,uf=null,e}function Ve(e,t){var n=t[yf];n===void 0&&(n=t[yf]=new Set);var r=e+"__bubble";n.has(r)||(Ey(t,e,2,!1),n.add(r))}function Ku(e,t,n){var r=0;t&&(r|=4),Ey(n,e,r,t)}var Ql="_reactListening"+Math.random().toString(36).slice(2);function Jo(e){if(!e[Ql]){e[Ql]=!0,$j.forEach(function(n){n!=="selectionchange"&&(bC.has(n)||Ku(n,!1,e),Ku(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ql]||(t[Ql]=!0,Ku("selectionchange",!1,t))}}function Ey(e,t,n,r){switch(uy(t)){case 1:var i=ON;break;case 4:i=DN;break;default:i=sp}n=i.bind(null,t,n,e),i=void 0,!cf||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Gu(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var l=r.tag;if(l===3||l===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(l===4)for(l=r.return;l!==null;){var c=l.tag;if((c===3||c===4)&&(c=l.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;l=l.return}for(;a!==null;){if(l=Nr(a),l===null)return;if(c=l.tag,c===5||c===6){r=o=l;continue e}a=a.parentNode}}r=r.return}Qj(function(){var u=o,p=Zh(n),f=[];e:{var h=Ny.get(e);if(h!==void 0){var v=ip,j=e;switch(e){case"keypress":if(Pa(n)===0)break e;case"keydown":case"keyup":v=XN;break;case"focusin":j="focus",v=Uu;break;case"focusout":j="blur",v=Uu;break;case"beforeblur":case"afterblur":v=Uu;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":v=zg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":v=UN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":v=tC;break;case wy:case by:case ky:v=WN;break;case Sy:v=sC;break;case"scroll":v=LN;break;case"wheel":v=iC;break;case"copy":case"cut":case"paste":v=VN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":v=Wg}var w=(t&4)!==0,b=!w&&e==="scroll",x=w?h!==null?h+"Capture":null:h;w=[];for(var g=u,y;g!==null;){y=g;var m=y.stateNode;if(y.tag===5&&m!==null&&(y=m,x!==null&&(m=Vo(g,x),m!=null&&w.push(Xo(g,m,y)))),b)break;g=g.return}0<w.length&&(h=new v(h,j,null,n,p),f.push({event:h,listeners:w}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",v=e==="mouseout"||e==="pointerout",h&&n!==lf&&(j=n.relatedTarget||n.fromElement)&&(Nr(j)||j[Ns]))break e;if((v||h)&&(h=p.window===p?p:(h=p.ownerDocument)?h.defaultView||h.parentWindow:window,v?(j=n.relatedTarget||n.toElement,v=u,j=j?Nr(j):null,j!==null&&(b=Wr(j),j!==b||j.tag!==5&&j.tag!==6)&&(j=null)):(v=null,j=u),v!==j)){if(w=zg,m="onMouseLeave",x="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(w=Wg,m="onPointerLeave",x="onPointerEnter",g="pointer"),b=v==null?h:hi(v),y=j==null?h:hi(j),h=new w(m,g+"leave",v,n,p),h.target=b,h.relatedTarget=y,m=null,Nr(p)===u&&(w=new w(x,g+"enter",j,n,p),w.target=y,w.relatedTarget=b,m=w),b=m,v&&j)t:{for(w=v,x=j,g=0,y=w;y;y=ei(y))g++;for(y=0,m=x;m;m=ei(m))y++;for(;0<g-y;)w=ei(w),g--;for(;0<y-g;)x=ei(x),y--;for(;g--;){if(w===x||x!==null&&w===x.alternate)break t;w=ei(w),x=ei(x)}w=null}else w=null;v!==null&&ex(f,h,v,w,!1),j!==null&&b!==null&&ex(f,b,j,w,!0)}}e:{if(h=u?hi(u):window,v=h.nodeName&&h.nodeName.toLowerCase(),v==="select"||v==="input"&&h.type==="file")var S=fC;else if(Kg(h))if(gy)S=gC;else{S=pC;var k=hC}else(v=h.nodeName)&&v.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(S=mC);if(S&&(S=S(e,u))){my(f,S,n,p);break e}k&&k(e,h,u),e==="focusout"&&(k=h._wrapperState)&&k.controlled&&h.type==="number"&&tf(h,"number",h.value)}switch(k=u?hi(u):window,e){case"focusin":(Kg(k)||k.contentEditable==="true")&&(di=k,pf=u,_o=null);break;case"focusout":_o=pf=di=null;break;case"mousedown":mf=!0;break;case"contextmenu":case"mouseup":case"dragend":mf=!1,Jg(f,n,p);break;case"selectionchange":if(jC)break;case"keydown":case"keyup":Jg(f,n,p)}var N;if(lp)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else ui?hy(e,n)&&(C="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(fy&&n.locale!=="ko"&&(ui||C!=="onCompositionStart"?C==="onCompositionEnd"&&ui&&(N=dy()):(Vs=p,rp="value"in Vs?Vs.value:Vs.textContent,ui=!0)),k=ic(u,C),0<k.length&&(C=new Bg(C,e,null,n,p),f.push({event:C,listeners:k}),N?C.data=N:(N=py(n),N!==null&&(C.data=N)))),(N=lC?aC(e,n):cC(e,n))&&(u=ic(u,"onBeforeInput"),0<u.length&&(p=new Bg("onBeforeInput","beforeinput",null,n,p),f.push({event:p,listeners:u}),p.data=N))}Cy(f,t)})}function Xo(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ic(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=Vo(e,n),o!=null&&r.unshift(Xo(e,o,i)),o=Vo(e,t),o!=null&&r.push(Xo(e,o,i))),e=e.return}return r}function ei(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function ex(e,t,n,r,i){for(var o=t._reactName,l=[];n!==null&&n!==r;){var a=n,c=a.alternate,u=a.stateNode;if(c!==null&&c===r)break;a.tag===5&&u!==null&&(a=u,i?(c=Vo(n,o),c!=null&&l.unshift(Xo(n,c,a))):i||(c=Vo(n,o),c!=null&&l.push(Xo(n,c,a)))),n=n.return}l.length!==0&&e.push({event:t,listeners:l})}var kC=/\r\n?/g,SC=/\u0000|\uFFFD/g;function tx(e){return(typeof e=="string"?e:""+e).replace(kC,`
38
- `).replace(SC,"")}function Jl(e,t,n){if(t=tx(t),tx(e)!==t&&n)throw Error(J(425))}function oc(){}var gf=null,xf=null;function vf(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var jf=typeof setTimeout=="function"?setTimeout:void 0,NC=typeof clearTimeout=="function"?clearTimeout:void 0,nx=typeof Promise=="function"?Promise:void 0,CC=typeof queueMicrotask=="function"?queueMicrotask:typeof nx<"u"?function(e){return nx.resolve(null).then(e).catch(EC)}:jf;function EC(e){setTimeout(function(){throw e})}function Yu(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),Yo(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);Yo(t)}function Js(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function sx(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Xi=Math.random().toString(36).slice(2),Jn="__reactFiber$"+Xi,Zo="__reactProps$"+Xi,Ns="__reactContainer$"+Xi,yf="__reactEvents$"+Xi,AC="__reactListeners$"+Xi,TC="__reactHandles$"+Xi;function Nr(e){var t=e[Jn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ns]||n[Jn]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=sx(e);e!==null;){if(n=e[Jn])return n;e=sx(e)}return t}e=n,n=e.parentNode}return null}function yl(e){return e=e[Jn]||e[Ns],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function hi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(J(33))}function Hc(e){return e[Zo]||null}var wf=[],pi=-1;function hr(e){return{current:e}}function Ke(e){0>pi||(e.current=wf[pi],wf[pi]=null,pi--)}function We(e,t){pi++,wf[pi]=e.current,e.current=t}var or={},Ut=hr(or),en=hr(!1),Ir=or;function Ii(e,t){var n=e.type.contextTypes;if(!n)return or;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function tn(e){return e=e.childContextTypes,e!=null}function lc(){Ke(en),Ke(Ut)}function rx(e,t,n){if(Ut.current!==or)throw Error(J(168));We(Ut,t),We(en,n)}function Ay(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(J(108,hN(e)||"Unknown",i));return et({},n,r)}function ac(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||or,Ir=Ut.current,We(Ut,e),We(en,en.current),!0}function ix(e,t,n){var r=e.stateNode;if(!r)throw Error(J(169));n?(e=Ay(e,t,Ir),r.__reactInternalMemoizedMergedChildContext=e,Ke(en),Ke(Ut),We(Ut,e)):Ke(en),We(en,n)}var xs=null,Vc=!1,qu=!1;function Ty(e){xs===null?xs=[e]:xs.push(e)}function RC(e){Vc=!0,Ty(e)}function pr(){if(!qu&&xs!==null){qu=!0;var e=0,t=Le;try{var n=xs;for(Le=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}xs=null,Vc=!1}catch(i){throw xs!==null&&(xs=xs.slice(e+1)),ey(ep,pr),i}finally{Le=t,qu=!1}}return null}var mi=[],gi=0,cc=null,uc=0,bn=[],kn=0,Mr=null,vs=1,js="";function kr(e,t){mi[gi++]=uc,mi[gi++]=cc,cc=e,uc=t}function Ry(e,t,n){bn[kn++]=vs,bn[kn++]=js,bn[kn++]=Mr,Mr=e;var r=vs;e=js;var i=32-Fn(r)-1;r&=~(1<<i),n+=1;var o=32-Fn(t)+i;if(30<o){var l=i-i%5;o=(r&(1<<l)-1).toString(32),r>>=l,i-=l,vs=1<<32-Fn(t)+i|n<<i|r,js=o+e}else vs=1<<o|n<<i|r,js=e}function cp(e){e.return!==null&&(kr(e,1),Ry(e,1,0))}function up(e){for(;e===cc;)cc=mi[--gi],mi[gi]=null,uc=mi[--gi],mi[gi]=null;for(;e===Mr;)Mr=bn[--kn],bn[kn]=null,js=bn[--kn],bn[kn]=null,vs=bn[--kn],bn[kn]=null}var gn=null,pn=null,Ye=!1,Dn=null;function Py(e,t){var n=Nn(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function ox(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,gn=e,pn=Js(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,gn=e,pn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Mr!==null?{id:vs,overflow:js}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Nn(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,gn=e,pn=null,!0):!1;default:return!1}}function bf(e){return(e.mode&1)!==0&&(e.flags&128)===0}function kf(e){if(Ye){var t=pn;if(t){var n=t;if(!ox(e,t)){if(bf(e))throw Error(J(418));t=Js(n.nextSibling);var r=gn;t&&ox(e,t)?Py(r,n):(e.flags=e.flags&-4097|2,Ye=!1,gn=e)}}else{if(bf(e))throw Error(J(418));e.flags=e.flags&-4097|2,Ye=!1,gn=e}}}function lx(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;gn=e}function Xl(e){if(e!==gn)return!1;if(!Ye)return lx(e),Ye=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!vf(e.type,e.memoizedProps)),t&&(t=pn)){if(bf(e))throw Iy(),Error(J(418));for(;t;)Py(e,t),t=Js(t.nextSibling)}if(lx(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(J(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){pn=Js(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}pn=null}}else pn=gn?Js(e.stateNode.nextSibling):null;return!0}function Iy(){for(var e=pn;e;)e=Js(e.nextSibling)}function Mi(){pn=gn=null,Ye=!1}function dp(e){Dn===null?Dn=[e]:Dn.push(e)}var PC=Ms.ReactCurrentBatchConfig;function jo(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(J(309));var r=n.stateNode}if(!r)throw Error(J(147,e));var i=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(l){var a=i.refs;l===null?delete a[o]:a[o]=l},t._stringRef=o,t)}if(typeof e!="string")throw Error(J(284));if(!n._owner)throw Error(J(290,e))}return e}function Zl(e,t){throw e=Object.prototype.toString.call(t),Error(J(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ax(e){var t=e._init;return t(e._payload)}function My(e){function t(x,g){if(e){var y=x.deletions;y===null?(x.deletions=[g],x.flags|=16):y.push(g)}}function n(x,g){if(!e)return null;for(;g!==null;)t(x,g),g=g.sibling;return null}function r(x,g){for(x=new Map;g!==null;)g.key!==null?x.set(g.key,g):x.set(g.index,g),g=g.sibling;return x}function i(x,g){return x=tr(x,g),x.index=0,x.sibling=null,x}function o(x,g,y){return x.index=y,e?(y=x.alternate,y!==null?(y=y.index,y<g?(x.flags|=2,g):y):(x.flags|=2,g)):(x.flags|=1048576,g)}function l(x){return e&&x.alternate===null&&(x.flags|=2),x}function a(x,g,y,m){return g===null||g.tag!==6?(g=nd(y,x.mode,m),g.return=x,g):(g=i(g,y),g.return=x,g)}function c(x,g,y,m){var S=y.type;return S===ci?p(x,g,y.props.children,m,y.key):g!==null&&(g.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===zs&&ax(S)===g.type)?(m=i(g,y.props),m.ref=jo(x,g,y),m.return=x,m):(m=La(y.type,y.key,y.props,null,x.mode,m),m.ref=jo(x,g,y),m.return=x,m)}function u(x,g,y,m){return g===null||g.tag!==4||g.stateNode.containerInfo!==y.containerInfo||g.stateNode.implementation!==y.implementation?(g=sd(y,x.mode,m),g.return=x,g):(g=i(g,y.children||[]),g.return=x,g)}function p(x,g,y,m,S){return g===null||g.tag!==7?(g=Tr(y,x.mode,m,S),g.return=x,g):(g=i(g,y),g.return=x,g)}function f(x,g,y){if(typeof g=="string"&&g!==""||typeof g=="number")return g=nd(""+g,x.mode,y),g.return=x,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Bl:return y=La(g.type,g.key,g.props,null,x.mode,y),y.ref=jo(x,null,g),y.return=x,y;case ai:return g=sd(g,x.mode,y),g.return=x,g;case zs:var m=g._init;return f(x,m(g._payload),y)}if(Ao(g)||po(g))return g=Tr(g,x.mode,y,null),g.return=x,g;Zl(x,g)}return null}function h(x,g,y,m){var S=g!==null?g.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return S!==null?null:a(x,g,""+y,m);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Bl:return y.key===S?c(x,g,y,m):null;case ai:return y.key===S?u(x,g,y,m):null;case zs:return S=y._init,h(x,g,S(y._payload),m)}if(Ao(y)||po(y))return S!==null?null:p(x,g,y,m,null);Zl(x,y)}return null}function v(x,g,y,m,S){if(typeof m=="string"&&m!==""||typeof m=="number")return x=x.get(y)||null,a(g,x,""+m,S);if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Bl:return x=x.get(m.key===null?y:m.key)||null,c(g,x,m,S);case ai:return x=x.get(m.key===null?y:m.key)||null,u(g,x,m,S);case zs:var k=m._init;return v(x,g,y,k(m._payload),S)}if(Ao(m)||po(m))return x=x.get(y)||null,p(g,x,m,S,null);Zl(g,m)}return null}function j(x,g,y,m){for(var S=null,k=null,N=g,C=g=0,P=null;N!==null&&C<y.length;C++){N.index>C?(P=N,N=null):P=N.sibling;var E=h(x,N,y[C],m);if(E===null){N===null&&(N=P);break}e&&N&&E.alternate===null&&t(x,N),g=o(E,g,C),k===null?S=E:k.sibling=E,k=E,N=P}if(C===y.length)return n(x,N),Ye&&kr(x,C),S;if(N===null){for(;C<y.length;C++)N=f(x,y[C],m),N!==null&&(g=o(N,g,C),k===null?S=N:k.sibling=N,k=N);return Ye&&kr(x,C),S}for(N=r(x,N);C<y.length;C++)P=v(N,x,C,y[C],m),P!==null&&(e&&P.alternate!==null&&N.delete(P.key===null?C:P.key),g=o(P,g,C),k===null?S=P:k.sibling=P,k=P);return e&&N.forEach(function(O){return t(x,O)}),Ye&&kr(x,C),S}function w(x,g,y,m){var S=po(y);if(typeof S!="function")throw Error(J(150));if(y=S.call(y),y==null)throw Error(J(151));for(var k=S=null,N=g,C=g=0,P=null,E=y.next();N!==null&&!E.done;C++,E=y.next()){N.index>C?(P=N,N=null):P=N.sibling;var O=h(x,N,E.value,m);if(O===null){N===null&&(N=P);break}e&&N&&O.alternate===null&&t(x,N),g=o(O,g,C),k===null?S=O:k.sibling=O,k=O,N=P}if(E.done)return n(x,N),Ye&&kr(x,C),S;if(N===null){for(;!E.done;C++,E=y.next())E=f(x,E.value,m),E!==null&&(g=o(E,g,C),k===null?S=E:k.sibling=E,k=E);return Ye&&kr(x,C),S}for(N=r(x,N);!E.done;C++,E=y.next())E=v(N,x,C,E.value,m),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?C:E.key),g=o(E,g,C),k===null?S=E:k.sibling=E,k=E);return e&&N.forEach(function(F){return t(x,F)}),Ye&&kr(x,C),S}function b(x,g,y,m){if(typeof y=="object"&&y!==null&&y.type===ci&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Bl:e:{for(var S=y.key,k=g;k!==null;){if(k.key===S){if(S=y.type,S===ci){if(k.tag===7){n(x,k.sibling),g=i(k,y.props.children),g.return=x,x=g;break e}}else if(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===zs&&ax(S)===k.type){n(x,k.sibling),g=i(k,y.props),g.ref=jo(x,k,y),g.return=x,x=g;break e}n(x,k);break}else t(x,k);k=k.sibling}y.type===ci?(g=Tr(y.props.children,x.mode,m,y.key),g.return=x,x=g):(m=La(y.type,y.key,y.props,null,x.mode,m),m.ref=jo(x,g,y),m.return=x,x=m)}return l(x);case ai:e:{for(k=y.key;g!==null;){if(g.key===k)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(x,g.sibling),g=i(g,y.children||[]),g.return=x,x=g;break e}else{n(x,g);break}else t(x,g);g=g.sibling}g=sd(y,x.mode,m),g.return=x,x=g}return l(x);case zs:return k=y._init,b(x,g,k(y._payload),m)}if(Ao(y))return j(x,g,y,m);if(po(y))return w(x,g,y,m);Zl(x,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(x,g.sibling),g=i(g,y),g.return=x,x=g):(n(x,g),g=nd(y,x.mode,m),g.return=x,x=g),l(x)):n(x,g)}return b}var $i=My(!0),$y=My(!1),dc=hr(null),fc=null,xi=null,fp=null;function hp(){fp=xi=fc=null}function pp(e){var t=dc.current;Ke(dc),e._currentValue=t}function Sf(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Ni(e,t){fc=e,fp=xi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Xt=!0),e.firstContext=null)}function En(e){var t=e._currentValue;if(fp!==e)if(e={context:e,memoizedValue:t,next:null},xi===null){if(fc===null)throw Error(J(308));xi=e,fc.dependencies={lanes:0,firstContext:e}}else xi=xi.next=e;return t}var Cr=null;function mp(e){Cr===null?Cr=[e]:Cr.push(e)}function _y(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,mp(t)):(n.next=i.next,i.next=n),t.interleaved=n,Cs(e,r)}function Cs(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Bs=!1;function gp(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Oy(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ys(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xs(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Pe&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Cs(e,n)}return i=r.interleaved,i===null?(t.next=t,mp(r)):(t.next=i.next,i.next=t),r.interleaved=t,Cs(e,n)}function Ia(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,tp(e,n)}}function cx(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=l:o=o.next=l,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function hc(e,t,n,r){var i=e.updateQueue;Bs=!1;var o=i.firstBaseUpdate,l=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var c=a,u=c.next;c.next=null,l===null?o=u:l.next=u,l=c;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==l&&(a===null?p.firstBaseUpdate=u:a.next=u,p.lastBaseUpdate=c))}if(o!==null){var f=i.baseState;l=0,p=u=c=null,a=o;do{var h=a.lane,v=a.eventTime;if((r&h)===h){p!==null&&(p=p.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var j=e,w=a;switch(h=t,v=n,w.tag){case 1:if(j=w.payload,typeof j=="function"){f=j.call(v,f,h);break e}f=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=w.payload,h=typeof j=="function"?j.call(v,f,h):j,h==null)break e;f=et({},f,h);break e;case 2:Bs=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=i.effects,h===null?i.effects=[a]:h.push(a))}else v={eventTime:v,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(u=p=v,c=f):p=p.next=v,l|=h;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;h=a,a=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(p===null&&(c=f),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=p,t=i.shared.interleaved,t!==null){i=t;do l|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);_r|=l,e.lanes=l,e.memoizedState=f}}function ux(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(J(191,i));i.call(r)}}}var wl={},ns=hr(wl),el=hr(wl),tl=hr(wl);function Er(e){if(e===wl)throw Error(J(174));return e}function xp(e,t){switch(We(tl,t),We(el,e),We(ns,wl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:sf(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=sf(t,e)}Ke(ns),We(ns,t)}function _i(){Ke(ns),Ke(el),Ke(tl)}function Dy(e){Er(tl.current);var t=Er(ns.current),n=sf(t,e.type);t!==n&&(We(el,e),We(ns,n))}function vp(e){el.current===e&&(Ke(ns),Ke(el))}var Je=hr(0);function pc(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Qu=[];function jp(){for(var e=0;e<Qu.length;e++)Qu[e]._workInProgressVersionPrimary=null;Qu.length=0}var Ma=Ms.ReactCurrentDispatcher,Ju=Ms.ReactCurrentBatchConfig,$r=0,Xe=null,ht=null,vt=null,mc=!1,Oo=!1,nl=0,IC=0;function $t(){throw Error(J(321))}function yp(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!zn(e[n],t[n]))return!1;return!0}function wp(e,t,n,r,i,o){if($r=o,Xe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ma.current=e===null||e.memoizedState===null?OC:DC,e=n(r,i),Oo){o=0;do{if(Oo=!1,nl=0,25<=o)throw Error(J(301));o+=1,vt=ht=null,t.updateQueue=null,Ma.current=LC,e=n(r,i)}while(Oo)}if(Ma.current=gc,t=ht!==null&&ht.next!==null,$r=0,vt=ht=Xe=null,mc=!1,t)throw Error(J(300));return e}function bp(){var e=nl!==0;return nl=0,e}function Qn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vt===null?Xe.memoizedState=vt=e:vt=vt.next=e,vt}function An(){if(ht===null){var e=Xe.alternate;e=e!==null?e.memoizedState:null}else e=ht.next;var t=vt===null?Xe.memoizedState:vt.next;if(t!==null)vt=t,ht=e;else{if(e===null)throw Error(J(310));ht=e,e={memoizedState:ht.memoizedState,baseState:ht.baseState,baseQueue:ht.baseQueue,queue:ht.queue,next:null},vt===null?Xe.memoizedState=vt=e:vt=vt.next=e}return vt}function sl(e,t){return typeof t=="function"?t(e):t}function Xu(e){var t=An(),n=t.queue;if(n===null)throw Error(J(311));n.lastRenderedReducer=e;var r=ht,i=r.baseQueue,o=n.pending;if(o!==null){if(i!==null){var l=i.next;i.next=o.next,o.next=l}r.baseQueue=i=o,n.pending=null}if(i!==null){o=i.next,r=r.baseState;var a=l=null,c=null,u=o;do{var p=u.lane;if(($r&p)===p)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(a=c=f,l=r):c=c.next=f,Xe.lanes|=p,_r|=p}u=u.next}while(u!==null&&u!==o);c===null?l=r:c.next=a,zn(r,t.memoizedState)||(Xt=!0),t.memoizedState=r,t.baseState=l,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do o=i.lane,Xe.lanes|=o,_r|=o,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Zu(e){var t=An(),n=t.queue;if(n===null)throw Error(J(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var l=i=i.next;do o=e(o,l.action),l=l.next;while(l!==i);zn(o,t.memoizedState)||(Xt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Ly(){}function Fy(e,t){var n=Xe,r=An(),i=t(),o=!zn(r.memoizedState,i);if(o&&(r.memoizedState=i,Xt=!0),r=r.queue,kp(By.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||vt!==null&&vt.memoizedState.tag&1){if(n.flags|=2048,rl(9,zy.bind(null,n,r,i,t),void 0,null),wt===null)throw Error(J(349));$r&30||Uy(n,t,i)}return i}function Uy(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Xe.updateQueue,t===null?(t={lastEffect:null,stores:null},Xe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function zy(e,t,n,r){t.value=n,t.getSnapshot=r,Wy(t)&&Hy(e)}function By(e,t,n){return n(function(){Wy(t)&&Hy(e)})}function Wy(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!zn(e,n)}catch{return!0}}function Hy(e){var t=Cs(e,1);t!==null&&Un(t,e,1,-1)}function dx(e){var t=Qn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:sl,lastRenderedState:e},t.queue=e,e=e.dispatch=_C.bind(null,Xe,e),[t.memoizedState,e]}function rl(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Xe.updateQueue,t===null?(t={lastEffect:null,stores:null},Xe.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Vy(){return An().memoizedState}function $a(e,t,n,r){var i=Qn();Xe.flags|=e,i.memoizedState=rl(1|t,n,void 0,r===void 0?null:r)}function Kc(e,t,n,r){var i=An();r=r===void 0?null:r;var o=void 0;if(ht!==null){var l=ht.memoizedState;if(o=l.destroy,r!==null&&yp(r,l.deps)){i.memoizedState=rl(t,n,o,r);return}}Xe.flags|=e,i.memoizedState=rl(1|t,n,o,r)}function fx(e,t){return $a(8390656,8,e,t)}function kp(e,t){return Kc(2048,8,e,t)}function Ky(e,t){return Kc(4,2,e,t)}function Gy(e,t){return Kc(4,4,e,t)}function Yy(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function qy(e,t,n){return n=n!=null?n.concat([e]):null,Kc(4,4,Yy.bind(null,t,e),n)}function Sp(){}function Qy(e,t){var n=An();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&yp(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Jy(e,t){var n=An();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&yp(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Xy(e,t,n){return $r&21?(zn(n,t)||(n=sy(),Xe.lanes|=n,_r|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Xt=!0),e.memoizedState=n)}function MC(e,t){var n=Le;Le=n!==0&&4>n?n:4,e(!0);var r=Ju.transition;Ju.transition={};try{e(!1),t()}finally{Le=n,Ju.transition=r}}function Zy(){return An().memoizedState}function $C(e,t,n){var r=er(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ew(e))tw(t,n);else if(n=_y(e,t,n,r),n!==null){var i=Ht();Un(n,e,r,i),nw(n,t,r)}}function _C(e,t,n){var r=er(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ew(e))tw(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var l=t.lastRenderedState,a=o(l,n);if(i.hasEagerState=!0,i.eagerState=a,zn(a,l)){var c=t.interleaved;c===null?(i.next=i,mp(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=_y(e,t,i,r),n!==null&&(i=Ht(),Un(n,e,r,i),nw(n,t,r))}}function ew(e){var t=e.alternate;return e===Xe||t!==null&&t===Xe}function tw(e,t){Oo=mc=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function nw(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,tp(e,n)}}var gc={readContext:En,useCallback:$t,useContext:$t,useEffect:$t,useImperativeHandle:$t,useInsertionEffect:$t,useLayoutEffect:$t,useMemo:$t,useReducer:$t,useRef:$t,useState:$t,useDebugValue:$t,useDeferredValue:$t,useTransition:$t,useMutableSource:$t,useSyncExternalStore:$t,useId:$t,unstable_isNewReconciler:!1},OC={readContext:En,useCallback:function(e,t){return Qn().memoizedState=[e,t===void 0?null:t],e},useContext:En,useEffect:fx,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,$a(4194308,4,Yy.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $a(4194308,4,e,t)},useInsertionEffect:function(e,t){return $a(4,2,e,t)},useMemo:function(e,t){var n=Qn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Qn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=$C.bind(null,Xe,e),[r.memoizedState,e]},useRef:function(e){var t=Qn();return e={current:e},t.memoizedState=e},useState:dx,useDebugValue:Sp,useDeferredValue:function(e){return Qn().memoizedState=e},useTransition:function(){var e=dx(!1),t=e[0];return e=MC.bind(null,e[1]),Qn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Xe,i=Qn();if(Ye){if(n===void 0)throw Error(J(407));n=n()}else{if(n=t(),wt===null)throw Error(J(349));$r&30||Uy(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,fx(By.bind(null,r,o,e),[e]),r.flags|=2048,rl(9,zy.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Qn(),t=wt.identifierPrefix;if(Ye){var n=js,r=vs;n=(r&~(1<<32-Fn(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=nl++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=IC++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},DC={readContext:En,useCallback:Qy,useContext:En,useEffect:kp,useImperativeHandle:qy,useInsertionEffect:Ky,useLayoutEffect:Gy,useMemo:Jy,useReducer:Xu,useRef:Vy,useState:function(){return Xu(sl)},useDebugValue:Sp,useDeferredValue:function(e){var t=An();return Xy(t,ht.memoizedState,e)},useTransition:function(){var e=Xu(sl)[0],t=An().memoizedState;return[e,t]},useMutableSource:Ly,useSyncExternalStore:Fy,useId:Zy,unstable_isNewReconciler:!1},LC={readContext:En,useCallback:Qy,useContext:En,useEffect:kp,useImperativeHandle:qy,useInsertionEffect:Ky,useLayoutEffect:Gy,useMemo:Jy,useReducer:Zu,useRef:Vy,useState:function(){return Zu(sl)},useDebugValue:Sp,useDeferredValue:function(e){var t=An();return ht===null?t.memoizedState=e:Xy(t,ht.memoizedState,e)},useTransition:function(){var e=Zu(sl)[0],t=An().memoizedState;return[e,t]},useMutableSource:Ly,useSyncExternalStore:Fy,useId:Zy,unstable_isNewReconciler:!1};function _n(e,t){if(e&&e.defaultProps){t=et({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Nf(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:et({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Gc={isMounted:function(e){return(e=e._reactInternals)?Wr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ht(),i=er(e),o=ys(r,i);o.payload=t,n!=null&&(o.callback=n),t=Xs(e,o,i),t!==null&&(Un(t,e,i,r),Ia(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ht(),i=er(e),o=ys(r,i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Xs(e,o,i),t!==null&&(Un(t,e,i,r),Ia(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ht(),r=er(e),i=ys(n,r);i.tag=2,t!=null&&(i.callback=t),t=Xs(e,i,r),t!==null&&(Un(t,e,r,n),Ia(t,e,r))}};function hx(e,t,n,r,i,o,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,l):t.prototype&&t.prototype.isPureReactComponent?!Qo(n,r)||!Qo(i,o):!0}function sw(e,t,n){var r=!1,i=or,o=t.contextType;return typeof o=="object"&&o!==null?o=En(o):(i=tn(t)?Ir:Ut.current,r=t.contextTypes,o=(r=r!=null)?Ii(e,i):or),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Gc,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function px(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Gc.enqueueReplaceState(t,t.state,null)}function Cf(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},gp(e);var o=t.contextType;typeof o=="object"&&o!==null?i.context=En(o):(o=tn(t)?Ir:Ut.current,i.context=Ii(e,o)),i.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Nf(e,t,o,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&Gc.enqueueReplaceState(i,i.state,null),hc(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Oi(e,t){try{var n="",r=t;do n+=fN(r),r=r.return;while(r);var i=n}catch(o){i=`
39
- Error generating stack: `+o.message+`
40
- `+o.stack}return{value:e,source:t,stack:i,digest:null}}function ed(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Ef(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var FC=typeof WeakMap=="function"?WeakMap:Map;function rw(e,t,n){n=ys(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){vc||(vc=!0,Df=r),Ef(e,t)},n}function iw(e,t,n){n=ys(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Ef(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Ef(e,t),typeof r!="function"&&(Zs===null?Zs=new Set([this]):Zs.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),n}function mx(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new FC;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=ZC.bind(null,e,t,n),t.then(e,e))}function gx(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function xx(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=ys(-1,1),t.tag=2,Xs(n,t,1))),n.lanes|=1),e)}var UC=Ms.ReactCurrentOwner,Xt=!1;function zt(e,t,n,r){t.child=e===null?$y(t,null,n,r):$i(t,e.child,n,r)}function vx(e,t,n,r,i){n=n.render;var o=t.ref;return Ni(t,i),r=wp(e,t,n,r,o,i),n=bp(),e!==null&&!Xt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Es(e,t,i)):(Ye&&n&&cp(t),t.flags|=1,zt(e,t,r,i),t.child)}function jx(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!Ip(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,ow(e,t,o,r,i)):(e=La(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var l=o.memoizedProps;if(n=n.compare,n=n!==null?n:Qo,n(l,r)&&e.ref===t.ref)return Es(e,t,i)}return t.flags|=1,e=tr(o,r),e.ref=t.ref,e.return=t,t.child=e}function ow(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(Qo(o,r)&&e.ref===t.ref)if(Xt=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(Xt=!0);else return t.lanes=e.lanes,Es(e,t,i)}return Af(e,t,n,r,i)}function lw(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},We(ji,fn),fn|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,We(ji,fn),fn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,We(ji,fn),fn|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,We(ji,fn),fn|=r;return zt(e,t,i,n),t.child}function aw(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Af(e,t,n,r,i){var o=tn(n)?Ir:Ut.current;return o=Ii(t,o),Ni(t,i),n=wp(e,t,n,r,o,i),r=bp(),e!==null&&!Xt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Es(e,t,i)):(Ye&&r&&cp(t),t.flags|=1,zt(e,t,n,i),t.child)}function yx(e,t,n,r,i){if(tn(n)){var o=!0;ac(t)}else o=!1;if(Ni(t,i),t.stateNode===null)_a(e,t),sw(t,n,r),Cf(t,n,r,i),r=!0;else if(e===null){var l=t.stateNode,a=t.memoizedProps;l.props=a;var c=l.context,u=n.contextType;typeof u=="object"&&u!==null?u=En(u):(u=tn(n)?Ir:Ut.current,u=Ii(t,u));var p=n.getDerivedStateFromProps,f=typeof p=="function"||typeof l.getSnapshotBeforeUpdate=="function";f||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(a!==r||c!==u)&&px(t,l,r,u),Bs=!1;var h=t.memoizedState;l.state=h,hc(t,r,l,i),c=t.memoizedState,a!==r||h!==c||en.current||Bs?(typeof p=="function"&&(Nf(t,n,p,r),c=t.memoizedState),(a=Bs||hx(t,n,a,r,h,c,u))?(f||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4194308)):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),l.props=r,l.state=c,l.context=u,r=a):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,Oy(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:_n(t.type,a),l.props=u,f=t.pendingProps,h=l.context,c=n.contextType,typeof c=="object"&&c!==null?c=En(c):(c=tn(n)?Ir:Ut.current,c=Ii(t,c));var v=n.getDerivedStateFromProps;(p=typeof v=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(a!==f||h!==c)&&px(t,l,r,c),Bs=!1,h=t.memoizedState,l.state=h,hc(t,r,l,i);var j=t.memoizedState;a!==f||h!==j||en.current||Bs?(typeof v=="function"&&(Nf(t,n,v,r),j=t.memoizedState),(u=Bs||hx(t,n,u,r,h,j,c)||!1)?(p||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,j,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,j,c)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),l.props=r,l.state=j,l.context=c,r=u):(typeof l.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Tf(e,t,n,r,o,i)}function Tf(e,t,n,r,i,o){aw(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return i&&ix(t,n,!1),Es(e,t,o);r=t.stateNode,UC.current=t;var a=l&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=$i(t,e.child,null,o),t.child=$i(t,null,a,o)):zt(e,t,a,o),t.memoizedState=r.state,i&&ix(t,n,!0),t.child}function cw(e){var t=e.stateNode;t.pendingContext?rx(e,t.pendingContext,t.pendingContext!==t.context):t.context&&rx(e,t.context,!1),xp(e,t.containerInfo)}function wx(e,t,n,r,i){return Mi(),dp(i),t.flags|=256,zt(e,t,n,r),t.child}var Rf={dehydrated:null,treeContext:null,retryLane:0};function Pf(e){return{baseLanes:e,cachePool:null,transitions:null}}function uw(e,t,n){var r=t.pendingProps,i=Je.current,o=!1,l=(t.flags&128)!==0,a;if((a=l)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),We(Je,i&1),e===null)return kf(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=r.children,e=r.fallback,o?(r=t.mode,o=t.child,l={mode:"hidden",children:l},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=l):o=Qc(l,r,0,null),e=Tr(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Pf(n),t.memoizedState=Rf,e):Np(t,l));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return zC(e,t,l,r,a,i,n);if(o){o=r.fallback,l=t.mode,i=e.child,a=i.sibling;var c={mode:"hidden",children:r.children};return!(l&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=tr(i,c),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?o=tr(a,o):(o=Tr(o,l,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,l=e.child.memoizedState,l=l===null?Pf(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},o.memoizedState=l,o.childLanes=e.childLanes&~n,t.memoizedState=Rf,r}return o=e.child,e=o.sibling,r=tr(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Np(e,t){return t=Qc({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function ea(e,t,n,r){return r!==null&&dp(r),$i(t,e.child,null,n),e=Np(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function zC(e,t,n,r,i,o,l){if(n)return t.flags&256?(t.flags&=-257,r=ed(Error(J(422))),ea(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=Qc({mode:"visible",children:r.children},i,0,null),o=Tr(o,i,l,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&$i(t,e.child,null,l),t.child.memoizedState=Pf(l),t.memoizedState=Rf,o);if(!(t.mode&1))return ea(e,t,l,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,o=Error(J(419)),r=ed(o,r,void 0),ea(e,t,l,r)}if(a=(l&e.childLanes)!==0,Xt||a){if(r=wt,r!==null){switch(l&-l){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|l)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,Cs(e,i),Un(r,e,i,-1))}return Pp(),r=ed(Error(J(421))),ea(e,t,l,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=eE.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,pn=Js(i.nextSibling),gn=t,Ye=!0,Dn=null,e!==null&&(bn[kn++]=vs,bn[kn++]=js,bn[kn++]=Mr,vs=e.id,js=e.overflow,Mr=t),t=Np(t,r.children),t.flags|=4096,t)}function bx(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Sf(e.return,t,n)}function td(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function dw(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(zt(e,t,r.children,n),r=Je.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&bx(e,n,t);else if(e.tag===19)bx(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(We(Je,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&pc(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),td(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&pc(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}td(t,!0,n,null,o);break;case"together":td(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function _a(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Es(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),_r|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(J(153));if(t.child!==null){for(e=t.child,n=tr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=tr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function BC(e,t,n){switch(t.tag){case 3:cw(t),Mi();break;case 5:Dy(t);break;case 1:tn(t.type)&&ac(t);break;case 4:xp(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;We(dc,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(We(Je,Je.current&1),t.flags|=128,null):n&t.child.childLanes?uw(e,t,n):(We(Je,Je.current&1),e=Es(e,t,n),e!==null?e.sibling:null);We(Je,Je.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return dw(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),We(Je,Je.current),r)break;return null;case 22:case 23:return t.lanes=0,lw(e,t,n)}return Es(e,t,n)}var fw,If,hw,pw;fw=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};If=function(){};hw=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Er(ns.current);var o=null;switch(n){case"input":i=Zd(e,i),r=Zd(e,r),o=[];break;case"select":i=et({},i,{value:void 0}),r=et({},r,{value:void 0}),o=[];break;case"textarea":i=nf(e,i),r=nf(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=oc)}rf(n,r);var l;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var a=i[u];for(l in a)a.hasOwnProperty(l)&&(n||(n={}),n[l]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Wo.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var c=r[u];if(a=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==a&&(c!=null||a!=null))if(u==="style")if(a){for(l in a)!a.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(n||(n={}),n[l]="");for(l in c)c.hasOwnProperty(l)&&a[l]!==c[l]&&(n||(n={}),n[l]=c[l])}else n||(o||(o=[]),o.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,a=a?a.__html:void 0,c!=null&&a!==c&&(o=o||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Wo.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Ve("scroll",e),o||a===c||(o=[])):(o=o||[]).push(u,c))}n&&(o=o||[]).push("style",n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}};pw=function(e,t,n,r){n!==r&&(t.flags|=4)};function yo(e,t){if(!Ye)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function _t(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function WC(e,t,n){var r=t.pendingProps;switch(up(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _t(t),null;case 1:return tn(t.type)&&lc(),_t(t),null;case 3:return r=t.stateNode,_i(),Ke(en),Ke(Ut),jp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Xl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Dn!==null&&(Uf(Dn),Dn=null))),If(e,t),_t(t),null;case 5:vp(t);var i=Er(tl.current);if(n=t.type,e!==null&&t.stateNode!=null)hw(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(J(166));return _t(t),null}if(e=Er(ns.current),Xl(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Jn]=t,r[Zo]=o,e=(t.mode&1)!==0,n){case"dialog":Ve("cancel",r),Ve("close",r);break;case"iframe":case"object":case"embed":Ve("load",r);break;case"video":case"audio":for(i=0;i<Ro.length;i++)Ve(Ro[i],r);break;case"source":Ve("error",r);break;case"img":case"image":case"link":Ve("error",r),Ve("load",r);break;case"details":Ve("toggle",r);break;case"input":Pg(r,o),Ve("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},Ve("invalid",r);break;case"textarea":Mg(r,o),Ve("invalid",r)}rf(n,o),i=null;for(var l in o)if(o.hasOwnProperty(l)){var a=o[l];l==="children"?typeof a=="string"?r.textContent!==a&&(o.suppressHydrationWarning!==!0&&Jl(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(o.suppressHydrationWarning!==!0&&Jl(r.textContent,a,e),i=["children",""+a]):Wo.hasOwnProperty(l)&&a!=null&&l==="onScroll"&&Ve("scroll",r)}switch(n){case"input":Wl(r),Ig(r,o,!0);break;case"textarea":Wl(r),$g(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=oc)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{l=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Bj(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Jn]=t,e[Zo]=r,fw(e,t,!1,!1),t.stateNode=e;e:{switch(l=of(n,r),n){case"dialog":Ve("cancel",e),Ve("close",e),i=r;break;case"iframe":case"object":case"embed":Ve("load",e),i=r;break;case"video":case"audio":for(i=0;i<Ro.length;i++)Ve(Ro[i],e);i=r;break;case"source":Ve("error",e),i=r;break;case"img":case"image":case"link":Ve("error",e),Ve("load",e),i=r;break;case"details":Ve("toggle",e),i=r;break;case"input":Pg(e,r),i=Zd(e,r),Ve("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=et({},r,{value:void 0}),Ve("invalid",e);break;case"textarea":Mg(e,r),i=nf(e,r),Ve("invalid",e);break;default:i=r}rf(n,i),a=i;for(o in a)if(a.hasOwnProperty(o)){var c=a[o];o==="style"?Vj(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Wj(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Ho(e,c):typeof c=="number"&&Ho(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Wo.hasOwnProperty(o)?c!=null&&o==="onScroll"&&Ve("scroll",e):c!=null&&qh(e,o,c,l))}switch(n){case"input":Wl(e),Ig(e,r,!1);break;case"textarea":Wl(e),$g(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ir(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?wi(e,!!r.multiple,o,!1):r.defaultValue!=null&&wi(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=oc)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return _t(t),null;case 6:if(e&&t.stateNode!=null)pw(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(J(166));if(n=Er(tl.current),Er(ns.current),Xl(t)){if(r=t.stateNode,n=t.memoizedProps,r[Jn]=t,(o=r.nodeValue!==n)&&(e=gn,e!==null))switch(e.tag){case 3:Jl(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Jl(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Jn]=t,t.stateNode=r}return _t(t),null;case 13:if(Ke(Je),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ye&&pn!==null&&t.mode&1&&!(t.flags&128))Iy(),Mi(),t.flags|=98560,o=!1;else if(o=Xl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(J(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(J(317));o[Jn]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;_t(t),o=!1}else Dn!==null&&(Uf(Dn),Dn=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Je.current&1?gt===0&&(gt=3):Pp())),t.updateQueue!==null&&(t.flags|=4),_t(t),null);case 4:return _i(),If(e,t),e===null&&Jo(t.stateNode.containerInfo),_t(t),null;case 10:return pp(t.type._context),_t(t),null;case 17:return tn(t.type)&&lc(),_t(t),null;case 19:if(Ke(Je),o=t.memoizedState,o===null)return _t(t),null;if(r=(t.flags&128)!==0,l=o.rendering,l===null)if(r)yo(o,!1);else{if(gt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=pc(e),l!==null){for(t.flags|=128,yo(o,!1),r=l.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,l=o.alternate,l===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=l.childLanes,o.lanes=l.lanes,o.child=l.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=l.memoizedProps,o.memoizedState=l.memoizedState,o.updateQueue=l.updateQueue,o.type=l.type,e=l.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return We(Je,Je.current&1|2),t.child}e=e.sibling}o.tail!==null&&ot()>Di&&(t.flags|=128,r=!0,yo(o,!1),t.lanes=4194304)}else{if(!r)if(e=pc(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),yo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!Ye)return _t(t),null}else 2*ot()-o.renderingStartTime>Di&&n!==1073741824&&(t.flags|=128,r=!0,yo(o,!1),t.lanes=4194304);o.isBackwards?(l.sibling=t.child,t.child=l):(n=o.last,n!==null?n.sibling=l:t.child=l,o.last=l)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=ot(),t.sibling=null,n=Je.current,We(Je,r?n&1|2:n&1),t):(_t(t),null);case 22:case 23:return Rp(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?fn&1073741824&&(_t(t),t.subtreeFlags&6&&(t.flags|=8192)):_t(t),null;case 24:return null;case 25:return null}throw Error(J(156,t.tag))}function HC(e,t){switch(up(t),t.tag){case 1:return tn(t.type)&&lc(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return _i(),Ke(en),Ke(Ut),jp(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return vp(t),null;case 13:if(Ke(Je),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(J(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ke(Je),null;case 4:return _i(),null;case 10:return pp(t.type._context),null;case 22:case 23:return Rp(),null;case 24:return null;default:return null}}var ta=!1,Dt=!1,VC=typeof WeakSet=="function"?WeakSet:Set,oe=null;function vi(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){nt(e,t,r)}else n.current=null}function Mf(e,t,n){try{n()}catch(r){nt(e,t,r)}}var kx=!1;function KC(e,t){if(gf=sc,e=jy(),ap(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var l=0,a=-1,c=-1,u=0,p=0,f=e,h=null;t:for(;;){for(var v;f!==n||i!==0&&f.nodeType!==3||(a=l+i),f!==o||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)h=f,f=v;for(;;){if(f===e)break t;if(h===n&&++u===i&&(a=l),h===o&&++p===r&&(c=l),(v=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=v}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(xf={focusedElem:e,selectionRange:n},sc=!1,oe=t;oe!==null;)if(t=oe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,oe=e;else for(;oe!==null;){t=oe;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var w=j.memoizedProps,b=j.memoizedState,x=t.stateNode,g=x.getSnapshotBeforeUpdate(t.elementType===t.type?w:_n(t.type,w),b);x.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(J(163))}}catch(m){nt(t,t.return,m)}if(e=t.sibling,e!==null){e.return=t.return,oe=e;break}oe=t.return}return j=kx,kx=!1,j}function Do(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&Mf(t,n,o)}i=i.next}while(i!==r)}}function Yc(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function $f(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function mw(e){var t=e.alternate;t!==null&&(e.alternate=null,mw(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Jn],delete t[Zo],delete t[yf],delete t[AC],delete t[TC])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function gw(e){return e.tag===5||e.tag===3||e.tag===4}function Sx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||gw(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function _f(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=oc));else if(r!==4&&(e=e.child,e!==null))for(_f(e,t,n),e=e.sibling;e!==null;)_f(e,t,n),e=e.sibling}function Of(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Of(e,t,n),e=e.sibling;e!==null;)Of(e,t,n),e=e.sibling}var Et=null,On=!1;function Fs(e,t,n){for(n=n.child;n!==null;)xw(e,t,n),n=n.sibling}function xw(e,t,n){if(ts&&typeof ts.onCommitFiberUnmount=="function")try{ts.onCommitFiberUnmount(Uc,n)}catch{}switch(n.tag){case 5:Dt||vi(n,t);case 6:var r=Et,i=On;Et=null,Fs(e,t,n),Et=r,On=i,Et!==null&&(On?(e=Et,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Et.removeChild(n.stateNode));break;case 18:Et!==null&&(On?(e=Et,n=n.stateNode,e.nodeType===8?Yu(e.parentNode,n):e.nodeType===1&&Yu(e,n),Yo(e)):Yu(Et,n.stateNode));break;case 4:r=Et,i=On,Et=n.stateNode.containerInfo,On=!0,Fs(e,t,n),Et=r,On=i;break;case 0:case 11:case 14:case 15:if(!Dt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&Mf(n,t,l),i=i.next}while(i!==r)}Fs(e,t,n);break;case 1:if(!Dt&&(vi(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){nt(n,t,a)}Fs(e,t,n);break;case 21:Fs(e,t,n);break;case 22:n.mode&1?(Dt=(r=Dt)||n.memoizedState!==null,Fs(e,t,n),Dt=r):Fs(e,t,n);break;default:Fs(e,t,n)}}function Nx(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new VC),t.forEach(function(r){var i=tE.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Mn(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var o=e,l=t,a=l;e:for(;a!==null;){switch(a.tag){case 5:Et=a.stateNode,On=!1;break e;case 3:Et=a.stateNode.containerInfo,On=!0;break e;case 4:Et=a.stateNode.containerInfo,On=!0;break e}a=a.return}if(Et===null)throw Error(J(160));xw(o,l,i),Et=null,On=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){nt(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)vw(t,e),t=t.sibling}function vw(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Mn(t,e),Yn(e),r&4){try{Do(3,e,e.return),Yc(3,e)}catch(w){nt(e,e.return,w)}try{Do(5,e,e.return)}catch(w){nt(e,e.return,w)}}break;case 1:Mn(t,e),Yn(e),r&512&&n!==null&&vi(n,n.return);break;case 5:if(Mn(t,e),Yn(e),r&512&&n!==null&&vi(n,n.return),e.flags&32){var i=e.stateNode;try{Ho(i,"")}catch(w){nt(e,e.return,w)}}if(r&4&&(i=e.stateNode,i!=null)){var o=e.memoizedProps,l=n!==null?n.memoizedProps:o,a=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{a==="input"&&o.type==="radio"&&o.name!=null&&Uj(i,o),of(a,l);var u=of(a,o);for(l=0;l<c.length;l+=2){var p=c[l],f=c[l+1];p==="style"?Vj(i,f):p==="dangerouslySetInnerHTML"?Wj(i,f):p==="children"?Ho(i,f):qh(i,p,f,u)}switch(a){case"input":ef(i,o);break;case"textarea":zj(i,o);break;case"select":var h=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var v=o.value;v!=null?wi(i,!!o.multiple,v,!1):h!==!!o.multiple&&(o.defaultValue!=null?wi(i,!!o.multiple,o.defaultValue,!0):wi(i,!!o.multiple,o.multiple?[]:"",!1))}i[Zo]=o}catch(w){nt(e,e.return,w)}}break;case 6:if(Mn(t,e),Yn(e),r&4){if(e.stateNode===null)throw Error(J(162));i=e.stateNode,o=e.memoizedProps;try{i.nodeValue=o}catch(w){nt(e,e.return,w)}}break;case 3:if(Mn(t,e),Yn(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Yo(t.containerInfo)}catch(w){nt(e,e.return,w)}break;case 4:Mn(t,e),Yn(e);break;case 13:Mn(t,e),Yn(e),i=e.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(Ap=ot())),r&4&&Nx(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Dt=(u=Dt)||p,Mn(t,e),Dt=u):Mn(t,e),Yn(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(oe=e,p=e.child;p!==null;){for(f=oe=p;oe!==null;){switch(h=oe,v=h.child,h.tag){case 0:case 11:case 14:case 15:Do(4,h,h.return);break;case 1:vi(h,h.return);var j=h.stateNode;if(typeof j.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(w){nt(r,n,w)}}break;case 5:vi(h,h.return);break;case 22:if(h.memoizedState!==null){Ex(f);continue}}v!==null?(v.return=h,oe=v):Ex(f)}p=p.sibling}e:for(p=null,f=e;;){if(f.tag===5){if(p===null){p=f;try{i=f.stateNode,u?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(a=f.stateNode,c=f.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,a.style.display=Hj("display",l))}catch(w){nt(e,e.return,w)}}}else if(f.tag===6){if(p===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(w){nt(e,e.return,w)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;p===f&&(p=null),f=f.return}p===f&&(p=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Mn(t,e),Yn(e),r&4&&Nx(e);break;case 21:break;default:Mn(t,e),Yn(e)}}function Yn(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(gw(n)){var r=n;break e}n=n.return}throw Error(J(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Ho(i,""),r.flags&=-33);var o=Sx(e);Of(e,o,i);break;case 3:case 4:var l=r.stateNode.containerInfo,a=Sx(e);_f(e,a,l);break;default:throw Error(J(161))}}catch(c){nt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function GC(e,t,n){oe=e,jw(e)}function jw(e,t,n){for(var r=(e.mode&1)!==0;oe!==null;){var i=oe,o=i.child;if(i.tag===22&&r){var l=i.memoizedState!==null||ta;if(!l){var a=i.alternate,c=a!==null&&a.memoizedState!==null||Dt;a=ta;var u=Dt;if(ta=l,(Dt=c)&&!u)for(oe=i;oe!==null;)l=oe,c=l.child,l.tag===22&&l.memoizedState!==null?Ax(i):c!==null?(c.return=l,oe=c):Ax(i);for(;o!==null;)oe=o,jw(o),o=o.sibling;oe=i,ta=a,Dt=u}Cx(e)}else i.subtreeFlags&8772&&o!==null?(o.return=i,oe=o):Cx(e)}}function Cx(e){for(;oe!==null;){var t=oe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Dt||Yc(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Dt)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:_n(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&ux(t,o,r);break;case 3:var l=t.updateQueue;if(l!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}ux(t,l,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var f=p.dehydrated;f!==null&&Yo(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(J(163))}Dt||t.flags&512&&$f(t)}catch(h){nt(t,t.return,h)}}if(t===e){oe=null;break}if(n=t.sibling,n!==null){n.return=t.return,oe=n;break}oe=t.return}}function Ex(e){for(;oe!==null;){var t=oe;if(t===e){oe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,oe=n;break}oe=t.return}}function Ax(e){for(;oe!==null;){var t=oe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Yc(4,t)}catch(c){nt(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){nt(t,i,c)}}var o=t.return;try{$f(t)}catch(c){nt(t,o,c)}break;case 5:var l=t.return;try{$f(t)}catch(c){nt(t,l,c)}}}catch(c){nt(t,t.return,c)}if(t===e){oe=null;break}var a=t.sibling;if(a!==null){a.return=t.return,oe=a;break}oe=t.return}}var YC=Math.ceil,xc=Ms.ReactCurrentDispatcher,Cp=Ms.ReactCurrentOwner,Cn=Ms.ReactCurrentBatchConfig,Pe=0,wt=null,dt=null,At=0,fn=0,ji=hr(0),gt=0,il=null,_r=0,qc=0,Ep=0,Lo=null,Qt=null,Ap=0,Di=1/0,ms=null,vc=!1,Df=null,Zs=null,na=!1,Ks=null,jc=0,Fo=0,Lf=null,Oa=-1,Da=0;function Ht(){return Pe&6?ot():Oa!==-1?Oa:Oa=ot()}function er(e){return e.mode&1?Pe&2&&At!==0?At&-At:PC.transition!==null?(Da===0&&(Da=sy()),Da):(e=Le,e!==0||(e=window.event,e=e===void 0?16:uy(e.type)),e):1}function Un(e,t,n,r){if(50<Fo)throw Fo=0,Lf=null,Error(J(185));vl(e,n,r),(!(Pe&2)||e!==wt)&&(e===wt&&(!(Pe&2)&&(qc|=n),gt===4&&Hs(e,At)),nn(e,r),n===1&&Pe===0&&!(t.mode&1)&&(Di=ot()+500,Vc&&pr()))}function nn(e,t){var n=e.callbackNode;PN(e,t);var r=nc(e,e===wt?At:0);if(r===0)n!==null&&Dg(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Dg(n),t===1)e.tag===0?RC(Tx.bind(null,e)):Ty(Tx.bind(null,e)),CC(function(){!(Pe&6)&&pr()}),n=null;else{switch(ry(r)){case 1:n=ep;break;case 4:n=ty;break;case 16:n=tc;break;case 536870912:n=ny;break;default:n=tc}n=Ew(n,yw.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function yw(e,t){if(Oa=-1,Da=0,Pe&6)throw Error(J(327));var n=e.callbackNode;if(Ci()&&e.callbackNode!==n)return null;var r=nc(e,e===wt?At:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=yc(e,r);else{t=r;var i=Pe;Pe|=2;var o=bw();(wt!==e||At!==t)&&(ms=null,Di=ot()+500,Ar(e,t));do try{JC();break}catch(a){ww(e,a)}while(!0);hp(),xc.current=o,Pe=i,dt!==null?t=0:(wt=null,At=0,t=gt)}if(t!==0){if(t===2&&(i=df(e),i!==0&&(r=i,t=Ff(e,i))),t===1)throw n=il,Ar(e,0),Hs(e,r),nn(e,ot()),n;if(t===6)Hs(e,r);else{if(i=e.current.alternate,!(r&30)&&!qC(i)&&(t=yc(e,r),t===2&&(o=df(e),o!==0&&(r=o,t=Ff(e,o))),t===1))throw n=il,Ar(e,0),Hs(e,r),nn(e,ot()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(J(345));case 2:Sr(e,Qt,ms);break;case 3:if(Hs(e,r),(r&130023424)===r&&(t=Ap+500-ot(),10<t)){if(nc(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Ht(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=jf(Sr.bind(null,e,Qt,ms),t);break}Sr(e,Qt,ms);break;case 4:if(Hs(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var l=31-Fn(r);o=1<<l,l=t[l],l>i&&(i=l),r&=~o}if(r=i,r=ot()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*YC(r/1960))-r,10<r){e.timeoutHandle=jf(Sr.bind(null,e,Qt,ms),r);break}Sr(e,Qt,ms);break;case 5:Sr(e,Qt,ms);break;default:throw Error(J(329))}}}return nn(e,ot()),e.callbackNode===n?yw.bind(null,e):null}function Ff(e,t){var n=Lo;return e.current.memoizedState.isDehydrated&&(Ar(e,t).flags|=256),e=yc(e,t),e!==2&&(t=Qt,Qt=n,t!==null&&Uf(t)),e}function Uf(e){Qt===null?Qt=e:Qt.push.apply(Qt,e)}function qC(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],o=i.getSnapshot;i=i.value;try{if(!zn(o(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Hs(e,t){for(t&=~Ep,t&=~qc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Fn(t),r=1<<n;e[n]=-1,t&=~r}}function Tx(e){if(Pe&6)throw Error(J(327));Ci();var t=nc(e,0);if(!(t&1))return nn(e,ot()),null;var n=yc(e,t);if(e.tag!==0&&n===2){var r=df(e);r!==0&&(t=r,n=Ff(e,r))}if(n===1)throw n=il,Ar(e,0),Hs(e,t),nn(e,ot()),n;if(n===6)throw Error(J(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Sr(e,Qt,ms),nn(e,ot()),null}function Tp(e,t){var n=Pe;Pe|=1;try{return e(t)}finally{Pe=n,Pe===0&&(Di=ot()+500,Vc&&pr())}}function Or(e){Ks!==null&&Ks.tag===0&&!(Pe&6)&&Ci();var t=Pe;Pe|=1;var n=Cn.transition,r=Le;try{if(Cn.transition=null,Le=1,e)return e()}finally{Le=r,Cn.transition=n,Pe=t,!(Pe&6)&&pr()}}function Rp(){fn=ji.current,Ke(ji)}function Ar(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,NC(n)),dt!==null)for(n=dt.return;n!==null;){var r=n;switch(up(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&lc();break;case 3:_i(),Ke(en),Ke(Ut),jp();break;case 5:vp(r);break;case 4:_i();break;case 13:Ke(Je);break;case 19:Ke(Je);break;case 10:pp(r.type._context);break;case 22:case 23:Rp()}n=n.return}if(wt=e,dt=e=tr(e.current,null),At=fn=t,gt=0,il=null,Ep=qc=_r=0,Qt=Lo=null,Cr!==null){for(t=0;t<Cr.length;t++)if(n=Cr[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,o=n.pending;if(o!==null){var l=o.next;o.next=i,r.next=l}n.pending=r}Cr=null}return e}function ww(e,t){do{var n=dt;try{if(hp(),Ma.current=gc,mc){for(var r=Xe.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}mc=!1}if($r=0,vt=ht=Xe=null,Oo=!1,nl=0,Cp.current=null,n===null||n.return===null){gt=1,il=t,dt=null;break}e:{var o=e,l=n.return,a=n,c=t;if(t=At,a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=a,f=p.tag;if(!(p.mode&1)&&(f===0||f===11||f===15)){var h=p.alternate;h?(p.updateQueue=h.updateQueue,p.memoizedState=h.memoizedState,p.lanes=h.lanes):(p.updateQueue=null,p.memoizedState=null)}var v=gx(l);if(v!==null){v.flags&=-257,xx(v,l,a,o,t),v.mode&1&&mx(o,u,t),t=v,c=u;var j=t.updateQueue;if(j===null){var w=new Set;w.add(c),t.updateQueue=w}else j.add(c);break e}else{if(!(t&1)){mx(o,u,t),Pp();break e}c=Error(J(426))}}else if(Ye&&a.mode&1){var b=gx(l);if(b!==null){!(b.flags&65536)&&(b.flags|=256),xx(b,l,a,o,t),dp(Oi(c,a));break e}}o=c=Oi(c,a),gt!==4&&(gt=2),Lo===null?Lo=[o]:Lo.push(o),o=l;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var x=rw(o,c,t);cx(o,x);break e;case 1:a=c;var g=o.type,y=o.stateNode;if(!(o.flags&128)&&(typeof g.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Zs===null||!Zs.has(y)))){o.flags|=65536,t&=-t,o.lanes|=t;var m=iw(o,a,t);cx(o,m);break e}}o=o.return}while(o!==null)}Sw(n)}catch(S){t=S,dt===n&&n!==null&&(dt=n=n.return);continue}break}while(!0)}function bw(){var e=xc.current;return xc.current=gc,e===null?gc:e}function Pp(){(gt===0||gt===3||gt===2)&&(gt=4),wt===null||!(_r&268435455)&&!(qc&268435455)||Hs(wt,At)}function yc(e,t){var n=Pe;Pe|=2;var r=bw();(wt!==e||At!==t)&&(ms=null,Ar(e,t));do try{QC();break}catch(i){ww(e,i)}while(!0);if(hp(),Pe=n,xc.current=r,dt!==null)throw Error(J(261));return wt=null,At=0,gt}function QC(){for(;dt!==null;)kw(dt)}function JC(){for(;dt!==null&&!bN();)kw(dt)}function kw(e){var t=Cw(e.alternate,e,fn);e.memoizedProps=e.pendingProps,t===null?Sw(e):dt=t,Cp.current=null}function Sw(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=HC(n,t),n!==null){n.flags&=32767,dt=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{gt=6,dt=null;return}}else if(n=WC(n,t,fn),n!==null){dt=n;return}if(t=t.sibling,t!==null){dt=t;return}dt=t=e}while(t!==null);gt===0&&(gt=5)}function Sr(e,t,n){var r=Le,i=Cn.transition;try{Cn.transition=null,Le=1,XC(e,t,n,r)}finally{Cn.transition=i,Le=r}return null}function XC(e,t,n,r){do Ci();while(Ks!==null);if(Pe&6)throw Error(J(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(J(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(IN(e,o),e===wt&&(dt=wt=null,At=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||na||(na=!0,Ew(tc,function(){return Ci(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Cn.transition,Cn.transition=null;var l=Le;Le=1;var a=Pe;Pe|=4,Cp.current=null,KC(e,n),vw(n,e),vC(xf),sc=!!gf,xf=gf=null,e.current=n,GC(n),kN(),Pe=a,Le=l,Cn.transition=o}else e.current=n;if(na&&(na=!1,Ks=e,jc=i),o=e.pendingLanes,o===0&&(Zs=null),CN(n.stateNode),nn(e,ot()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(vc)throw vc=!1,e=Df,Df=null,e;return jc&1&&e.tag!==0&&Ci(),o=e.pendingLanes,o&1?e===Lf?Fo++:(Fo=0,Lf=e):Fo=0,pr(),null}function Ci(){if(Ks!==null){var e=ry(jc),t=Cn.transition,n=Le;try{if(Cn.transition=null,Le=16>e?16:e,Ks===null)var r=!1;else{if(e=Ks,Ks=null,jc=0,Pe&6)throw Error(J(331));var i=Pe;for(Pe|=4,oe=e.current;oe!==null;){var o=oe,l=o.child;if(oe.flags&16){var a=o.deletions;if(a!==null){for(var c=0;c<a.length;c++){var u=a[c];for(oe=u;oe!==null;){var p=oe;switch(p.tag){case 0:case 11:case 15:Do(8,p,o)}var f=p.child;if(f!==null)f.return=p,oe=f;else for(;oe!==null;){p=oe;var h=p.sibling,v=p.return;if(mw(p),p===u){oe=null;break}if(h!==null){h.return=v,oe=h;break}oe=v}}}var j=o.alternate;if(j!==null){var w=j.child;if(w!==null){j.child=null;do{var b=w.sibling;w.sibling=null,w=b}while(w!==null)}}oe=o}}if(o.subtreeFlags&2064&&l!==null)l.return=o,oe=l;else e:for(;oe!==null;){if(o=oe,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Do(9,o,o.return)}var x=o.sibling;if(x!==null){x.return=o.return,oe=x;break e}oe=o.return}}var g=e.current;for(oe=g;oe!==null;){l=oe;var y=l.child;if(l.subtreeFlags&2064&&y!==null)y.return=l,oe=y;else e:for(l=g;oe!==null;){if(a=oe,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Yc(9,a)}}catch(S){nt(a,a.return,S)}if(a===l){oe=null;break e}var m=a.sibling;if(m!==null){m.return=a.return,oe=m;break e}oe=a.return}}if(Pe=i,pr(),ts&&typeof ts.onPostCommitFiberRoot=="function")try{ts.onPostCommitFiberRoot(Uc,e)}catch{}r=!0}return r}finally{Le=n,Cn.transition=t}}return!1}function Rx(e,t,n){t=Oi(n,t),t=rw(e,t,1),e=Xs(e,t,1),t=Ht(),e!==null&&(vl(e,1,t),nn(e,t))}function nt(e,t,n){if(e.tag===3)Rx(e,e,n);else for(;t!==null;){if(t.tag===3){Rx(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Zs===null||!Zs.has(r))){e=Oi(n,e),e=iw(t,e,1),t=Xs(t,e,1),e=Ht(),t!==null&&(vl(t,1,e),nn(t,e));break}}t=t.return}}function ZC(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Ht(),e.pingedLanes|=e.suspendedLanes&n,wt===e&&(At&n)===n&&(gt===4||gt===3&&(At&130023424)===At&&500>ot()-Ap?Ar(e,0):Ep|=n),nn(e,t)}function Nw(e,t){t===0&&(e.mode&1?(t=Kl,Kl<<=1,!(Kl&130023424)&&(Kl=4194304)):t=1);var n=Ht();e=Cs(e,t),e!==null&&(vl(e,t,n),nn(e,n))}function eE(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Nw(e,n)}function tE(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(J(314))}r!==null&&r.delete(t),Nw(e,n)}var Cw;Cw=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||en.current)Xt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Xt=!1,BC(e,t,n);Xt=!!(e.flags&131072)}else Xt=!1,Ye&&t.flags&1048576&&Ry(t,uc,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;_a(e,t),e=t.pendingProps;var i=Ii(t,Ut.current);Ni(t,n),i=wp(null,t,r,e,i,n);var o=bp();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,tn(r)?(o=!0,ac(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,gp(t),i.updater=Gc,t.stateNode=i,i._reactInternals=t,Cf(t,r,e,n),t=Tf(null,t,r,!0,o,n)):(t.tag=0,Ye&&o&&cp(t),zt(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(_a(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=sE(r),e=_n(r,e),i){case 0:t=Af(null,t,r,e,n);break e;case 1:t=yx(null,t,r,e,n);break e;case 11:t=vx(null,t,r,e,n);break e;case 14:t=jx(null,t,r,_n(r.type,e),n);break e}throw Error(J(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:_n(r,i),Af(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:_n(r,i),yx(e,t,r,i,n);case 3:e:{if(cw(t),e===null)throw Error(J(387));r=t.pendingProps,o=t.memoizedState,i=o.element,Oy(e,t),hc(t,r,null,n);var l=t.memoizedState;if(r=l.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Oi(Error(J(423)),t),t=wx(e,t,r,n,i);break e}else if(r!==i){i=Oi(Error(J(424)),t),t=wx(e,t,r,n,i);break e}else for(pn=Js(t.stateNode.containerInfo.firstChild),gn=t,Ye=!0,Dn=null,n=$y(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Mi(),r===i){t=Es(e,t,n);break e}zt(e,t,r,n)}t=t.child}return t;case 5:return Dy(t),e===null&&kf(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,l=i.children,vf(r,i)?l=null:o!==null&&vf(r,o)&&(t.flags|=32),aw(e,t),zt(e,t,l,n),t.child;case 6:return e===null&&kf(t),null;case 13:return uw(e,t,n);case 4:return xp(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=$i(t,null,r,n):zt(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:_n(r,i),vx(e,t,r,i,n);case 7:return zt(e,t,t.pendingProps,n),t.child;case 8:return zt(e,t,t.pendingProps.children,n),t.child;case 12:return zt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,l=i.value,We(dc,r._currentValue),r._currentValue=l,o!==null)if(zn(o.value,l)){if(o.children===i.children&&!en.current){t=Es(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var a=o.dependencies;if(a!==null){l=o.child;for(var c=a.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=ys(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Sf(o.return,n,t),a.lanes|=n;break}c=c.next}}else if(o.tag===10)l=o.type===t.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(J(341));l.lanes|=n,a=l.alternate,a!==null&&(a.lanes|=n),Sf(l,n,t),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===t){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}zt(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Ni(t,n),i=En(i),r=r(i),t.flags|=1,zt(e,t,r,n),t.child;case 14:return r=t.type,i=_n(r,t.pendingProps),i=_n(r.type,i),jx(e,t,r,i,n);case 15:return ow(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:_n(r,i),_a(e,t),t.tag=1,tn(r)?(e=!0,ac(t)):e=!1,Ni(t,n),sw(t,r,i),Cf(t,r,i,n),Tf(null,t,r,!0,e,n);case 19:return dw(e,t,n);case 22:return lw(e,t,n)}throw Error(J(156,t.tag))};function Ew(e,t){return ey(e,t)}function nE(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nn(e,t,n,r){return new nE(e,t,n,r)}function Ip(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sE(e){if(typeof e=="function")return Ip(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Jh)return 11;if(e===Xh)return 14}return 2}function tr(e,t){var n=e.alternate;return n===null?(n=Nn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function La(e,t,n,r,i,o){var l=2;if(r=e,typeof e=="function")Ip(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case ci:return Tr(n.children,i,o,t);case Qh:l=8,i|=8;break;case qd:return e=Nn(12,n,t,i|2),e.elementType=qd,e.lanes=o,e;case Qd:return e=Nn(13,n,t,i),e.elementType=Qd,e.lanes=o,e;case Jd:return e=Nn(19,n,t,i),e.elementType=Jd,e.lanes=o,e;case Dj:return Qc(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case _j:l=10;break e;case Oj:l=9;break e;case Jh:l=11;break e;case Xh:l=14;break e;case zs:l=16,r=null;break e}throw Error(J(130,e==null?e:typeof e,""))}return t=Nn(l,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Tr(e,t,n,r){return e=Nn(7,e,r,t),e.lanes=n,e}function Qc(e,t,n,r){return e=Nn(22,e,r,t),e.elementType=Dj,e.lanes=n,e.stateNode={isHidden:!1},e}function nd(e,t,n){return e=Nn(6,e,null,t),e.lanes=n,e}function sd(e,t,n){return t=Nn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function rE(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Du(0),this.expirationTimes=Du(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Du(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Mp(e,t,n,r,i,o,l,a,c){return e=new rE(e,t,n,a,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Nn(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},gp(o),e}function iE(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ai,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function Aw(e){if(!e)return or;e=e._reactInternals;e:{if(Wr(e)!==e||e.tag!==1)throw Error(J(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(tn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(J(171))}if(e.tag===1){var n=e.type;if(tn(n))return Ay(e,n,t)}return t}function Tw(e,t,n,r,i,o,l,a,c){return e=Mp(n,r,!0,e,i,o,l,a,c),e.context=Aw(null),n=e.current,r=Ht(),i=er(n),o=ys(r,i),o.callback=t??null,Xs(n,o,i),e.current.lanes=i,vl(e,i,r),nn(e,r),e}function Jc(e,t,n,r){var i=t.current,o=Ht(),l=er(i);return n=Aw(n),t.context===null?t.context=n:t.pendingContext=n,t=ys(o,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Xs(i,t,l),e!==null&&(Un(e,i,l,o),Ia(e,i,l)),l}function wc(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Px(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function $p(e,t){Px(e,t),(e=e.alternate)&&Px(e,t)}function oE(){return null}var Rw=typeof reportError=="function"?reportError:function(e){console.error(e)};function _p(e){this._internalRoot=e}Xc.prototype.render=_p.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(J(409));Jc(e,t,null,null)};Xc.prototype.unmount=_p.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Or(function(){Jc(null,e,null,null)}),t[Ns]=null}};function Xc(e){this._internalRoot=e}Xc.prototype.unstable_scheduleHydration=function(e){if(e){var t=ly();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ws.length&&t!==0&&t<Ws[n].priority;n++);Ws.splice(n,0,e),n===0&&cy(e)}};function Op(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Zc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Ix(){}function lE(e,t,n,r,i){if(i){if(typeof r=="function"){var o=r;r=function(){var u=wc(l);o.call(u)}}var l=Tw(t,r,e,0,null,!1,!1,"",Ix);return e._reactRootContainer=l,e[Ns]=l.current,Jo(e.nodeType===8?e.parentNode:e),Or(),l}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var u=wc(c);a.call(u)}}var c=Mp(e,0,!1,null,null,!1,!1,"",Ix);return e._reactRootContainer=c,e[Ns]=c.current,Jo(e.nodeType===8?e.parentNode:e),Or(function(){Jc(t,c,n,r)}),c}function eu(e,t,n,r,i){var o=n._reactRootContainer;if(o){var l=o;if(typeof i=="function"){var a=i;i=function(){var c=wc(l);a.call(c)}}Jc(t,l,e,i)}else l=lE(n,t,e,i,r);return wc(l)}iy=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=To(t.pendingLanes);n!==0&&(tp(t,n|1),nn(t,ot()),!(Pe&6)&&(Di=ot()+500,pr()))}break;case 13:Or(function(){var r=Cs(e,1);if(r!==null){var i=Ht();Un(r,e,1,i)}}),$p(e,1)}};np=function(e){if(e.tag===13){var t=Cs(e,134217728);if(t!==null){var n=Ht();Un(t,e,134217728,n)}$p(e,134217728)}};oy=function(e){if(e.tag===13){var t=er(e),n=Cs(e,t);if(n!==null){var r=Ht();Un(n,e,t,r)}$p(e,t)}};ly=function(){return Le};ay=function(e,t){var n=Le;try{return Le=e,t()}finally{Le=n}};af=function(e,t,n){switch(t){case"input":if(ef(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=Hc(r);if(!i)throw Error(J(90));Fj(r),ef(r,i)}}}break;case"textarea":zj(e,n);break;case"select":t=n.value,t!=null&&wi(e,!!n.multiple,t,!1)}};Yj=Tp;qj=Or;var aE={usingClientEntryPoint:!1,Events:[yl,hi,Hc,Kj,Gj,Tp]},wo={findFiberByHostInstance:Nr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},cE={bundleType:wo.bundleType,version:wo.version,rendererPackageName:wo.rendererPackageName,rendererConfig:wo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ms.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Xj(e),e===null?null:e.stateNode},findFiberByHostInstance:wo.findFiberByHostInstance||oE,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var sa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sa.isDisabled&&sa.supportsFiber)try{Uc=sa.inject(cE),ts=sa}catch{}}vn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=aE;vn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Op(t))throw Error(J(200));return iE(e,t,null,n)};vn.createRoot=function(e,t){if(!Op(e))throw Error(J(299));var n=!1,r="",i=Rw;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Mp(e,1,!1,null,null,n,!1,r,i),e[Ns]=t.current,Jo(e.nodeType===8?e.parentNode:e),new _p(t)};vn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(J(188)):(e=Object.keys(e).join(","),Error(J(268,e)));return e=Xj(t),e=e===null?null:e.stateNode,e};vn.flushSync=function(e){return Or(e)};vn.hydrate=function(e,t,n){if(!Zc(t))throw Error(J(200));return eu(null,e,t,!0,n)};vn.hydrateRoot=function(e,t,n){if(!Op(e))throw Error(J(405));var r=n!=null&&n.hydratedSources||null,i=!1,o="",l=Rw;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(l=n.onRecoverableError)),t=Tw(t,null,e,1,n??null,i,!1,o,l),e[Ns]=t.current,Jo(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Xc(t)};vn.render=function(e,t,n){if(!Zc(t))throw Error(J(200));return eu(null,e,t,!1,n)};vn.unmountComponentAtNode=function(e){if(!Zc(e))throw Error(J(40));return e._reactRootContainer?(Or(function(){eu(null,null,e,!1,function(){e._reactRootContainer=null,e[Ns]=null})}),!0):!1};vn.unstable_batchedUpdates=Tp;vn.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Zc(n))throw Error(J(200));if(e==null||e._reactInternals===void 0)throw Error(J(38));return eu(e,t,n,!1,r)};vn.version="18.3.1-next-f1338f8080-20240426";function Pw(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Pw)}catch(e){console.error(e)}}Pw(),Pj.exports=vn;var Li=Pj.exports,Iw,Mx=Li;Iw=Mx.createRoot,Mx.hydrateRoot;var uE=Object.defineProperty,Zi=(e,t)=>uE(e,"name",{value:t,configurable:!0}),Mw=!!(typeof window<"u"&&window.document&&window.document.createElement);function we(e,t,{checkForDefaultPrevented:n=!0}={}){return Zi(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}Zi(we,"composeEventHandlers");function dE(e){var t;if(!Mw)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Zi(dE,"getOwnerWindow");function zf(e){if(!Mw)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Zi(zf,"getOwnerDocument");function $w(e,t=!1){const{activeElement:n}=zf(e);if(!(n!=null&&n.nodeName))return null;if(_w(n)&&n.contentDocument)return $w(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=zf(n).getElementById(r);if(i)return i}}return n}Zi($w,"getActiveElement");function _w(e){return e.tagName==="IFRAME"}Zi(_w,"isFrame");var fE=Object.defineProperty,Dp=(e,t)=>fE(e,"name",{value:t,configurable:!0});function Bf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Dp(Bf,"setRef");function Ow(...e){return t=>{let n=!1;const r=e.map(i=>{const o=Bf(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){const o=r[i];typeof o=="function"?o():Bf(e[i],null)}}}}Dp(Ow,"composeRefs");function Ze(...e){return d.useCallback(Ow(...e),e)}Dp(Ze,"useComposedRefs");var hE=Object.defineProperty,Sn=(e,t)=>hE(e,"name",{value:t,configurable:!0});function pE(e,t){const n=d.createContext(t);n.displayName=e+"Context";const r=Sn(o=>{const{children:l,...a}=o,c=d.useMemo(()=>a,Object.values(a));return s.jsx(n.Provider,{value:c,children:l})},"Provider");r.displayName=e+"Provider";function i(o,l={}){const{optional:a=!1}=l,c=d.useContext(n);if(c)return c;if(t!==void 0)return t;if(!a)throw new Error(`\`${o}\` must be used within \`${e}\``)}return Sn(i,"useContext"),[r,i]}Sn(pE,"createContext");function Wn(e,t=[]){let n=[];function r(o,l){const a=d.createContext(l);a.displayName=o+"Context";const c=n.length;n=[...n,l];const u=Sn(f=>{var x;const{scope:h,children:v,...j}=f,w=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,b=d.useMemo(()=>j,Object.values(j));return s.jsx(w.Provider,{value:b,children:v})},"Provider");u.displayName=o+"Provider";function p(f,h,v={}){var x;const{optional:j=!1}=v,w=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,b=d.useContext(w);if(b)return b;if(l!==void 0)return l;if(!j)throw new Error(`\`${f}\` must be used within \`${o}\``)}return Sn(p,"useContext"),[u,p]}Sn(r,"createContext");const i=Sn(()=>{const o=n.map(l=>d.createContext(l));return Sn(function(a){const c=(a==null?void 0:a[e])||o;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])},"useScope")},"createScope");return i.scopeName=e,[r,Dw(i,...t)]}Sn(Wn,"createContextScope");function Dw(...e){const t=e[0];if(e.length===1)return t;const n=Sn(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Sn(function(o){const l=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(o)[`__scope${u}`];return{...a,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Sn(Dw,"composeContextScopes");var mE=Object.defineProperty,Hn=(e,t)=>mE(e,"name",{value:t,configurable:!0});function lr(e){const t=d.forwardRef((n,r)=>{let{children:i,...o}=n,l=null,a=!1;const c=[];Wf(i)&&typeof ra=="function"&&(i=ra(i._payload)),d.Children.forEach(i,h=>{var v;if(Bw(h)){a=!0;const j=h;let w="child"in j.props?j.props.child:j.props.children;Wf(w)&&typeof ra=="function"&&(w=ra(w._payload)),l=gE(j,w),c.push((v=l==null?void 0:l.props)==null?void 0:v.children)}else c.push(h)}),l?l=d.cloneElement(l,void 0,c):!a&&d.Children.count(i)===1&&d.isValidElement(i)&&(l=i);const u=l?zw(l):void 0,p=Ze(r,u);if(!l){if(i||i===0)throw new Error(a?jE(e):vE(e));return i}const f=Uw(o,l.props??{});return l.type!==d.Fragment&&(f.ref=r?p:u),d.cloneElement(l,f)});return t.displayName=`${e}.Slot`,t}Hn(lr,"createSlot");var Lw=Symbol.for("radix.slottable");function Fw(e){const t=Hn(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Lw,t}Hn(Fw,"createSlottable");var gE=Hn((e,t)=>{if("child"in e.props){const n=e.props.child;return d.isValidElement(n)?d.cloneElement(n,void 0,e.props.children(n.props.children)):null}return d.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Uw(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...a)=>{const c=o(...a);return i(...a),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}Hn(Uw,"mergeProps");function zw(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Hn(zw,"getElementRef");function Bw(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lw}Hn(Bw,"isSlottable");var xE=Symbol.for("react.lazy");function Wf(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===xE&&"_payload"in e&&Ww(e._payload)}Hn(Wf,"isLazyComponent");function Ww(e){return typeof e=="object"&&e!==null&&"then"in e}Hn(Ww,"isPromiseLike");var vE=Hn(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),jE=Hn(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),ra=Qi[" use ".trim().toString()],yE=Object.defineProperty,jt=(e,t)=>yE(e,"name",{value:t,configurable:!0});function tu(e){const t=e+"CollectionProvider",[n,r]=Wn(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=jt(w=>{const{scope:b,children:x}=w,g=d.useRef(null),y=d.useRef(new Map).current;return s.jsx(i,{scope:b,itemMap:y,collectionRef:g,children:x})},"CollectionProvider");l.displayName=t;const a=e+"CollectionSlot",c=lr(a),u=d.forwardRef((w,b)=>{const{scope:x,children:g}=w,y=o(a,x),m=Ze(b,y.collectionRef);return s.jsx(c,{ref:m,children:g})});u.displayName=a;const p=e+"CollectionItemSlot",f="data-radix-collection-item",h=lr(p),v=d.forwardRef((w,b)=>{const{scope:x,children:g,...y}=w,m=d.useRef(null),S=Ze(b,m),k=o(p,x);return d.useEffect(()=>(k.itemMap.set(m,{ref:m,...y}),()=>void k.itemMap.delete(m))),s.jsx(h,{[f]:"",ref:S,children:g})});v.displayName=p;function j(w){const b=o(e+"CollectionConsumer",w);return d.useCallback(()=>{const g=b.collectionRef.current;if(!g)return[];const y=Array.from(g.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((k,N)=>y.indexOf(k.ref.current)-y.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return jt(j,"useCollection"),[{Provider:l,Slot:u,ItemSlot:v},j,r]}jt(tu,"createCollection");var $x=new WeakMap,ut,hn,rd=(hn=class extends Map{constructor(n){super(n);Sg(this,ut);Pu(this,ut,[...super.keys()]),$x.set(this,!0)}set(n,r){return $x.get(this)&&(this.has(n)?Mt(this,ut)[Mt(this,ut).indexOf(n)]=n:Mt(this,ut).push(n)),super.set(n,r),this}insert(n,r,i){const o=this.has(r),l=Mt(this,ut).length,a=Lp(n);let c=a>=0?a:l+a;const u=c<0||c>=l?-1:c;if(u===this.size||o&&u===this.size-1||u===-1)return this.set(r,i),this;const p=this.size+(o?0:1);a<0&&c++;const f=[...Mt(this,ut)];let h,v=!1;for(let j=c;j<p;j++)if(c===j){let w=f[j];f[j]===r&&(w=f[j+1]),o&&this.delete(r),h=this.get(w),this.set(r,i)}else{!v&&f[j-1]===r&&(v=!0);const w=f[v?j:j-1],b=h;h=this.get(w),this.delete(w),this.set(w,b)}return this}with(n,r,i){const o=new hn(this);return o.insert(n,r,i),o}before(n){const r=Mt(this,ut).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,i){const o=Mt(this,ut).indexOf(n);return o===-1?this:this.insert(o,r,i)}after(n){let r=Mt(this,ut).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,i){const o=Mt(this,ut).indexOf(n);return o===-1?this:this.insert(o+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Pu(this,ut,[]),super.clear()}delete(n){const r=super.delete(n);return r&&Mt(this,ut).splice(Mt(this,ut).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=Fa(Mt(this,ut),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=Fa(Mt(this,ut),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return Mt(this,ut).indexOf(n)}keyAt(n){return Fa(Mt(this,ut),n)}from(n,r){const i=this.indexOf(n);if(i===-1)return;let o=i+r;return o<0&&(o=0),o>=this.size&&(o=this.size-1),this.at(o)}keyFrom(n,r){const i=this.indexOf(n);if(i===-1)return;let o=i+r;return o<0&&(o=0),o>=this.size&&(o=this.size-1),this.keyAt(o)}find(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return o;i++}}findIndex(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return i;i++}return-1}filter(n,r){const i=[];let o=0;for(const l of this)Reflect.apply(n,r,[l,o,this])&&i.push(l),o++;return new hn(i)}map(n,r){const i=[];let o=0;for(const l of this)i.push([l[0],Reflect.apply(n,r,[l,o,this])]),o++;return new hn(i)}reduce(...n){const[r,i]=n;let o=0,l=i??this.at(0);for(const a of this)o===0&&n.length===1?l=a:l=Reflect.apply(r,this,[l,a,o,this]),o++;return l}reduceRight(...n){const[r,i]=n;let o=i??this.at(-1);for(let l=this.size-1;l>=0;l--){const a=this.at(l);l===this.size-1&&n.length===1?o=a:o=Reflect.apply(r,this,[o,a,l,this])}return o}toSorted(n){const r=[...this.entries()].sort(n);return new hn(r)}toReversed(){const n=new hn;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),o=this.get(i);n.set(i,o)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new hn(r)}slice(n,r){const i=new hn;let o=this.size-1;if(n===void 0)return i;n<0&&(n=n+this.size),r!==void 0&&r>0&&(o=r-1);for(let l=n;l<=o;l++){const a=this.keyAt(l),c=this.get(a);i.set(a,c)}return i}every(n,r){let i=0;for(const o of this){if(!Reflect.apply(n,r,[o,i,this]))return!1;i++}return!0}some(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return!0;i++}return!1}},ut=new WeakMap,jt(hn,"OrderedDict"),hn);function Fa(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Hw(e,t);return n===-1?void 0:e[n]}jt(Fa,"at");function Hw(e,t){const n=e.length,r=Lp(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}jt(Hw,"toSafeIndex");function Lp(e){return e!==e||e===0?0:Math.trunc(e)}jt(Lp,"toSafeInteger");function wE(e){const t=e+"CollectionProvider",[n,r]=Wn(t),[i,o]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new rd,setItemMap:jt(()=>{},"setItemMap")}),l=jt(({state:y,...m})=>y?s.jsx(c,{...m,state:y}):s.jsx(a,{...m}),"CollectionProvider");l.displayName=t;const a=jt(y=>{const m=b();return s.jsx(c,{...y,state:m})},"CollectionInit");a.displayName=t+"Init";const c=jt(y=>{const{scope:m,children:S,state:k}=y,N=d.useRef(null),[C,P]=d.useState(null),E=Ze(N,P),[O,F]=k;return d.useEffect(()=>{if(!C)return;const D=Gw(()=>{});return D.observe(C,{childList:!0,subtree:!0}),()=>{D.disconnect()}},[C]),s.jsx(i,{scope:m,itemMap:O,setItemMap:F,collectionRef:E,collectionRefObject:N,collectionElement:C,children:S})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",p=lr(u),f=d.forwardRef((y,m)=>{const{scope:S,children:k}=y,N=o(u,S),C=Ze(m,N.collectionRef);return s.jsx(p,{ref:C,children:k})});f.displayName=u;const h=e+"CollectionItemSlot",v="data-radix-collection-item",j=lr(h),w=d.forwardRef((y,m)=>{const{scope:S,children:k,...N}=y,C=d.useRef(null),[P,E]=d.useState(null),O=Ze(m,C,E),F=o(h,S),{setItemMap:D}=F,T=d.useRef(N);Vw(T.current,N)||(T.current=N);const z=T.current;return d.useEffect(()=>{const Q=z;return D(Y=>P?Y.has(P)?Y.set(P,{...Q,element:P}).toSorted(Hf):(Y.set(P,{...Q,element:P}),Y.toSorted(Hf)):Y),()=>{D(Y=>!P||!Y.has(P)?Y:(Y.delete(P),new rd(Y)))}},[P,z,D]),s.jsx(j,{[v]:"",ref:O,children:k})});w.displayName=h;function b(){return d.useState(new rd)}jt(b,"useInitCollection");function x(y){const{itemMap:m}=o(e+"CollectionConsumer",y);return m}return jt(x,"useCollection"),[{Provider:l,Slot:f,ItemSlot:w},{createCollectionScope:r,useCollection:x,useInitCollection:b}]}jt(wE,"createCollection");function Vw(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}jt(Vw,"shallowEqual");function Kw(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}jt(Kw,"isElementPreceding");function Hf(e,t){return!e[1].element||!t[1].element?0:Kw(e[1].element,t[1].element)?-1:1}jt(Hf,"sortByDocumentPosition");function Gw(e){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){e();return}})}jt(Gw,"getChildListObserver");var bE=Object.defineProperty,kE=(e,t)=>bE(e,"name",{value:t,configurable:!0}),SE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],tt=SE.reduce((e,t)=>{const n=lr(`Primitive.${t}`),r=d.forwardRef((i,o)=>{const{asChild:l,...a}=i,c=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...a,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function nu(e,t){e&&Li.flushSync(()=>e.dispatchEvent(t))}kE(nu,"dispatchDiscreteCustomEvent");var NE=Object.defineProperty,CE=(e,t)=>NE(e,"name",{value:t,configurable:!0});function Bn(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}CE(Bn,"useCallbackRef");var EE=Object.defineProperty,pt=(e,t)=>EE(e,"name",{value:t,configurable:!0}),Vf="dismissableLayer.update",AE="dismissableLayer.pointerDownOutside",TE="dismissableLayer.focusOutside",_x,Fp=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Up=d.forwardRef(pt(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:a,onInteractOutside:c,onDismiss:u,...p}=t,f=d.useContext(Fp),[h,v]=d.useState(null),j=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=d.useState({}),b=Ze(n,v),x=Array.from(f.layers),[g]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=g?x.indexOf(g):-1,m=h?x.indexOf(h):-1,S=f.layersWithOutsidePointerEventsDisabled.size>0,k=m>=y,N=d.useRef(!1),C=qw(F=>{l==null||l(F),c==null||c(F),F.defaultPrevented||u==null||u()},{ownerDocument:j,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:N,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(F=>{if(!(F instanceof Node))return!1;const D=[...f.branches].some(T=>T.contains(F));return k&&!D},[f.branches,k])}),P=Qw(F=>{if(i&&N.current)return;const D=F.target;[...f.branches].some(z=>z.contains(D))||(a==null||a(F),c==null||c(F),F.defaultPrevented||u==null||u())},j),E=h?m===x.length-1:!1,O=Bn(F=>{F.key==="Escape"&&(o==null||o(F),!F.defaultPrevented&&u&&(F.preventDefault(),u()))});return d.useEffect(()=>{if(E)return j.addEventListener("keydown",O,{capture:!0}),()=>j.removeEventListener("keydown",O,{capture:!0})},[j,E,O]),d.useEffect(()=>{if(h)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(_x=j.body.style.pointerEvents,j.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(h)),f.layers.add(h),Kf(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(h),f.layersWithOutsidePointerEventsDisabled.size===0&&(j.body.style.pointerEvents=_x))}},[h,j,r,f]),d.useEffect(()=>()=>{h&&(f.layers.delete(h),f.layersWithOutsidePointerEventsDisabled.delete(h),Kf())},[h,f]),d.useEffect(()=>{const F=pt(()=>w({}),"handleUpdate");return document.addEventListener(Vf,F),()=>document.removeEventListener(Vf,F)},[]),s.jsx(tt.div,{...p,ref:b,style:{pointerEvents:S?k?"auto":"none":void 0,...t.style},onFocusCapture:we(t.onFocusCapture,P.onFocusCapture),onBlurCapture:we(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:we(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),RE=d.forwardRef(pt(function(t,n){const r=d.useContext(Fp),i=d.useRef(null),o=Ze(n,i);return d.useEffect(()=>{const l=i.current;if(l)return r.branches.add(l),()=>{r.branches.delete(l)}},[r.branches]),s.jsx(tt.div,{...t,ref:o})},"DismissableLayerBranch"));function Yw(){const e=d.useContext(Fp),[t,n]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}pt(Yw,"useDismissableLayerSurface");var PE=pt(()=>!0,"IS_TRUE");function qw(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:o,shouldHandlePointerDownOutside:l=PE}=t,a=Bn(e),c=d.useRef(!1),u=d.useRef(!1),p=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function h(){u.current=!1,i.current=!1,p.current.clear()}pt(h,"resetOutsideInteraction");function v(){return Array.from(p.current.values()).some(Boolean)}pt(v,"isOutsideInteractionIntercepted");function j(y){if(!u.current)return;const m=y.target;m instanceof Node&&[...o].some(k=>k.contains(m))||p.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}pt(j,"handleInteractionCapture");function w(y){u.current&&p.current.set(y.type,!1)}pt(w,"handleInteractionBubble");const b=pt(y=>{if(y.target&&!c.current){let m=function(){n.removeEventListener("click",f.current);const k=v();h(),k||zp(AE,a,S,{discrete:!0})};if(pt(m,"handleAndDispatchPointerDownOutsideEvent"),!l(y.target)){n.removeEventListener("click",f.current),h(),c.current=!1;return}const S={originalEvent:y};u.current=!0,i.current=r&&y.button===0,p.current.clear(),!r||y.button!==0?m():(n.removeEventListener("click",f.current),f.current=m,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),h();c.current=!1},"handlePointerDown"),x=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of x)n.addEventListener(y,j,!0),n.addEventListener(y,w);const g=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(g),n.removeEventListener("pointerdown",b),n.removeEventListener("click",f.current);for(const y of x)n.removeEventListener(y,j,!0),n.removeEventListener(y,w)}},[n,a,r,i,o,l]),{onPointerDownCapture:pt(()=>c.current=!0,"onPointerDownCapture")}}pt(qw,"usePointerDownOutside");function Qw(e,t=globalThis==null?void 0:globalThis.document){const n=Bn(e),r=d.useRef(!1);return d.useEffect(()=>{const i=pt(o=>{o.target&&!r.current&&zp(TE,n,{originalEvent:o},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:pt(()=>r.current=!0,"onFocusCapture"),onBlurCapture:pt(()=>r.current=!1,"onBlurCapture")}}pt(Qw,"useFocusOutside");function Kf(){const e=new CustomEvent(Vf);document.dispatchEvent(e)}pt(Kf,"dispatchUpdate");function zp(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?nu(i,o):i.dispatchEvent(o)}pt(zp,"handleAndDispatchCustomEvent");var IE=RE,sn=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},ME=Object.defineProperty,$E=(e,t)=>ME(e,"name",{value:t,configurable:!0}),Bp=d.forwardRef($E(function(t,n){var c;const{container:r,...i}=t,[o,l]=d.useState(!1);sn(()=>l(!0),[]);const a=r||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?Li.createPortal(s.jsx(tt.div,{...i,ref:n}),a):null},"Portal")),_E=Object.defineProperty,As=(e,t)=>_E(e,"name",{value:t,configurable:!0});function Jw(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}As(Jw,"useStateMachine");var mr=As(e=>{const{present:t,children:n}=e,r=Xw(t),i=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),o=Zw(r.ref,eb(i));return typeof n=="function"||r.isPresent?d.cloneElement(i,{ref:o}):null},"Presence");function Xw(e){const[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),o=d.useRef("none"),l=d.useRef(void 0),a=e?"mounted":"unmounted",[c,u]=Jw(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{c==="mounted"?(o.current=l.current??li(r.current),l.current=void 0):o.current="none"},[c]),sn(()=>{const p=r.current,f=i.current;if(f!==e){const v=o.current,j=li(p);e?(l.current=j,u("MOUNT")):j==="none"||(p==null?void 0:p.display)==="none"?u("UNMOUNT"):u(f&&v!==j?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),sn(()=>{if(t){let p;const f=t.ownerDocument.defaultView??window,h=As(j=>{const b=li(r.current).includes(CSS.escape(j.animationName));if(j.target===t&&b&&(u("ANIMATION_END"),!i.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",p=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},"handleAnimationEnd"),v=As(j=>{j.target===t&&(o.current=li(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(p),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:d.useCallback(p=>{if(p){const f=getComputedStyle(p);r.current=f,l.current=li(f)}else r.current=null;n(p)},[])}}As(Xw,"usePresence");function Gf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}As(Gf,"setRef");function Zw(...e){const t=d.useRef(e);return t.current=e,d.useCallback(n=>{const r=t.current;let i=!1;const o=r.map(l=>{const a=Gf(l,n);return!i&&typeof a=="function"&&(i=!0),a});if(i)return()=>{for(let l=0;l<o.length;l++){const a=o[l];typeof a=="function"?a():Gf(r[l],null)}}},[])}As(Zw,"useStableComposedRefs");function li(e){return(e==null?void 0:e.animationName)||"none"}As(li,"getAnimationName");function eb(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}As(eb,"getElementRef");var OE=Object.defineProperty,DE=(e,t)=>OE(e,"name",{value:t,configurable:!0}),Ox=Qi[" useEffectEvent ".trim().toString()],Dx=Qi[" useInsertionEffect ".trim().toString()];function tb(e){if(typeof Ox=="function")return Ox(e);const t=d.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Dx=="function"?Dx(()=>{t.current=e}):sn(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}DE(tb,"useEffectEvent");var LE=Object.defineProperty,bl=(e,t)=>LE(e,"name",{value:t,configurable:!0}),FE=Qi[" useInsertionEffect ".trim().toString()]||sn;function eo({prop:e,defaultProp:t,onChange:n=bl(()=>{},"onChange"),caller:r}){const[i,o,l]=nb({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:i,u=d.useCallback(p=>{var f;if(a){const h=sb(p)?p(e):p;h!==e&&((f=l.current)==null||f.call(l,h))}else o(p)},[a,e,o,l]);return[c,u]}bl(eo,"useControllableState");function nb({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),i=d.useRef(n),o=d.useRef(t);return FE(()=>{o.current=t},[t]),d.useEffect(()=>{var l;i.current!==n&&((l=o.current)==null||l.call(o,n),i.current=n)},[n,i]),[n,r,o]}bl(nb,"useUncontrolledState");function sb(e){return typeof e=="function"}bl(sb,"isFunction");var Lx=Symbol("RADIX:SYNC_STATE");function UE(e,t,n,r){const{prop:i,defaultProp:o,onChange:l,caller:a}=t,c=i!==void 0,u=tb(l),p=[{...n,state:o}];r&&p.push(r);const[f,h]=d.useReducer((b,x)=>{if(x.type===Lx)return{...b,state:x.state};const g=e(b,x);return c&&!Object.is(g.state,b.state)&&u(g.state),g},...p),v=f.state,j=d.useRef(v);d.useEffect(()=>{j.current!==v&&(j.current=v,c||u(v))},[v,j,c]);const w=d.useMemo(()=>i!==void 0?{...f,state:i}:f,[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&h({type:Lx,state:i})},[i,f.state,c]),[w,h]}bl(UE,"useControllableStateReducer");var zE=Object.defineProperty,BE=(e,t)=>zE(e,"name",{value:t,configurable:!0}),WE=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),rb=d.forwardRef(BE(function(t,n){return s.jsx(tt.span,{...t,ref:n,style:{...WE,...t.style}})},"VisuallyHidden")),HE=rb,VE=Object.defineProperty,Ot=(e,t)=>VE(e,"name",{value:t,configurable:!0}),ib="ToastProvider",[ob,KE,GE]=tu("Toast"),[lb,v6]=Wn("Toast",[GE]),[YE,ab]=lb(ib),qE=Ot(e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:o=50,announcerContainer:l,children:a}=e,[c,u]=d.useState(null),[p,f]=d.useState(0),h=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${ib}\`. Expected non-empty \`string\`.`),s.jsx(ob.Provider,{scope:t,children:s.jsx(YE,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:o,toastCount:p,viewport:c,onViewportChange:u,onToastAdd:d.useCallback(()=>f(v=>v+1),[]),onToastRemove:d.useCallback(()=>f(v=>v-1),[]),isClosePausedRef:h,announcerContainer:l,children:a})})},"ToastProvider"),QE="ToastViewport",JE=["F8"],XE="toast.viewportPause",ZE="toast.viewportResume",eA=d.forwardRef(Ot(function(t,n){const{__scopeToast:r,hotkey:i=JE,label:o="Notifications ({hotkey})",...l}=t,a=ab(QE,r),c=KE(r),u=d.useRef(null),p=d.useRef(null),f=d.useRef(null),h=d.useRef(null),v=Ze(n,h,a.onViewportChange),j=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=a.toastCount>0;d.useEffect(()=>{const x=Ot(g=>{var m;i.length!==0&&i.every(S=>g[S]||g.code===S)&&((m=h.current)==null||m.focus())},"handleKeyDown");return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[i]),d.useEffect(()=>{const x=u.current,g=h.current;if(w&&x&&g){const y=Ot(()=>{if(!a.isClosePausedRef.current){const N=new CustomEvent(XE);g.dispatchEvent(N),a.isClosePausedRef.current=!0}},"handlePause"),m=Ot(()=>{if(a.isClosePausedRef.current){const N=new CustomEvent(ZE);g.dispatchEvent(N),a.isClosePausedRef.current=!1}},"handleResume"),S=Ot(N=>{!x.contains(N.relatedTarget)&&m()},"handleFocusOutResume"),k=Ot(()=>{x.contains(document.activeElement)||m()},"handlePointerLeaveResume");return x.addEventListener("focusin",y),x.addEventListener("focusout",S),x.addEventListener("pointermove",y),x.addEventListener("pointerleave",k),window.addEventListener("blur",y),window.addEventListener("focus",m),()=>{x.removeEventListener("focusin",y),x.removeEventListener("focusout",S),x.removeEventListener("pointermove",y),x.removeEventListener("pointerleave",k),window.removeEventListener("blur",y),window.removeEventListener("focus",m)}}},[w,a.isClosePausedRef]);const b=d.useCallback(({tabbingDirection:x})=>{const y=c().map(m=>{const S=m.ref.current,k=[S,...db(S)];return x==="forwards"?k:k.reverse()});return(x==="forwards"?y.reverse():y).flat()},[c]);return d.useEffect(()=>{const x=h.current;if(x){const g=Ot(y=>{var k,N,C;const m=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!m){const P=document.activeElement,E=y.shiftKey;if(y.target===x&&E){(k=p.current)==null||k.focus();return}const D=b({tabbingDirection:E?"backwards":"forwards"}),T=D.findIndex(z=>z===P);Ua(D.slice(T+1))?y.preventDefault():E?(N=p.current)==null||N.focus():(C=f.current)==null||C.focus()}},"handleKeyDown");return x.addEventListener("keydown",g),()=>x.removeEventListener("keydown",g)}},[c,b]),s.jsxs(IE,{ref:u,role:"region","aria-label":o.replace("{hotkey}",j),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&s.jsx(Fx,{ref:p,onFocusFromOutsideViewport:()=>{const x=b({tabbingDirection:"forwards"});Ua(x)}}),s.jsx(ob.Slot,{scope:r,children:s.jsx(tt.ol,{tabIndex:-1,...l,ref:v})}),w&&s.jsx(Fx,{ref:f,onFocusFromOutsideViewport:()=>{const x=b({tabbingDirection:"backwards"});Ua(x)}})]})},"ToastViewport")),tA="ToastFocusProxy",Fx=d.forwardRef(Ot(function(t,n){const{__scopeToast:r,onFocusFromOutsideViewport:i,...o}=t,l=ab(tA,r);return s.jsx(rb,{tabIndex:0,...o,ref:n,style:{position:"fixed"},onFocus:a=>{var p;const c=a.relatedTarget;!((p=l.viewport)!=null&&p.contains(c))&&i()}})},"ToastFocusProxy")),nA="Toast",[j6,y6]=lb(nA,{onClose(){}});function cb(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),ub(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",o=r.dataset.radixToastAnnounceExclude==="";if(!i)if(o){const l=r.dataset.radixToastAnnounceAlt;l&&t.push(l)}else t.push(...cb(r))}}),t}Ot(cb,"getAnnounceTextContent");function sA(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?nu(i,o):i.dispatchEvent(o)}Ot(sA,"handleAndDispatchCustomEvent");function rA(e=()=>{}){const t=Bn(e);sn(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}Ot(rA,"useNextFrame");function ub(e){return e.nodeType===e.ELEMENT_NODE}Ot(ub,"isHTMLElement");function db(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Ot(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Ot(db,"getTabbableCandidates");function Ua(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}Ot(Ua,"focusFirst");var Ux=qE,zx=eA,iA=Object.defineProperty,oA=(e,t)=>iA(e,"name",{value:t,configurable:!0}),lA=Qi[" useId ".trim().toString()]||(()=>{}),aA=0;function ws(e){const[t,n]=d.useState(lA());return sn(()=>{e||n(r=>r??String(aA++))},[e]),e||(t?`radix-${t}`:"")}oA(ws,"useId");const cA=["top","right","bottom","left"],ar=Math.min,bs=Math.max,bc=Math.round,ia=Math.floor,ks=e=>({x:e,y:e}),uA={left:"right",right:"left",bottom:"top",top:"bottom"};function fb(e,t,n){return bs(e,ar(t,n))}function Ts(e,t){return typeof e=="function"?e(t):e}function cr(e){return e.split("-")[0]}function to(e){return e.split("-")[1]}function Wp(e){return e==="x"?"y":"x"}function Hp(e){return e==="y"?"height":"width"}function Zn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Vp(e){return Wp(Zn(e))}function dA(e,t,n){n===void 0&&(n=!1);const r=to(e),i=Vp(e),o=Hp(i);let l=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(l=kc(l)),[l,kc(l)]}function fA(e){const t=kc(e);return[Yf(e),t,Yf(t)]}function Yf(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Bx=["left","right"],Wx=["right","left"],hA=["top","bottom"],pA=["bottom","top"];function mA(e,t,n){switch(e){case"top":case"bottom":return n?t?Wx:Bx:t?Bx:Wx;case"left":case"right":return t?hA:pA;default:return[]}}function gA(e,t,n,r){const i=to(e);let o=mA(cr(e),n==="start",r);return i&&(o=o.map(l=>l+"-"+i),t&&(o=o.concat(o.map(Yf)))),o}function kc(e){const t=cr(e);return uA[t]+e.slice(t.length)}function xA(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function hb(e){return typeof e!="number"?xA(e):{top:e,right:e,bottom:e,left:e}}function Sc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Hx(e,t,n){let{reference:r,floating:i}=e;const o=Zn(t),l=Vp(t),a=Hp(l),c=cr(t),u=o==="y",p=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2;let v;switch(c){case"top":v={x:p,y:r.y-i.height};break;case"bottom":v={x:p,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:f};break;case"left":v={x:r.x-i.width,y:f};break;default:v={x:r.x,y:r.y}}const j=to(t);return j&&(v[l]+=h*(j==="end"?1:-1)*(n&&u?-1:1)),v}async function vA(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:l,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:h=!1,padding:v=0}=Ts(t,e),j=hb(v),b=a[h?f==="floating"?"reference":"floating":f],x=Sc(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:u,rootBoundary:p,strategy:c})),g=f==="floating"?{x:r,y:i,width:l.floating.width,height:l.floating.height}:l.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),m=await(o.isElement==null?void 0:o.isElement(y))&&await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1},S=Sc(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:g,offsetParent:y,strategy:c}):g);return{top:(x.top-S.top+j.top)/m.y,bottom:(S.bottom-x.bottom+j.bottom)/m.y,left:(x.left-S.left+j.left)/m.x,right:(S.right-x.right+j.right)/m.x}}const jA=50,yA=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,a=l.detectOverflow?l:{...l,detectOverflow:vA},c=await(l.isRTL==null?void 0:l.isRTL(t));let u=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:f}=Hx(u,r,c),h=r,v=0;const j={};for(let w=0;w<o.length;w++){const b=o[w];if(!b)continue;const{name:x,fn:g}=b,{x:y,y:m,data:S,reset:k}=await g({x:p,y:f,initialPlacement:r,placement:h,strategy:i,middlewareData:j,rects:u,platform:a,elements:{reference:e,floating:t}});p=y??p,f=m??f,j[x]={...j[x],...S},k&&v<jA&&(v++,typeof k=="object"&&(k.placement&&(h=k.placement),k.rects&&(u=k.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:p,y:f}=Hx(u,h,c)),w=-1)}return{x:p,y:f,placement:h,strategy:i,middlewareData:j}},wA=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:l,elements:a,middlewareData:c}=t,{element:u,padding:p=0}=Ts(e,t)||{};if(u==null)return{};const f=hb(p),h={x:n,y:r},v=Vp(i),j=Hp(v),w=await l.getDimensions(u),b=v==="y",x=b?"top":"left",g=b?"bottom":"right",y=b?"clientHeight":"clientWidth",m=o.reference[j]+o.reference[v]-h[v]-o.floating[j],S=h[v]-o.reference[v],k=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let N=k?k[y]:0;(!N||!await(l.isElement==null?void 0:l.isElement(k)))&&(N=a.floating[y]||o.floating[j]);const C=m/2-S/2,P=N/2-w[j]/2-1,E=ar(f[x],P),O=ar(f[g],P),F=N-w[j]-O,D=N/2-w[j]/2+C,T=fb(E,D,F),z=!c.arrow&&to(i)!=null&&D!==T&&o.reference[j]/2-(D<E?E:O)-w[j]/2<0,Q=z?D<E?D-E:D-F:0;return{[v]:h[v]+Q,data:{[v]:T,centerOffset:D-T-Q,...z&&{alignmentOffset:Q}},reset:z}}}),bA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:l,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:w=!0,...b}=Ts(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const x=cr(i),g=Zn(a),y=cr(a)===a,m=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=h||(y||!w?[kc(a)]:fA(a)),k=j!=="none";!h&&k&&S.push(...gA(a,w,j,m));const N=[a,...S],C=await c.detectOverflow(t,b),P=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&P.push(C[x]),f){const T=dA(i,l,m);P.push(C[T[0]],C[T[1]])}if(E=[...E,{placement:i,overflows:P}],!P.every(T=>T<=0)){var O,F;const T=(((O=o.flip)==null?void 0:O.index)||0)+1,z=N[T];if(z&&(!(f==="alignment"?g!==Zn(z):!1)||E.every(M=>Zn(M.placement)===g?M.overflows[0]>0:!0)))return{data:{index:T,overflows:E},reset:{placement:z}};let Q=(F=E.filter(Y=>Y.overflows[0]<=0).sort((Y,M)=>Y.overflows[1]-M.overflows[1])[0])==null?void 0:F.placement;if(!Q)switch(v){case"bestFit":{var D;const Y=(D=E.filter(M=>{if(k){const B=Zn(M.placement);return B===g||B==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(B=>B>0).reduce((B,$)=>B+$,0)]).sort((M,B)=>M[1]-B[1])[0])==null?void 0:D[0];Y&&(Q=Y);break}case"initialPlacement":Q=a;break}if(i!==Q)return{reset:{placement:Q}}}return{}}}};function Vx(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Kx(e){return cA.some(t=>e[t]>=0)}const kA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...o}=Ts(e,t);switch(i){case"referenceHidden":{const l=await r.detectOverflow(t,{...o,elementContext:"reference"}),a=Vx(l,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Kx(a)}}}case"escaped":{const l=await r.detectOverflow(t,{...o,altBoundary:!0}),a=Vx(l,n.floating);return{data:{escapedOffsets:a,escaped:Kx(a)}}}default:return{}}}}},pb=new Set(["left","top"]);async function SA(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),l=cr(n),a=to(n),c=Zn(n)==="y",u=pb.has(l)?-1:1,p=o&&c?-1:1,f=Ts(t,e);let{mainAxis:h,crossAxis:v,alignmentAxis:j}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof j=="number"&&(v=a==="end"?j*-1:j),c?{x:v*p,y:h*u}:{x:h*u,y:v*p}}const NA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:l,middlewareData:a}=t,c=await SA(t,e);return l===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:l}}}}},CA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:o}=t,{mainAxis:l=!0,crossAxis:a=!1,limiter:c={fn:g=>{let{x:y,y:m}=g;return{x:y,y:m}}},...u}=Ts(e,t),p={x:n,y:r},f=await o.detectOverflow(t,u),h=Zn(i),v=Wp(h);let j=p[v],w=p[h];const b=(g,y)=>fb(y+f[g==="y"?"top":"left"],y,y-f[g==="y"?"bottom":"right"]);l&&(j=b(v,j)),a&&(w=b(h,w));const x=c.fn({...t,[v]:j,[h]:w});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[v]:l,[h]:a}}}}}},EA=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:o,placement:l,rects:a,middlewareData:c}=t,{offset:u=0,mainAxis:p=!0,crossAxis:f=!0}=Ts(e,t),h={x:i,y:o},v=Zn(l),j=Wp(v);let w=h[j],b=h[v];const x=Ts(u,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:(n=x.mainAxis)!=null?n:0,crossAxis:(r=x.crossAxis)!=null?r:0};if(p){const S=j==="y"?"height":"width",k=a.reference[j]-a.floating[S]+g.mainAxis,N=a.reference[j]+a.reference[S]-g.mainAxis;w<k?w=k:w>N&&(w=N)}if(f){var y,m;const S=j==="y"?"width":"height",k=pb.has(cr(l)),N=a.reference[v]-a.floating[S]+(k&&((y=c.offset)==null?void 0:y[v])||0)+(k?0:g.crossAxis),C=a.reference[v]+a.reference[S]+(k?0:((m=c.offset)==null?void 0:m[v])||0)-(k?g.crossAxis:0);b<N?b=N:b>C&&(b=C)}return{[j]:w,[v]:b}}}},AA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:o}=t,{apply:l=()=>{},...a}=Ts(e,t),c=await i.detectOverflow(t,a),u=cr(n),p=to(n),f=Zn(n)==="y",{width:h,height:v}=r.floating;let j,w;u==="top"||u==="bottom"?(j=u,w=p===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(w=u,j=p==="end"?"top":"bottom");const b=v-c.top-c.bottom,x=h-c.left-c.right,g=ar(v-c[j],b),y=ar(h-c[w],x),m=t.middlewareData.shift,S=!m;let k=g,N=y;m!=null&&m.enabled.x&&(N=x),m!=null&&m.enabled.y&&(k=b),S&&!p&&(f?N=h-2*bs(c.left,c.right):k=v-2*bs(c.top,c.bottom)),await l({...t,availableWidth:N,availableHeight:k});const C=await i.getDimensions(o.floating);return h!==C.width||v!==C.height?{reset:{rects:!0}}:{}}}};function su(){return typeof window<"u"}function no(e){return mb(e)?(e.nodeName||"").toLowerCase():"#document"}function rn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function $s(e){var t;return(t=(mb(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mb(e){return su()?e instanceof Node||e instanceof rn(e).Node:!1}function is(e){return su()?e instanceof Element||e instanceof rn(e).Element:!1}function gr(e){return su()?e instanceof HTMLElement||e instanceof rn(e).HTMLElement:!1}function Gx(e){return!su()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof rn(e).ShadowRoot}function ru(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=os(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function TA(e){return/^(table|td|th)$/.test(no(e))}function iu(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const RA=/transform|translate|scale|rotate|perspective|filter/,PA=/paint|layout|strict|content/,br=e=>!!e&&e!=="none";let id;function Kp(e){const t=is(e)?os(e):e;return br(t.transform)||br(t.translate)||br(t.scale)||br(t.rotate)||br(t.perspective)||!Gp()&&(br(t.backdropFilter)||br(t.filter))||RA.test(t.willChange||"")||PA.test(t.contain||"")}function IA(e){let t=Dr(e);for(;gr(t)&&!ol(t);){if(Kp(t))return t;if(iu(t))return null;t=Dr(t)}return null}function Gp(){return id==null&&(id=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),id}function ol(e){return/^(html|body|#document)$/.test(no(e))}function os(e){return rn(e).getComputedStyle(e)}function ou(e){return is(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Dr(e){if(no(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gx(e)&&e.host||$s(e);return Gx(t)?t.host:t}function gb(e){const t=Dr(e);return ol(t)?(e.ownerDocument||e).body:gr(t)&&ru(t)?t:gb(t)}function ll(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=gb(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),l=rn(i);if(o){const a=qf(l);return t.concat(l,l.visualViewport||[],ru(i)?i:[],a&&n?ll(a):[])}else return t.concat(i,ll(i,[],n))}function qf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xb(e){const t=os(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=gr(e),o=i?e.offsetWidth:n,l=i?e.offsetHeight:r,a=bc(n)!==o||bc(r)!==l;return a&&(n=o,r=l),{width:n,height:r,$:a}}function Yp(e){return is(e)?e:e.contextElement}function Ei(e){const t=Yp(e);if(!gr(t))return ks(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=xb(t);let l=(o?bc(n.width):n.width)/r,a=(o?bc(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!a||!Number.isFinite(a))&&(a=1),{x:l,y:a}}const MA=ks(0);function vb(e){const t=rn(e);return!Gp()||!t.visualViewport?MA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $A(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===rn(e)}function Lr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=Yp(e);let l=ks(1);t&&(r?is(r)&&(l=Ei(r)):l=Ei(e));const a=$A(o,n,r)?vb(o):ks(0);let c=(i.left+a.x)/l.x,u=(i.top+a.y)/l.y,p=i.width/l.x,f=i.height/l.y;if(o&&r){const h=rn(o),v=is(r)?rn(r):r;let j=h,w=qf(j);for(;w&&v!==j;){const b=Ei(w),x=w.getBoundingClientRect(),g=os(w),y=x.left+(w.clientLeft+parseFloat(g.paddingLeft))*b.x,m=x.top+(w.clientTop+parseFloat(g.paddingTop))*b.y;c*=b.x,u*=b.y,p*=b.x,f*=b.y,c+=y,u+=m,j=rn(w),w=qf(j)}}return Sc({width:p,height:f,x:c,y:u})}function lu(e,t){const n=ou(e).scrollLeft;return t?t.left+n:Lr($s(e)).left+n}function jb(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-lu(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function _A(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",l=$s(r),a=t?iu(t.floating):!1;if(r===l||a&&o)return n;let c={scrollLeft:0,scrollTop:0},u=ks(1);const p=ks(0),f=gr(r);if((f||!o)&&((no(r)!=="body"||ru(l))&&(c=ou(r)),f)){const v=Lr(r);u=Ei(r),p.x=v.x+r.clientLeft,p.y=v.y+r.clientTop}const h=l&&!f&&!o?jb(l,c):ks(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+h.x,y:n.y*u.y-c.scrollTop*u.y+p.y+h.y}}function OA(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function DA(e){const t=ou(e),n=e.ownerDocument.body,r=bs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=bs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+lu(e);const l=-t.scrollTop;return os(n).direction==="rtl"&&(o+=bs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:o,y:l}}const LA=25;function FA(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=rn(e),o=$s(e),l=i.visualViewport;let a=o.clientWidth,c=o.clientHeight,u=0,p=0;if(l){const h=!Gp()||t==="fixed";r?h||(u=-l.offsetLeft,p=-l.offsetTop):(a=l.width,c=l.height,h&&(u=l.offsetLeft,p=l.offsetTop))}if(lu(o)<=0){const h=o.ownerDocument,v=h.body,j=getComputedStyle(v),w=h.compatMode==="CSS1Compat"&&parseFloat(j.marginLeft)+parseFloat(j.marginRight)||0,b=Math.abs(o.clientWidth-v.clientWidth-w),x=getComputedStyle(o).scrollbarGutter==="stable both-edges"?b/2:b;x<=LA&&(a-=x)}return{width:a,height:c,x:u,y:p}}function UA(e,t){const n=Lr(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Ei(e),l=e.clientWidth*o.x,a=e.clientHeight*o.y,c=i*o.x,u=r*o.y;return{width:l,height:a,x:c,y:u}}function Yx(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=FA(e,n,t);else if(t==="document")r=DA($s(e));else if(is(t))r=UA(t,n);else{const i=vb(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Sc(r)}function zA(e,t){const n=t.get(e);if(n)return n;let r=ll(e,[],!1).filter(a=>is(a)&&no(a)!=="body"),i=null;const o=os(e).position==="fixed";let l=o?Dr(e):e;for(;is(l)&&!ol(l);){const a=os(l),c=Kp(l),u=i?i.position:o?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&a.position==="static")?r=r.filter(f=>f!==l):i=a,l=Dr(l)}return t.set(e,r),r}function BA(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const l=[...n==="clippingAncestors"?iu(t)?[]:zA(t,this._c):[].concat(n),r],a=Yx(t,l[0],i);let c=a.top,u=a.right,p=a.bottom,f=a.left;for(let h=1;h<l.length;h++){const v=Yx(t,l[h],i);c=bs(v.top,c),u=ar(v.right,u),p=ar(v.bottom,p),f=bs(v.left,f)}return{width:u-f,height:p-c,x:f,y:c}}function WA(e){const{width:t,height:n}=xb(e);return{width:t,height:n}}function HA(e,t,n){const r=gr(t),i=$s(t),o=n==="fixed",l=Lr(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const c=ks(0);if((r||!o)&&((no(t)!=="body"||ru(i))&&(a=ou(t)),r)){const h=Lr(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}!r&&i&&(c.x=lu(i));const u=i&&!r&&!o?jb(i,a):ks(0),p=l.left+a.scrollLeft-c.x-u.x,f=l.top+a.scrollTop-c.y-u.y;return{x:p,y:f,width:l.width,height:l.height}}function od(e){return os(e).position==="static"}function qx(e,t){if(!gr(e)||os(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return $s(e)===n&&(n=n.ownerDocument.body),n}function yb(e,t){const n=rn(e);if(iu(e))return n;if(!gr(e)){let i=Dr(e);for(;i&&!ol(i);){if(is(i)&&!od(i))return i;i=Dr(i)}return n}let r=qx(e,t);for(;r&&TA(r)&&od(r);)r=qx(r,t);return r&&ol(r)&&od(r)&&!Kp(r)?n:r||IA(e)||n}const VA=async function(e){const t=this.getOffsetParent||yb,n=this.getDimensions,r=await n(e.floating);return{reference:HA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function KA(e){return os(e).direction==="rtl"}const GA={convertOffsetParentRelativeRectToViewportRelativeRect:_A,getDocumentElement:$s,getClippingRect:BA,getOffsetParent:yb,getElementRects:VA,getClientRects:OA,getDimensions:WA,getScale:Ei,isElement:is,isRTL:KA};function wb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function YA(e,t,n){let r=null,i;const o=$s(e);function l(){var p;clearTimeout(i),(p=r)==null||p.disconnect(),r=null}function a(p,f){p===void 0&&(p=!1),f===void 0&&(f=1),l();const h=e.getBoundingClientRect(),{left:v,top:j,width:w,height:b}=h;if(p||t(),!w||!b)return;const x=ia(j),g=ia(o.clientWidth-(v+w)),y=ia(o.clientHeight-(j+b)),m=ia(v),k={rootMargin:-x+"px "+-g+"px "+-y+"px "+-m+"px",threshold:bs(0,ar(1,f))||1};let N=!0;function C(P){const E=P[0].intersectionRatio;if(!wb(h,e.getBoundingClientRect()))return a();if(E!==f){if(!N)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}N=!1}try{r=new IntersectionObserver(C,{...k,root:o.ownerDocument})}catch{r=new IntersectionObserver(C,k)}r.observe(e)}const c=rn(e),u=()=>a(n);return c.addEventListener("resize",u),a(!0),()=>{c.removeEventListener("resize",u),l()}}function qA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Yp(e),p=i||o?[...u?ll(u):[],...t?ll(t):[]]:[];p.forEach(x=>{i&&x.addEventListener("scroll",n),o&&x.addEventListener("resize",n)});const f=u&&a?YA(u,n,o):null;let h=-1,v=null;l&&(v=new ResizeObserver(x=>{let[g]=x;g&&g.target===u&&v&&t&&(v.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=v)==null||y.observe(t)})),n()}),u&&!c&&v.observe(u),t&&v.observe(t));let j,w=c?Lr(e):null;c&&b();function b(){const x=Lr(e);w&&!wb(w,x)&&n(),w=x,j=requestAnimationFrame(b)}return n(),()=>{var x;p.forEach(g=>{i&&g.removeEventListener("scroll",n),o&&g.removeEventListener("resize",n)}),f==null||f(),(x=v)==null||x.disconnect(),v=null,c&&cancelAnimationFrame(j)}}const QA=NA,JA=CA,XA=bA,ZA=AA,eT=kA,Qx=wA,tT=EA,nT=(e,t,n)=>{const r=new Map,i=n??{},o={...GA,...i.platform,_c:r};return yA(e,t,{...i,platform:o})};var sT=typeof document<"u",rT=function(){},za=sT?d.useLayoutEffect:rT;function Nc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Nc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!Nc(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function bb(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Jx(e,t){const n=bb(e);return Math.round(t*n)/n}function ld(e){const t=d.useRef(e);return za(()=>{t.current=e}),t}function iT(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[p,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,v]=d.useState(r);Nc(h,r)||v(r);const[j,w]=d.useState(null),[b,x]=d.useState(null),g=d.useCallback(M=>{M!==k.current&&(k.current=M,w(M))},[]),y=d.useCallback(M=>{M!==N.current&&(N.current=M,x(M))},[]),m=o||j,S=l||b,k=d.useRef(null),N=d.useRef(null),C=d.useRef(p),P=c!=null,E=ld(c),O=ld(i),F=ld(u),D=d.useCallback(()=>{if(!k.current||!N.current)return;const M={placement:t,strategy:n,middleware:h};O.current&&(M.platform=O.current),nT(k.current,N.current,M).then(B=>{const $={...B,isPositioned:F.current!==!1};T.current&&!Nc(C.current,$)&&(C.current=$,Li.flushSync(()=>{f($)}))})},[h,t,n,O,F]);za(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const T=d.useRef(!1);za(()=>(T.current=!0,()=>{T.current=!1}),[]),za(()=>{if(m&&(k.current=m),S&&(N.current=S),m&&S){if(E.current)return E.current(m,S,D);D()}},[m,S,D,E,P]);const z=d.useMemo(()=>({reference:k,floating:N,setReference:g,setFloating:y}),[g,y]),Q=d.useMemo(()=>({reference:m,floating:S}),[m,S]),Y=d.useMemo(()=>{const M={position:n,left:0,top:0};if(!Q.floating)return M;const B=Jx(Q.floating,p.x),$=Jx(Q.floating,p.y);return a?{...M,transform:"translate("+B+"px, "+$+"px)",...bb(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:$}},[n,a,Q.floating,p.x,p.y]);return d.useMemo(()=>({...p,update:D,refs:z,elements:Q,floatingStyles:Y}),[p,D,z,Q,Y])}const oT=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Qx({element:r.current,padding:i}).fn(n):{}:r?Qx({element:r,padding:i}).fn(n):{}}}},lT=(e,t)=>{const n=QA(e);return{name:n.name,fn:n.fn,options:[e,t]}},aT=(e,t)=>{const n=JA(e);return{name:n.name,fn:n.fn,options:[e,t]}},cT=(e,t)=>({fn:tT(e).fn,options:[e,t]}),uT=(e,t)=>{const n=XA(e);return{name:n.name,fn:n.fn,options:[e,t]}},dT=(e,t)=>{const n=ZA(e);return{name:n.name,fn:n.fn,options:[e,t]}},fT=(e,t)=>{const n=eT(e);return{name:n.name,fn:n.fn,options:[e,t]}},hT=(e,t)=>{const n=oT(e);return{name:n.name,fn:n.fn,options:[e,t]}};var pT=Object.defineProperty,mT=(e,t)=>pT(e,"name",{value:t,configurable:!0});function kb(e){const[t,n]=d.useState(void 0);return sn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let l,a;if("borderBoxSize"in o){const c=o.borderBoxSize,u=Array.isArray(c)?c[0]:c;l=u.inlineSize,a=u.blockSize}else l=e.offsetWidth,a=e.offsetHeight;n({width:l,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}mT(kb,"useSize");var gT=Object.defineProperty,nr=(e,t)=>gT(e,"name",{value:t,configurable:!0}),Sb="Popper",[Nb,au]=Wn(Sb),[xT,Cb]=Nb(Sb),vT=nr(e=>{const{__scopePopper:t,children:n}=e,[r,i]=d.useState(null),[o,l]=d.useState(void 0);return s.jsx(xT,{scope:t,anchor:r,onAnchorChange:i,placementState:o,setPlacementState:l,children:n})},"Popper"),jT="PopperAnchor",yT=d.forwardRef(nr(function(t,n){const{__scopePopper:r,virtualRef:i,...o}=t,l=Cb(jT,r),a=d.useRef(null),c=l.onAnchorChange,u=d.useCallback(w=>{a.current=w,w&&c(w)},[c]),p=Ze(n,u),f=d.useRef(null);d.useEffect(()=>{if(!i)return;const w=f.current;f.current=i.current,w!==f.current&&c(f.current)});const h=l.placementState&&cu(l.placementState),v=h==null?void 0:h[0],j=h==null?void 0:h[1];return i?null:s.jsx(tt.div,{"data-radix-popper-side":v,"data-radix-popper-align":j,...o,ref:p})},"PopperAnchor")),Eb="PopperContent",[wT,w6]=Nb(Eb),bT=d.forwardRef(nr(function(t,n){var Me,De,he,_e,Ce,He,_;const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:l="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:p=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:v=!1,updatePositionStrategy:j="optimized",onPlaced:w,...b}=t,x=Cb(Eb,r),[g,y]=d.useState(null),m=Ze(n,y),[S,k]=d.useState(null),N=kb(S),C=(N==null?void 0:N.width)??0,P=(N==null?void 0:N.height)??0,E=i+(l!=="center"?"-"+l:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},F=Array.isArray(p)?p:[p],D=F.length>0,T={padding:O,boundary:F.filter(Ab),altBoundary:D},{refs:z,floatingStyles:Q,placement:Y,isPositioned:M,middlewareData:B}=iT({strategy:"fixed",placement:E,whileElementsMounted:nr((...ue)=>qA(...ue,{animationFrame:j==="always"}),"whileElementsMounted"),elements:{reference:x.anchor},middleware:[lT({mainAxis:o+P,alignmentAxis:a}),u&&aT({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?cT():void 0,...T}),u&&uT({...T}),dT({...T,apply:nr(({elements:ue,rects:ve,availableWidth:qe,availableHeight:ct})=>{const{width:Ae,height:un}=ve.reference,Rn=ue.floating.style;Rn.setProperty("--radix-popper-available-width",`${qe}px`),Rn.setProperty("--radix-popper-available-height",`${ct}px`),Rn.setProperty("--radix-popper-anchor-width",`${Ae}px`),Rn.setProperty("--radix-popper-anchor-height",`${un}px`)},"apply")}),S&&hT({element:S,padding:c}),kT({arrowWidth:C,arrowHeight:P}),v&&fT({strategy:"referenceHidden",...T,boundary:D?T.boundary:void 0})]}),$=x.setPlacementState;sn(()=>($(Y),()=>{$(void 0)}),[Y,$]);const[Z,V]=cu(Y),de=Bn(w);sn(()=>{M&&(de==null||de())},[M,de]);const ge=(Me=B.arrow)==null?void 0:Me.x,je=(De=B.arrow)==null?void 0:De.y,ne=((he=B.arrow)==null?void 0:he.centerOffset)!==0,[xe,Se]=d.useState();return sn(()=>{g&&Se(window.getComputedStyle(g).zIndex)},[g]),s.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...Q,transform:M?Q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:xe,"--radix-popper-transform-origin":[(_e=B.transformOrigin)==null?void 0:_e.x,(Ce=B.transformOrigin)==null?void 0:Ce.y].join(" "),...((He=B.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(wT,{scope:r,placedSide:Z,placedAlign:V,onArrowChange:k,arrowX:ge,arrowY:je,shouldHideArrow:ne,children:s.jsx(tt.div,{"data-side":Z,"data-align":V,...b,ref:m,style:{...b.style,animation:M?(_=b.style)==null?void 0:_.animation:"none"}})})})},"PopperContent"));function Ab(e){return e!==null}nr(Ab,"isNotNull");var kT=nr(e=>({name:"transformOrigin",options:e,fn(t){var b,x,g;const{placement:n,rects:r,middlewareData:i}=t,l=((b=i.arrow)==null?void 0:b.centerOffset)!==0,a=l?0:e.arrowWidth,c=l?0:e.arrowHeight,[u,p]=cu(n),f={start:"0%",center:"50%",end:"100%"}[p],h=(((x=i.arrow)==null?void 0:x.x)??0)+a/2,v=(((g=i.arrow)==null?void 0:g.y)??0)+c/2;let j="",w="";return u==="bottom"?(j=l?f:`${h}px`,w=`${-c}px`):u==="top"?(j=l?f:`${h}px`,w=`${r.floating.height+c}px`):u==="right"?(j=`${-c}px`,w=l?f:`${v}px`):u==="left"&&(j=`${r.floating.width+c}px`,w=l?f:`${v}px`),{data:{x:j,y:w}}}}),"transformOrigin");function cu(e){const[t,n="center"]=e.split("-");return[t,n]}nr(cu,"getSideAndAlignFromPlacement");var Tb=vT,Rb=yT,Pb=bT,ST=Object.defineProperty,yt=(e,t)=>ST(e,"name",{value:t,configurable:!0}),[qp,b6]=Wn("Tooltip",[au]),Qp=au(),NT="TooltipProvider",CT=700,Qf="tooltip.open",[ET,Jp]=qp(NT),AT=yt(e=>{const{__scopeTooltip:t,delayDuration:n=CT,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,l=d.useRef(!0),a=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(ET,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),l.current=!1)},[r]),onClose:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:d.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:o})},"TooltipProvider"),Jf="Tooltip",[TT,kl]=qp(Jf),RT=yt(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:l,delayDuration:a}=e,c=Jp(Jf,e.__scopeTooltip),u=Qp(t),[p,f]=d.useState(null),[h,v]=d.useState(void 0),j=ws(),w=d.useRef(0),b=l??c.disableHoverableContent,x=a??c.delayDuration,g=d.useRef(!1),[y,m]=eo({prop:r,defaultProp:i??!1,onChange:yt(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(Qf))):c.onClose(),o==null||o(E)},"onChange"),caller:Jf}),S=d.useMemo(()=>y?g.current?"delayed-open":"instant-open":"closed",[y]),k=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,g.current=!1,m(!0)},[m]),N=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,m(!1)},[m]),C=d.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{g.current=!0,m(!0),w.current=0},x)},[x,m]);d.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const P=h??j;return s.jsx(Tb,{...u,children:s.jsx(TT,{scope:t,contentId:P,setContentId:v,open:y,stateAttribute:S,trigger:p,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?C():k()},[c.isOpenDelayedRef,C,k]),onTriggerLeave:d.useCallback(()=>{b?N():(window.clearTimeout(w.current),w.current=0)},[N,b]),onOpen:k,onClose:N,disableHoverableContent:b,children:n})})},"Tooltip"),Xx="TooltipTrigger",PT=d.forwardRef(yt(function(t,n){const{__scopeTooltip:r,...i}=t,o=kl(Xx,r),l=Jp(Xx,r),a=Qp(r),c=d.useRef(null),u=Ze(n,c,o.onTriggerChange),p=d.useRef(!1),f=d.useRef(!1),h=d.useCallback(()=>p.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(Rb,{asChild:!0,...a,children:s.jsx(tt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:u,onPointerMove:we(t.onPointerMove,v=>{v.pointerType!=="touch"&&!f.current&&!l.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:we(t.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:we(t.onPointerDown,()=>{o.open&&o.onClose(),p.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:we(t.onFocus,()=>{p.current||o.onOpen()}),onBlur:we(t.onBlur,o.onClose),onClick:we(t.onClick,o.onClose)})})},"TooltipTrigger")),Ib="TooltipPortal",[IT,MT]=qp(Ib,{forceMount:void 0}),$T=yt(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,o=kl(Ib,t);return s.jsx(IT,{scope:t,forceMount:n,children:s.jsx(mr,{present:n||o.open,children:s.jsx(Bp,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),al="TooltipContent",_T=d.forwardRef(yt(function(t,n){const r=MT(al,t.__scopeTooltip),{forceMount:i=r.forceMount,side:o="top",...l}=t,a=kl(al,t.__scopeTooltip);return s.jsx(mr,{present:i||a.open,children:a.disableHoverableContent?s.jsx(Mb,{side:o,...l,ref:n}):s.jsx(OT,{side:o,...l,ref:n})})},"TooltipContent")),OT=d.forwardRef(yt(function(t,n){const r=kl(al,t.__scopeTooltip),i=Jp(al,t.__scopeTooltip),o=d.useRef(null),l=Ze(n,o),[a,c]=d.useState(null),{trigger:u,onClose:p}=r,f=o.current,{onPointerInTransitChange:h}=i,v=d.useCallback(()=>{c(null),h(!1)},[h]),j=d.useCallback((w,b)=>{const x=w.currentTarget,g={x:w.clientX,y:w.clientY},y=$b(g,x.getBoundingClientRect()),m=_b(g,y),S=Ob(b.getBoundingClientRect()),k=Lb([...m,...S]);c(k),h(!0)},[h]);return d.useEffect(()=>()=>v(),[v]),d.useEffect(()=>{if(u&&f){const w=yt(x=>j(x,f),"handleTriggerLeave"),b=yt(x=>j(x,u),"handleContentLeave");return u.addEventListener("pointerleave",w),f.addEventListener("pointerleave",b),()=>{u.removeEventListener("pointerleave",w),f.removeEventListener("pointerleave",b)}}},[u,f,j,v]),d.useEffect(()=>{if(a){const w=yt(b=>{const x=b.target,g={x:b.clientX,y:b.clientY},y=(u==null?void 0:u.contains(x))||(f==null?void 0:f.contains(x)),m=!Db(g,a);y?v():m&&(v(),p())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,f,a,p,v]),s.jsx(Mb,{...t,ref:l})},"TooltipContentHoverable")),DT=Fw("TooltipContent"),Mb=d.forwardRef(yt(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":o,id:l,onEscapeKeyDown:a,onPointerDownOutside:c,...u}=t,p=kl(al,r),f=Qp(r),{onClose:h}=p;d.useEffect(()=>(document.addEventListener(Qf,h),()=>document.removeEventListener(Qf,h)),[h]),d.useEffect(()=>{if(p.trigger){const j=yt(w=>{w.target instanceof Node&&w.target.contains(p.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",j,{capture:!0}),()=>window.removeEventListener("scroll",j,{capture:!0})}},[p.trigger,h]);const{setContentId:v}=p;return sn(()=>(v(l),()=>{v(void 0)}),[l,v]),s.jsx(Up,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:j=>j.preventDefault(),onDismiss:h,children:s.jsxs(Pb,{"data-state":p.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:p.contentId,...f,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(DT,{children:i}),o?s.jsx(HE,{id:p.contentId,role:"tooltip",children:o}):null]})})},"TooltipContentImpl"));function $b(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}yt($b,"getExitSideFromRect");function _b(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}yt(_b,"getPaddedExitPoints");function Ob(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}yt(Ob,"getPointsFromRect");function Db(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,l=t.length-1;o<t.length;l=o++){const a=t[o],c=t[l],u=a.x,p=a.y,f=c.x,h=c.y;p>r!=h>r&&n<(f-u)*(r-p)/(h-p)+u&&(i=!i)}return i}yt(Db,"isPointInPolygon");function Lb(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Fb(t)}yt(Lb,"getHull");function Fb(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const o=t[t.length-1],l=t[t.length-2];if((o.x-l.x)*(i.y-l.y)>=(o.y-l.y)*(i.x-l.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const o=n[n.length-1],l=n[n.length-2];if((o.x-l.x)*(i.y-l.y)>=(o.y-l.y)*(i.x-l.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}yt(Fb,"getHullPresorted");var Zx=AT,Cc=RT,Ec=PT,Ac=$T,Tc=_T;const ev="buddi_csrf",so="x-buddi-csrf",cl="buddi:agents-changed",LT="This page's sign-in no longer matches its cookies. Reload the page and try again.";class le extends Error{constructor(t,n,r){super(n),this.status=t,this.detail=r,this.name="ApiError"}}function Hr(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${ev}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const n=[...document.cookie.matchAll(new RegExp(`(?:^|; )${ev}(?:_\\d+)?=([^;]*)`,"g"))];return n.length===1&&((r=n[0])!=null&&r[1])?decodeURIComponent(n[0][1]):""}async function Vr(e,t={}){const n=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}});if(n.status===401)throw new le(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await n.text(),i=r===""?null:FT(r);if(!n.ok){const o=i&&typeof i=="object"&&"error"in i?String(i.error):void 0,l=(t.method??"GET").toUpperCase(),a=o??(n.status===403&&l!=="GET"&&l!=="HEAD"?LT:`request failed (${n.status})`);throw new le(n.status,a,i)}return i}function FT(e){try{return JSON.parse(e)}catch{return null}}function ae(e,t={}){const n=new URLSearchParams;for(const[i,o]of Object.entries(t))o!==void 0&&o!==""&&n.set(i,String(o));const r=n.toString();return Vr(`/api${e}${r?`?${r}`:""}`)}function Ub(e,t){return Vr(`/api${e}`,{method:"POST",headers:{[so]:Hr()},body:t})}function Uo(e){return Vr(`/api${e}`,{method:"DELETE",headers:{[so]:Hr()}})}function te(e,t={}){return Vr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[so]:Hr()},body:JSON.stringify(t??{})})}function zb(e,t,n,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||n;return Vr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[so]:Hr(),"X-Filename":i,...r},body:t})}function tv(e,t,n){return zb(e,t,"backup.tar.gz",{...n.passphrase?{"X-Backup-Passphrase":n.passphrase}:{},...n.confirm?{"X-Backup-Confirm":n.confirm}:{}})}function UT(e,t={}){return Vr(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[so]:Hr()},body:JSON.stringify(t??{})})}function bo(e,t={}){return Vr(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[so]:Hr()},body:JSON.stringify(t??{})})}function zT(e){if(e.dismissedAt)return"You said no to this one.";switch(e.lapseReason){case"owner-moved-on":return"The conversation moved on.";case"rolled-over":return"That conversation ended.";case"agent-removed":return"That agent is no longer here.";default:return"It lapsed."}}const Ba="gpt-oss:120b",BT=["approval","question","watcher","reminder","failure","recap","plugin"],ze={agents:()=>ae("/chat/agents"),views:()=>ae("/chat/views"),conversations:(e,t)=>ae(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>te(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>ae(`/chat/conversations/${encodeURIComponent(e)}`),send:(e,t)=>te(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>te(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>te(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),Ub("/chat/attachments",t)},discardAttachment:e=>Uo(`/artifacts/${encodeURIComponent(e)}`),groups:()=>ae("/groups"),group:e=>ae(`/groups/${encodeURIComponent(e)}`),createGroup:e=>te("/groups",e),updateGroup:(e,t)=>UT(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>Uo(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>ae(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>te(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>te(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`},A={providers:()=>ae("/providers"),providerAccounts:()=>ae("/provider-accounts"),probeModels:e=>te("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>te(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>te("/provider-accounts/save",e),testProviderAccount:e=>te(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>te(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,n)=>te(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:n}),ollamaConnect:(e,t)=>te(`/provider-accounts/${encodeURIComponent(e)}/ollama/connect`,{revision:t}),ollamaPoll:(e,t)=>te(`/provider-accounts/${encodeURIComponent(e)}/ollama/poll`,{attemptId:t}),ollamaDisconnect:(e,t)=>te(`/provider-accounts/${encodeURIComponent(e)}/ollama/disconnect`,{revision:t}),anthropicAccountAction:(e,t,n,r)=>te(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:n,...r}),assignProviderAccount:(e,t,n)=>te(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:n}),configureProvider:(e,t)=>te(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>te(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>te(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>te(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>ae("/host/browser-profiles",{app:e}),installedApps:()=>ae("/host/apps"),browser:e=>ae(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>te(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>te("/browser/settings",e),computerPermissions:(e=!1)=>te("/browser/permissions",{prompt:e}),browserInstall:()=>te("/browser/install",{}),browserCheck:()=>te("/browser/check",{}),previewLink:(e,t)=>ae(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>ae(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>ae("/extension"),pairExtension:e=>te("/extension/pair",{code:e}),forgetExtension:()=>Uo("/extension/pair"),session:()=>ae("/session"),overview:()=>ae("/overview"),events:e=>ae("/events",e),eventKinds:()=>ae("/events/kinds"),conversations:()=>ae("/conversations"),conversation:e=>ae(`/conversations/${encodeURIComponent(e)}`),missions:()=>ae("/missions"),jobs:(e={})=>ae("/jobs",e),approvals:()=>ae("/approvals"),approval:e=>ae(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>ae("/offers"),dismissOffer:e=>te(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>te("/offers/dismiss-all",{ids:e}),agentOffers:()=>ae("/agent-offers"),dismissAgentOffer:(e,t)=>te(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>ae("/proposals"),setDigestSchedule:(e,t)=>te("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>te(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),discardProposal:(e,t)=>te(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>ae("/reminders"),sentinels:()=>ae("/sentinels"),setSentinelEnabled:(e,t)=>te(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),snoozeAlert:(e,t)=>te(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>ae("/agents"),library:e=>ae("/artifacts",e),libraryEntry:(e,t=0)=>ae(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>ae("/onboarding"),onboardingStep:(e,t={})=>te("/onboarding/step",{step:e,...t}),completeOnboarding:()=>te("/onboarding/complete"),skipOnboarding:()=>te("/onboarding/skip"),createFirstAgent:e=>te("/onboarding/agent",e),ollama:()=>ae("/onboarding/ollama"),firstAgentPersona:()=>ae("/onboarding/agent"),updateFirstAgent:e=>te("/onboarding/agent/update",e),bindBrain:e=>te("/onboarding/brain",e),pages:()=>ae("/pages"),pageQuery:(e,t,n={})=>ae(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n),pageFileUrl:(e,t,n={})=>{const r=new URLSearchParams(Object.entries(n).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>te(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>ae("/telegram"),saveTelegramToken:e=>te("/telegram/token",{token:e}),telegramPairing:()=>te("/telegram/pairing"),telegramBot:()=>ae("/telegram/bot"),telegramDevices:()=>ae("/telegram/devices"),unpairTelegramDevice:e=>Uo(`/telegram/devices/${encodeURIComponent(e)}`),notifications:(e=20)=>ae("/notifications",{limit:e}),notificationSeen:e=>te(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>ae("/notifications/settings"),saveNotificationSettings:e=>bo("/notifications/settings",e),testChannel:e=>te("/notifications/test",{channel:e}),presence:e=>te("/presence",{state:e}),owner:()=>ae("/owner"),setOwner:e=>te("/owner",e),memory:e=>ae(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>te("/memory/preferences",e),forgetPreference:e=>te("/memory/preferences/forget",e),updateNote:(e,t)=>te(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>te(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>te(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>ae(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>ae(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>te(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>ae("/host",{agentId:e,conversationId:t}),secrets:()=>ae("/secrets"),secretUses:(e,t)=>ae("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>te("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>te("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>te("/host/revoke",{id:e}),decide:(e,t,n,r)=>te(`/approvals/${encodeURIComponent(e)}/${t}`,n||r?{...n?{permissionScope:n}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>te("/pause",{paused:e}),service:()=>ae("/service"),serviceAction:e=>te(`/service/${e}`),version:()=>ae("/version"),checkVersion:()=>te("/version/check"),setVersionCheck:e=>bo("/version/check",{enabled:e}),tailscale:()=>ae("/tailscale"),setTailscale:e=>bo("/tailscale",e),startUpgrade:e=>te("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>ae(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>ae("/backups"),startBackup:e=>te("/backups",{encrypt:e}),verifyArchive:e=>te("/backups/verify",{name:e}),restoreArchive:e=>te("/backups/restore",e),restoreUpload:(e,t)=>tv("/backups/restore",e,t),backupJob:e=>ae(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>ae("/backups/schedule"),setBackupSchedule:e=>bo("/backups/schedule",e),backupPassphrase:()=>ae("/backups/passphrase"),setBackupPassphrase:e=>bo("/backups/passphrase",{passphrase:e}),plugins:()=>ae("/plugins"),stagePlugin:e=>te("/plugins/stage",{spec:e}),uploadPlugin:e=>zb("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>ae(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>te(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>te(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>te(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),uninstallPlugin:(e,t)=>te(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>te(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>ae("/recovery"),leaveRecovery:e=>te("/recovery/leave",e),firstRunRestore:(e,t)=>tv("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>te(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,n)=>te(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...n===void 0?{}:{deadlineMinutes:n}}),retryJob:e=>te(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>te(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>te("/agents/default",{agentId:e}),agentTools:e=>ae(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>ae(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const n=new FormData;return n.append("file",t,t.name),Ub(`/agents/${encodeURIComponent(e)}/avatar`,n)},removeAgentPicture:e=>Uo(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>te(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>te(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>te(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>te(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};function Bb(e){return e==="anthropic"||e==="openai"}function Wb(e,t){var i,o;if(!e)return null;const n=e.credentialEnv&&(t!=null&&t.accounts.some(l=>l.id===e.credentialEnv))?e.credentialEnv:(o=(i=t==null?void 0:t.bindings)==null?void 0:i.find(l=>l.agentId===e.id))==null?void 0:o.accountId,r=n?t==null?void 0:t.accounts.find(l=>l.id===n):void 0;return(r==null?void 0:r.kind)??e.provider}const WT="Thinking is up to this model. What it writes while thinking is shown apart and kept out of the answer.";var HT=Object.defineProperty,VT=(e,t)=>HT(e,"name",{value:t,configurable:!0}),KT=d.createContext(void 0);function uu(e){const t=d.useContext(KT);return e||t||"ltr"}VT(uu,"useDirection");var GT=Object.defineProperty,Xp=(e,t)=>GT(e,"name",{value:t,configurable:!0}),oa=0,qn=null;function YT(e){return du(),e.children}Xp(YT,"FocusGuards");function du(){d.useEffect(()=>{qn||(qn={start:Xf(),end:Xf()});const{start:e,end:t}=qn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),oa++,()=>{oa===1&&(qn==null||qn.start.remove(),qn==null||qn.end.remove(),qn=null),oa=Math.max(0,oa-1)}},[])}Xp(du,"useFocusGuards");function Xf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}Xp(Xf,"createFocusGuard");var qT=Object.defineProperty,Bt=(e,t)=>qT(e,"name",{value:t,configurable:!0}),ad="focusScope.autoFocusOnMount",cd="focusScope.autoFocusOnUnmount",nv={bubbles:!1,cancelable:!0},Hb=d.forwardRef(Bt(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:l,...a}=t,[c,u]=d.useState(null),p=Bn(o),f=Bn(l),h=d.useRef(null),v=Ze(n,u),j=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let b=function(m){if(j.paused||!c)return;const S=m.target;c.contains(S)?h.current=S:gs(h.current,{select:!0})},x=function(m){if(j.paused||!c)return;const S=m.relatedTarget;S!==null&&(c.contains(S)||gs(h.current,{select:!0}))},g=function(m){if(document.activeElement===document.body)for(const k of m)k.removedNodes.length>0&&gs(c)};Bt(b,"handleFocusIn"),Bt(x,"handleFocusOut"),Bt(g,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",x);const y=new MutationObserver(g);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",x),y.disconnect()}}},[i,c,j.paused]),d.useEffect(()=>{if(c){sv.add(j);const b=document.activeElement;if(!c.contains(b)){const g=new CustomEvent(ad,nv);c.addEventListener(ad,p),c.dispatchEvent(g),g.defaultPrevented||(Vb(Qb(Zp(c)),{select:!0}),document.activeElement===b&&gs(c))}return()=>{c.removeEventListener(ad,p),setTimeout(()=>{const g=new CustomEvent(cd,nv);c.addEventListener(cd,f),c.dispatchEvent(g),g.defaultPrevented||gs(b??document.body,{select:!0}),c.removeEventListener(cd,f),sv.remove(j)},0)}}},[c,p,f,j]);const w=d.useCallback(b=>{if(!r&&!i||j.paused)return;const x=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,g=document.activeElement;if(x&&g){const y=b.currentTarget,[m,S]=Kb(y);m&&S?!b.shiftKey&&g===S?(b.preventDefault(),r&&gs(m,{select:!0})):b.shiftKey&&g===m&&(b.preventDefault(),r&&gs(S,{select:!0})):g===y&&b.preventDefault()}},[r,i,j.paused]);return s.jsx(tt.div,{tabIndex:-1,...a,ref:v,onKeyDown:w})},"FocusScope"));function Vb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(gs(r,{select:t}),document.activeElement!==n)return}Bt(Vb,"focusFirst");function Kb(e){const t=Zp(e),n=Zf(t,e),r=Zf(t.reverse(),e);return[n,r]}Bt(Kb,"getTabbableEdges");function Zp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Bt(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Bt(Zp,"getTabbableCandidates");function Zf(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Gb(r,{upTo:t})))return r}Bt(Zf,"findVisible");function Gb(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}Bt(Gb,"isHidden");function Yb(e){return e instanceof HTMLInputElement&&"select"in e}Bt(Yb,"isSelectableInput");function gs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yb(e)&&t&&e.select()}}Bt(gs,"focus");var sv=qb();function qb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=eh(e,t),e.unshift(t)},remove(t){var n;e=eh(e,t),(n=e[0])==null||n.resume()}}}Bt(qb,"createFocusScopesStack");function eh(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Bt(eh,"arrayRemove");function Qb(e){return e.filter(t=>t.tagName!=="A")}Bt(Qb,"removeLinks");var QT=Object.defineProperty,em=(e,t)=>QT(e,"name",{value:t,configurable:!0}),ud=!1;function Jb(){const[e,t]=d.useState(ud);return d.useEffect(()=>{ud||(ud=!0,t(!0))},[]),e}em(Jb,"useIsHydrated");var Xb=Qi[" useSyncExternalStore ".trim().toString()];function Zb(){return()=>{}}em(Zb,"subscribe");function e0(){return Xb(Zb,()=>!0,()=>!1)}em(e0,"useIsHydratedModern");var JT=typeof Xb=="function"?e0:Jb,XT=Object.defineProperty,Kr=(e,t)=>XT(e,"name",{value:t,configurable:!0}),dd="rovingFocusGroup.onEntryFocus",ZT={bubbles:!1,cancelable:!0},fu="RovingFocusGroup",[th,t0,eR]=tu(fu),[tR,hu]=Wn(fu,[eR]),[nR,sR]=tR(fu),rR=d.forwardRef(Kr(function(t,n){return s.jsx(th.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(th.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(iR,{...t,ref:n})})})},"RovingFocusGroup")),iR=d.forwardRef(Kr(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:o=!1,dir:l,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:p,preventScrollOnEntryFocus:f=!1,...h}=t,v=d.useRef(null),j=Ze(n,v),w=uu(l),[b,x]=eo({prop:a,defaultProp:c??null,onChange:u,caller:fu}),[g,y]=d.useState(!1),m=Bn(p),S=t0(r),k=d.useRef(!1),[N,C]=d.useState(0);return d.useEffect(()=>{const P=v.current;if(P)return P.addEventListener(dd,m),()=>P.removeEventListener(dd,m)},[m]),s.jsx(nR,{scope:r,orientation:i,dir:w,loop:o,currentTabStopId:b,onItemFocus:d.useCallback(P=>x(P),[x]),onItemShiftTab:d.useCallback(()=>y(!0),[]),onFocusableItemAdd:d.useCallback(()=>C(P=>P+1),[]),onFocusableItemRemove:d.useCallback(()=>C(P=>P-1),[]),children:s.jsx(tt.div,{tabIndex:g||N===0?-1:0,"data-orientation":i,...h,ref:j,style:{outline:"none",...t.style},onMouseDown:we(t.onMouseDown,()=>{k.current=!0}),onFocus:we(t.onFocus,P=>{const E=!k.current;if(P.target===P.currentTarget&&E&&!g){const O=new CustomEvent(dd,ZT);if(P.currentTarget.dispatchEvent(O),!O.defaultPrevented){const F=S().filter(Y=>Y.focusable),D=F.find(Y=>Y.active),T=F.find(Y=>Y.id===b),Q=[D,T,...F].filter(Boolean).map(Y=>Y.ref.current);tm(Q,f)}}k.current=!1}),onBlur:we(t.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),oR="RovingFocusGroupItem",lR=d.forwardRef(Kr(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:o=!1,tabStopId:l,children:a,...c}=t,u=ws(),p=l||u,f=sR(oR,r),h=f.currentTabStopId===p,v=t0(r),{onFocusableItemAdd:j,onFocusableItemRemove:w,currentTabStopId:b}=f,x=JT();return sn(()=>{if(!(!x||!i))return j(),()=>w()},[x,i,j,w]),d.useEffect(()=>{if(!(x||!i))return j(),()=>w()},[x,i,j,w]),s.jsx(th.ItemSlot,{scope:r,id:p,focusable:i,active:o,children:s.jsx(tt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:we(t.onMouseDown,g=>{i?f.onItemFocus(p):g.preventDefault()}),onFocus:we(t.onFocus,()=>f.onItemFocus(p)),onKeyDown:we(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){f.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=s0(g,f.orientation,f.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=v().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(g.currentTarget);S=f.loop?r0(S,k+1):S.slice(k+1)}setTimeout(()=>tm(S))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:b!=null}):a})})},"RovingFocusGroupItem")),aR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function n0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Kr(n0,"getDirectionAwareKey");function s0(e,t,n){const r=n0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return aR[r]}Kr(s0,"getFocusIntent");function tm(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Kr(tm,"focusFirst");function r0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Kr(r0,"wrapArray");var i0=rR,o0=lR,cR=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ti=new WeakMap,la=new WeakMap,aa={},fd=0,l0=function(e){return e&&(e.host||l0(e.parentNode))},uR=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=l0(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},dR=function(e,t,n,r){var i=uR(t,Array.isArray(e)?e:[e]);aa[n]||(aa[n]=new WeakMap);var o=aa[n],l=[],a=new Set,c=new Set(i),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};i.forEach(u);var p=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))p(h);else try{var v=h.getAttribute(r),j=v!==null&&v!=="false",w=(ti.get(h)||0)+1,b=(o.get(h)||0)+1;ti.set(h,w),o.set(h,b),l.push(h),w===1&&j&&la.set(h,!0),b===1&&h.setAttribute(n,"true"),j||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return p(t),a.clear(),fd++,function(){l.forEach(function(f){var h=ti.get(f)-1,v=o.get(f)-1;ti.set(f,h),o.set(f,v),h||(la.has(f)||f.removeAttribute(r),la.delete(f)),v||f.removeAttribute(n)}),fd--,fd||(ti=new WeakMap,ti=new WeakMap,la=new WeakMap,aa={})}},a0=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=cR(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),dR(r,i,n,"aria-hidden")):function(){return null}},Xn=function(){return Xn=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Xn.apply(this,arguments)};function c0(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function fR(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var Wa="right-scroll-bar-position",Ha="width-before-scroll-bar",hR="with-scroll-bars-hidden",pR="--removed-body-scroll-bar-size";function hd(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mR(e,t){var n=d.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var gR=typeof window<"u"?d.useLayoutEffect:d.useEffect,rv=new WeakMap;function xR(e,t){var n=mR(null,function(r){return e.forEach(function(i){return hd(i,r)})});return gR(function(){var r=rv.get(n);if(r){var i=new Set(r),o=new Set(e),l=n.current;i.forEach(function(a){o.has(a)||hd(a,null)}),o.forEach(function(a){i.has(a)||hd(a,l)})}rv.set(n,e)},[e]),n}function vR(e){return e}function jR(e,t){t===void 0&&(t=vR);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var l=t(o,r);return n.push(l),function(){n=n.filter(function(a){return a!==l})}},assignSyncMedium:function(o){for(r=!0;n.length;){var l=n;n=[],l.forEach(o)}n={push:function(a){return o(a)},filter:function(){return n}}},assignMedium:function(o){r=!0;var l=[];if(n.length){var a=n;n=[],a.forEach(o),l=n}var c=function(){var p=l;l=[],p.forEach(o)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(p){l.push(p),u()},filter:function(p){return l=l.filter(p),n}}}};return i}function yR(e){e===void 0&&(e={});var t=jR(null);return t.options=Xn({async:!0,ssr:!1},e),t}var u0=function(e){var t=e.sideCar,n=c0(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,Xn({},n))};u0.isSideCarExport=!0;function wR(e,t){return e.useMedium(t),u0}var d0=yR(),pd=function(){},pu=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:pd,onWheelCapture:pd,onTouchMoveCapture:pd}),i=r[0],o=r[1],l=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,p=e.enabled,f=e.shards,h=e.sideCar,v=e.noRelative,j=e.noIsolation,w=e.inert,b=e.allowPinchZoom,x=e.as,g=x===void 0?"div":x,y=e.gapMode,m=c0(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,k=xR([n,t]),N=Xn(Xn({},m),i);return d.createElement(d.Fragment,null,p&&d.createElement(S,{sideCar:d0,removeScrollBar:u,shards:f,noRelative:v,noIsolation:j,inert:w,setCallbacks:o,allowPinchZoom:!!b,lockRef:n,gapMode:y}),l?d.cloneElement(d.Children.only(a),Xn(Xn({},N),{ref:k})):d.createElement(g,Xn({},N,{className:c,ref:k}),a))});pu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};pu.classNames={fullWidth:Ha,zeroRight:Wa};var bR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function kR(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=bR();return t&&e.setAttribute("nonce",t),e}function SR(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function NR(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var CR=function(){var e=0,t=null;return{add:function(n){e==0&&(t=kR())&&(SR(t,n),NR(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ER=function(){var e=CR();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},f0=function(){var e=ER(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},AR={left:0,top:0,right:0,gap:0},md=function(e){return parseInt(e||"",10)||0},TR=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[md(n),md(r),md(i)]},RR=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return AR;var t=TR(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},PR=f0(),Ai="data-scroll-locked",IR=function(e,t,n,r){var i=e.left,o=e.top,l=e.right,a=e.gap;return n===void 0&&(n="margin"),`
41
- .`.concat(hR,` {
42
- overflow: hidden `).concat(r,`;
43
- padding-right: `).concat(a,"px ").concat(r,`;
44
- }
45
- body[`).concat(Ai,`] {
46
- overflow: hidden `).concat(r,`;
47
- overscroll-behavior: contain;
48
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
49
- padding-left: `.concat(i,`px;
50
- padding-top: `).concat(o,`px;
51
- padding-right: `).concat(l,`px;
52
- margin-left:0;
53
- margin-top:0;
54
- margin-right: `).concat(a,"px ").concat(r,`;
55
- `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
56
- }
57
-
58
- .`).concat(Wa,` {
59
- right: `).concat(a,"px ").concat(r,`;
60
- }
61
-
62
- .`).concat(Ha,` {
63
- margin-right: `).concat(a,"px ").concat(r,`;
64
- }
65
-
66
- .`).concat(Wa," .").concat(Wa,` {
67
- right: 0 `).concat(r,`;
68
- }
69
-
70
- .`).concat(Ha," .").concat(Ha,` {
71
- margin-right: 0 `).concat(r,`;
72
- }
73
-
74
- body[`).concat(Ai,`] {
75
- `).concat(pR,": ").concat(a,`px;
76
- }
77
- `)},iv=function(){var e=parseInt(document.body.getAttribute(Ai)||"0",10);return isFinite(e)?e:0},MR=function(){d.useEffect(function(){return document.body.setAttribute(Ai,(iv()+1).toString()),function(){var e=iv()-1;e<=0?document.body.removeAttribute(Ai):document.body.setAttribute(Ai,e.toString())}},[])},$R=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;MR();var o=d.useMemo(function(){return RR(i)},[i]);return d.createElement(PR,{styles:IR(o,!t,i,n?"":"!important")})},nh=!1;if(typeof window<"u")try{var ca=Object.defineProperty({},"passive",{get:function(){return nh=!0,!0}});window.addEventListener("test",ca,ca),window.removeEventListener("test",ca,ca)}catch{nh=!1}var ni=nh?{passive:!1}:!1,_R=function(e){return e.tagName==="TEXTAREA"},h0=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!_R(e)&&n[t]==="visible")},OR=function(e){return h0(e,"overflowY")},DR=function(e){return h0(e,"overflowX")},ov=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=p0(e,r);if(i){var o=m0(e,r),l=o[1],a=o[2];if(l>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},LR=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},FR=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},p0=function(e,t){return e==="v"?OR(t):DR(t)},m0=function(e,t){return e==="v"?LR(t):FR(t)},UR=function(e,t){return e==="h"&&t==="rtl"?-1:1},zR=function(e,t,n,r,i){var o=UR(e,window.getComputedStyle(t).direction),l=o*r,a=n.target,c=t.contains(a),u=!1,p=l>0,f=0,h=0;do{if(!a)break;var v=m0(e,a),j=v[0],w=v[1],b=v[2],x=w-b-o*j;(j||x)&&p0(e,a)&&(f+=x,h+=j);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(p&&Math.abs(f)<1||!p&&Math.abs(h)<1)&&(u=!0),u},ua=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},lv=function(e){return[e.deltaX,e.deltaY]},av=function(e){return e&&"current"in e?e.current:e},BR=function(e,t){return e[0]===t[0]&&e[1]===t[1]},WR=function(e){return`
78
- .block-interactivity-`.concat(e,` {pointer-events: none;}
79
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
80
- `)},HR=0,si=[];function VR(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),i=d.useState(HR++)[0],o=d.useState(f0)[0],l=d.useRef(e);d.useEffect(function(){l.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var w=fR([e.lockRef.current],(e.shards||[]).map(av),!0).filter(Boolean);return w.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=d.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var x=ua(w),g=n.current,y="deltaX"in w?w.deltaX:g[0]-x[0],m="deltaY"in w?w.deltaY:g[1]-x[1],S,k=w.target,N=Math.abs(y)>Math.abs(m)?"h":"v";if("touches"in w&&N==="h"&&k.type==="range")return!1;var C=window.getSelection(),P=C&&C.anchorNode,E=P?P===k||P.contains(k):!1;if(E)return!1;var O=ov(N,k);if(!O)return!0;if(O?S=N:(S=N==="v"?"h":"v",O=ov(N,k)),!O)return!1;if(!r.current&&"changedTouches"in w&&(y||m)&&(r.current=S),!S)return!0;var F=r.current||S;return zR(F,b,w,F==="h"?y:m)},[]),c=d.useCallback(function(w){var b=w;if(!(!si.length||si[si.length-1]!==o)){var x="deltaY"in b?lv(b):ua(b),g=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&BR(S.delta,x)})[0];if(g&&g.should){b.cancelable&&b.preventDefault();return}if(!g){var y=(l.current.shards||[]).map(av).filter(Boolean).filter(function(S){return S.contains(b.target)}),m=y.length>0?a(b,y[0]):!l.current.noIsolation;m&&b.cancelable&&b.preventDefault()}}},[]),u=d.useCallback(function(w,b,x,g){var y={name:w,delta:b,target:x,should:g,shadowParent:KR(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(m){return m!==y})},1)},[]),p=d.useCallback(function(w){n.current=ua(w),r.current=void 0},[]),f=d.useCallback(function(w){u(w.type,lv(w),w.target,a(w,e.lockRef.current))},[]),h=d.useCallback(function(w){u(w.type,ua(w),w.target,a(w,e.lockRef.current))},[]);d.useEffect(function(){return si.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,ni),document.addEventListener("touchmove",c,ni),document.addEventListener("touchstart",p,ni),function(){si=si.filter(function(w){return w!==o}),document.removeEventListener("wheel",c,ni),document.removeEventListener("touchmove",c,ni),document.removeEventListener("touchstart",p,ni)}},[]);var v=e.removeScrollBar,j=e.inert;return d.createElement(d.Fragment,null,j?d.createElement(o,{styles:WR(i)}):null,v?d.createElement($R,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function KR(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const GR=wR(d0,VR);var nm=d.forwardRef(function(e,t){return d.createElement(pu,Xn({},e,{ref:t,sideCar:GR}))});nm.classNames=pu.classNames;var YR=Object.defineProperty,Oe=(e,t)=>YR(e,"name",{value:t,configurable:!0}),qR=["Enter"," "],QR=["ArrowDown","PageUp","Home"],g0=["ArrowUp","PageDown","End"],JR=[...QR,...g0],mu="Menu",[sh,XR,ZR]=tu(mu),[Gr,x0]=Wn(mu,[ZR,au,hu]),sm=au(),v0=hu(),[eP,Sl]=Gr(mu),[tP,rm]=Gr(mu),nP=Oe(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:l=!0}=e,a=sm(t),[c,u]=d.useState(null),p=d.useRef(!1),f=Bn(o),h=uu(i);return d.useEffect(()=>{const v=Oe(()=>{p.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},"handleKeyDown"),j=Oe(()=>p.current=!1,"handlePointer");return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),d.useEffect(()=>{if(!n)return;const v=Oe(()=>f(!1),"handleBlur");return window.addEventListener("blur",v),()=>window.removeEventListener("blur",v)},[n,f]),s.jsx(Tb,{...a,children:s.jsx(eP,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:s.jsx(tP,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:h,modal:l,children:r})})})},"Menu"),sP=d.forwardRef(Oe(function(t,n){const{__scopeMenu:r,...i}=t,o=sm(r);return s.jsx(Rb,{...o,...i,ref:n})},"MenuAnchor")),j0="MenuPortal",[rP,iP]=Gr(j0,{forceMount:void 0}),oP=Oe(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=Sl(j0,t);return s.jsx(rP,{scope:t,forceMount:n,children:s.jsx(mr,{present:n||o.open,children:s.jsx(Bp,{asChild:!0,container:i,children:r})})})},"MenuPortal"),sr="MenuContent",[lP,y0]=Gr(sr),aP=d.forwardRef(Oe(function(t,n){const r=iP(sr,t.__scopeMenu),{forceMount:i=r.forceMount,...o}=t,l=Sl(sr,t.__scopeMenu),a=rm(sr,t.__scopeMenu);return s.jsx(sh.Provider,{scope:t.__scopeMenu,children:s.jsx(mr,{present:i||l.open,children:s.jsx(sh.Slot,{scope:t.__scopeMenu,children:a.modal?s.jsx(cP,{...o,ref:n}):s.jsx(uP,{...o,ref:n})})})})},"MenuContent")),cP=d.forwardRef(Oe(function(t,n){const r=Sl(sr,t.__scopeMenu),i=d.useRef(null),o=Ze(n,i);return d.useEffect(()=>{const l=i.current;if(l)return a0(l)},[]),s.jsx(w0,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:we(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),uP=d.forwardRef(Oe(function(t,n){const r=Sl(sr,t.__scopeMenu);return s.jsx(w0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),dP=lr("MenuContent.ScrollLock"),w0=d.forwardRef(Oe(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:p,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:v,onDismiss:j,disableOutsideScroll:w,...b}=t,x=Sl(sr,r),g=rm(sr,r),y=sm(r),m=v0(r),S=XR(r),[k,N]=d.useState(null),C=d.useRef(null),P=Ze(n,C,x.onContentChange),E=d.useRef(0),O=d.useRef(""),F=d.useRef(0),D=d.useRef(null),T=d.useRef("right"),z=d.useRef(0),Q=w?nm:d.Fragment,Y=w?{as:dP,allowPinchZoom:!0}:void 0,M=Oe($=>{var Se,Me;const Z=O.current+$,V=S().filter(De=>!De.disabled),de=document.activeElement,ge=(Se=V.find(De=>De.ref.current===de))==null?void 0:Se.textValue,je=V.map(De=>De.textValue),ne=T0(je,Z,ge),xe=(Me=V.find(De=>De.textValue===ne))==null?void 0:Me.ref.current;Oe(function De(he){O.current=he,window.clearTimeout(E.current),he!==""&&(E.current=window.setTimeout(()=>De(""),1e3))},"updateSearch")(Z),xe&&setTimeout(()=>xe.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(E.current),[]),du();const B=d.useCallback($=>{var V,de;return T.current===((V=D.current)==null?void 0:V.side)&&P0($,(de=D.current)==null?void 0:de.area)},[]);return s.jsx(lP,{scope:r,searchRef:O,onItemEnter:d.useCallback($=>{B($)&&$.preventDefault()},[B]),onItemLeave:d.useCallback($=>{var Z;B($)||((Z=C.current)==null||Z.focus(),N(null))},[B]),onTriggerLeave:d.useCallback($=>{B($)&&$.preventDefault()},[B]),pointerGraceTimerRef:F,onPointerGraceIntentChange:d.useCallback($=>{D.current=$},[]),children:s.jsx(Q,{...Y,children:s.jsx(Hb,{asChild:!0,trapped:o,onMountAutoFocus:we(l,$=>{var Z;$.preventDefault(),(Z=C.current)==null||Z.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:s.jsx(Up,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:p,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:v,onDismiss:j,children:s.jsx(i0,{asChild:!0,...m,dir:g.dir,orientation:"vertical",loop:i,currentTabStopId:k,onCurrentTabStopIdChange:N,onEntryFocus:we(u,$=>{g.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Pb,{role:"menu","aria-orientation":"vertical","data-state":S0(x.open),"data-radix-menu-content":"",dir:g.dir,...y,...b,ref:P,style:{outline:"none",...b.style},onKeyDown:we(b.onKeyDown,$=>{const V=$.target.closest("[data-radix-menu-content]")===$.currentTarget,de=$.ctrlKey||$.altKey||$.metaKey,ge=$.key.length===1;V&&($.key==="Tab"&&$.preventDefault(),!de&&ge&&M($.key));const je=C.current;if($.target!==je||!JR.includes($.key))return;$.preventDefault();const xe=S().filter(Se=>!Se.disabled).map(Se=>Se.ref.current);g0.includes($.key)&&xe.reverse(),E0(xe)}),onBlur:we(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(E.current),O.current="")}),onPointerMove:we(t.onPointerMove,Rc($=>{const Z=$.target,V=z.current!==$.clientX;if($.currentTarget.contains(Z)&&V){const de=$.clientX>z.current?"right":"left";T.current=de,z.current=$.clientX}}))})})})})})})},"MenuContentImpl")),b0=d.forwardRef(Oe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(tt.div,{role:"group",...i,ref:n})},"MenuGroup")),fP=d.forwardRef(Oe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(tt.div,{...i,ref:n})},"MenuLabel")),rh="MenuItem",cv="menu.itemSelect",k0=d.forwardRef(Oe(function(t,n){const{disabled:r=!1,onSelect:i,...o}=t,l=d.useRef(null),a=rm(rh,t.__scopeMenu),c=y0(rh,t.__scopeMenu),u=Ze(n,l),p=d.useRef(!1),f=Oe(()=>{const h=l.current;if(!r&&h){const v=new CustomEvent(cv,{bubbles:!0,cancelable:!0});h.addEventListener(cv,j=>i==null?void 0:i(j),{once:!0}),nu(h,v),v.defaultPrevented?p.current=!1:a.onClose()}},"handleSelect");return s.jsx(hP,{...o,ref:u,disabled:r,onClick:we(t.onClick,f),onPointerDown:h=>{var v;(v=t.onPointerDown)==null||v.call(t,h),p.current=!0},onPointerUp:we(t.onPointerUp,h=>{var v;p.current||(v=h.currentTarget)==null||v.click()}),onKeyDown:we(t.onKeyDown,h=>{r||h.target!==h.currentTarget||c.searchRef.current!==""&&h.key===" "||qR.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})},"MenuItem")),hP=d.forwardRef(Oe(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:o,...l}=t,a=y0(rh,r),c=v0(r),u=d.useRef(null),p=Ze(n,u),[f,h]=d.useState(!1),[v,j]=d.useState("");return d.useEffect(()=>{const w=u.current;w&&j((w.textContent??"").trim())},[l.children]),s.jsx(sh.ItemSlot,{scope:r,disabled:i,textValue:o??v,children:s.jsx(o0,{asChild:!0,...c,focusable:!i,children:s.jsx(tt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...l,ref:p,onPointerMove:we(t.onPointerMove,Rc(w=>{i?a.onItemLeave(w):(a.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:we(t.onPointerLeave,Rc(w=>a.onItemLeave(w))),onFocus:we(t.onFocus,()=>h(!0)),onBlur:we(t.onBlur,()=>h(!1))})})})},"MenuItemImpl")),pP="MenuRadioGroup",[mP,gP]=Gr(pP,{value:void 0,onValueChange:Oe(()=>{},"onValueChange")}),xP=d.forwardRef(Oe(function(t,n){const{value:r,onValueChange:i,...o}=t,l=Bn(i);return s.jsx(mP,{scope:t.__scopeMenu,value:r,onValueChange:l,children:s.jsx(b0,{...o,ref:n})})},"MenuRadioGroup")),vP="MenuRadioItem",jP=d.forwardRef(Oe(function(t,n){const{value:r,...i}=t,o=gP(vP,t.__scopeMenu),l=r===o.value;return s.jsx(wP,{scope:t.__scopeMenu,checked:l,children:s.jsx(k0,{role:"menuitemradio","aria-checked":l,...i,ref:n,"data-state":C0(l),onSelect:we(i.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),yP="MenuItemIndicator",[wP,k6]=Gr(yP,{checked:!1}),bP=d.forwardRef(Oe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(tt.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),kP="MenuSub",[S6,N6]=Gr(kP);function S0(e){return e?"open":"closed"}Oe(S0,"getOpenState");function N0(e){return e==="indeterminate"}Oe(N0,"isIndeterminate");function C0(e){return N0(e)?"indeterminate":e?"checked":"unchecked"}Oe(C0,"getCheckedState");function E0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Oe(E0,"focusFirst");function A0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Oe(A0,"wrapArray");function T0(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=A0(e,Math.max(o,0));i.length===1&&(l=l.filter(u=>u!==n));const c=l.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}Oe(T0,"getNextMatch");function R0(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,l=t.length-1;o<t.length;l=o++){const a=t[o],c=t[l],u=a.x,p=a.y,f=c.x,h=c.y;p>r!=h>r&&n<(f-u)*(r-p)/(h-p)+u&&(i=!i)}return i}Oe(R0,"isPointInPolygon");function P0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return R0(n,t)}Oe(P0,"isPointerInGraceArea");function Rc(e){return t=>t.pointerType==="mouse"?e(t):void 0}Oe(Rc,"whenMouse");var SP=nP,NP=sP,CP=oP,EP=aP,AP=b0,TP=fP,RP=k0,PP=xP,IP=jP,MP=bP,$P=Object.defineProperty,as=(e,t)=>$P(e,"name",{value:t,configurable:!0}),im="DropdownMenu",[_P,C6]=Wn(im,[x0]),cs=x0(),[OP,I0]=_P(im),DP=as(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:l,modal:a=!0}=e,c=cs(t),u=d.useRef(null),[p,f]=eo({prop:i,defaultProp:o??!1,onChange:l,caller:im});return s.jsx(OP,{scope:t,triggerId:ws(),triggerRef:u,contentId:ws(),open:p,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(h=>!h),[f]),modal:a,children:s.jsx(SP,{...c,open:p,onOpenChange:f,dir:r,modal:a,children:n})})},"DropdownMenu"),LP="DropdownMenuTrigger",FP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...o}=t,l=I0(LP,r),a=cs(r),c=Ze(n,l.triggerRef);return s.jsx(NP,{asChild:!0,...a,children:s.jsx(tt.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...o,ref:c,onPointerDown:we(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(l.onOpenToggle(),l.open||u.preventDefault())}),onKeyDown:we(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&l.onOpenToggle(),u.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),UP=as(e=>{const{__scopeDropdownMenu:t,...n}=e,r=cs(t);return s.jsx(CP,{...r,...n})},"DropdownMenuPortal"),zP="DropdownMenuContent",BP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=I0(zP,r),l=cs(r),a=d.useRef(!1);return s.jsx(EP,{id:o.contentId,"aria-labelledby":o.triggerId,...l,...i,ref:n,onCloseAutoFocus:we(t.onCloseAutoFocus,c=>{var u;a.current||(u=o.triggerRef.current)==null||u.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:we(t.onInteractOutside,c=>{const u=c.detail.originalEvent,p=u.button===0&&u.ctrlKey===!0,f=u.button===2||p;(!o.modal||f)&&(a.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),WP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=cs(r);return s.jsx(AP,{...o,...i,ref:n})},"DropdownMenuGroup")),HP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=cs(r);return s.jsx(TP,{...o,...i,ref:n})},"DropdownMenuLabel")),VP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=cs(r);return s.jsx(RP,{...o,...i,ref:n})},"DropdownMenuItem")),KP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=cs(r);return s.jsx(PP,{...o,...i,ref:n})},"DropdownMenuRadioGroup")),GP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=cs(r);return s.jsx(IP,{...o,...i,ref:n})},"DropdownMenuRadioItem")),YP=d.forwardRef(as(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=cs(r);return s.jsx(MP,{...o,...i,ref:n})},"DropdownMenuSeparator")),om=DP,lm=FP,am=UP,cm=BP,qP=WP,um=HP,ih=VP,QP=KP,JP=GP,Va=YP,XP=Object.defineProperty,ro=(e,t)=>XP(e,"name",{value:t,configurable:!0}),dm="Tabs",[ZP,E6]=Wn(dm,[hu]),M0=hu(),[eI,fm]=ZP(dm),tI=d.forwardRef(ro(function(t,n){const{__scopeTabs:r,value:i,onValueChange:o,defaultValue:l,orientation:a="horizontal",dir:c,activationMode:u="automatic",...p}=t,f=uu(c),[h,v]=eo({prop:i,onChange:o,defaultProp:l??"",caller:dm});return s.jsx(eI,{scope:r,baseId:ws(),value:h,onValueChange:v,orientation:a,dir:f,activationMode:u,children:s.jsx(tt.div,{dir:f,"data-orientation":a,...p,ref:n})})},"Tabs")),nI="TabsList",sI=d.forwardRef(ro(function(t,n){const{__scopeTabs:r,loop:i=!0,...o}=t,l=fm(nI,r),a=M0(r);return s.jsx(i0,{asChild:!0,...a,orientation:l.orientation,dir:l.dir,loop:i,children:s.jsx(tt.div,{role:"tablist","aria-orientation":l.orientation,...o,ref:n})})},"TabsList")),rI="TabsTrigger",iI=d.forwardRef(ro(function(t,n){const{__scopeTabs:r,value:i,disabled:o=!1,...l}=t,a=fm(rI,r),c=M0(r),u=hm(a.baseId,i),p=pm(a.baseId,i),f=i===a.value;return s.jsx(o0,{asChild:!0,...c,focusable:!o,active:f,children:s.jsx(tt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":p,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...l,ref:n,onMouseDown:we(t.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?a.onValueChange(i):h.preventDefault()}),onKeyDown:we(t.onKeyDown,h=>{o||h.target!==h.currentTarget||[" ","Enter"].includes(h.key)&&a.onValueChange(i)}),onFocus:we(t.onFocus,()=>{const h=a.activationMode!=="manual";!f&&!o&&h&&a.onValueChange(i)})})})},"TabsTrigger")),oI="TabsContent",lI=d.forwardRef(ro(function(t,n){const{__scopeTabs:r,value:i,forceMount:o,children:l,...a}=t,c=fm(oI,r),u=hm(c.baseId,i),p=pm(c.baseId,i),f=i===c.value,h=d.useRef(f);return d.useEffect(()=>{const v=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(v)},[]),s.jsx(mr,{present:o||f,children:({present:v})=>s.jsx(tt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!v,id:p,tabIndex:0,...a,ref:n,style:{...t.style,animationDuration:h.current?"0s":void 0},children:v&&l})})},"TabsContent"));function hm(e,t){return`${e}-trigger-${t}`}ro(hm,"makeTriggerId");function pm(e,t){return`${e}-content-${t}`}ro(pm,"makeContentId");var aI=tI,cI=sI,uI=iI,dI=lI;function Ie(e,t){if(!e)return"—";const n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function ke(e,t=Date.now()){if(!e)return"";const n=new Date(e).getTime();if(Number.isNaN(n))return"";const r=Math.round((n-t)/1e3),i=Math.abs(r),[o,l]=i<60?[r,"second"]:i<3600?[Math.round(r/60),"minute"]:i<86400?[Math.round(r/3600),"hour"]:[Math.round(r/86400),"day"];return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(o,l)}function fI(e,t){if(e==null||!Number.isFinite(e))return"—";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:0}).format(e)}catch{return e.toFixed(2)}}function Lt(e){return new Intl.NumberFormat("en-US").format(e)}function on(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function ul(e,t=8){return e.length<=t?e:e.slice(0,t)}function Rs(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Fi(e){return e.replace(/<<<[^<>]*>>>/g,"")}function bt(e,t,n){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?hI(r,n):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${dv(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Lt(r):dv(r):String(e)}case"date":return pI(String(e));default:return typeof e=="string"?e:typeof e=="number"?Lt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function hI(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return fI(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function pI(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short",year:"numeric"}).format(n)}function uv(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short"}).format(n)}function dv(e){return String(Math.round(e*100)/100)}function mI(e,t,n=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,n),i=10**Math.floor(Math.log10(r)),o=[1,2,2.5,5,10].map(a=>a*i).find(a=>a>=r)??i*10,l=[];for(let a=Math.ceil(e/o)*o;a<=t+o/1e3;a+=o)l.push(Math.round(a*1e6)/1e6);return l.filter(a=>a>=e&&a<=t)}function gI({props:e}){if(e.bars.length===0)return s.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(o=>o.value),n=Math.max(0,...t),r=Math.min(0,...t),i=n-r||1;return s.jsx("div",{className:"wb-bars",children:e.bars.map(o=>{const l=Math.abs(o.value)/i;return s.jsxs("div",{className:"wb-bar-row",children:[s.jsx("div",{className:"wb-bar-cat",title:o.category,children:o.category}),s.jsx("div",{className:"wb-bar-track",children:s.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,l*100)}%`,background:o.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),s.jsx("div",{className:"wb-bar-val",children:bt(o.value,e.unit,e.currency)})]},o.category)})})}const xI=/^(diff --git |index [0-9a-f]|--- (a\/|\/dev\/null)|\+\+\+ (b\/|\/dev\/null)|new file mode|deleted file mode|similarity index|rename (from|to) |old mode|new mode|Binary files )/,vI=/^(… |\.\.\. |\(no change\)$|\)/;function jI(e){return e.replace(/\n$/,"").split(`
81
- `).map(n=>({kind:yI(n),text:n}))}function yI(e){return e.startsWith("@@")?"hunk":xI.test(e)||vI.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function wI({text:e,marks:t}){const n=e.toLowerCase(),r=[];for(const l of t){const a=l.trim().toLowerCase();if(a!=="")for(let c=n.indexOf(a);c!==-1;c=n.indexOf(a,c+a.length))r.push([c,c+a.length])}if(r.length===0)return s.jsx(s.Fragment,{children:e===""?" ":e});r.sort((l,a)=>l[0]-a[0]);const i=[];let o=0;for(const[l,a]of r)l<o||(l>o&&i.push(s.jsx("span",{children:e.slice(o,l)},`t${o}`)),i.push(s.jsx("mark",{className:"wb-diff-mark",children:e.slice(l,a)},`m${l}`)),o=a);return o<e.length&&i.push(s.jsx("span",{children:e.slice(o)},`t${o}`)),s.jsx(s.Fragment,{children:i})}function Pc({text:e,limit:t,more:n,label:r="Diff",marks:i}){const o=jI(e),l=t===void 0?o:o.slice(0,t),a=o.length-l.length;return s.jsxs("div",{className:"wb-diff-wrap",children:[s.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:l.map((c,u)=>s.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?s.jsx(wI,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),a>0?s.jsxs("p",{className:"wb-diff-more",children:[a," more line",a===1?"":"s",n?s.jsxs(s.Fragment,{children:[" · ",s.jsx("button",{type:"button",className:"wb-diff-open",onClick:n.onClick,children:n.label})]}):null]}):null]})}function bI({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:bt(t.value,t.unit,null)})]},t.label))}):null,e.diff?s.jsx(Pc,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):s.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const Vt="#/",Ui="#/chat",rt="#/agents",st="#/activity",Jt="#/settings",Fr="#/files",kI="#/welcome";function fv(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function da(e,t={}){const n=new URLSearchParams;t.q&&n.set("q",t.q),t.origin&&n.set("origin",t.origin),t.family&&n.set("family",t.family);const r=n.toString();return`${Fr}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function SI(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[2]??""),r={};return n.get("q")&&(r.q=n.get("q")),n.get("origin")&&(r.origin=n.get("origin")),n.get("family")&&(r.family=n.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function Be(e,t,n){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function NI(e){if($0(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...n?{tab:n}:{}}}catch{return null}}function zo(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function $0(e){const t=/^#\/chat\/g\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{groupId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{}}}catch{return null}}function mt(e,t,n){return`${rt}/${encodeURIComponent(e)}${t?`/${t}${n?`/${n}`:""}`:""}`}function CI(e){const t=/^#\/agents\/([^/]+)(?:\/([a-z-]+)(?:\/([a-z-]+))?)?$/.exec(e);if(!t)return null;try{return{agentId:decodeURIComponent(t[1]),...t[2]?{tab:t[2]}:{},...t[3]?{section:t[3]}:{}}}catch{return null}}function zi(e){return`${st}/conversations/${encodeURIComponent(e)}`}const EI="#/p";function dl(e,t,n){const r=`${EI}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return n?`${r}/${encodeURIComponent(n)}`:r}function mm(e){const t=/^#\/p\/([^/?]+)\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{plugin:decodeURIComponent(t[1]),page:decodeURIComponent(t[2]),...t[3]?{item:decodeURIComponent(t[3])}:{}}}catch{return null}}const AI="p.";function gm(e,t){return`${Jt}/${encodeURIComponent(_0(e,t))}`}function TI(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const n=decodeURIComponent(t[1]);return{plugin:n,page:t[2]?decodeURIComponent(t[2]):n}}function _0(e,t){return`${AI}${e}${t===e?"":`.${t}`}`}function lt(e){return e?`${Jt}/${e}`:Jt}function RI(e){return`${lt("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function PI(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}const II=[{route:Vt,label:"Home"},{route:Ui,label:"Chat"},{route:rt,label:"Agents"},{route:st,label:"Activity"},{route:Fr,label:"Files"},{route:Jt,label:"Settings"}],MI=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],$I=[{id:"you",label:"Profile",group:"you"},{id:"appearance",label:"Appearance",group:"you"},{id:"notifications",label:"Notifications",group:"you"},{id:"memory",label:"Memory",group:"you"},{id:"proposals",label:"Proposals",group:"you"},{id:"accounts",label:"Model accounts",group:"access"},{id:"computer",label:"Computer & browser",group:"access"},{id:"secrets",label:"Keys and secrets",group:"access"},{id:"watchers",label:"Watchers",group:"running"},{id:"backup",label:"Backup",group:"running"},{id:"system",label:"System",group:"running"},{id:"plugins",label:"All plugins",group:"plugins"}];function _I(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const hv=lt("backup");function OI(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return zi(decodeURIComponent(t[1]));const n=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(n)try{return dl("email","mail",n[1]?decodeURIComponent(n[1]):null)}catch{return dl("email","mail")}return e==="#/settings/email"?gm("email","settings"):{"#/overview":Vt,"#/approvals":Vt,"#/events":`${st}/events`,"#/jobs":`${st}/jobs`,"#/conversations":st,"#/missions":`${rt}?tab=missions`,"#/offers":`${rt}?tab=offers`,"#/reminders":`${rt}?tab=reminders`,"#/providers":lt("accounts"),"#/browser":lt("computer"),"#/sentinels":lt("watchers"),"#/settings/sentinels":lt("watchers")}[e]??null}function DI(e){if(e===""||e==="#"||e===Vt)return Vt;if(e.startsWith(Ui))return Ui;if(e.startsWith(rt))return rt;if(e.startsWith(st))return st;if(e.startsWith(Fr))return Fr;if(e.startsWith(Jt))return Jt;const t=mm(e);return t?dl(t.plugin,t.page):Vt}const xm="front-desk",vm=[{id:xm,label:"Front desk",meaning:"Where things go when you do not say who."},{id:"overview",label:"Overview",meaning:"Answers /status and speaks for the watchers."},{id:"recap",label:"Recap",meaning:"Runs /recap."},{id:"maker",label:"Maker",meaning:"/new opens its interview."}],O0=new Set(vm.map(e=>e.id)),pv=e=>O0.has(e);function mv(e,t){const n=t.filter(r=>!O0.has(r));return[...vm.filter(r=>e.has(r.id)).map(r=>r.id),...n.filter((r,i)=>n.indexOf(r)===i)]}function LI(e,t){return e.find(n=>(n.roles??[]).includes(t))}const gv=["coding","finance","mail","research","calendar","files","memory"],FI={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[xm]:"buddi"},UI=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function zI(e){const t=new Set(e.map(n=>n.split(".")[0]??n));for(const[n,r]of UI)if(r.some(i=>t.has(i)))return n;return t.size>0&&[...t].every(n=>n==="memory")?"memory":null}let oh=null;function BI(e){oh=e}function Nl(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const n of e.roles??[]){const r=FI[n];if(r)return{key:r}}const t=zI(e.tools??[]);return t?{key:t}:oh!==null&&e.id===oh?{key:"buddi"}:{key:gv[WI(e.id)%gv.length]??"coding"}}function Cl(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function WI(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t}const HI=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function VI(e){const n=e.replace(/\r\n/g,`
82
- `).split(`
83
-
84
- `),r=n.pop()??"",i=[];for(const o of n){let l=null,a="message";const c=[];for(const u of o.split(`
85
- `)){if(u===""||u.startsWith(":"))continue;const p=u.indexOf(":"),f=p===-1?u:u.slice(0,p),h=p===-1?"":u.slice(p+1).replace(/^ /,"");f==="id"?l=h:f==="event"?a=h:f==="data"&&c.push(h)}c.length===0&&a==="message"||i.push({id:l,name:HI.includes(a)?a:"ping",data:KI(c.join(`
86
- `))})}return{events:i,rest:r}}function KI(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function D0(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),n=e.wait??(c=>new Promise(u=>setTimeout(u,c))),r=e.retryMs??1500;let i=e.lastEventId??null,o=!1,l=null;return(async()=>{var c,u,p,f;for(;!o;){(c=e.onStatus)==null||c.call(e,"connecting"),l=new AbortController;try{const h=await t(e.url,{credentials:"same-origin",signal:l.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!h.ok||!h.body)throw new Error(`stream ${h.status}`);(u=e.onStatus)==null||u.call(e,"open");const v=h.body.getReader(),j=new TextDecoder;let w="";for(;;){const{done:b,value:x}=await v.read();if(b)break;w+=j.decode(x,{stream:!0});const{events:g,rest:y}=VI(w);w=y;for(const m of g)e.onEvent(m),m.id!==null&&(i=m.id);if(o)break}}catch{}if(o)break;(p=e.onStatus)==null||p.call(e,"closed"),await n(r)}(f=e.onStatus)==null||f.call(e,"closed")})(),{close:()=>{o=!0,l==null||l.abort()},lastEventId:()=>i}}const GI="/api/chat/attention/stream";function L0(e,t){const n=(o,l)=>o.name.localeCompare(l.name),r=o=>e.filter(l=>l.anchor===o).sort(n),i=e.filter(o=>o.anchor!=="top"&&o.anchor!=="bottom").sort((o,l)=>o.id===t?l.id===t?0:-1:l.id===t?1:n(o,l));return{top:r("top"),middle:i,bottom:r("bottom")}}function F0(e,t){const n=L0(e,t);return[...n.top,...n.middle,...n.bottom]}function gu(e){if(!e)return null;const t=[];return e.approvals>0&&t.push(e.approvals===1?"one approval is waiting for you":`${e.approvals} approvals are waiting for you`),e.question&&t.push("asked you a question and is holding for the answer"),t.length===0?null:t.join(", and ")}function YI(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function qI(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function QI(){const[e,t]=d.useState(null);return d.useEffect(()=>{let n=!1;const r=()=>{ae("/chat/attention").then(o=>{n||t(o)}).catch(()=>{})};r();const i=D0({url:GI,onEvent:()=>r()});return()=>{n=!0,i.close()}},[]),qI(e)}const jm="maker";function U0(e){return e.filter(t=>t.available&&!t.roles.includes(jm))}function z0(e){return U0(e).length>=2}function JI(e){var t;return((t=e.find(n=>n.roles.includes(jm)))==null?void 0:t.name)??"the agent maker"}const XI="{{default}}";function ZI(e,t){return e.split(XI).join(t??"your assistant")}function e2(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(n=>ZI(n,t))}function t2(e){var n,r;const t=(n=e==null?void 0:e.intro)==null?void 0:n.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function n2(e){const t=(e??"·").trim().split(/\s+/).filter(Boolean);return t.length===0?"·":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function B0(e){var r,i;const t=(r=e.heldBack)==null?void 0:r.message.trim();if(t!==void 0&&t!=="")return`${e.name??"This agent"} is held back. ${t}`;const n=(i=e.unavailableReason)==null?void 0:i.trim();return n&&n!==""?`${e.name??"This agent"} cannot run: ${n}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const s2="Settings → Model accounts",r2="Install it in Settings → Plugins";function lh(e){return e!=null&&e.heldBack?{section:"plugins",label:r2}:{section:"accounts",label:s2}}const i2={home:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),s.jsx("path",{d:"M5.2 8.4v7.4a1 1 0 0 0 1 1h2.6v-4.6h2.4v4.6h2.6a1 1 0 0 0 1-1V8.4"})]})],chat:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 10.6a4.9 4.9 0 0 1-4.9 4.9H7.8L3.6 18l.9-3A4.9 4.9 0 0 1 3 11V8.2A4.9 4.9 0 0 1 7.9 3.3h4.2A4.9 4.9 0 0 1 17 8.2Z"}),s.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),s.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),s.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),s.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,s.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[24,1.9,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),20],files:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 2.8h5.2L16.5 6.6v8.6a1.2 1.2 0 0 1-1.2 1.2H7.5a1.2 1.2 0 0 1-1.2-1.2V4a1.2 1.2 0 0 1 1.2-1.2z"}),s.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),s.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),s.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),s.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),s.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,s.jsx("path",{d:"M3.2 16.4V8.6M8.4 16.4V3.9M13.6 16.4v-5.8M3.2 16.4h13.6"})],bell:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),s.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),s.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),s.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),s.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),s.jsx("path",{d:"M2.9 10h14.2M10 2.9c3.4 3.7 3.4 10.5 0 14.2-3.4-3.7-3.4-10.5 0-14.2Z"})]})],person:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),s.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],sun:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),s.jsx("path",{d:"M10 2.6v1.6M10 15.8v1.6M2.6 10h1.6M15.8 10h1.6M4.8 4.8l1.1 1.1M14.1 14.1l1.1 1.1M4.8 15.2l1.1-1.1M14.1 5.9l1.1-1.1"})]})],notebook:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.5 3.2h8.3a1 1 0 0 1 1 1v11.6a1 1 0 0 1-1 1H5.5a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1Z"}),s.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),s.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),s.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],eye:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.4 10S5.2 4.8 10 4.8 17.6 10 17.6 10 14.8 15.2 10 15.2 2.4 10 2.4 10Z"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),s.jsx("path",{d:"M4 7.2v8a1.2 1.2 0 0 0 1.2 1.2h9.6a1.2 1.2 0 0 0 1.2-1.2v-8M8.2 10.4h3.6"})]})],chip:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),s.jsx("path",{d:"M8 2.8v2.6M12 2.8v2.6M8 14.6v2.6M12 14.6v2.6M2.8 8h2.6M2.8 12h2.6M14.6 8h2.6M14.6 12h2.6"})]})],camera:[17,1.5,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.6 6.2a1.4 1.4 0 0 1 1.4-1.4h2l1.1-1.6h2.8l1.1 1.6h2a1.4 1.4 0 0 1 1.4 1.4v6.4a1.4 1.4 0 0 1-1.4 1.4H4a1.4 1.4 0 0 1-1.4-1.4z"}),s.jsx("circle",{cx:"8.5",cy:"9.2",r:"2.4"})]})],clip:[17,1.5,s.jsx("path",{d:"M13.2 8 8.4 12.8a3 3 0 0 1-4.2-4.2l5.1-5.1a2 2 0 1 1 2.8 2.8l-5 5"})],send:[16,1.8,s.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],thought:[13,1.4,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),s.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,s.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],out:[12,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),s.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,s.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,s.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,s.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],"chevron-down":[14,1.4,s.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),s.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),s.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,s.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,s.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,s.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,s.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-document":[16,1.4,s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,s.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 11l3.6-3.4 2.6 2.4 2-1.8 3.4 3M10.6 6.2h.01"})],"shape-preview":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 6h11.6M4.1 4.7h.01M6 4.7h.01"})],"shape-envelope":[16,1.4,s.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],"shape-structured":[16,1.4,s.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function Ue({name:e,size:t,className:n,...r}){const[i,o,l,a]=i2[e],c=t??a??i;return s.jsx("svg",{className:n,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:l})}const W0="buddi.rosterCollapsed";function o2(){try{return window.localStorage.getItem(W0)==="1"}catch{return!1}}function l2(e){try{window.localStorage.setItem(W0,e?"1":"0")}catch{}}function H0({agents:e,currentId:t,attention:n,onSelect:r,orientation:i="vertical",lastActivity:o,groups:l=[],currentGroupId:a=null,onSelectGroup:c,onNewGroup:u}){const p=[...e.top,...e.middle,...e.bottom],f=i==="vertical"?"right":"bottom",[h,v]=d.useState(o2),j=w=>s.jsx(a2,{agent:w,active:w.id===t,attention:n.get(w.id),side:f,onSelect:r,lastAt:(o==null?void 0:o.get(w.id))??null},w.id);return s.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&h?"true":void 0,children:[e.top.map(j),e.top.length>0&&e.middle.length>0?s.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!h&&e.middle.length>0?s.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,s.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(j),c&&z0(p)?s.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[s.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),s.jsxs("div",{className:"wb-groups-head",children:[s.jsx("span",{className:"wb-groups-label",children:"Groups"}),u?s.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"New group",title:"A team of agents in one conversation",onClick:u,children:s.jsx(Ue,{name:"plus"})}):null]}),l.map(w=>s.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":w.id===a?"true":void 0,"aria-current":w.id===a?"true":void 0,"aria-label":`${w.name}, ${w.members.length} agents`,onClick:()=>c(w.id),children:[s.jsxs("span",{className:"wb-face-mark wb-group-stack","aria-hidden":"true",children:[w.members.slice(0,3).map(b=>{const x=p.find(g=>g.id===b);return s.jsx(ym,{className:"wb-group-chip",id:b,name:(x==null?void 0:x.name)??"?",face:x,initials:1},b)}),w.members.length>3?s.jsxs("span",{className:"wb-group-chip wb-group-more",children:["+",w.members.length-3]}):null]}),s.jsxs("span",{className:"wb-face-text",children:[s.jsx("span",{className:"wb-face-name",children:w.name}),s.jsx("span",{className:"wb-face-status",children:w.members.map(b=>{var x;return((x=p.find(g=>g.id===b))==null?void 0:x.name)??b}).join(", ")})]})]},w.id))]}):null]}),e.bottom.map(j),i==="vertical"?s.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":h?"Show agent names":"Hide agent names","aria-pressed":h,onClick:()=>v(w=>(l2(!w),!w)),children:s.jsx(Ue,{name:h?"chevron-right":"chevron-left"})}):null]})}function a2({agent:e,active:t,attention:n,side:r,onSelect:i,lastAt:o=null}){const l=gu(n),a=l?xv(l):e.available?o?`Last spoke ${ke(o)}`:e.description:e.unavailableReason??"Cannot run right now",c=YI(n),u=e.unavailableReason??"This agent cannot run on this machine right now.",p=[e.name,e.available?null:"unavailable",l,t?"current":null].filter(f=>f!==null&&f!=="").join(" — ");return s.jsxs(Cc,{children:[s.jsx(Ec,{asChild:!0,children:s.jsxs("button",{className:"wb-face",...Cl(Nl(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":p,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[s.jsx(ym,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),s.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[s.jsxs("span",{className:"wb-face-name",children:[e.name,s.jsxs("span",{className:"wb-face-handle",children:["@",e.handle]})]}),s.jsx("span",{className:"wb-face-status","data-tone":l?"critical":void 0,children:a})]}),c?s.jsx("span",{className:"wb-face-badge","data-kind":c.count===null?"dot":"count","data-testid":`agent-badge-${e.id}`,"aria-hidden":"true",children:c.count===null?"":c.count}):null,e.available?null:s.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:s.jsx(Ue,{name:"out"})})]})}),s.jsx(Ac,{children:s.jsxs(Tc,{className:"ui-tip",side:r,sideOffset:8,children:[s.jsx("span",{className:"ui-tip-title",children:e.name}),s.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:u}),l?s.jsx("span",{className:"ui-tip-alert",children:xv(l)}):null]})})]})}function xv(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function c2(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t%6+1}function ym({className:e,id:t,name:n,face:r,tint:i,size:o,unavailable:l,initials:a=2}){const[c,u]=d.useState(null),p=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,f=r==null?void 0:r.avatar,h=p?"image":f==null?void 0:f.kind,v=t?Cl(Nl({id:t,accent:r==null?void 0:r.accent,roles:r==null?void 0:r.roles,tools:r==null?void 0:r.tools})):void 0;return s.jsx("span",{className:e,"data-tint":v?void 0:i,"data-size":o,"data-kind":h,"data-unavailable":l?"true":void 0,...v,"aria-hidden":"true",children:p?s.jsx("img",{src:p,alt:"",onError:()=>u(p)}):(f==null?void 0:f.kind)==="image"?s.jsx("img",{src:f.url,alt:""}):(f==null?void 0:f.kind)==="emoji"?f.value:n2(n).slice(0,a)})}function us({id:e,name:t,size:n,unavailable:r,face:i}){return s.jsx(ym,{className:"ui-avatar",id:e,tint:c2(e),name:t,size:n,unavailable:r,face:i})}function Zt({agents:e,id:t,size:n}){const r=e.find(i=>i.id===t);return s.jsx(us,{id:t,name:(r==null?void 0:r.name)??t,size:n,unavailable:r?!r.available:!1,face:r})}const V0=d.createContext(null);function u2({picture:e,children:t}){return s.jsx(V0.Provider,{value:e??null,children:t})}function K0({size:e}){const t=d.useContext(V0),[n,r]=d.useState(null);return!t||t===n?null:s.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:s.jsx("img",{src:t,alt:"",onError:()=>r(t)})})}const G0=d.createContext([]);function ur({text:e,className:t}){const n=ah(e.replace(/\r\n/g,`
87
- `).split(`
88
- `));return s.jsx("div",{className:t??"wb-md",children:n.map((r,i)=>s.jsx(ch,{block:r},i))})}const vv=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,jv=/^(#{1,6})\s+(.*?)\s*#*\s*$/,yv=/^\s*([-*_])(\s*\1){2,}\s*$/,fa=/^(\s*)([-*+])\s+(.*)$/,ko=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,ha=/^\s*>\s?(.*)$/,gd=/^\s*\|.*\|\s*$/,wv=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function ah(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r.trim()===""){n+=1;continue}const i=vv.exec(r);if(i){const a=i[2],c=[];for(n+=1;n<e.length&&!new RegExp(`^\\s*${a}\\s*$`).test(e[n]);)c.push(e[n]),n+=1;n+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
89
- `)});continue}const o=jv.exec(r);if(o){t.push({type:"h",level:o[1].length,text:o[2]}),n+=1;continue}if(yv.test(r)){t.push({type:"hr"}),n+=1;continue}if(ha.test(r)){const a=[];for(;n<e.length&&ha.test(e[n]);)a.push(ha.exec(e[n])[1]),n+=1;t.push({type:"quote",blocks:ah(a),raw:a.join(`
90
- `)});continue}if(gd.test(r)&&n+1<e.length&&wv.test(e[n+1])){const a=vd(r),c=vd(e[n+1]).map(p=>{const f=p.startsWith(":"),h=p.endsWith(":");return f&&h?"center":h?"right":f?"left":null});n+=2;const u=[];for(;n<e.length&&gd.test(e[n]);)u.push(vd(e[n])),n+=1;t.push({type:"table",head:a,rows:u,align:c});continue}if(fa.test(r)||ko.test(r)){const a=ko.exec(r)??fa.exec(r),c=ko.test(r),u=a[1].length,p=c?Number(a[2]):1,f=[];for(;n<e.length;){const h=c?ko.exec(e[n]):fa.exec(e[n]);if(!h||h[1].length!==u)break;const v=[h[3]];for(n+=1;n<e.length;){const j=e[n],w=j.trim()!==""&&xd(j)>u,b=j.trim()===""&&n+1<e.length&&e[n+1].trim()!==""&&xd(e[n+1])>u;if(!w&&!b)break;v.push(j.trim()===""?"":j.slice(Math.min(xd(j),u+2))),n+=1}f.push(ah(v))}t.push({type:"list",ordered:c,start:p,items:f});continue}const l=[];for(;n<e.length;){const a=e[n];if(a.trim()===""||vv.test(a)||jv.test(a)||yv.test(a)||ha.test(a)||fa.test(a)||ko.test(a)||gd.test(a)&&n+1<e.length&&wv.test(e[n+1]))break;l.push(a.trim()),n+=1}l.length>0&&t.push({type:"p",text:l.join(`
91
- `)})}return t}function xd(e){return e.length-e.trimStart().length}function vd(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="";for(let i=0;i<t.length;i+=1){const o=t[i];if(o==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(o==="|"){n.push(r.trim()),r="";continue}r+=o}return n.push(r.trim()),n}function ch({block:e}){switch(e.type){case"p":return s.jsx("p",{children:Ln(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),n=`h${Math.min(t+2,6)}`;return s.jsx(n,{className:"wb-md-h","data-level":t,children:Ln(e.text)})}case"code":return s.jsxs("div",{className:"wb-md-code-frame",children:[s.jsxs("div",{className:"wb-md-code-head",children:[s.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),s.jsx(bv,{text:e.text,what:"code",always:!0})]}),s.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:s.jsx("code",{children:e.text})})]});case"quote":return s.jsxs("div",{className:"wb-md-copyable",children:[s.jsx("blockquote",{children:e.blocks.map((t,n)=>s.jsx(ch,{block:t},n))}),s.jsx(bv,{text:e.raw,what:"quote"})]});case"hr":return s.jsx("hr",{});case"list":{const t=e.items.map((n,r)=>s.jsx("li",{children:n.map((i,o)=>i.type==="p"?s.jsx(d.Fragment,{children:Ln(i.text)},o):s.jsx(ch,{block:i},o))},r));return e.ordered?s.jsx("ol",{start:e.start,children:t}):s.jsx("ul",{children:t})}case"table":return s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table wb-md-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.head.map((t,n)=>s.jsx("th",{style:e.align[n]?{textAlign:e.align[n]}:void 0,children:Ln(t)},n))})}),s.jsx("tbody",{children:e.rows.map((t,n)=>s.jsx("tr",{children:t.map((r,i)=>s.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:Ln(r)},i))},n))})]})})}}function bv({text:e,what:t,always:n=!1}){const[r,i]=d.useState("idle"),o=()=>{var l;if(!((l=navigator.clipboard)!=null&&l.writeText)){i("failed");return}navigator.clipboard.writeText(e).then(()=>i("done"),()=>i("failed")),window.setTimeout(()=>i("idle"),1500)};return s.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":n||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:o,children:r==="done"?"Copied":r==="failed"?"Select to copy":s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),s.jsx("path",{d:"M8.5 4.5V3a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4.5a1 1 0 0 0 1 1h1.5"})]})})}function d2({handle:e}){const n=d.useContext(G0).find(r=>r.handle.toLowerCase()===e.toLowerCase());return n?s.jsxs(Cc,{children:[s.jsx(Ec,{asChild:!0,children:s.jsxs("a",{className:"wb-mention-link",href:Be(n.id),children:["@",n.handle]})}),s.jsx(Ac,{children:s.jsxs(Tc,{className:"wb-agent-card",sideOffset:6,children:[s.jsx(us,{id:n.id,name:n.name,face:n,unavailable:!n.available}),s.jsxs("span",{className:"wb-agent-card-text",children:[s.jsx("span",{className:"wb-agent-card-name",children:n.name}),s.jsx("span",{className:"wb-agent-card-desc",children:n.description}),s.jsxs("span",{className:"wb-agent-card-meta",children:[n.model,n.available?"":" · unavailable"]})]})]})})]}):s.jsxs(s.Fragment,{children:["@",e]})}const f2=new RegExp("(`+)([\\s\\S]*?[^`])\\1(?!`)|\\*\\*([^*]+?)\\*\\*|__([^_]+?)__|~~([^~]+?)~~|(?<![\\w*])\\*([^*\\n]+?)\\*(?![\\w*])|(?<![\\w_])_([^_\\n]+?)_(?![\\w_])|\\[([^\\]\\n]+)\\]\\((https?:\\/\\/[^\\s)]+)\\)|<?(https?:\\/\\/[^\\s<>)\\]]+[^\\s<>)\\].,;:!?'\"])>?|(?<![\\w@/])@([a-z0-9][a-z0-9_-]{0,63})(?![\\w-])","i");function Ln(e){const t=[];let n=e,r=0;for(;n!=="";){const i=f2.exec(n);if(!i){t.push(...kv(n,r));break}i.index>0&&t.push(...kv(n.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(s.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(s.jsx("strong",{children:Ln(i[3])},r)):i[4]!==void 0?t.push(s.jsx("strong",{children:Ln(i[4])},r)):i[5]!==void 0?t.push(s.jsx("s",{children:Ln(i[5])},r)):i[6]!==void 0?t.push(s.jsx("em",{children:Ln(i[6])},r)):i[7]!==void 0?t.push(s.jsx("em",{children:Ln(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(s.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:Ln(i[8])},r)):i[10]!==void 0?t.push(s.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(s.jsx(d2,{handle:i[11]},r)),n=n.slice(i.index+i[0].length)}return t}function kv(e,t){return e.split(`
92
- `).flatMap((r,i)=>i===0?[r]:[s.jsx("br",{},`${t}-br-${i}`),r])}function h2({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:bt(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?s.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?s.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:s.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?s.jsx("div",{className:"wb-doc",children:s.jsx(ur,{text:e.text})}):s.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}function me(e,t){if(t===""||t==="$")return e;let n=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,o="",l=""]=i;if(o!==""){if(n===null||typeof n!="object")return;n=n[o]}for(const a of l.match(/\d+/g)??[]){if(!Array.isArray(n))return;n=n[Number(a)]}if(n===void 0)return}return n}function be(e,t){if(t)return"const"in t?t.const:me(e,t.path)}function rr(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function Ge(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Rr(e){return Array.isArray(e)?e:[]}function p2(e,t){const n=Rr(me(e,t.points)).map(i=>{const o=rr(me(i,t.y)),l=Ge(me(i,t.x));return o===null||l===null?null:{x:l,y:o}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const o=rr(be(e,i.value));return o===null?null:{value:o,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:n,unit:t.unit??"number",currency:Ge(be(e,t.currency)),label:Ge(be(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:rr(be(e,t.shadeBelow)),events:m2(e,t)}}function m2(e,t){const n=t.events;if(!n)return[];const r=[],i=(o,l)=>{const a=Ge(me(o,n.label));if(a===null)return;const c=Ge(me(o,n.at))??l;c!==null&&r.push({at:c,label:a,amount:n.amount?rr(me(o,n.amount)):null})};if(n.parent){for(const o of Rr(me(e,t.points))){const l=Ge(me(o,t.x));for(const a of Rr(me(o,n.parent)))i(a,l)}return r}for(const o of Rr(me(e,n.path??t.points)))i(o,null);return r}function g2(e,t){const n=(t.columns??[]).map(a=>({key:a.key,label:a.label,type:a.type??"text"})),r=a=>(t.columns??[]).map(c=>{const u=me(a,c.key);let p=null;if(c.bar){const f=rr(be(a,c.bar.max))??rr(be(e,c.bar.max)),h=rr(u);if(f!==null&&f>0&&h!==null){const v=Math.max(0,Math.min(1,h/f));p={fraction:v,tone:v2(v*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:Ge(be(a,c.currency))??Ge(be(e,c.currency)),bar:p}}),i=Rr(me(e,t.rows)),o=t.groupBy?x2(i,t.groupBy,r):[{label:null,rows:i.map(r)}],l=(t.summary??[]).map(a=>({label:a.label,value:be(e,a.value),unit:a.unit??"text",currency:Ge(be(e,a.currency)),tone:a.tone??"neutral"}));return{columns:n,groups:o,summary:l,empty:t.empty??"Nothing to show."}}function x2(e,t,n){const r=new Map;for(const i of e){const o=String(me(i,t.key)??""),l=r.get(o);l?l.push(i):r.set(o,[i])}return[...r.entries()].map(([i,o])=>{var l;return{label:((l=t.labels)==null?void 0:l[i])??i,rows:o.map(n)}})}function v2(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,o)=>o.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function j2(e,t){return{bars:Rr(me(e,t.bars)).map(r=>{const i=rr(me(r,t.value)),o=Ge(me(r,t.category));return i===null||o===null?null:{category:o,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:Ge(be(e,t.currency))}}function y2(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:be(e,r.value),unit:r.unit??"text",currency:Ge(be(e,r.currency)),tone:r.tone??"neutral"}))};const n=me(e,t.from??"$");return n===null||typeof n!="object"||Array.isArray(n)?{pairs:[]}:{pairs:Object.entries(n).map(([r,i])=>({label:Wt(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}function w2(e,t){const n=Ge(be(e,t.kind)),r=n==="image"||n==="pdf"?n:"text",i=t.src?Ge(me(e,t.src)):null;return{kind:r,text:t.text?Ge(me(e,t.text)):null,src:i&&q0(i)?i:null,title:Ge(be(e,t.title)),metadata:(t.metadata??[]).map(o=>({label:o.label,value:be(e,o.value),unit:o.unit??"text"}))}}function b2(e,t){const n=t.diff?me(e,t.diff):void 0;return{diff:typeof n=="string"&&n.trim()!==""?n:null,title:Ge(be(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:be(e,r.value),unit:r.unit??"text"}))}}function k2(e,t){const n=t.output?me(e,t.output):void 0,r=l=>{const a=l?me(e,l):void 0;return typeof a=="number"&&Number.isInteger(a)?a:null},i=r(t.omittedBytes),o=t.elapsedMs?me(e,t.elapsedMs):void 0;return{command:Ge(be(e,t.command)),output:typeof n=="string"?n:null,exitCode:r(t.exitCode),elapsedMs:typeof o=="number"&&Number.isFinite(o)&&o>=0?o:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(l=>({label:l.label,value:be(e,l.value),unit:l.unit??"text"}))}}const S2=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Y0(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&S2.test(t)?t.toLowerCase():null}function N2(e,t){return{artifactId:t.src?Y0(me(e,t.src)):null,title:Ge(be(e,t.title)),caption:Ge(be(e,t.caption)),...t.captionLabel?{captionLabel:Ge(be(e,t.captionLabel))}:{}}}function Sv(e){if(!q0(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const n=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return n?{plugin:n[1],name:n[2]}:null}function C2(e,t){const n=t.src?Ge(me(e,t.src)):null,r=t.port?me(e,t.port):null,i=t.awaiting?Ge(me(e,t.awaiting)):null;return{target:n?Sv(n):null,title:Ge(be(e,t.title)),output:t.output?Ge(me(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?Sv(i):null,reloadsItself:t.reloadsItself?me(e,t.reloadsItself)===!0:!1,ports:t.ports?E2(me(e,t.ports)):[]}}function E2(e){const t=Rr(e).filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>0&&n<=65535);return[...new Set(t)].sort((n,r)=>n-r)}function q0(e){return e.startsWith("/")&&!e.startsWith("//")}function Wt(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Q0(e,t){const n=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:p2(t,n)};case"table":return{renderer:"table",props:g2(t,n)};case"bars":return{renderer:"bars",props:j2(t,n)};case"keyvalue":return{renderer:"keyvalue",props:y2(t,n)};case"document":return{renderer:"document",props:w2(t,n)};case"diff":return{renderer:"diff",props:b2(t,n)};case"terminal":return{renderer:"terminal",props:k2(t,n)};case"image":return{renderer:"image",props:N2(t,n)};case"preview":return{renderer:"preview",props:C2(t,n)};default:return{renderer:"structured",props:{value:t}}}}var A2=Object.defineProperty,Vn=(e,t)=>A2(e,"name",{value:t,configurable:!0}),wm="Dialog",[J0,A6]=Wn(wm),[T2,_s]=J0(wm),R2=Vn(e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,a=d.useRef(null),c=d.useRef(null),[u,p]=eo({prop:r,defaultProp:i??!1,onChange:o,caller:wm}),[f,h]=d.useState(0),[v,j]=d.useState(0);return s.jsx(T2,{scope:t,triggerRef:a,contentRef:c,contentId:ws(),titleId:ws(),descriptionId:ws(),titlePresent:f>0,descriptionPresent:v>0,setTitleCount:h,setDescriptionCount:j,open:u,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(w=>!w),[p]),modal:l,children:n})},"Dialog"),X0="DialogPortal",[P2,Z0]=J0(X0,{forceMount:void 0}),I2=Vn(e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=_s(X0,t);return s.jsx(P2,{scope:t,forceMount:n,children:d.Children.map(r,l=>s.jsx(mr,{present:n||o.open,children:s.jsx(Bp,{asChild:!0,container:i,children:l})}))})},"DialogPortal"),uh="DialogOverlay",M2=d.forwardRef(Vn(function(t,n){const r=Z0(uh,t.__scopeDialog),{forceMount:i=r.forceMount,...o}=t,l=_s(uh,t.__scopeDialog);return l.modal?s.jsx(mr,{present:i||l.open,children:s.jsx(_2,{...o,ref:n})}):null},"DialogOverlay")),$2=lr("DialogOverlay.RemoveScroll"),_2=d.forwardRef(Vn(function(t,n){const{__scopeDialog:r,...i}=t,o=_s(uh,r),l=Yw(),a=Ze(n,l);return s.jsx(nm,{as:$2,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(tt.div,{"data-state":bm(o.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),fl="DialogContent",O2=d.forwardRef(Vn(function(t,n){const r=Z0(fl,t.__scopeDialog),{forceMount:i=r.forceMount,...o}=t,l=_s(fl,t.__scopeDialog);return s.jsx(mr,{present:i||l.open,children:l.modal?s.jsx(D2,{...o,ref:n}):s.jsx(L2,{...o,ref:n})})},"DialogContent")),D2=d.forwardRef(Vn(function(t,n){const r=_s(fl,t.__scopeDialog),i=d.useRef(null),o=Ze(n,r.contentRef,i);return d.useEffect(()=>{const l=i.current;if(l)return a0(l)},[]),s.jsx(ek,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:we(t.onCloseAutoFocus,l=>{var a;l.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:we(t.onPointerDownOutside,l=>{const a=l.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&l.preventDefault()}),onFocusOutside:we(t.onFocusOutside,l=>l.preventDefault())})},"DialogContentModal")),L2=d.forwardRef(Vn(function(t,n){const r=_s(fl,t.__scopeDialog),i=d.useRef(!1),o=d.useRef(!1);return s.jsx(ek,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var a,c;(a=t.onCloseAutoFocus)==null||a.call(t,l),l.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),l.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:l=>{var u,p;(u=t.onInteractOutside)==null||u.call(t,l),l.defaultPrevented||(i.current=!0,l.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=l.target;((p=r.triggerRef.current)==null?void 0:p.contains(a))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&o.current&&l.preventDefault()}})},"DialogContentNonModal")),ek=d.forwardRef(Vn(function(t,n){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:l,...a}=t,c=_s(fl,r);return du(),s.jsx(s.Fragment,{children:s.jsx(Hb,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:l,children:s.jsx(Up,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":bm(c.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),F2="DialogTitle",U2=d.forwardRef(Vn(function(t,n){const{__scopeDialog:r,...i}=t,o=_s(F2,r),{setTitleCount:l}=o;return sn(()=>(l(a=>a+1),()=>l(a=>a-1)),[l]),s.jsx(tt.h2,{id:o.titleId,...i,ref:n})},"DialogTitle")),z2="DialogClose",B2=d.forwardRef(Vn(function(t,n){const{__scopeDialog:r,...i}=t,o=_s(z2,r);return s.jsx(tt.button,{type:"button",...i,ref:n,onClick:we(t.onClick,()=>o.onOpenChange(!1))})},"DialogClose"));function bm(e){return e?"open":"closed"}Vn(bm,"getState");const W2=5;function se(e,t,n){const[r,i]=d.useState(void 0),[o,l]=d.useState(null),[a,c]=d.useState(!0),[u,p]=d.useState(0),[f,h]=d.useState(0),v=d.useRef(e);return v.current=e,d.useEffect(()=>{let j=!1;return c(!0),v.current().then(w=>{j||(i(w),l(null),h(0))}).catch(w=>{j||(l(w instanceof le?w.message:String(w)),h(b=>b+1))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[...t,u]),d.useEffect(()=>{if(!n||f>=W2)return;const j=window.setTimeout(()=>p(w=>w+1),n*2**f);return()=>window.clearTimeout(j)},[n,f,u]),{data:r,error:o,loading:a,reload:()=>{h(0),p(j=>j+1)}}}function Yr(...e){return e.filter(Boolean).join(" ")}function R({variant:e,size:t,className:n,type:r="button",...i}){return s.jsx("button",{type:r,className:Yr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function ln({variant:e,size:t,className:n,...r}){return s.jsx("a",{className:Yr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function q({children:e,align:t,valign:n,className:r}){return s.jsx("div",{className:Yr("ui-toolbar",r),"data-align":t,"data-valign":n,children:e})}function io(){return s.jsx("span",{className:"ui-toolbar-spacer"})}function X({label:e,hint:t,inline:n,grow:r,wide:i,children:o}){return s.jsxs("div",{className:"ui-field","data-inline":n?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[s.jsxs("label",{className:"ui-field-control",children:[s.jsx("span",{className:"ui-field-label",children:e}),o]}),t?s.jsx("span",{className:"ui-field-hint",children:t}):null]})}function Ps({children:e,dense:t}){return s.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,children:e})}function pe({tone:e,mono:t,dot:n,children:r,className:i,title:o}){return s.jsxs("span",{className:Yr("ui-pill",t&&"mono",i),"data-tone":e,title:o,children:[n?s.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function Ka({children:e}){return s.jsx("span",{className:"ui-tag",children:e})}function xu({state:e}){const t=e==="succeeded"||e==="approved"||e==="fired"||e==="running"||e==="leased"?"good":e==="failed"||e==="rejected"||e==="unknown"||e==="error"||e==="refused"?"critical":e==="pending"||e==="suspended"||e==="expired"||e==="paused"?"warning":void 0;return s.jsx(pe,{tone:t,children:e})}function H({tone:e,title:t,children:n,role:r}){return s.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?s.jsx("div",{className:"ui-notice-title",children:t}):null,n]})}function re({message:e}){return e?s.jsx(H,{tone:"critical",role:"alert",children:e}):null}function ie({mascot:e,warm:t,title:n,action:r,children:i}){return t||n?s.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[n?s.jsx("div",{className:"ui-empty-title",children:n}):null,s.jsx("div",{children:i}),r]}):e?s.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[s.jsx(K0,{size:"sm"}),s.jsx("p",{children:i})]}):s.jsx("p",{className:"ui-empty",children:i})}function kt({icon:e,title:t,action:n,children:r}){return s.jsxs("div",{className:"ui-empty-state",children:[e?s.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?s.jsx(Ue,{name:e}):e}):null,s.jsx("div",{className:"ui-empty-state-title",children:t}),r?s.jsx("p",{className:"ui-empty-state-line",children:r}):null,n?s.jsx("div",{className:"ui-empty-state-action",children:n}):null]})}function H2({children:e}){return s.jsx("div",{className:"ui-page",children:e})}function km({title:e,lede:t,actions:n,before:r}){return s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[r,s.jsx("span",{children:e})]}),n?s.jsx("div",{className:"ui-page-actions",children:n}):null]}),t?s.jsx("p",{className:"ui-page-lede",children:t}):null]})}function cn({embedded:e,title:t,lede:n,actions:r,children:i}){return e?s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):s.jsxs(H2,{children:[s.jsx(km,{title:t,lede:n,actions:r}),i]})}function G({title:e,aside:t,actions:n,panel:r,flush:i,foot:o,children:l}){const a=e||t||n?s.jsxs("div",{className:"ui-section-head",children:[e?s.jsx("h3",{className:"ui-section-title",children:e}):s.jsx("span",{}),t||n?s.jsxs("div",{className:"ui-section-side",children:[t?s.jsx("span",{className:"ui-section-aside",children:t}):null,n?s.jsx("div",{className:"ui-section-actions",children:n}):null]}):null]}):null;return s.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[a,r?s.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[l,o?s.jsx("div",{className:"ui-panel-foot",children:o}):null]}):s.jsxs(s.Fragment,{children:[l,o?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:o}):null]})]})}function at({title:e,tool:t,actions:n,flush:r,children:i}){return s.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||n?s.jsxs("header",{className:"ui-panel-head",children:[e?s.jsx("h3",{className:"ui-panel-title",children:e}):s.jsx("span",{}),t?s.jsx("span",{className:"ui-panel-tool",children:t}):null,n?s.jsx("div",{className:"ui-panel-actions",children:n}):null]}):null,i]})}function Ur({tone:e,title:t,meta:n,actions:r,children:i,foot:o,as:l="div"}){return s.jsxs(l,{className:"ui-card","data-tone":e,children:[t||n||r?s.jsxs("div",{className:"ui-card-head",children:[t?s.jsx("h3",{className:"ui-card-title",children:t}):null,n,r?s.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,o?s.jsx("div",{className:"ui-card-foot",children:o}):null]})}function K({gap:e,divided:t,children:n}){return s.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:n})}function V2({children:e}){return s.jsx("div",{className:"ui-row",children:e})}function vu({inline:e,children:t}){return s.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function es({label:e,value:t,note:n,tone:r,size:i}){return s.jsxs("div",{className:"ui-stat",children:[s.jsx("div",{className:"ui-stat-k",children:e}),s.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),n?s.jsx("div",{className:"ui-stat-n",children:n}):null]})}function Tt({items:e}){return s.jsx("dl",{className:"ui-kv",children:e.map((t,n)=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:t.value})]},t.key??n))})}function an({children:e}){return s.jsx("div",{className:"ui-table-wrap",children:s.jsx("table",{className:"ui-table",children:e})})}function K2({value:e,label:t}){const n=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return s.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-valuetext":`${n}%`,children:s.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${n}%`}})})}function ft({children:e,label:t}){return s.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function St({summary:e,boxed:t,open:n,className:r,onToggle:i,children:o}){return s.jsxs("details",{className:Yr("ui-details",r),"data-boxed":t?"true":void 0,open:n,onToggle:i?l=>i(l.currentTarget.open):void 0,children:[s.jsx("summary",{children:e}),o]})}function qt({title:e,onClose:t,size:n,children:r}){return s.jsx(R2,{open:!0,onOpenChange:i=>{i||t()},children:s.jsxs(I2,{children:[s.jsx(M2,{className:"ui-sheet-overlay"}),s.jsxs(O2,{className:"ui-sheet","data-size":n,"aria-describedby":void 0,children:[s.jsxs("div",{className:"ui-sheet-head",children:[s.jsx(U2,{className:"ui-sheet-title",children:e}),s.jsx(B2,{asChild:!0,children:s.jsx(R,{size:"sm",children:"Close"})})]}),r]})]})})}function ju({level:e,label:t,children:n}){return s.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:n})}function yu({href:e,active:t,count:n,onClick:r,children:i}){return s.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,n?s.jsx("span",{className:"ui-count",children:n}):null]})}function Ga({label:e,options:t,value:n,onChange:r}){return s.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>s.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===n,onClick:()=>r(i.value),children:i.label},i.value))})}function Ft({children:e}){return s.jsx("div",{className:"ui-list",children:e})}function Kt({href:e,onClick:t,lead:n,title:r,sub:i,side:o}){const l=s.jsxs(s.Fragment,{children:[n,s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:r}),i?s.jsx("span",{className:"ui-list-sub",children:i}):null]}),o?s.jsx("span",{className:"ui-list-side",children:o}):null]});return e?s.jsx("a",{className:"ui-list-row",href:e,onClick:t?a=>{a.preventDefault(),t()}:void 0,children:l}):s.jsx("div",{className:"ui-list-row",children:l})}function tk({href:e,onClick:t,current:n,lead:r,title:i,meta:o,sub:l,snippet:a,side:c}){return s.jsxs("a",{className:"ui-pick",href:e,"aria-current":n?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?s.jsx("span",{className:"ui-pick-lead",children:r}):null,s.jsxs("span",{className:"ui-pick-main",children:[s.jsxs("span",{className:"ui-pick-top",children:[s.jsx("span",{className:"ui-pick-title",children:i}),o?s.jsx("span",{className:"ui-pick-meta",children:o}):null]}),l||c?s.jsxs("span",{className:"ui-pick-line",children:[l?s.jsx("span",{className:"ui-pick-sub",children:l}):null,c?s.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,a?s.jsx("span",{className:"ui-pick-snippet",children:a}):null]})]})}function nk({list:e,detail:t,empty:n,label:r,className:i}){return s.jsxs("div",{className:Yr("ui-split",i),"data-open":t?"true":void 0,children:[s.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),s.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??s.jsx("p",{className:"ui-empty ui-split-empty",children:n})})]})}function dh({children:e,onRemove:t,label:n}){return s.jsxs("span",{className:"ui-chip",children:[e,s.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${n}`,onClick:t,children:"×"})]})}function sk({main:e,filters:t,filtersOpen:n,onToggleFilters:r,active:i,chips:o,actions:l,onSubmit:a,label:c}){return s.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),a()},children:[s.jsxs("div",{className:"ui-searchbar-row",children:[e?s.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?s.jsxs(R,{"aria-expanded":n===!0,"aria-pressed":n===!0,onClick:r,children:["Filters",i?s.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?s.jsx("div",{className:"ui-searchbar-inline",children:t}):null,l?s.jsx("div",{className:"ui-searchbar-actions",children:l}):null]}),t&&r&&n?s.jsx("div",{className:"ui-searchbar-filters",children:t}):null,o?s.jsx("div",{className:"ui-searchbar-chips",children:o}):null]})}function G2({size:e}){return s.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function Y2({quiet:e,still:t,className:n,children:r}){return s.jsx("div",{className:Yr("ui-fieldbg",n),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function q2(e){const t={};for(const n of e??[])t[n.key]=n.default;return t}function Sm(e){const[t,n]=d.useState({}),r=e??[],i={...q2(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:s.jsx("div",{className:"ui-choices",children:r.map(o=>s.jsx(X,{label:o.label,inline:!0,children:s.jsx("select",{value:i[o.key],onChange:l=>n(a=>({...a,[o.key]:l.target.value})),children:o.options.map(l=>s.jsx("option",{value:l,children:l},l))})},o.key))})}}function Q2({props:e,timezone:t="UTC",onDecided:n}){var g;const[r,i]=d.useState(null),[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(null);d.useEffect(()=>{let y=!1;return i(null),l(null),A.approval(e.approvalId).then(m=>{y||i(m)}).catch(m=>{y||l(m instanceof le?m.message:String(m))}),()=>{y=!0}},[e.approvalId]);const{values:f,controls:h}=Sm(r==null?void 0:r.choices),v=(y,m)=>{p(y),l(null),(f&&y==="approve"?A.decide(e.approvalId,y,m,f):A.decide(e.approvalId,y,m)).then(S=>{i(S.action),n==null||n(S.action)}).catch(S=>l(S instanceof le?S.message:String(S))).finally(()=>p(null))};if(o&&!r)return s.jsx("p",{className:"wb-empty",children:o});if(!r)return s.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const j=r.state==="pending",w=(g=r.permissionScopes)==null?void 0:g.includes("always"),b=J2(r),x=(r.preview??"").split(`
93
- `).length>12||(r.preview??"").length>900;return s.jsxs("div",{children:[s.jsxs("div",{className:"ui-stats","data-inline":"true",children:[s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"Tool"}),s.jsx("div",{className:"ui-stat-v mono",children:r.tool})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"State"}),s.jsx("div",{className:"ui-stat-v","data-tone":X2(r.state),children:r.state})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:j?"Expires":"Decided"}),s.jsx("div",{className:"ui-stat-v","data-size":"sm",children:Ie(j?r.expiresAt:r.decidedAt,t)})]})]}),s.jsx(re,{message:o}),j?h:null,j?s.jsxs("div",{className:"wb-row-wrap wb-block",children:[s.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>v("approve"),children:u==="approve"?"Approving…":w?"Allow once":"Approve"}),w?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>v("approve","conversation"),children:"Auto: this conversation"}),s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>v("approve","always"),children:"Always: this agent"})]}):null,s.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>v("reject"),children:u==="reject"?"Rejecting…":"Reject"}),s.jsx("span",{className:"wb-hint",children:w?"Auto-mode and Always also approve future calls to this tool within that scope. Host permissions can be revoked under Host execution.":"This runs the action exactly as printed above."})]}):s.jsxs("p",{className:"muted",children:[r.state," ",r.decidedBy?`by ${r.decidedBy}`:""," ",r.decidedVia?`via ${r.decidedVia}`:""]}),s.jsx("h4",{className:"ui-stat-k wb-label",children:"Preview"}),s.jsxs("div",{className:"wb-doc wb-block","data-clamp":x&&!a?"true":void 0,children:[r.preview||"(this tool wrote no preview)",x&&!a?s.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]}),s.jsxs("details",{className:"ui-details wb-block",children:[s.jsx("summary",{children:"The envelope, field by field"}),s.jsx("dl",{className:"ui-kv",children:b.map(y=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:y.label}),s.jsx("dd",{className:y.mono?"mono":void 0,children:y.value})]},y.label))})]})]})}function J2(e){const t=[],n=e.envelope;if(n!==null&&typeof n=="object"&&!Array.isArray(n))for(const[i,o]of Object.entries(n))t.push({label:Wt(i),value:Ya(o)});else n!=null&&t.push({label:"Envelope",value:Ya(n)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,o]of Object.entries(r)){const l=`Argument · ${Wt(i)}`;t.some(a=>a.label===l)||t.push({label:l,value:Ya(o)})}return t.push({label:"Action id",value:e.id,mono:!0},{label:"Tool version",value:e.toolVersion,mono:!0},{label:"Agent",value:e.agentId,mono:!0},{label:"Args hash",value:e.argsHash,mono:!0},{label:"Policy version",value:String(e.policyVersion)}),e.conversationId&&t.push({label:"Conversation",value:e.conversationId,mono:!0}),e.jobId&&t.push({label:"Job",value:e.jobId,mono:!0}),t}function Ya(e){return e==null?"—":Array.isArray(e)?e.map(t=>Ya(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):bt(e,"text",null)}function X2(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const Z2=new Set(["image/png","image/jpeg","image/gif","image/webp"]),eM=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function fh(e){const t=e!==null&&typeof e=="object"?e.artifacts:null;return Array.isArray(t)?t.flatMap(n=>{if(n===null||typeof n!="object")return[];const r=n;return typeof r.id!="string"||!eM.test(r.id)?[]:[{type:"attachment",artifactId:r.id,filename:typeof r.filename=="string"?r.filename:null,mime:typeof r.mime=="string"?r.mime:"application/octet-stream",kind:typeof r.kind=="string"?r.kind:"other",sizeBytes:null}]}):[]}function rk(e){return Z2.has(e.toLowerCase())}function dr(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function El(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function Tn(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Nm(e,t){const n=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return n.startsWith("image/")?"image":n==="application/pdf"?"pdf":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":n==="text/csv"||n==="text/tab-separated-values"||n.includes("spreadsheet")||n.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":n.includes("zip")||n.includes("tar")||n.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":n==="application/json"||n.includes("javascript")||n.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":n.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const Pr={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function qa(e){return`artifact:${e}`}function tM(e){const t=Nm(e.mime,e.filename);return{id:qa(e.artifactId),tool:Pr[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function nM({props:e}){const t=Y0(e.artifactId),[n,r]=d.useState(null),[i,o]=d.useState(null),[l,a]=d.useState(!1);if(d.useEffect(()=>{if(t===null)return;let p=!0;return r(null),o(null),a(!1),A.libraryEntry(t).then(f=>{p&&r({filename:f.entry.filename,sizeBytes:f.entry.sizeBytes})}).catch(()=>{}),()=>{p=!1}},[t]),t===null)return s.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(n==null?void 0:n.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,n!=null&&n.sizeBytes?Tn(n.sizeBytes):null].filter(p=>p!==null);return s.jsxs("figure",{className:"wb-image",children:[s.jsx("div",{className:"wb-image-frame",children:l?s.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):s.jsx("a",{href:dr(t),className:"wb-image-link",title:"Open at full size",children:s.jsx("img",{src:dr(t),alt:e.caption??c,onLoad:p=>{const f=p.currentTarget;f.naturalWidth>0&&o({width:f.naturalWidth,height:f.naturalHeight})},onError:()=>a(!0)})})}),s.jsxs("figcaption",{className:"wb-image-caption",children:[s.jsxs(q,{children:[s.jsx("span",{className:"wb-image-name",children:c}),u.length>0?s.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(ln,{size:"sm",href:El(t),download:(n==null?void 0:n.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?s.jsx(St,{summary:e.captionLabel,className:"wb-image-note",children:s.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?s.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function sM({props:e}){return e.pairs.length===0?s.jsx("p",{className:"wb-empty",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:bt(t.value,t.unit,t.currency)})]},t.label))})}const rM=8;function ik({text:e,label:t="Output",className:n}){const r=d.useRef(null),i=d.useRef(!0);return d.useLayoutEffect(()=>{const o=r.current;o&&i.current&&(o.scrollTop=o.scrollHeight)},[e]),s.jsx("pre",{ref:r,className:n?`wb-terminal-body ${n}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:o=>{const l=o.currentTarget;i.current=l.scrollHeight-l.scrollTop-l.clientHeight<=rM},children:e})}function iM(e){if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?1:0)} s`;const n=Math.floor(t/60);return`${n} min ${Math.round(t-n*60)} s`}function oM({text:e}){const[t,n]=d.useState("");return s.jsxs(s.Fragment,{children:[t?s.jsx("span",{role:"status",className:"wb-hint",children:t}):null,s.jsx(R,{size:"sm",onClick:()=>{var r;if(n(""),!((r=navigator.clipboard)!=null&&r.writeText)){n("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>n("Copied"),()=>n("Copy failed; select the text to copy."))},children:"Copy"})]})}function lM({props:e}){const t=e.output??"";return s.jsxs("div",{className:"wb-terminal",children:[s.jsxs(q,{className:"wb-terminal-head",children:[e.command!==null?s.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?s.jsxs(pe,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?s.jsx("span",{className:"wb-terminal-fact",children:iM(e.elapsedMs)}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?s.jsx(oM,{text:t}):null]}),e.omittedBytes!==null?s.jsxs("p",{className:"wb-terminal-note",children:["First ",Tn(e.omittedBytes)," not shown."]}):null,t!==""?s.jsx(ik,{text:t}):s.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(n=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:n.label}),s.jsx("dd",{children:bt(n.value,n.unit,null)})]},n.label))}):null]})}function aM(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function Nv(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function cM(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((n,r)=>n-r)}function uM({props:e}){var S;const[t,n]=d.useState(null),[r,i]=d.useState(null),[o,l]=d.useState(null),[a,c]=d.useState(!1),u=((S=e.target)==null?void 0:S.plugin)??null,p=cM(e),[f,h]=d.useState(null),v=f!==null&&p.includes(f)?f:e.port,j=e.target?v!==null&&v!==e.port?`${e.target.name}.${v}`:e.target.name:null,w=e.changes??0,b=d.useRef(w),[x,g]=d.useState(0);d.useEffect(()=>{w<=b.current||(b.current=w,e.reloadsItself||g(k=>k+1))},[w,e.reloadsItself]),d.useEffect(()=>{if(u===null||j===null)return;let k=!0;return n(null),i(null),l(null),g(0),A.previewLink(u,j).then(N=>{k&&(n(N.url),i(Nv(N.url)))}).catch(N=>{k&&l(N instanceof Error?N.message:"That preview could not be opened.")}),()=>{k=!1}},[u,j]);const y=()=>{u===null||j===null||A.previewLink(u,j).then(k=>i(k.url)).catch(()=>{})};if(e.target===null)return s.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",s.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const m=!(e.output===null||e.output==="");return s.jsxs("div",{className:"wb-preview","data-output":a||void 0,children:[s.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,p.length>1?s.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:v??"",onChange:k=>h(Number(k.target.value)),children:p.map(k=>s.jsxs("option",{value:k,children:[":",k]},k))}):null,m?s.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":a,onClick:()=>c(k=>!k),children:a?"Hide output":"Output"}):null,r?s.jsx("a",{className:"wb-preview-open",href:r,target:"_blank",rel:"noreferrer noopener",onPointerEnter:y,onFocus:y,title:"Through buddi: works from anywhere the dashboard does, including the tailnet.",children:"Open in a tab"}):null,v!==null&&aM()?s.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${v}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",v]}):null]}),s.jsxs("div",{className:"wb-preview-body",children:[t?s.jsx("iframe",{className:"wb-preview-frame",src:x===0?t:Nv(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},x):s.jsx("p",{className:"wb-empty wb-preview-frame",children:o??"Opening the preview…"}),m&&a?s.jsx(ik,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const dM=50,fM=9,hM=24,pM=.6,mM=48,gM=/(amount|total|balance|price|cost|paid|pay|payment|net|spend|spent|due|limit|owed|fee|income|charge|burn|minimum|principal|interest|worth|cash|debt|deposit|credit|debit|value|revenue|budget|floor|avg|mean|median)/i,xM=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,vM=/^id$|(^|[a-z0-9])Id$|_id$/;function yi(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function mn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ok(...e){for(const t of e)if(mn(t))for(const n of["currency","currencyCode"]){const r=t[n];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function lk(e,t,n){const r=t.filter(i=>i!=null&&i!=="");return r.length===0?"text":r.every(i=>typeof i=="boolean")?"boolean":r.every(i=>typeof i=="number"&&Number.isFinite(i))?n!==null&&gM.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&xM.test(i))?"date":"text"}function jM(e,t){if(!vM.test(e))return!1;const n=t.filter(r=>!oo(r));return n.length<2?!1:new Set(n.map(r=>String(r))).size===n.length}function oo(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:mn(e)?Object.keys(e).length===0:!1}function Cv(e,t){const n=e.filter(mn);if(n.length===0||n.length/e.length<.8)return null;const r=n.slice(0,dM),i=new Map,o=[];for(const p of r)for(const f of Object.keys(p))i.has(f)||o.push(f),i.set(f,(i.get(f)??0)+1);if(i.size===0||i.size>hM||[...i.values()].reduce((p,f)=>p+f,0)/(i.size*r.length)<pM)return null;const a=[...i.keys()].sort((p,f)=>{const h=(i.get(f)??0)-(i.get(p)??0);return h!==0?h:o.indexOf(p)-o.indexOf(f)}),c=[],u=[];for(const p of a){const f=r.map(w=>w[p]),h=f.filter(w=>!oo(w));if(h.length===0||jM(p,f))continue;const v=ok(r[0],t),j=lk(p,f,v);if(r.length>=4&&h.length===f.length&&f.every(w=>yi(w)&&w===f[0])){u.push({label:Wt(p),value:f[0],type:j,currency:v});continue}if(c.push({key:p,label:Wt(p),type:j,currency:j==="currency"?v:null}),c.length===fM)break}return c.length===0?null:{columns:c,rows:n,constants:u}}function yM(e,t,n){const r=ok(n);return{label:Wt(e),value:t,type:lk(e,[t],r),currency:r}}function ak(e){return typeof e=="string"&&e.length>mM}function wM(e){return e==null?"This tool returned nothing.":typeof e=="string"&&e.trim()===""?"This tool returned an empty string.":Array.isArray(e)&&e.length===0?"This tool returned no items.":mn(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function hh(e){if(typeof e=="string"&&e.trim()!=="")return e;if(mn(e))for(const t of["message","error","reason","detail","description"]){const n=e[t];if(typeof n=="string"&&n.trim()!=="")return n;if(mn(n)){const r=hh(n);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function Cm(e,t={}){if(t.failed){let f=e;if(typeof e=="string")try{const h=JSON.parse(e.replace(/^tool-error:\s*/,""));mn(h)&&(f=h)}catch{}return{kind:"error",summary:hh(f),detail:Ev(f)}}if(mn(e)){const f=e.error,h=e.ok;if(typeof f=="string"&&f.trim()!==""||h===!1)return{kind:"error",summary:hh(e),detail:Ev(e)}}const n=wM(e);if(n)return{kind:"empty",note:n,stats:[]};if(Array.isArray(e)){const f=Cv(e,e);return f?{kind:"table",label:null,columns:f.columns,rows:f.rows,total:f.rows.length,stats:f.constants,notes:[],asides:[]}:e.every(yi)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!mn(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,o=null;for(const[f,h]of r){if(!Array.isArray(h))continue;const v=Cv(h,e);if(v){(!i||v.rows.length>i.candidate.rows.length)&&(i={key:f,candidate:v});continue}h.length>0&&h.every(yi)&&(!o||h.length>o.items.length)&&(o={key:f,items:h})}const l=(i==null?void 0:i.key)??(o==null?void 0:o.key)??null,a=[],c=[],u=[];for(const[f,h]of r)if(f!==l){if(ak(h)){c.push(h);continue}if(yi(h)){if(h==="")continue;a.push(yM(f,h,e));continue}h!==void 0&&u.push({label:Wt(f),value:h})}if(i)return{kind:"table",label:Wt(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...a,...i.candidate.constants],notes:c,asides:u};if(o)return{kind:"list",label:Wt(o.key),items:o.items,total:o.items.length,stats:a,notes:c,asides:u};const p=r.filter(([,f])=>Array.isArray(f)&&f.length===0);return p.length>0&&p.length===r.filter(([,f])=>Array.isArray(f)).length?{kind:"empty",note:`No ${p.map(([h])=>Wt(h).toLowerCase()).join(", ")} to show.`,stats:a}:r.every(([,f])=>yi(f)||mn(f)||Array.isArray(f))?{kind:"record",pairs:a,notes:c,asides:u}:{kind:"tree",value:e}}function Ev(e){if(!mn(e))return null;const t=Object.entries(e).filter(([n])=>n!=="message"&&n!=="error");return t.length===0?null:Object.fromEntries(t)}const Ic=25,bM=3,ph=8,ck=6;function mh(e,t=0){if(t>ck||oo(e)||ak(e))return 0;if(yi(e))return 1;if(Array.isArray(e)){let n=0;for(const r of e)if(n+=mh(r,t+1),n>=ph)return n;return n}if(mn(e)){let n=0;for(const r of Object.values(e))if(n+=mh(r,t+1),n>=ph)return n;return n}return 0}function gh(e,t=0){if(t>ck)return!1;if(Array.isArray(e))return e.some(o=>gh(o,t+1));if(!mn(e))return!1;const n=e.artifactId??e.artifact_id;if(typeof n=="string"&&n.trim()!=="")return!0;const r=e.mime??e.mimeType??e.contentType,i=e.url??e.src??e.downloadUrl??e.path;return typeof r=="string"&&r.includes("/")&&typeof i=="string"&&i.trim()!==""?!0:Object.values(e).some(o=>gh(o,t+1))}function kM(e){if(gh(e))return!0;const t=Cm(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=bM;case"record":case"tree":return mh(e)>=ph;default:return!1}}function jd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Em(e){const t=jd(e);if(!t)return null;const n=jd(t.output)??t;if(typeof n.state!="string"||typeof n.stdout!="string"||typeof n.stderr!="string"||!(n.exitCode===null||typeof n.exitCode=="number"&&Number.isFinite(n.exitCode)))return null;const r=n===t?null:jd(t.input),i=(r==null?void 0:r.command)??n.command;return{command:typeof i=="string"?i:null,input:r,result:n}}function SM({text:e,label:t}){const[n,r]=d.useState("");return s.jsxs("span",{className:"wb-command-copy",children:[s.jsx("button",{className:"ui-btn",onClick:()=>{var i;if(r(""),!((i=navigator.clipboard)!=null&&i.writeText)){r("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>r("Copied"),()=>r("Copy failed; select the text to copy."))},children:t}),n&&s.jsx("span",{role:"status",className:"wb-hint",children:n})]})}function yd({title:e,text:t,error:n=!1}){return s.jsxs("section",{className:"wb-command-stream","data-error":n||void 0,children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("h4",{children:e}),s.jsx(SM,{text:t,label:`Copy ${e.toLowerCase()}`})]}),s.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function NM({value:e,children:t}){const{result:n,command:r,input:i}=e,o=n.state==="completed"&&n.exitCode!==null&&n.exitCode!==0,l=typeof n.signal=="string"&&n.signal?n.signal:null,a=n.state==="completed"&&n.exitCode===0,c=Object.fromEntries(Object.entries(n).filter(([p,f])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(p)&&f!==null&&f!==void 0&&f!=="")),u=Array.isArray(n.outputErrors)?n.outputErrors.filter(p=>typeof p=="string"):[];return s.jsxs("div",{className:"wb-command-result",children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("span",{className:"ui-pill","data-tone":a?"good":"critical",children:o?"Failed":n.state==="completed"&&l?"Terminated":n.state}),n.exitCode!==null&&s.jsxs("span",{className:"mono",children:["Exit code ",n.exitCode]}),l&&s.jsxs("span",{className:"mono",children:["Signal ",l]}),s.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&s.jsx(yd,{title:"Command",text:r}),n.state==="output-limit"&&s.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),n.state==="timed-out"&&s.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),n.state==="cancelled"&&s.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),n.stdout?s.jsx(yd,{title:"Output",text:n.stdout}):s.jsx("p",{className:"wb-note",children:"No standard output."}),n.stderr?s.jsx(yd,{title:"Standard error",text:n.stderr,error:!0}):null,u.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"File export errors"}),u.map((p,f)=>s.jsx("p",{className:"wb-fail",children:p},f))]}),t,(Object.keys(c).length>0||i!==null)&&s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Execution details"}),s.jsx("pre",{children:on({...c,...i?{input:i}:{}})})]})]})}const pa=2,Av=64;function CM({props:e}){const[t,n]=d.useState(!1),r=Em(e.value),i=EM((r==null?void 0:r.result)??e.value),o=d.useMemo(()=>Cm(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return s.jsxs("div",{children:[!r&&s.jsx(Tv,{files:i}),t?s.jsx("pre",{className:"ui-code",children:on(e.value)}):r?s.jsx(NM,{value:r,children:i.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"Generated files"}),s.jsx(Tv,{files:i})]})}):i.length?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Tool details"}),s.jsx(Rv,{shape:o})]}):s.jsx(Rv,{shape:o}),s.jsx("div",{className:"wb-row-end wb-section",children:s.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>n(l=>!l),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function EM(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(n=>n&&typeof n.id=="string"&&/^[0-9a-f-]{36}$/i.test(n.id)&&typeof n.filename=="string"):[]}function Tv({files:e}){return e.length?s.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var n;return s.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?s.jsx(AM,{file:t}):null,s.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(n=t.mime)!=null&&n.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function AM({file:e}){const[t,n]=d.useState(!1);return t?s.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):s.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>n(!0)})}function Rv({shape:e}){switch(e.kind){case"error":return s.jsxs("div",{children:[s.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"What came back with it"}),s.jsx("div",{className:"wb-tree",children:hl(e.detail,1)})]})]});case"empty":return s.jsxs("div",{children:[s.jsx(wd,{stats:e.stats}),s.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=$M(e.columns,e.rows);return s.jsxs("div",{children:[s.jsx(wd,{stats:e.stats}),s.jsx(bd,{notes:e.notes}),t?s.jsx(_M,{label:e.label,plan:t,rows:e.rows,total:e.total}):s.jsx(RM,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),s.jsx(kd,{asides:e.asides})]})}case"list":return s.jsxs("div",{children:[s.jsx(wd,{stats:e.stats}),s.jsx(bd,{notes:e.notes}),e.label?s.jsx("h4",{className:"wb-sub",children:e.label}):null,s.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,n)=>s.jsx("li",{children:bt(t,"text",null)},n))}),e.total>100?s.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,s.jsx(kd,{asides:e.asides})]});case"record":return s.jsxs("div",{children:[s.jsx(bd,{notes:e.notes}),s.jsx(TM,{pairs:e.pairs}),s.jsx(kd,{asides:e.asides})]});default:return s.jsx("div",{className:"wb-tree",children:hl(e.value,0)})}}function wd({stats:e}){return e.length===0?null:s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:t.label}),s.jsx("div",{className:"ui-stat-v",children:Am(t.value,t.type,t.currency)})]},t.label))})}const Pv=200;function bd({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=Pv),n=e.filter(r=>r.length>Pv);return s.jsxs(s.Fragment,{children:[t.map(r=>s.jsx("p",{className:"wb-note",children:r},r)),n.length>0?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:n.length===1?"A note that came with this result":`${n.length} notes that came with this result`}),n.map(r=>s.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function TM({pairs:e}){return e.length===0?s.jsx("p",{className:"wb-note",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:Am(t.value,t.type,t.currency)})]},t.label))})}function kd({asides:e}){return e.length===0?null:s.jsx("div",{className:"wb-section",children:e.map(t=>s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:t.label}),s.jsx("div",{className:"wb-tree",children:hl(t.value,1)})]},t.label))})}function RM({label:e,columns:t,rows:n,total:r}){const[i,o]=d.useState(!1),l=r<=Ic+5?r:Ic,a=i?n:n.slice(0,l);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:t.map(c=>s.jsx("th",{className:dk(c.type)?"num":void 0,children:c.label},c.key))})}),s.jsx("tbody",{children:a.map((c,u)=>s.jsx("tr",{children:t.map(p=>s.jsx(OM,{value:c[p.key],column:p},p.key))},u))})]})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>o(!0),children:["Show all ",r]})]}):null]})}const PM=/^(title|name|headline|subject|label|heading)$/i,IM=/^(url|link|href|uri|permalink)$/i;function Mc(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function MM(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function uk(e,t=48){try{const n=new URL(e),r=n.pathname==="/"?"":n.pathname,i=`${n.hostname.replace(/^www\./,"")}${r}${n.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function ma(e,t){const n=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return n.length===0?0:n.reduce((r,i)=>r+i.length,0)/n.length}function $M(e,t){if(t.length===0)return null;const n=e.filter(p=>p.type==="text"),r=n.find(p=>IM.test(p.key)&&t.some(f=>Mc(f[p.key])))??n.find(p=>{const f=t.map(h=>h[p.key]).filter(h=>!oo(h));return f.length>0&&f.filter(Mc).length/f.length>=.6});if(!r)return null;const i=n.filter(p=>p.key!==r.key),o=i.find(p=>PM.test(p.key))??i.find(p=>ma(t,p.key)>0);if(!o)return null;const a=[...i.filter(p=>p.key!==o.key)].sort((p,f)=>ma(t,f.key)-ma(t,p.key)),c=a[0]&&ma(t,a[0].key)>40?a[0]:null,u=e.filter(p=>p.key!==r.key&&p.key!==o.key&&p.key!==(c==null?void 0:c.key)).map(p=>p.key);return{url:r.key,title:o.key,description:(c==null?void 0:c.key)??null,meta:u}}function _M({label:e,plan:t,rows:n,total:r}){const[i,o]=d.useState(!1),l=r<=Ic+5?r:Ic,a=i?n:n.slice(0,l);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("ol",{className:"wb-records",children:a.map((c,u)=>{const p=c[t.url],f=Mc(p)?p.trim():null,h=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:f?uk(f):"Untitled",v=t.description&&typeof c[t.description]=="string"?c[t.description]:null,j=f?MM(f):null,w=t.meta.map(b=>c[b]).filter(b=>!oo(b)&&typeof b!="object").map(b=>String(b)).filter(b=>j===null||b.replace(/^www\./,"")!==j);return s.jsxs("li",{className:"wb-record",children:[f?s.jsx("a",{className:"wb-record-title",href:f,target:"_blank",rel:"noopener noreferrer",children:h}):s.jsx("span",{className:"wb-record-title",children:h}),s.jsxs("div",{className:"wb-record-meta",children:[j?s.jsx("span",{className:"wb-record-host",title:f??void 0,children:j}):null,w.map((b,x)=>s.jsx("span",{children:b.length>60?`${b.slice(0,59)}…`:b},x))]}),v?s.jsx("p",{className:"wb-record-desc",children:v.length>280?`${v.slice(0,279)}…`:v}):null]},u)})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>o(!0),children:["Show all ",r]})]}):null]})}function OM({value:e,column:t}){if(oo(e))return s.jsx("td",{className:"wb-cell-soft",children:"—"});if(Mc(e)){const i=e.trim();return s.jsx("td",{className:"wb-cell-link",children:s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:uk(i)})})}if(e!==null&&typeof e=="object"){const i=Array.isArray(e)?`${e.length} item${e.length===1?"":"s"}`:`${Object.keys(e).length} fields`;return s.jsx("td",{className:"wb-cell-soft",title:on(e),children:i})}const n=Am(e,t.type,t.currency),r=n.length>Av?`${n.slice(0,Av-1)}…`:n;return s.jsx("td",{className:dk(t.type)?"num":"wb-cell-text",...r===n?{}:{title:n},children:r})}function dk(e){return e==="number"||e==="currency"}function Am(e,t,n){return e==null?"—":t==="boolean"?e?"yes":"no":bt(e,t==="text"?"text":t,n)}function hl(e,t){if(e===null)return s.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return s.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return s.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return s.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return s.jsx("span",{children:e===""?s.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return s.jsx("span",{className:"wb-tree-null",children:"none"});const i=s.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((o,l)=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[l,". "]}),hl(o,t+1)]},l)),e.length>50?s.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=pa?s.jsx(Iv,{summary:`${e.length} items`,open:t===pa,children:i}):i}const n=Object.entries(e);if(n.length===0)return s.jsx("span",{className:"wb-tree-null",children:"empty"});const r=s.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:n.map(([i,o])=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[Wt(i),": "]}),hl(o,t+1)]},i))});return t>=pa?s.jsx(Iv,{summary:`${n.length} fields`,open:t===pa,children:r}):r}function Iv({summary:e,open:t,children:n}){return s.jsxs("details",{open:t,children:[s.jsx("summary",{className:"wb-tree-key",children:e}),n]})}function DM({props:e}){const t=e.groups.every(n=>n.rows.length===0);return s.jsxs("div",{children:[e.summary.length>0?s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(n=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:n.label}),s.jsx("div",{className:"ui-stat-v","data-tone":n.tone,children:bt(n.value,n.unit,n.currency)})]},n.label))}):null,t?s.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((n,r)=>s.jsxs("div",{className:r>0?"wb-section":void 0,children:[n.label?s.jsx("h4",{className:"ui-stat-k wb-label",children:n.label}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.columns.map(i=>s.jsx("th",{className:fk(i.type)?"num":void 0,"data-type":i.type,children:i.label},i.key))})}),s.jsx("tbody",{children:n.rows.map((i,o)=>s.jsx("tr",{children:i.map((l,a)=>{var c;return s.jsx(LM,{cell:l},((c=e.columns[a])==null?void 0:c.key)??a)})},o))})]})})]},n.label??r))]})}function LM({cell:e}){const t=bt(e.value,e.type,e.currency);return e.bar?s.jsx("td",{className:"num",children:s.jsxs("div",{className:"wb-row wb-row-end",children:[s.jsx("div",{className:"ui-meter",role:"meter","aria-valuenow":Math.round(e.bar.fraction*100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":t,children:s.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),s.jsx("span",{className:"tnum",children:t})]})}):s.jsx("td",{className:fk(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function fk(e){return e==="number"||e==="currency"||e==="percent"}const ri=760,Sd=400,it={top:18,right:18,bottom:36,left:66},FM=5;function UM({props:e}){const{points:t,referenceLines:n,unit:r,currency:i}=e;if(t.length===0)return s.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const o=[...t.map(m=>m.y),...n.map(m=>m.value)],l=Math.min(...o),a=Math.max(...o),c=a-l||Math.abs(a)||1,u=l-c*.08,p=a+c*.08,f=ri-it.left-it.right,h=Sd-it.top-it.bottom,v=m=>it.left+(t.length===1?f/2:m/(t.length-1)*f),j=m=>it.top+h-(m-u)/(p-u)*h,w=mI(l,a,4),b=BM(t.map(m=>m.y),e.mark),x=e.shadeBelow===null?[]:WM(t.map(m=>m.y),e.shadeBelow),g=t.map((m,S)=>`${S===0?"M":"L"}${v(S)},${j(m.y)}`).join(" "),y=m=>bt(m,r,i);return s.jsxs("div",{children:[e.label?s.jsx("p",{className:"ui-panel-sub",children:e.label}):null,s.jsxs("div",{className:"wb-chart-layout",children:[s.jsx("div",{className:"wb-chart-plot",children:s.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${ri} ${Sd}`,role:"img","aria-label":zM(e,y),preserveAspectRatio:"xMidYMid meet",children:[x.map(m=>s.jsx("rect",{className:"wb-chart-breach",x:v(m.from),width:Math.max(2,v(m.to)-v(m.from)),y:it.top,height:h},`band-${m.from}`)),w.map(m=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-grid",x1:it.left,x2:ri-it.right,y1:j(m),y2:j(m)}),s.jsx("text",{x:it.left-8,y:j(m)+4,textAnchor:"end",children:y(m)})]},`tick-${m}`)),n.map(m=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-floor",x1:it.left,x2:ri-it.right,y1:j(m.value),y2:j(m.value)}),s.jsxs("text",{x:ri-it.right,y:j(m.value)-6,textAnchor:"end",children:[m.label," ",y(m.value)]})]},`rule-${m.label}`)),s.jsx("line",{className:"wb-chart-axis",x1:it.left,x2:it.left,y1:it.top,y2:it.top+h}),s.jsx("line",{className:"wb-chart-axis",x1:it.left,x2:ri-it.right,y1:it.top+h,y2:it.top+h}),s.jsx("path",{className:"wb-chart-series",d:g}),b!==null?s.jsxs("g",{children:[s.jsx("circle",{className:"wb-chart-min",cx:v(b),cy:j(t[b].y),r:4.5}),s.jsx("text",{x:v(b),y:j(t[b].y)+20,textAnchor:"middle",children:y(t[b].y)})]}):null,HM(t.length).map(m=>s.jsx("text",{x:v(m),y:Sd-10,textAnchor:"middle",children:uv(t[m].x)},`x-${m}`))]})}),e.events.length>0?s.jsxs("aside",{className:"wb-chart-events",children:[s.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),s.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((m,S)=>s.jsxs("li",{className:"wb-chart-event",children:[s.jsxs("span",{children:[s.jsx("span",{className:"wb-chart-event-day",children:uv(m.at)}),m.label]}),m.amount===null?null:s.jsx("span",{className:m.amount<0?"tnum critical":"tnum good",children:bt(m.amount,r,i)})]},`${m.at}-${m.label}-${S}`))})]}):null]})]})}function zM(e,t){const n=e.points.map(l=>l.y),r=e.points[0],i=e.points[e.points.length-1],o=e.referenceLines.map(l=>`${l.label} at ${t(l.value)}`).join(", ");return[`${e.points.length} points from ${r==null?void 0:r.x} to ${i==null?void 0:i.x}`,`low ${t(Math.min(...n))}, high ${t(Math.max(...n))}`,o].filter(Boolean).join("; ")}function BM(e,t){if(!t||e.length===0)return null;let n=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[n]:e[r]>e[n])&&(n=r);return n}function WM(e,t){const n=[];let r=null;return e.forEach((i,o)=>{i<t?r===null&&(r=o):r!==null&&(n.push({from:r,to:o}),r=null)}),r!==null&&n.push({from:r,to:e.length-1}),n}function HM(e,t=FM){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const n=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*n));return[...r].sort((i,o)=>i-o)}const $n=e=>e,xh={timeseries:$n(UM),table:$n(DM),bars:$n(gI),keyvalue:$n(sM),document:$n(h2),diff:$n(bI),terminal:$n(lM),image:$n(nM),preview:$n(uM),envelope:$n(Q2),structured:$n(CM)},VM="structured";function KM(e){return($c(e)?xh[e]:void 0)??xh[VM]}function $c(e){return Object.prototype.hasOwnProperty.call(xh,e)}function GM({renderer:e,props:t,timezone:n,onDecided:r}){const i=KM(e),l=$c(e)?t:{value:t};return s.jsx(i,{props:l,timezone:n,onDecided:r})}function YM({profile:e,onChange:t}){return s.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[s.jsx("p",{className:"wb-prof-lead",children:e.description}),s.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?s.jsx(Nd,{children:"Opens by default"}):null,s.jsx(Nd,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(n=>s.jsx(Nd,{title:`A surface command that asks for "${n}" lands on this agent.`,children:Wt(n)},n))]}),e.available?null:s.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[s.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),s.jsx(So,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:s.jsxs("ul",{className:"wb-prof-list",children:[s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),s.jsx("span",{className:"wb-prof-row-desc",children:"When it knows the likely answers, it can show one-tap choices in the dashboard and Telegram. You can still write a different answer when the question allows it."})]}),s.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),s.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),s.jsx("span",{className:"wb-prof-row-desc",children:"A request to send, spend, publish or otherwise affect the world appears in the conversation with the exact action. Answering a question never approves it."})]}),s.jsxs("span",{className:"wb-prof-gate",children:[s.jsx(hk,{}),"Exact action"]})]})]})}),s.jsx(So,{title:"What it can do",note:qM(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?s.jsx("p",{className:"wb-prof-empty",children:"No tools at all. It answers from the conversation and from what it remembers, and it can change nothing."}):[...e.tools].sort((n,r)=>+(r.gated>0)-+(n.gated>0)).map(n=>s.jsx(QM,{family:n},n.family))}),s.jsx(So,{title:"What it runs on",children:s.jsxs("dl",{className:"wb-prof-kv",children:[s.jsx(No,{label:"Provider",children:e.engine.provider}),s.jsx(No,{label:"Model",children:s.jsx("span",{className:"mono",children:e.engine.model})}),s.jsxs(No,{label:"Credential",children:[e.engine.credentialKind," from"," ",s.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),s.jsxs(No,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),s.jsx(No,{label:"Language",children:t$(e.engine.language)})]})}),e.skills.length>0?s.jsx(So,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:s.jsx("ul",{className:"wb-prof-list",children:e.skills.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:n.name}),n.description?s.jsx("span",{className:"wb-prof-row-desc",children:n.description}):null]}),s.jsxs("span",{className:"wb-prof-row-side",title:n.file,children:[n.scope==="private"?"its own":"shared"," · ",n.provenance]})]},n.file))})}):null,e.delegates.length>0?s.jsx(So,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:s.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsxs("span",{className:"wb-prof-row-name mono",children:["@",n.handle]}),s.jsx("span",{className:"wb-prof-row-desc",children:n.description})]}),s.jsx("span",{className:"wb-prof-row-side",children:n.available?n.name:`${n.name} · cannot run`})]},n.id))})}):null,s.jsxs("footer",{className:"wb-prof-foot",children:[s.jsx("p",{className:"wb-prof-note",children:e.note}),s.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?s.jsxs("button",{className:"ui-btn","data-testid":"agent-profile-change",title:e.changeVia.prompt,onClick:()=>t({agentId:e.changeVia.agentId,prompt:e.changeVia.prompt}),children:["Ask @",e.changeVia.handle," to change this"]}):null]})]})}function qM(e){if(e.toolCount===0)return"Nothing. This agent holds no tools.";const t=`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`;if(e.gatedCount===0)return`${t}, every one of them running without asking you. None of them can send, spend or write to the world.`;const n=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${n}.`}function QM({family:e}){const t=[...e.tools].sort((n,r)=>Number(r.gated)-Number(n.gated));return s.jsxs("section",{className:"wb-prof-family",children:[s.jsxs("h4",{className:"wb-prof-family-head",children:[s.jsx("span",{className:"wb-prof-family-name",children:Wt(e.family)}),s.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),s.jsx("ul",{className:"wb-prof-list",children:t.map(n=>s.jsx(JM,{tool:n},n.name))})]})}function JM({tool:e}){return s.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:e$(e.name)}),s.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?s.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[s.jsx(hk,{}),"Needs your approval"]}):s.jsx("span",{className:"wb-prof-auto",title:ZM(e.tier),children:XM(e.tier)})]})}function XM(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function ZM(e){return e==="auto"?"Called during a run without asking you. It reads, or records something you can see.":`Tier "${e}" does not execute in this build; a call to it is refused.`}function e$(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function t$(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function So({title:e,note:t,tone:n,children:r}){return s.jsxs("section",{className:"wb-prof-section",children:[s.jsx("h3",{className:"wb-prof-title",children:e}),t?s.jsx("p",{className:"wb-prof-note-lead","data-tone":n,children:t}):null,r]})}function No({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"wb-prof-k",children:e}),s.jsx("dd",{className:"wb-prof-v",children:t})]})}function Nd({children:e,title:t}){return s.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function hk(){return s.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),s.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const Cd=1e5,Ed=200,Ad=30;function pk({artifactId:e,filename:t,mime:n,family:r,available:i=!0}){const[o,l]=d.useState(!1);return i?r==="image"&&!o?s.jsx("figure",{className:"file-preview file-preview-image",children:s.jsx("img",{src:dr(e),alt:t??"Image",onError:()=>l(!0)})}):r==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:dr(e),type:"application/pdf","aria-label":t??"PDF",children:s.jsx(H,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?s.jsx(n$,{artifactId:e,filename:t,mime:n,family:r}):s.jsx(H,{children:"Preview not supported for this kind of file. Download it to open it."}):s.jsx(H,{children:"The file is no longer available; its record is kept."})}function n$({artifactId:e,filename:t,mime:n,family:r}){const[i,o]=d.useState("loading");if(d.useEffect(()=>{let a=!1;return o("loading"),fetch(dr(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();a||o({text:u.slice(0,Cd),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>Cd})}).catch(()=>{a||o("failed")}),()=>{a=!0}},[e]),i==="loading")return s.jsx("div",{className:"file-preview",children:s.jsx(ie,{children:"Loading preview…"})});if(i==="failed")return s.jsx(H,{children:"The preview could not be loaded. Download the file to open it."});const l=r==="table"&&(/csv|tab-separated/.test(n)||/\.(csv|tsv)$/i.test(t??""));return s.jsxs("div",{className:"file-preview",children:[l?s.jsx(r$,{text:i.text,delimiter:/tab|\.tsv$/i.test(n+(t??""))?" ":","}):s.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?s.jsxs("p",{className:"muted",children:["Showing the first ",Cd.toLocaleString()," characters. The download has the whole file."]}):null]})}function s$(e,t,n,r){const i=[];let o=[],l="",a=!1,c=!1,u=!1;const p=()=>{o.length<r?o.push(l):c=!0,l=""},f=()=>{p(),i.push(o),o=[]};let h=0;for(;h<e.length;h+=1){if(i.length>=n){u=e.slice(h).trim()!=="";break}const v=e[h];if(a){v==='"'?e[h+1]==='"'?(l+='"',h+=1):a=!1:l+=v;continue}if(v==='"'){a=!0;continue}if(v===t){p();continue}if(v!=="\r"){if(v===`
94
- `){f();continue}l+=v}}return i.length<n&&(l!==""||o.length>0)&&f(),{rows:i,truncatedRows:u,truncatedCols:c}}function r$({text:e,delimiter:t}){const n=d.useMemo(()=>s$(e,t,Ed+1,Ad),[e,t]),[r,...i]=n.rows;if(!r)return s.jsx("p",{className:"muted",children:"The file is empty."});const o=Math.min(Ad,n.rows.reduce((a,c)=>Math.max(a,c.length),0)),l=Array.from({length:o},(a,c)=>c);return s.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:l.map(a=>s.jsx("th",{children:r[a]??""},a))})}),s.jsx("tbody",{children:i.slice(0,Ed).map((a,c)=>s.jsx("tr",{children:l.map(u=>s.jsx("td",{children:a[u]??""},u))},c))})]}),n.truncatedRows||n.truncatedCols?s.jsxs("p",{className:"muted",children:["Showing the first ",Ed," rows",n.truncatedCols?` and ${Ad} columns`:"",". The download has the whole file."]}):null]})}function i$({attachment:e}){const t=Nm(e.mime,e.filename),n=e.filename??"Untitled file";return s.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[s.jsx(pk,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),s.jsxs("dl",{className:"ui-kv",children:[s.jsx("dt",{children:"Type"}),s.jsxs("dd",{children:[Pr[t],s.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Size"}),s.jsx("dd",{children:Tn(e.sizeBytes)})]}):null,s.jsx("dt",{children:"Id"}),s.jsx("dd",{className:"mono",children:e.artifactId})]}),s.jsx("div",{className:"ui-toolbar","data-align":"end",children:s.jsx("a",{className:"ui-btn",href:El(e.artifactId),download:n,children:"Download"})})]})}const Mv=80,o$=["query","path","url","dir"],l$=["message","task"];function Tm(e,t){const n=a$(t);if(!n)return null;const r=ii(n.command);if(r!==null){const l=ii(n.name);return ga(l===null?r:`${l}: ${r}`)}for(const l of o$){const a=ii(n[l]);if(a!==null)return ga(a)}const i=ii(n.action);if(i!==null){const l=l$.map(a=>ii(n[a])).find(a=>a!==null)??null;return ga(l===null?i:`${i} · ${l}`)}const o=Object.values(n).filter(l=>typeof l=="string");return o.length===1?ga(ii(o[0])):null}function ii(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function ga(e){return e===null?null:e.length>Mv?`${e.slice(0,Mv-1)}…`:e}function a$(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const pl="agent.delegate";function c$(e){if(e===null||typeof e!="object")return null;const t=e,n=t.conversationId;if(typeof n!="string"||n==="")return null;const r=t.agentId??t.agent;return{conversationId:n,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function u$(e){if(typeof e=="string")return e;if(e===null||typeof e!="object")return null;const t=e.text;return typeof t=="string"?t:null}const vh="canvas.show",$v="canvas.clear",_v=12;function Ti(e){return`${e.plugin}/${e.name}`}function d$(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function f$({messages:e,descriptors:t}){const n=new Map(t.filter(o=>o.renderer==="preview").map(o=>[o.tool,o]));if(n.size===0)return[];const r=new Map,i=[];for(const o of e)for(const l of o.blocks??[]){if(l.type==="tool_use"&&r.set(l.id,l.name),l.type!=="tool_result"||l.ok===!1)continue;const a=n.get(l.name||r.get(l.toolUseId)||"");if(!a)continue;const c=Q0(a,mk(l.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:o.at??null})}return i}function h$({messages:e,descriptors:t,awaiting:n,folded:r,served:i}){var u;const o=new Map(t.map(p=>[p.tool,p])),l=new Map;let a=[],c=0;for(const p of e)for(const f of p.blocks??[]){if(f.type==="tool_use"){if(l.set(f.id,{name:f.name,input:f.input,at:p.at??null}),f.name===vh){const m=m$(f.id,f.input,p.at??null);m&&a.push(m)}if(f.name===$v&&(a=[]),f.name===pl){const m=c$(f.input);m&&a.push({id:f.id,tool:pl,title:"Delegation",renderer:"delegate",props:{...m,result:null},at:p.at??null,source:"delegate",substantial:!0})}continue}if(f.type!=="tool_result"||f.name===vh||f.name===$v)continue;const h=l.get(f.toolUseId),v=p.at??(h==null?void 0:h.at)??null,j=f.name||(h==null?void 0:h.name)||"tool",w=a.find(m=>m.source==="delegate"&&m.id===f.toolUseId);if(w&&((u=f.delegation)==null?void 0:u.state)==="waiting"){w.props={...w.props,result:null,waiting:{approvalId:f.delegation.approvalId}},f.delegation.approvalId&&(w.tone="warning");continue}if(w){w.props={...w.props,result:{ok:f.ok,text:u$(f.ok?f.output:f.error??f.output),...f.ok&&fh(f.output).length>0?{files:fh(f.output)}:{}}},f.ok||(w.tone="critical");continue}const b=f.approval?yh(f):(n==null?void 0:n.get(f.toolUseId))??yh(f);if(b){a.push({id:f.toolUseId,tool:j,title:"Approval",renderer:"envelope",props:{approvalId:b},at:v,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(j))continue;const x=mk(f.output);if(f.ok===!1){a.push({id:f.toolUseId,tool:j,title:ss(j),renderer:"structured",props:{value:f.error??x??null,failed:!0},at:v,tone:"critical",source:"fallback",substantial:!1});continue}d$(x)&&(c+=1);const g=o.get(j);if(g){const m=Q0(g,x),{renderer:S}=m;let{props:k}=m;if(S==="preview"){const N=k,C=N.target??(N.awaiting&&(i!=null&&i.has(Ti(N.awaiting)))?N.awaiting:null);if(C===null)continue;k={...N,target:C,awaiting:null};const P=Ti(C);a=a.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&Ti(E.props.target)===P))}a.push({id:f.toolUseId,tool:j,title:g.title??ss(j),renderer:S,props:k,at:v,source:"descriptor",substantial:jh(S,k)});continue}const y={value:Em(x)?{input:h==null?void 0:h.input,output:x}:x};g$("structured",y)&&a.push({id:f.toolUseId,tool:j,title:ss(j),renderer:"structured",props:y,at:v,source:"fallback",substantial:jh("structured",y)})}for(const p of a)p.source==="descriptor"&&p.renderer==="preview"&&(p.props={...p.props,changes:c});return p$(a)}const Ov="forAgent";function mk(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(Ov in e))return e;const{[Ov]:t,...n}=e;return n}function p$(e){if(e.length<=_v)return e;const t=e.length-_v;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function m$(e,t,n){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:o}=t,l=typeof r=="string"&&$c(r)?r:"structured";return{id:e,tool:vh,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:l,props:l==="structured"&&!$c(String(r))?{value:o}:o,at:n,substantial:!0,source:"canvas"}}function g$(e,t){const n=t??{};return!!(n.failed===!0||jh(e,t)||Cm(n.value).kind==="error")}function jh(e,t){const n=t??{};switch(e){case"timeseries":return xa(n.points)>0;case"bars":return xa(n.bars)>0;case"keyvalue":return xa(n.pairs)>0;case"document":return!!n.text||!!n.src;case"diff":return!!n.diff;case"terminal":return!!n.output||!!n.command;case"image":return!!n.artifactId;case"preview":return!!n.target;case"envelope":return!0;case"table":return(Array.isArray(n.groups)?n.groups:[]).some(i=>xa(i.rows)>0);default:return Em(n.value)?!0:n.failed===!0?!1:kM(n.value)}}function xa(e){return Array.isArray(e)?e.length:0}function yh(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const n=xk(t,0);if(n)return n}return null}function x$(e,t,n={}){var a,c;const r=e.flatMap(u=>u.blocks),i=r.find(u=>u.type==="tool_use"&&u.id===t);if((i==null?void 0:i.type)!=="tool_use")return null;const o=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),l=(a=n.redactInputOf)!=null&&a.has(i.name)?gk(i.input):i.input;return{id:t,tool:i.name,title:ss(i.name),renderer:"structured",props:{value:{input:l,...(o==null?void 0:o.type)==="tool_result"?{status:((c=o.approval)==null?void 0:c.state)??(o.ok?"completed":"failed"),output:o.output,...o.error?{error:o.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const v$=new Set(["value","text","password","secret","code"]);function gk(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=v$.has(n)&&typeof r=="string"?"— withheld —":gk(r);return t}function xk(e,t){if(t>3||e===null||typeof e!="object")return null;const n=e,r=n.reason,i=n.actionId??n.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const o of Object.values(n)){const l=xk(o,t+1);if(l)return l}return null}function ss(e){const t=e.split(".");return t.length===1?Wt(e):t.map(n=>Wt(n)).join(" · ")}function Rm({name:e,mime:t,sizeBytes:n,thumbnail:r,state:i,error:o,onOpen:l,onRemove:a,size:c="md"}){const u=Nm(t,e),p=[Pr[u],Tn(n)].filter(Boolean).join(" · "),f=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wb-file-visual","data-family":u,children:r?s.jsx("img",{src:r,alt:""}):s.jsx(Pm,{family:u})}),s.jsxs("span",{className:"wb-file-text",children:[s.jsx("span",{className:"wb-file-name",title:e,children:e}),s.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":p})]})]});return s.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?o:void 0,children:[l?s.jsx("button",{type:"button",className:"wb-file-open",onClick:l,"aria-label":`Open ${e}`,children:f}):s.jsx("span",{className:"wb-file-open",children:f}),a?s.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:a,children:s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:s.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function Pm({family:e}){const t={width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"image":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),s.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),s.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),s.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),s.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),s.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"})]})}}function j$(e){const t=y$(e);if(!t)return null;const n=Td(t.diff);if(n!==null)return{kind:"diff",diff:n};const r=Td(t.command),i=Td(t.plain),o=Rd(t.exitCode);return r!==null&&(i!==null||o!==null||Rd(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:o,elapsedMs:Rd(t.elapsedMs)}:null}function Td(e){return typeof e=="string"&&e.trim()!==""?e:null}function Rd(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function y$(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Dv="offer:",vk="owner:interjection";function w$(e){return e===vk}function b$(e){if(typeof e!="string"||!e.startsWith(Dv))return null;const t=e.slice(Dv.length).trim();return t===""?null:t}function jk({messages:e,live:t,now:n,onOpen:r,working:i=!1,partial:o=null,agents:l,speakers:a,coordinatorId:c,workingAs:u,onOpenFile:p,children:f,agentName:h,emptyHint:v,empty:j,plain:w=!1,workingLine:b,runs:x}){var k,N;const g=d.useRef(null);d.useEffect(()=>{var C;(C=g.current)==null||C.scrollIntoView({block:"end"})},[e.length,t.length,i,o==null?void 0:o.text.length,o==null?void 0:o.thinking.length,!!f]);const y=o&&!o.settled&&(o.text!==""||o.thinking!==""),m=e.filter(C=>(C.blocks??[]).some(I$)),S=R$(m,x??[]);return s.jsx(G0.Provider,{value:l??a??[],children:s.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[m.length===0&&t.length===0?j??s.jsx("p",{className:"wb-chat-empty",children:v}):null,m.map((C,P)=>{const E=C.speaker??null,O=a?E==="owner"||E===null&&C.role==="user":C.role==="user",F=a&&E==="room",D=a&&E&&E!=="owner"&&E!=="room"?a.find(V=>V.id===E)??null:null,T=m[P-1],z=P===0||(a?((T==null?void 0:T.speaker)??null)!==E:T.role!==C.role);if(F)return s.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(C.blocks??[]).filter(V=>V.type==="text").map((V,de)=>s.jsx("span",{children:V.text},de))},C.id);const Q=(C.blocks??[]).filter(V=>V.type==="approval_result");if(Q.length>0)return s.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:Q.map((V,de)=>s.jsx(M$,{block:V},de))},C.id);const Y=C.role==="user"&&w$(E),M=C.role==="user"?b$(E):null;if(M){const V=(C.blocks??[]).filter(de=>de.type==="text").map(de=>de.text).join(`
95
- `);return s.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:s.jsx("div",{className:"wb-bubble wb-bubble-offer",title:V,children:M})},C.id)}const B=a&&D&&C.role==="user"?A$(C):null;if(B){const V=m.slice(P+1).find(ge=>ge.role==="assistant"&&ge.speaker&&ge.speaker!==D.id),de=V!=null&&V.speaker?a.find(ge=>ge.id===V.speaker):void 0;return s.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[s.jsxs("summary",{children:[D.name," asked ",(de==null?void 0:de.name)??"a member",B.request?`: ${B.request.length>120?`${B.request.slice(0,119)}…`:B.request}`:""]}),B.request?s.jsx("p",{children:B.request}):null]},C.id)}const $=S.get(C.id)??null,Z=T$(C,e);return s.jsxs("div",{className:"wb-msg","data-role":O||Y?"user":"assistant",children:[Y?s.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,z&&!O&&!Y?s.jsxs("div",{className:"wb-msg-who",children:[D&&a?s.jsx(Zt,{agents:a,id:D.id,size:"sm"}):null,s.jsx("span",{children:D?D.name:h??"Assistant"}),D&&c===D.id?s.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null]}):null,Z.length>0?s.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:Z.map(V=>s.jsx("span",{role:"listitem",children:s.jsx(Rm,{name:V.filename??"Untitled file",mime:V.mime,sizeBytes:V.sizeBytes,thumbnail:rk(V.mime)?dr(V.artifactId):null,...p?{onOpen:()=>p(V)}:{}})},V.artifactId))}):null,(C.blocks??[]).map((V,de)=>{const ge=N$(C.blocks??[],de,e);if(ge==="inside")return null;if(ge)return s.jsx(C$,{refusals:ge.refusals},de);if(V.type==="thinking")return w||V.text.trim()===""?null:s.jsx(wh,{text:V.text},de);if(V.type==="text")return V.text.trim()===""?null:O?s.jsx("div",{className:"wb-bubble",children:V.text},de):s.jsx("div",{className:"wb-bubble","data-rich":"true",children:s.jsx(ur,{text:V.text})},de);if(V.type==="attachment")return null;if(V.type==="tool_use"){if(w)return null;const je=Im(e,V.id),ne=je?O$(je):null;return s.jsx(bh,{label:ne&&!(je!=null&&je.delegation)?`Approval · ${V.name}`:ss(V.name),tool:V.name,ok:(je==null?void 0:je.ok)??null,running:je===null,...ne?{status:ne.status,waiting:ne.waiting,approval:!0}:{},gist:Tm(V.name,V.input),body:je?j$(je.output):null,opens:!0,onOpen:()=>r(V.id)},de)}return null}),$?s.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:P$($)}):null]},C.id)}),y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[((k=m.at(-1))==null?void 0:k.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??h??"Assistant"}):null,o.thinking!==""&&!w?s.jsx(wh,{text:o.thinking,live:o.text==="",seconds:E$(o.thinkingStartedAt,o.textStartedAt??n)}):null,o.text!==""?s.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[s.jsx(ur,{text:o.text}),s.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null]}):null,i&&t.length===0&&!y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"working",children:[((N=m.at(-1))==null?void 0:N.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??h??"Assistant"}):null,s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[b??`${u??h??"The agent"} is working`,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})]}):null,t.map(C=>s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx(bh,{label:ss(C.name),tool:C.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((n-C.startedAt)/1e3)),opens:!1,onOpen:()=>r(C.toolUseId)})},C.toolUseId)),f,s.jsx("div",{ref:g})]})})}function k$(e){var t,n;return((n=(t=/ may delegate to ([^;]*);/.exec(e)??/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:n.trim())||null}const S$="delegation refused:";function N$(e,t,n){const r=o=>{const l=e[o];if(!l||l.type!=="tool_use"||l.name!==pl)return null;const a=Im(n,l.id);if(!a||a.ok!==!1)return null;const c=typeof a.error=="string"?a.error:String(a.error??"");if(!c.trimStart().startsWith(S$))return null;const u=l.input??{};return{target:typeof u.agent=="string"&&u.agent!==""?u.agent:"a colleague",message:c}};if(!r(t))return null;if(r(t-1))return"inside";const i=[];for(let o=t;;o+=1){const l=r(o);if(!l)break;i.push(l)}return i.length<2?null:{refusals:i}}function C$({refusals:e}){const[t,n]=d.useState(!1),r=e.map(a=>k$(a.message)).find(a=>a!==null)??null,i=e.map(a=>a.target),o=i.slice(0,3),l=`Delegation refused ${e.length} times: ${o.join(", ")}${i.length>o.length?", …":""}`+(r?` (allowed: ${r})`:"");return s.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>n(a=>!a),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:l}),s.jsx(Ue,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("div",{className:"wb-refusals-list",children:e.map((a,c)=>s.jsxs("div",{className:"wb-refusal",children:[s.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsxs("span",{className:"wb-tool-label",children:[ss(pl)," · ",a.target]}),s.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),s.jsx("p",{className:"wb-refusal-why",children:a.message})]},c))}):null]})}function E$(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function wh({text:e,live:t=!1,seconds:n=null}){const[r,i]=d.useState(!1),o=t?`Thinking${n!==null&&n>0?` · ${n}s`:""}`:n!==null&&n>0?`Thought for ${n}s`:"Thoughts";return s.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[s.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(l=>!l),children:[t?s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}):s.jsx(Ue,{name:"thought"}),s.jsx("span",{children:o}),s.jsx(Ue,{name:"arrow",className:"wb-tool-arrow"})]}),r?s.jsx("div",{className:"wb-thought-text",children:s.jsx(ur,{text:e})}):null]})}function A$(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",n=/You are a member of the group "[^"]*"\. @([\w-]+), the coordinator, asks you now:\n\n([\s\S]*?)(?:\n\nAnswer for the room|$)/.exec(t);return n?{handle:n[1],request:n[2].trim()}:null}function T$(e,t){const n=[],r=new Set,i=o=>{r.has(o.artifactId)||(r.add(o.artifactId),n.push(o))};for(const o of e.blocks??[])if(o.type==="attachment"&&i(o),o.type==="tool_use"&&o.name===pl){const l=Im(t,o.id);l!=null&&l.ok&&fh(l.output).forEach(i)}return n}function R$(e,t){const n=t.filter(l=>l.startedAt!==null&&l.finishedAt!==null),r=(l,a)=>a.at!==""&&a.at>=l.startedAt&&a.at<=l.finishedAt,i=(l,a)=>l!==a&&l.startedAt>=a.startedAt&&l.finishedAt<=a.finishedAt&&(l.startedAt>a.startedAt||l.finishedAt<a.finishedAt),o=new Map;for(const l of n){if(l.stopped!=="max_turns"&&l.stopped!=="max_tokens"||l.noticed!==!0||l.runId===null)continue;let a=null;for(const c of e)c.role!=="assistant"||!r(l,c)||(a=c);a===null||n.some(c=>i(c,l)&&r(c,a))||o.has(a.id)||o.set(a.id,l)}return o}function P$(e){if(e.stopped==="max_tokens")return"Length limit reached · answer cut off";const t=e.turns;return t===null?"Turn budget reached":`Turn budget reached · ${t} ${t===1?"step":"steps"}`}function I$(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function M$({block:e}){const[t,n]=d.useState(!1),r=e.state==="succeeded";return s.jsxs("div",{className:"wb-approval","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":r,"aria-expanded":t,onClick:()=>n(i=>!i),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":r?"true":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":ss(e.name)}),s.jsx("span",{className:"wb-tool-elapsed",children:e.state}),s.jsx(Ue,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("pre",{className:"wb-approval-output mono",children:$$(e.output)}):null]})}function $$(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const _$=40;function O$(e){var n,r;if(((n=e.delegation)==null?void 0:n.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(yh(e))return{status:"waiting",waiting:!0};const t=(r=e.approval)==null?void 0:r.state;return t?t==="approved"||t==="executing"?{status:"approved",waiting:!0}:t==="succeeded"?{status:"approved",waiting:!1}:{status:t,waiting:!1}:null}function bh({label:e,tool:t,ok:n,running:r,elapsed:i,opens:o,onOpen:l,status:a,waiting:c=!1,approval:u=!1,gist:p=null,body:f=null}){const[h,v]=d.useState(!1),j=s.jsxs(s.Fragment,{children:[r?s.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):s.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":n===!1?"false":"true","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e}),p?s.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:p}):null,i===void 0?null:s.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),a||n===!1?s.jsx("span",{className:"wb-tool-elapsed",children:a??"failed"}):null]}),w={"data-ok":n===null?void 0:n,"data-running":r,"data-gist":p?!0:void 0,"data-approval":u||void 0};return f?s.jsxs("div",{className:"wb-toolcall","data-open":h||void 0,children:[s.jsxs("div",{className:"wb-tool","data-split":"true",...w,children:[s.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":h,onClick:()=>v(b=>!b),children:[s.jsx(Ue,{name:"chevron",className:"wb-tool-chevron"}),j]}),o?s.jsxs(Cc,{children:[s.jsx(Ec,{asChild:!0,children:s.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:l,children:s.jsx(Ue,{name:"arrow",className:"wb-tool-arrow"})})}),s.jsx(Ac,{children:s.jsxs(Tc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),h?s.jsx(D$,{body:f,onOpen:o?l:null}):null]}):o?s.jsxs(Cc,{children:[s.jsx(Ec,{asChild:!0,children:s.jsxs("button",{className:"wb-tool",...w,onClick:l,children:[j,s.jsx(Ue,{name:"arrow",className:"wb-tool-arrow"})]})}),s.jsx(Ac,{children:s.jsxs(Tc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):s.jsx("span",{className:"wb-tool","data-static":"true",...w,children:j})}function D$({body:e,onOpen:t}){const n=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return s.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:s.jsx(Pc,{text:e.diff,limit:_$,...n?{more:n}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:L$(e.elapsedMs)].filter(i=>i!==null);return s.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[s.jsxs("div",{className:"wb-tool-command",children:[s.jsx("code",{className:"mono",children:e.command}),r.length>0?s.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?s.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function L$(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Im(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}const yk="approval-dock";function F$(){var t;const e=document.getElementById(yk);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const U$=["workspace","cwd","workdir","root"];function z$({approvals:e,timezone:t,now:n,version:r,onDecided:i,onSay:o,onOpenFull:l}){const[a,c]=d.useState([]),u=e.filter(h=>!a.includes(h.approvalId)),p=u[0];if(!p)return null;const f=h=>c(v=>v.includes(h)?v:[...v,h]);return s.jsx(B$,{item:p,count:u.length,timezone:t,now:n,version:r,onSettled:h=>{f(p.approvalId),h&&i(h)},onSay:o,onOpenFull:()=>l(p.toolUseId)},p.approvalId)}function B$({item:e,count:t,timezone:n,now:r,version:i,onSettled:o,onSay:l,onOpenFull:a}){var C;const[c,u]=d.useState(null),[p,f]=d.useState(null),[h,v]=d.useState(null),[j,w]=d.useState("");d.useEffect(()=>{let P=!1;return A.approval(e.approvalId).then(E=>{P||(u(E),E.state!=="pending"&&o(E))}).catch(E=>{P||f(E instanceof le?E.message:String(E))}),()=>{P=!0}},[e.approvalId,i]);const b=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;d.useEffect(()=>{b&&c&&o({...c,state:"expired"})},[b]);const{values:x,controls:g}=Sm(c==null?void 0:c.choices),y=(P,E)=>{const O=j.trim();v(P),f(null),(x&&P==="approve"?A.decide(e.approvalId,P,E,x):A.decide(e.approvalId,P,E)).then(F=>{o(F.action),O&&l(O)}).catch(F=>{f(F instanceof le?F.message:String(F)),v(null)})},m=h!==null||c===null||c.state!=="pending",S=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,k=c?Tm(c.tool,c.canonicalArgs)??H$(c.preview):null,N=c?W$(c):null;return s.jsxs("section",{id:yk,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?s.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,s.jsx("strong",{children:c?ss(c.tool):"Loading the request…"}),e.askedBy?s.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),k||N?s.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[k?s.jsx("code",{className:"wb-dock-gist",children:k}):null,N?s.jsxs("span",{className:"wb-dock-where",children:["in ",s.jsx("span",{className:"mono",children:N})]}):null]}):null,g?s.jsx("div",{className:"wb-dock-section",children:g}):null,s.jsx(re,{message:p}),s.jsx("div",{className:"wb-dock-section",children:s.jsx("input",{className:"wb-dock-instead",value:j,onChange:P=>w(P.target.value),onKeyDown:P=>{P.key==="Enter"&&P.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:h!==null})}),s.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[s.jsxs("span",{className:"wb-dock-meta",children:[c?s.jsxs(s.Fragment,{children:["Expires ",Ie(c.expiresAt,n)," · "]}):null,s.jsx("button",{type:"button",className:"wb-link",onClick:a,children:"See the full request on the Canvas"})]}),s.jsx(R,{variant:"ghost",size:"sm",disabled:m,onClick:()=>y("reject"),children:h==="reject"?"Rejecting…":"Reject"}),S?s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",size:"sm",disabled:m,onClick:()=>y("approve","conversation"),children:"Auto: this conversation"}),s.jsx(R,{size:"sm",disabled:m,onClick:()=>y("approve","always"),children:"Always: this agent"})]}):null,s.jsx(R,{variant:"good",size:"sm",disabled:m,onClick:()=>y("approve"),children:h==="approve"?"Approving…":S?"Allow once":"Approve"})]})]})}function W$(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const n of U$){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function H$(e){const t=(e??"").split(`
96
- `).map(n=>n.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const V$=2e3;function K$({conversationId:e,agentId:t,runId:n=null,result:r=null,waiting:i=null,agents:o=[]}){const l=r!==null,[a,c]=d.useState(l),u=!a||i!==null,{data:p,error:f}=se(()=>ze.conversation(e),[e,a,(i==null?void 0:i.approvalId)??null],u?V$:void 0),h=(p==null?void 0:p.runs)??[],v=n===null?null:h.find(m=>m.runId===n)??null,j=l||i===null&&(n!==null?v!==null&&v.finishedAt!==null:h.length>0&&h.every(m=>m.finishedAt!==null));d.useEffect(()=>{j&&c(!0)},[j]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":j?"done":"working",b=o.find(m=>m.id===t)??null,x=(b==null?void 0:b.name)??(p==null?void 0:p.agentId)??t,g=(p==null?void 0:p.messages)??[],y=(r==null?void 0:r.text)??G$(g);return s.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":w,children:[s.jsxs("header",{className:"wb-delegate-head",children:[s.jsx(Zt,{agents:o,id:t}),s.jsxs("div",{className:"wb-delegate-who",children:[s.jsx("strong",{children:x}),s.jsx("span",{className:"wb-delegate-status","data-status":w,role:"status",children:w==="working"?s.jsxs(s.Fragment,{children:["Working",s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]}):w==="waiting"?"Waiting for your approval":w==="failed"?"Failed":"Done"})]})]}),f?s.jsx("p",{className:"muted",children:f}):null,s.jsx("div",{className:"wb-delegate-work",children:g.map((m,S)=>s.jsx("div",{className:"wb-delegate-turn",children:(m.blocks??[]).map((k,N)=>{if(k.type==="thinking")return k.text.trim()===""?null:s.jsx(wh,{text:k.text},N);if(k.type==="tool_use"){const C=q$(Y$(g,k.id));return s.jsx(bh,{label:ss(k.name),tool:k.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:Tm(k.name,k.input),opens:!1,onOpen:()=>{}},N)}return null})},m.id??S))}),y?s.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:s.jsx(ur,{text:y})}):w==="working"||w==="waiting"?s.jsxs("p",{className:"muted",children:[x," has not answered yet."]}):null,r!=null&&r.files&&r.files.length>0?s.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${x} made`,"data-testid":"delegate-files",children:r.files.map(m=>s.jsx("a",{role:"listitem",href:El(m.artifactId),download:!0,children:s.jsx(Rm,{name:m.filename??"Untitled file",mime:m.mime,sizeBytes:m.sizeBytes,thumbnail:rk(m.mime)?dr(m.artifactId):null})},m.artifactId))}):null,s.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?s.jsx(R,{variant:"accent",onClick:()=>F$(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,s.jsx("a",{className:"ui-btn",href:Be(t||(p==null?void 0:p.agentId)||"",e),children:"Open this conversation"})]})]})}function G$(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.role!=="assistant")continue;const r=(n.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
97
-
98
- `);if(r!=="")return r}return null}function Y$(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function q$(e){var n;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(n=e.approval)==null?void 0:n.state;return t==="pending"?{running:!1,ok:null,waiting:!0,status:"waiting approval"}:t==="approved"||t==="executing"?{running:!0,ok:null,waiting:!1,status:"running"}:t==="succeeded"?{running:!1,ok:!0,waiting:!1,status:void 0}:t?{running:!1,ok:!1,waiting:!1,status:t}:{running:!1,ok:e.ok,waiting:!1,status:void 0}}const Lv=1024*1024;function Q$({files:e,agentId:t,root:n,revision:r}){const[i,o]=d.useState({kind:"dir",path:""});return d.useEffect(()=>o({kind:"dir",path:""}),[e.plugin,t]),s.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?s.jsx(J$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:o}):s.jsx(X$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:o})})}function wk({root:e,path:t,go:n}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((o,l)=>({label:o,path:r.slice(0,l+1).join("/")}))];return s.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((o,l)=>{const a=l===i.length-1;return s.jsxs("span",{className:"wb-files-crumb",children:[l>0?s.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,a?s.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:o.label}):s.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>n({kind:"dir",path:o.path}),children:o.label})]},o.path)})})}function J$({files:e,agentId:t,root:n,path:r,revision:i,go:o}){const[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(!1),[h,v]=d.useState(null);d.useEffect(()=>{let b=!1;return u(null),A.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(x=>{b||a(x.data)}).catch(x=>{b||u(x instanceof Error?x.message:String(x))}),()=>{b=!0}},[e.plugin,e.list,t,r,i]),d.useEffect(()=>v(null),[r]);const j=async()=>{f(!0),v(null);try{const b=await fetch(A.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!b.ok){const m=await b.json().catch(()=>null);v((m==null?void 0:m.error)??"The archive could not be made.");return}const x=await b.blob(),g=URL.createObjectURL(x),y=document.createElement("a");y.href=g,y.download=`${r===""?n:r.split("/").at(-1)}.zip`,y.click(),window.setTimeout(()=>URL.revokeObjectURL(g),1e4)}catch{v("The archive could not be made.")}finally{f(!1)}},w=l&&l.path===r?l.entries:null;return s.jsxs(s.Fragment,{children:[s.jsxs(q,{children:[s.jsx(wk,{root:n,path:r,go:o}),s.jsx(io,{}),s.jsx(R,{size:"sm",onClick:()=>void j(),disabled:p||w===null||w.length===0,children:p?"Packing…":"Download as archive"})]}),h?s.jsx(H,{tone:"warning",role:"alert",children:h}):null,c?s.jsx(H,{tone:"critical",role:"alert",children:c}):null,w===null?c?null:s.jsx(ie,{children:"Reading the folder…"}):w.length===0?s.jsx(ie,{children:r===""?s.jsxs(s.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",s.jsx("a",{href:Fr,children:"Files library"})," and mention it here."]}):"This folder is empty."}):s.jsx(Ft,{children:w.map(b=>s.jsx(Kt,{href:"#",onClick:()=>o({kind:b.kind,path:b.path}),lead:s.jsx(e_,{kind:b.kind}),title:s.jsxs("span",{className:"mono",children:[b.name,b.kind==="dir"?"/":""]}),side:b.kind==="file"?Tn(b.bytes):void 0},b.path))}),l&&l.path===r&&(l.skipped>0||l.truncated)?s.jsxs("p",{className:"wb-files-note",children:[l.truncated?`Only the first ${l.entries.length} entries are shown. `:"",l.skipped>0?`${l.skipped} ${l.skipped===1?"entry is":"entries are"} not shown: symbolic links and protected paths are never read.`:""]}):null]})}function X$({files:e,agentId:t,root:n,path:r,revision:i,go:o}){const[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(!1);d.useEffect(()=>{let x=!1;return u(null),A.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(g=>{x||a(g.data)}).catch(g=>{x||u(g instanceof Error?g.message:String(g))}),()=>{x=!0}},[e.plugin,e.stat,t,r,i]);const h=l&&l.path===r?l:null,v=h?`${h.bytes}-${Math.round(h.mtimeMs)}`:"",j=h?A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v}):"",w=A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),b=(h==null?void 0:h.type)==="text"&&h.bytes<=Lv;return s.jsxs(s.Fragment,{children:[s.jsxs(q,{children:[s.jsx(wk,{root:n,path:r,go:o}),s.jsx(io,{}),b?s.jsx(R,{size:"sm","aria-pressed":p,onClick:()=>f(x=>!x),children:"Wrap"}):null,s.jsx(ln,{size:"sm",href:w,download:(h==null?void 0:h.name)??r.split("/").at(-1),children:"Download"})]}),c?s.jsx(H,{tone:"critical",role:"alert",children:c}):null,h===null?c?null:s.jsx(ie,{children:"Reading the file…"}):h.type==="image"?s.jsx("figure",{className:"wb-files-picture",children:s.jsx("img",{src:j,alt:h.name})}):h.type==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:j,type:"application/pdf","aria-label":h.name,children:s.jsx(H,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):b?s.jsx(Z$,{src:j,wrap:p}):s.jsxs(s.Fragment,{children:[s.jsx(H,{children:h.type==="text"?`This file is over ${Tn(Lv)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),s.jsx(Tt,{items:[{label:"Size",value:Tn(h.bytes)},{label:"Type",value:s.jsx("span",{className:"mono",children:h.mime})}]})]})]})}function Z$({src:e,wrap:t}){const[n,r]=d.useState(null),[i,o]=d.useState(!1);return d.useEffect(()=>{let l=!1;return o(!1),fetch(e,{credentials:"same-origin"}).then(async a=>{if(!a.ok)throw new Error(String(a.status));const c=await a.text();l||r(c)}).catch(()=>{l||o(!0)}),()=>{l=!0}},[e]),i?s.jsx(H,{tone:"critical",children:"The file could not be read."}):n===null?s.jsx(ie,{children:"Reading the file…"}):n===""?s.jsx(ie,{children:"This file is empty."}):s.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:n})}function e_({kind:e}){return s.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:e==="dir"?s.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}const t_=3,n_=152,s_=104,r_=100,i_=2,Fv=5;function o_({renderables:e,activeId:t,onActivate:n,timezone:r,onDecided:i,onChangeAgent:o,face:l,descriptors:a,grantedTools:c,agentName:u,maxTabs:p,browserPanel:f,agents:h,onClose:v,loading:j=!1}){const[w,b]=l_(p);if(e.length===0)return s.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[s.jsx("div",{className:"wb-canvas-tabs",ref:w,"aria-hidden":"true",children:s.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),s.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:j?null:s.jsxs("div",{className:"wb-empty",children:[l?s.jsx("span",{className:"wb-empty-face",children:l}):null,s.jsx("p",{className:"ui-empty wb-empty-line",children:f_(u,h_(a??[],c??[]))})]})})]});const x=e.some(m=>m.id===t)?t:e[e.length-1].id,{shown:g,hidden:y}=a_(e,x,b);return s.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:s.jsxs(aI,{value:x,onValueChange:n,className:"contents",children:[s.jsxs("div",{className:"wb-canvas-tabs",ref:w,children:[s.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),s.jsx(cI,{className:"wb-tabstrip","aria-label":"Canvas",children:g.map(m=>s.jsxs("div",{className:"wb-tab-item",children:[s.jsxs(uI,{value:m.id,className:"wb-tab","data-tone":m.tone,onKeyDown:S=>{S.key==="Delete"&&v&&Uv(m)&&(S.preventDefault(),v(m.id))},children:[m.tone==="warning"||m.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":m.tone,"aria-hidden":"true"}):null,s.jsx("span",{className:"wb-tab-text",children:m.title})]}),v&&Uv(m)?s.jsx("button",{className:"wb-tab-close","aria-label":`Close ${m.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>v(m.id),children:"×"}):null]},m.id))}),s.jsx(c_,{items:y,onActivate:n,timezone:r})]}),e.map(m=>s.jsx(dI,{value:m.id,className:"wb-canvas-body","data-renderer":m.source==="descriptor"&&m.renderer==="preview"?"preview":void 0,"data-dense":m_.has(m.renderer)?"true":void 0,children:s.jsxs("section",{className:"ui-panel","data-flush":m.source==="descriptor"&&m.renderer==="preview"?"true":void 0,children:[m.source!=="browser"&&m.source!=="files"&&!(m.source==="descriptor"&&m.renderer==="preview")?s.jsxs("header",{className:"ui-panel-head",children:[s.jsx("h2",{className:"ui-panel-title",children:m.title}),s.jsx("span",{className:"ui-panel-tool mono",children:m.tool})]}):null,m.tone==="critical"?s.jsxs("p",{className:"muted",children:["Recorded tool failure",m.at?` · ${new Date(m.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,m.source==="browser"?f:m.source==="profile"?s.jsx(YM,{...m.props,...o?{onChange:o}:{}}):m.source==="artifact"?s.jsx(i$,{...m.props}):m.source==="files"?s.jsx(Q$,{...m.props}):m.source==="delegate"?s.jsx(K$,{...m.props,agents:h??[]}):s.jsx(GM,{renderer:m.renderer,props:m.props,timezone:r,onDecided:i})]})},m.id))]})})}function Uv(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function l_(e){const[t,n]=d.useState(Fv),r=d.useRef(null);return[d.useCallback(o=>{var a;if((a=r.current)==null||a.disconnect(),r.current=null,!o||e!==void 0||typeof ResizeObserver>"u")return;const l=()=>{const c=o.clientWidth;if(c===0)return;const u=Math.floor((c-r_-s_)/n_);n(Math.max(i_,Math.min(Fv,u)))};l(),r.current=new ResizeObserver(l),r.current.observe(o)},[e]),e??t]}function a_(e,t,n){const r=new Set(e.filter(o=>o.id===t||o.source==="approval"||o.pinned===!0).map(o=>o.id)),i=new Set(r);for(let o=e.length-1;o>=0&&i.size<n;o-=1)i.add(e[o].id);return{shown:e.filter(o=>i.has(o.id)),hidden:e.filter(o=>!i.has(o.id))}}function c_({items:e,onActivate:t,timezone:n}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return s.jsxs(om,{modal:!1,children:[s.jsx(lm,{asChild:!0,children:s.jsxs("button",{className:"wb-tab wb-tab-more","data-tone":r??void 0,"aria-label":`${e.length} more ${e.length===1?"view":"views"} in this conversation`,children:[r?s.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,s.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),s.jsx(Ue,{name:"chevron-down"})]})}),s.jsx(am,{children:s.jsxs(cm,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[s.jsx(um,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>s.jsxs(ih,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[s.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),s.jsx("span",{className:"ui-menu-note mono",children:u_(i.at,n)??i.tool})]},i.id))]})})]})}function u_(e,t){if(!e)return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit"}).format(n)}const d_={timeseries:"charts",table:"tables",bars:"comparisons",keyvalue:"figures",document:"pages it read",diff:"diffs",terminal:"command output",image:"pictures",preview:"running apps",envelope:"drafts",structured:"results"};function f_(e,t){const n=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>d_[i.renderer]??"results"))].slice(0,3);return r.length>0?`${n} lands here: ${r.join(", ")}.`:`${n} lands here.`}function h_(e,t){const n=new Set(t),r=new Set,i=e.filter(c=>{if(!n.has(c.tool))return!1;const u=p_(c);return r.has(u)?!1:(r.add(u),!0)}),o=new Set,l=i.filter(c=>o.has(c.renderer)?!1:(o.add(c.renderer),!0)),a=i.filter(c=>!l.includes(c));return[...l,...a].slice(0,t_)}function p_(e){return e.title&&e.title.trim()!==""?e.title:e.tool.split(".").map(t=>t.replace(/[_-]+/g," ")).join(" · ").replace(/\b\w/,t=>t.toUpperCase())}const m_=new Set(["table","diff","files"]),g_=3.5*6e4,x_=2e3;function v_(e,t,n={}){const[r,i]=d.useState({served:new Set,live:new Set,scope:t}),o=d.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};o.current=u.served,i(u)}const l=n.check??A.previewCheck,a=n.everyMs??x_,c=e.map(u=>`${Ti(u)}@${u.at??""}`).join("|");return d.useEffect(()=>{const u=new Map;for(const v of e){const j=Ti(v);if(o.current.has(j))continue;const w=v.at===null?Number.NaN:Date.parse(v.at),b=Number.isNaN(w)?0:w+g_,x=u.get(j);(!x||b>x.until)&&u.set(j,{plugin:v.plugin,name:v.name,until:b})}if(u.size===0)return;let p=!1,f;const h=async()=>{const v=Date.now();for(const[j,w]of[...u]){const b=await l(w.plugin,w.name).catch(()=>null);if(p)return;const x=v<=w.until;b!=null&&b.ok?(u.delete(j),i(g=>{const y={served:new Set(g.served).add(j),live:x?new Set(g.live).add(j):g.live,scope:g.scope};return o.current=y.served,y})):x||u.delete(j)}!p&&u.size>0&&(f=setTimeout(()=>void h(),a))};return h(),()=>{p=!0,f!==void 0&&clearTimeout(f)}},[c,t,l,a]),r}const kh="workspace-files";function j_(e){let t=0;for(const n of e)for(const r of n.blocks??[]){if(r.type!=="tool_result"||r.ok===!1)continue;const i=r.output;if(i===null||typeof i!="object"||Array.isArray(i))continue;const{diff:o,path:l}=i;typeof o=="string"&&o.trim()!==""&&typeof l=="string"&&l!==""&&(t+=1)}return t}function y_(e){const[t,n]=d.useState(null);return d.useEffect(()=>{if(n(null),!e)return;let r=!1;return(async()=>{var o;const i=await A.pages();for(const l of Array.isArray(i==null?void 0:i.files)?i.files:[]){const a=await A.pageQuery(l.plugin,l.workspace,{agent:e}).catch(()=>null),c=(o=a==null?void 0:a.data)==null?void 0:o.workspace;if(c&&typeof c.name=="string")return{files:l,agentId:e,root:c.name}}return null})().then(i=>{r||n(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function w_(e,t){return{id:kh,tool:"",title:"Files",renderer:"files",props:{files:e.files,agentId:e.agentId,root:e.root,revision:t},at:null,source:"files",pinned:!0,substantial:!1}}function Sh(e){return`agent-properties:${e}`}function b_(e){return{id:Sh(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function k_(e){return!e||e.download===0?"Fetching the browser…":e.phase==="downloading"?`Fetching ${e.what}… ${e.percent}%`:e.phase==="installing"?`Setting up ${e.what}…`:e.phase==="done"?"Installed.":"The install stopped."}function bk({progress:e}){return s.jsxs(K,{gap:"sm",children:[s.jsx("span",{role:"status",children:k_(e)}),s.jsx(K2,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function S_(e,t,n,r){const i=e.width||1,o=e.height||1,l=t.pageScaleFactor||1,a=(n-e.left)*(t.deviceWidth/i)/l,c=((r-e.top)*(t.deviceHeight/o)-t.offsetTop)/l,u=(p,f)=>Math.max(0,Math.min(Math.round(p),Math.round(f)));return{x:u(a,t.deviceWidth),y:u(c,t.deviceHeight)}}function Pd(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function zv(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const N_=4e3;function C_(e){return e.replace(/\r\n?/g,`
99
- `).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,N_)}const E_=["left","middle","right"],A_=33;function T_(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function R_(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const n=t.getUint16(1);if(e.byteLength<3+n)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,n))),jpeg:new Blob([new Uint8Array(e,3+n)],{type:"image/jpeg"})}}catch{return null}}function P_(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function I_({sessionId:e,csrf:t,onGiveBack:n,connect:r}){const[i,o]=d.useState("connecting"),[l,a]=d.useState(null),[c,u]=d.useState(!1),[p,f]=d.useState(null),[h,v]=d.useState(!1),[j,w]=d.useState(0),b=d.useRef(null),x=d.useRef(null),g=d.useRef(null),y=d.useRef({at:0});d.useEffect(()=>{const T=r??(Y=>new WebSocket(Y));let z=!0,Q;try{Q=T(P_())}catch{o("lost");return}return Q.binaryType="arraybuffer",b.current=Q,Q.onopen=()=>Q.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),Q.onmessage=Y=>{if(!z)return;if(typeof Y.data!="string"){const B=R_(Y.data);if(!B||(f($=>$&&T_($,B.metadata)?$:B.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(B.jpeg).then($=>{var V,de,ge;const Z=x.current;if(!z||!Z){(V=$.close)==null||V.call($);return}(Z.width!==$.width||Z.height!==$.height)&&(Z.width=$.width,Z.height=$.height),(de=Z.getContext("2d"))==null||de.drawImage($,0,0),(ge=$.close)==null||ge.call($)}).catch(()=>{});return}const M=JSON.parse(Y.data);if(M.type==="driving"){o("driving"),a(null);return}(M.type==="refused"||M.type==="ended")&&(a(M.error??"The screen cannot be driven from here."),o("refused"))},Q.onclose=()=>{z&&o(Y=>Y==="refused"?Y:"lost")},Q.onerror=()=>{z&&o(Y=>Y==="refused"?Y:"lost")},()=>{z=!1,b.current=null;try{Q.close()}catch{}}},[e,t,j,r]),d.useEffect(()=>()=>{clearTimeout(y.current.timer)},[]);const m=d.useCallback(T=>{const z=b.current;if(z)try{z.send(JSON.stringify({type:"input",input:T}))}catch{}},[]),S=T=>{var Y;const z=x.current;if(!z||!p)return null;const Q=(Y=z.getBoundingClientRect)==null?void 0:Y.call(z);return Q?S_(Q,p,T.clientX,T.clientY):null},k=T=>{const z=y.current,Q=Date.now();clearTimeout(z.timer),z.timer=void 0;const Y=z.at+A_-Q;if(Y<=0){z.at=Q,z.pending=void 0,m(T);return}z.pending=T,z.timer=setTimeout(()=>{const M=y.current.pending;y.current.timer=void 0,y.current.pending=void 0,y.current.at=Date.now(),M&&m(M)},Y)},N=()=>{const T=y.current;clearTimeout(T.timer),T.timer=void 0;const z=T.pending;T.pending=void 0,z&&(T.at=Date.now(),m(z))},C=T=>z=>{var M,B;const Q=S(z);if(!Q)return;T==="mousePressed"&&(z.preventDefault(),(B=(M=x.current)==null?void 0:M.focus)==null||B.call(M));const Y={kind:"mouse",type:T,x:Q.x,y:Q.y,button:E_[z.button]??"left",clickCount:T==="mouseMoved"?0:Math.min(3,Math.max(1,z.detail||1)),modifiers:Pd(z)};if(T==="mouseMoved"){k(Y);return}N(),m(Y)},P=T=>{const z=S(T);z&&(N(),m({kind:"wheel",x:z.x,y:z.y,deltaX:Math.round(T.deltaX),deltaY:Math.round(T.deltaY)}))},E=T=>T.ctrlKey||T.metaKey||T.altKey,O=T=>{var Q,Y;if(T.key==="Escape"&&E(T)){v(!1),(Y=(Q=T.target).blur)==null||Y.call(Q);return}if(T.preventDefault(),(T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))return;const z=Pd(T);if(zv(T.key)&&!E(T)){m({kind:"key",type:"char",key:T.key,code:T.code,text:T.key,modifiers:z});return}m({kind:"key",type:"keyDown",key:T.key,code:T.code,modifiers:z})},F=T=>{T.key==="Escape"&&E(T)||(T.preventDefault(),!((T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))&&(zv(T.key)&&!E(T)||m({kind:"key",type:"keyUp",key:T.key,code:T.code,modifiers:Pd(T)})))},D=T=>{var Q;T.preventDefault();const z=C_(((Q=T.clipboardData)==null?void 0:Q.getData("text/plain"))??"");z!==""&&m({kind:"text",text:z})};return s.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[s.jsxs("div",{className:"hand-bar",children:[s.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),s.jsxs(q,{align:"end",children:[s.jsx(R,{size:"sm",variant:h?"accent":"ghost","aria-pressed":h,onClick:()=>{var z,Q,Y,M;const T=!h;v(T),T?(Q=(z=g.current)==null?void 0:z.focus)==null||Q.call(z):(M=(Y=g.current)==null?void 0:Y.blur)==null||M.call(Y)},children:"Keyboard"}),s.jsx(R,{size:"sm",variant:"accent",onClick:n,children:"Give it back"})]})]}),i==="lost"?s.jsxs(H,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",s.jsx(q,{align:"end",children:s.jsx(R,{size:"sm",variant:"accent",onClick:()=>{o("connecting"),w(T=>T+1)},children:"Reconnect"})})]}):null,i==="refused"&&l?s.jsx(H,{tone:"warning",role:"status",children:l}):null,s.jsx("div",{className:"hand-screen",children:c?s.jsx("canvas",{ref:x,className:"hand-picture",role:"img","aria-label":"The host browser, live","data-testid":"hand-picture",tabIndex:0,onMouseDown:C("mousePressed"),onMouseUp:C("mouseReleased"),onMouseMove:C("mouseMoved"),onWheel:P,onKeyDown:O,onKeyUp:F,onPaste:D,onContextMenu:T=>T.preventDefault()}):s.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),s.jsx("input",{ref:g,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:O,onKeyUp:F,onPaste:D,onBlur:()=>v(!1)})]})}function M_(e){return e==="darwin"?"this Mac":"this computer"}let Id=null;function Mm(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{let n=!0;return Id??(Id=A.session().then(r=>r.platform,()=>{Id=null})),Id.then(r=>{n&&t(r)}),()=>{n=!1}},[]),M_(e)}function $_({embedded:e,timezone:t}={}){var c;const{data:n,error:r,reload:i}=se(()=>A.browser(),[],3e3),o=se(()=>A.session(),[]),l=(c=o.data)!=null&&c.platform?o.data.platform==="darwin":!0,a=!!o.data||!!o.error;return s.jsxs(cn,{embedded:e,title:"Computer & browser",children:[s.jsx(re,{message:r}),!n||!a?s.jsx(ie,{children:"Checking the host…"}):s.jsx(__,{data:n,macOS:l,reload:i,timezone:t},JSON.stringify(n.settings??null))]})}function __({data:e,macOS:t,reload:n,timezone:r}){var N,C,P;const[i,o]=d.useState(!1),[l,a]=d.useState(null),[c,u]=d.useState(!1),p=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,f=(p==null?void 0:p.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),h=f==="computer",v=(N=e.sessions)!=null&&N.length?e.sessions:e.session?[e]:[],j=v.length>0||e.busy,w=async E=>{o(!0),a(null);try{await E()}catch(O){a(O instanceof Error?O.message:String(O))}finally{o(!1),n()}},b=E=>void w(()=>A.browserSettings(E)),x=e.permissions,g=f==="playwright"?e.browser:void 0,y=((C=g==null?void 0:g.install)==null?void 0:C.state)==="running",m=(g==null?void 0:g.engine)==="none",S=!!e.enabled&&!m&&!(g!=null&&g.problem)&&(!h||!(x!=null&&x.supported)||x.accessibility&&x.screenRecording),k=h?"Ready. Agents can use your computer within the apps you allow below.":f==="extension"?"Ready. Agents work in your Chrome, in background tabs, through the buddi extension.":(g==null?void 0:g.engine)==="chrome"?"Ready. Agents work in their own browser, a separate Google Chrome profile. Your apps are never touched.":"Ready. Agents work in their own browser. Your apps are never touched.";return s.jsxs(K,{gap:"lg",children:[s.jsx(re,{message:l}),s.jsx(G,{title:"Status",panel:!0,actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",disabled:i,onClick:()=>void w(()=>A.computerPermissions(!1)),children:"Check again"}),h&&!S&&(x!=null&&x.supported)?s.jsx(R,{size:"sm",variant:"accent",disabled:i||j,onClick:()=>void w(()=>A.computerPermissions(!0)),children:"Request macOS permissions"}):null,m||y?s.jsx(R,{size:"sm",variant:"accent",disabled:i||y,onClick:()=>void w(()=>A.browserInstall()),children:y?"Installing…":"Install Chromium"}):null]}),children:s.jsxs(K,{children:[e.enabled?m?s.jsxs(H,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",s.jsx("code",{children:"buddi browser install"})," on this machine."]}):g!=null&&g.problem?s.jsx(H,{tone:"warning",children:g.message}):S?s.jsx(H,{tone:"good",children:k}):s.jsx(H,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):s.jsx(H,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),h?x!=null&&x.supported?s.jsxs("ul",{className:"perm-list",children:[s.jsxs("li",{className:"perm-row",children:[s.jsx(pe,{tone:x.accessibility?"good":"warning",children:x.accessibility?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Accessibility"}),s.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),s.jsxs("li",{className:"perm-row",children:[s.jsx(pe,{tone:x.screenRecording?"good":"warning",children:x.screenRecording?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Screen Recording"}),s.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):x?s.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,((P=g==null?void 0:g.install)==null?void 0:P.state)==="running"?s.jsx(bk,{progress:g.install.progress}):g!=null&&g.install?s.jsx("p",{className:"muted",role:"status",children:g.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${g.install.line??"no reason given"}`}):null,g!=null&&g.headless&&!m?s.jsx("p",{className:"muted",children:"The agents’ browser runs headless on this machine, since it has no display. Watch it and take over from the conversation’s Canvas."}):null,h&&(x!=null&&x.message)?s.jsx("p",{className:"muted",children:x.message}):null,h&&(x!=null&&x.supported)&&!S?s.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),s.jsx(G,{title:"Who is driving",panel:!0,actions:v.length>0?s.jsx(R,{variant:"danger",size:"sm",disabled:i,onClick:()=>void w(()=>A.browserControl("stop")),children:h?"Stop computer control":"Stop all browsers"}):void 0,children:v.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nobody right now. Ask an agent to open a website or one of the allowed apps, and you will see it working on that conversation’s Canvas."}):s.jsx("div",{className:"ui-list",children:v.map(E=>s.jsxs("a",{className:"ui-list-row",href:Be(E.session.agentId,E.session.conversationId),children:[s.jsx(us,{id:E.session.agentId,name:E.session.agentId,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:E.session.task}),s.jsxs("span",{className:"ui-list-sub",children:[E.session.agentId,", ",E.busy?"working":E.state,", ",E.session.steps," of ",E.session.maxSteps," steps"]})]}),s.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},E.session.id))})}),p?s.jsxs(s.Fragment,{children:[s.jsx(G,{title:"How agents get a screen",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?s.jsx(Md,{current:p.mode,value:"computer",disabled:i||j||!e.enabled,title:"Use my apps",body:"Agents work in your own windows, signed in as you, in the browser profile you choose below. One agent at a time. Releasing control leaves everything open.",onPick:()=>b({...p,mode:"computer"})}):null,s.jsx(Md,{current:p.mode,value:"playwright",disabled:i||j||!e.enabled,title:"Give agents their own browser",body:"A separate browser profile with its own tabs, one per conversation. Your apps are never touched.",onPick:()=>b({...p,mode:"playwright"})}),s.jsx(Md,{current:p.mode,value:"extension",disabled:i||j||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>b({...p,mode:"extension"})})]}),t?null:s.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),j?s.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,p.mode==="extension"?s.jsx(F_,{busy:i,timezone:r}):null]})}),t?s.jsx(G,{title:"Apps agents may use",panel:!0,children:s.jsxs(K,{children:[p.mode!=="computer"?s.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,s.jsx(U_,{settings:p,disabled:i||j||!e.enabled,onChange:b,onAdd:()=>u(!0)}),s.jsx(St,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Agents see what is on screen in these apps, and what they see goes to the agent’s model provider. Allow only apps you want operated."}),s.jsx("p",{children:"Never type a password or a sign-in code in chat. Sign in yourself, in the app, while you have taken over."}),s.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?s.jsx(V_,{chosen:p.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),p.allowedApps.includes(E)||b({...p,allowedApps:[...p.allowedApps,E]})}}):null]}):null]})}const O_="kmbckpnnjfggeffkkbmkggojnolkdokb";async function D_(){var e;try{if(typeof chrome>"u"||!((e=chrome==null?void 0:chrome.runtime)!=null&&e.sendMessage))return null;const t=await chrome.runtime.sendMessage(O_,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function L_(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function F_({busy:e,timezone:t}){const{data:n,error:r,reload:i}=se(()=>A.extension(),[],3e3),o=Mm(),l=se(()=>D_(),[],3e3).data??null,[a,c]=d.useState(""),[u,p]=d.useState(!1),[f,h]=d.useState(null),v=(l==null?void 0:l.state)==="pairing"?l.code??"":"";d.useEffect(()=>{v&&c(v)},[v]);const j=async g=>{p(!0),h(null);try{await g()}catch(y){h(y instanceof Error?y.message:String(y))}finally{p(!1),i()}},w=e||u,b=t??Intl.DateTimeFormat().resolvedOptions().timeZone,x=s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),s.jsx(ft,{label:"The unpacked extension",children:(n==null?void 0:n.path)??"…"})]});return s.jsxs(K,{divided:!0,children:[s.jsx(re,{message:r??f}),s.jsxs(q,{children:[s.jsx(pe,{tone:n!=null&&n.connected?"good":"warning",children:n!=null&&n.connected?"Connected":"Not connected"}),s.jsxs("span",{className:"muted",children:[n!=null&&n.connected&&n.pairedAt?`Paired with Chrome on ${o} since ${Ie(n.pairedAt,b)}`:n!=null&&n.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",n!=null&&n.extension?` · extension ${n.extension}`:""]})]}),s.jsxs(K,{children:[s.jsxs("p",{className:"muted",children:[l?`The browser you are reading this in has the extension, version ${l.version}.`:n!=null&&n.connected?"The browser you are reading this in has no buddi extension. You only need it here to pair this browser instead.":"The browser you are reading this in has no buddi extension yet.",(l==null?void 0:l.state)==="paired"?" It is already paired with a buddi.":"",(l==null?void 0:l.state)==="disconnected"?" It is not connected yet: press Connect in its popup.":""]}),l&&!L_(l.gateway)?s.jsx(H,{tone:"warning",children:`The extension is pointed at ${l.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),n!=null&&n.pending?s.jsxs(q,{valign:"end",children:[s.jsx(X,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:s.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:a,onChange:g=>c(g.target.value)})}),s.jsx(io,{}),s.jsx(R,{variant:"accent",disabled:w||a.replace(/[^0-9]/g,"").length!==6,onClick:()=>void j(async()=>{await A.pairExtension(a),c("")}),children:"Pair"})]}):null,n!=null&&n.connected?s.jsx(St,{summary:"Pair a different browser",children:x}):x,s.jsx(q,{align:"end",children:s.jsx(R,{variant:"danger",disabled:w||!(n!=null&&n.pairedAt),onClick:()=>void j(()=>A.forgetExtension()),children:"Forget this browser"})})]})}function Md({current:e,value:t,title:n,body:r,disabled:i,onPick:o}){const l=e===t;return s.jsxs("button",{type:"button",role:"radio","aria-checked":l,className:"mode-option",disabled:i,onClick:()=>{l||o()},children:[s.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),s.jsxs("span",{className:"mode-option-text",children:[s.jsx("span",{className:"mode-option-title",children:n}),s.jsx("span",{className:"mode-option-body",children:r})]})]})}function U_({settings:e,disabled:t,onChange:n,onAdd:r}){const i=se(()=>A.installedApps(),[]),o=l=>{var a,c;return((c=(a=i.data)==null?void 0:a.apps.find(u=>u.id===l))==null?void 0:c.name)??l};return s.jsxs(s.Fragment,{children:[e.allowedApps.length===0?s.jsx(ie,{children:"No apps yet. Agents cannot touch anything until you add one."}):s.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(l=>s.jsxs("li",{className:"ui-list-row",children:[s.jsx(us,{id:l,name:o(l),size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[o(l),l===e.browserApp?s.jsx(pe,{tone:"accent",className:"app-role",children:"browser"}):null]}),s.jsx("span",{className:"ui-list-sub mono",children:l})]}),s.jsxs(q,{children:[l!==e.browserApp&&H_(l)?s.jsx(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,browserApp:l}),children:"Use as browser"}):null,l===e.browserApp?s.jsx("span",{className:"muted",children:"In use as the browser"}):s.jsx(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,allowedApps:e.allowedApps.filter(a=>a!==l)}),children:"Remove"})]})]},l))}),s.jsxs(q,{children:[s.jsx(R,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),s.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&z_.includes(e.browserApp)?s.jsx(B_,{settings:e,disabled:t,onChange:n}):null]})}const z_=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function B_({settings:e,disabled:t,onChange:n}){var l;const i=((l=se(()=>A.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:l.profiles)??[],o=e.browserProfile?i.some(a=>a.directory===e.browserProfile):!0;return s.jsx(X,{label:"Browser profile",hint:e.browserProfile?"Websites open in this profile, signed in as it is.":"Not chosen: websites open in whichever profile’s window is in front, or the last one you used.",children:s.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:a=>{const{browserProfile:c,...u}=e;n(a.target.value?{...u,browserProfile:a.target.value}:u)},children:[s.jsx("option",{value:"",children:"Whichever is in front"}),!o&&e.browserProfile?s.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(a=>s.jsxs("option",{value:a.directory,children:[a.name,a.directory==="Default"?"":` (${a.directory})`]},a.directory))]})})}const W_=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function H_(e){return W_.includes(e)}function V_({chosen:e,onClose:t,onPick:n}){const r=se(()=>A.installedApps(),[]),[i,o]=d.useState(""),[l,a]=d.useState(""),c=d.useMemo(()=>{var f;const u=((f=r.data)==null?void 0:f.apps)??[],p=i.trim().toLowerCase();return u.filter(h=>!p||h.name.toLowerCase().includes(p)||h.id.toLowerCase().includes(p)).slice(0,60)},[r.data,i]);return s.jsxs(qt,{title:"Add an app",onClose:t,children:[s.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>o(u.target.value)}),s.jsx(re,{message:r.error}),r.data?c.length===0?s.jsx(ie,{children:"No app matches."}):s.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const p=e.includes(u.id);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx(us,{id:u.id,name:u.name,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:u.name}),s.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),s.jsx(R,{size:"sm",disabled:p,onClick:()=>n(u.id),children:p?"Allowed":"Allow"})]},u.id)})}):s.jsx(ie,{children:"Reading your Applications folder…"}),s.jsx(St,{summary:"Add by bundle identifier instead",children:s.jsxs(q,{children:[s.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:l,onChange:u=>a(u.target.value)}),s.jsx(R,{disabled:!l.trim(),onClick:()=>n(l.trim()),children:"Allow this identifier"})]})})]})}function K_({data:e,error:t,reload:n,compact:r=!1,refresh:i,screenshotSrc:o,onScreenshotError:l,onScreenshotLoad:a,controls:c=!0}){var P,E,O;const[u,p]=d.useState(!1),[f,h]=d.useState(null),[v,j]=d.useState(null),[w,b]=d.useState(null),x=async F=>{p(!0),h(null),b(null);try{const D=F!=="stop"&&(e!=null&&e.session)?await A.browserControl(F,e.session.id):await A.browserControl(F);F==="takeover"?D.hand&&D.session?j(D.session.id):b(D.handMessage??null):j(null)}catch(D){h(D instanceof Error?D.message:String(D))}finally{p(!1),n()}},g=v&&((P=e==null?void 0:e.session)==null?void 0:P.id)===v&&e.state==="paused"?v:null,y=!!(e!=null&&e.enabled)&&!u,m=(e==null?void 0:e.mode)==="computer",S=(e==null?void 0:e.mode)==="extension",k=m?"Stop computer control interrupts native input and revokes access. Take over pauses agent input. Release ends this conversation’s control without closing your apps. Already dispatched actions cannot be undone. Avoid using the same mouse and keyboard while the agent is working.":"Stop all browsers closes every session and revokes access until you resume. Take over, Resume and Close & release affect only the selected conversation. An in-flight action is interrupted by closing its tabs. Actions already submitted cannot be undone.",N=e!=null&&e.busy?"Working":(e==null?void 0:e.state)==="running"?"Ready":(e==null?void 0:e.state)??"Connecting",C=e!=null&&e.busy||(e==null?void 0:e.state)==="running"?"good":(e==null?void 0:e.state)==="stopped"||(e==null?void 0:e.state)==="error"?"critical":void 0;return s.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[s.jsxs("div",{className:"browser-heading",children:[s.jsxs("div",{children:[r?null:s.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),s.jsx("h2",{className:"browser-title",children:m?"Computer":S?"Your browser":"Browser"})]}),s.jsx(pe,{tone:C,children:s.jsx("span",{role:"status",children:N})})]}),r?s.jsx("a",{className:"browser-full-view",href:"#/browser",children:m?"Open computer view & settings ↗":"Open full browser view ↗"}):s.jsx("p",{className:"ui-page-lede",children:m?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":S?"Your own Chrome, signed in as you, working in background tabs grouped as “buddi”. You keep browsing.":"A real browser window, driven by your assistant. You stay in control."}),s.jsx(re,{message:t??f}),c?s.jsxs(q,{children:[s.jsx(R,{variant:"danger",disabled:!y||(e==null?void 0:e.state)==="stopped",onClick:()=>void x("stop"),children:m?"Stop computer control":"Stop all browsers"}),s.jsx(R,{disabled:!y||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void x("takeover"),children:"Take over"}),s.jsx(R,{disabled:!y||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void x("resume"),children:"Resume access"}),s.jsx(R,{disabled:!y||!(e!=null&&e.session),onClick:()=>void x("release"),children:m?"Release control":"Close & release"})]}):null,c?r?s.jsx(St,{summary:"About these controls",children:s.jsx("p",{className:"muted",children:k})}):s.jsx("p",{className:"muted",children:k}):null,w?s.jsx(H,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!g?s.jsx(H,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?s.jsxs("div",{className:"browser-task",children:[s.jsxs("div",{className:"ui-row",children:[s.jsx("strong",{children:e.session.agentId}),s.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:s.jsx("p",{children:e.session.task}),s.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",new Date(e.session.expiresAt).toLocaleTimeString()]})]}):s.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?m?"No agent is driving. Ask an agent granted browser.* to open a website or an allowed native app.":"No agent is driving. Ask an agent granted browser.* to open a website.":"The host browser is unavailable. Start buddi serve on a machine with a desktop session."}),g?s.jsx(I_,{sessionId:g,csrf:Hr(),onGiveBack:()=>void x("resume")}):null,s.jsxs("div",{className:"browser-window",hidden:!!g,children:[s.jsxs("div",{className:"browser-address",children:[s.jsx("span",{"aria-hidden":"true",children:"◉"}),s.jsx("span",{children:((E=e==null?void 0:e.page)==null?void 0:E.url)??(m?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?s.jsxs("figure",{children:[s.jsx("img",{src:o??`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:""}${i?`&tick=${i}`:""}`,alt:`Last browser observation: ${e.page.title||e.page.url}`,...l?{onError:l}:{},...a?{onLoad:a}:{}},o??e.page.id),s.jsxs("figcaption",{children:["Last observation · ",new Date(e.page.capturedAt).toLocaleTimeString()," · ",e.page.title||"Untitled page"]})]}):s.jsxs("div",{className:"browser-empty",children:[s.jsx("strong",{children:m?"Your selected app will appear here":"Your browser activity will appear here"}),s.jsx("p",{children:m?"Only the selected app window is captured, not the whole desktop. This preview is not interactive.":"This is a view of the host browser, not a second browser or a remote desktop."})]})]}),(((O=e==null?void 0:e.page)==null?void 0:O.tabs.length)??0)>1?s.jsx(St,{summary:`${e.page.tabs.length} open tabs`,children:s.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(F=>s.jsxs("li",{children:[F.title||F.id," — ",F.url]},F.id))})}):null,s.jsxs("p",{className:"muted",children:[m?"Sign in directly in the host app during takeover. Don’t send passwords or MFA codes in chat. Native apps retain your existing logins and documents. Secure accessibility fields are masked; other sensitive window content can still appear in screenshots.":"Sign in directly in this conversation’s host tab during takeover. Don’t send passwords or MFA codes in chat. Agent tabs share saved logins and cookies."," ",g?"While you are driving this is a live view of the page; nothing you type is kept.":"Screenshots update after agent actions; this is not a live video feed."]})]})}const G_=2e3,Y_=5;function q_(e,t){if(!e.hasScreenshot||!e.page)return null;const n=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${n}`}function Q_({status:e,error:t,reload:n,steps:r,live:i,focusedStepId:o=null}){var y;const[l,a]=d.useState(0),[c,u]=d.useState(0),p=c>=Y_;d.useEffect(()=>{if(!i||p)return;const m=window.setInterval(()=>{typeof document<"u"&&document.hidden||a(S=>S+1)},G_);return()=>window.clearInterval(m)},[i,p]);const f=d.useRef(null);i&&(e!=null&&e.session)&&(f.current=e);const[h,v]=d.useState(null),j=d.useRef(null),w=((y=e==null?void 0:e.page)==null?void 0:y.id)??null;d.useEffect(()=>{const m=i&&e?q_(e):null;if(!m||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let S=!1;return(async()=>{try{const k=await fetch(m);if(!k.ok||S)return;const N=await k.blob();if(S)return;const C=URL.createObjectURL(N);j.current&&URL.revokeObjectURL(j.current),j.current=C,v(C)}catch{}})(),()=>{S=!0}},[i,w]),d.useEffect(()=>()=>{j.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(j.current)},[]);const b=f.current,x=i?e:b?h?b:{...b,hasScreenshot:!1}:e,g=r.at(-1)??null;return s.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[s.jsx(K_,{data:x,error:t,reload:n,compact:!0,controls:i,...i?{refresh:l}:{},...!i&&h?{screenshotSrc:h}:{},onScreenshotError:()=>u(m=>m+1),onScreenshotLoad:()=>u(0)}),i?p?s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"This session has ended. What is on this panel is the last thing it showed."}),s.jsx(J_,{steps:r,newestId:(g==null?void 0:g.id)??null,focusedId:o??null,live:i})]})}function J_({steps:e,newestId:t,focusedId:n,live:r}){const i=d.useRef(null);return d.useEffect(()=>{var l;if(!n||!i.current)return;const o=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(n):n}"]`);(l=o==null?void 0:o.scrollIntoView)==null||l.call(o,{block:"nearest"})},[n]),e.length===0?s.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):s.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:s.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((o,l)=>{const a=o.awaiting?"awaiting":o.ok===null?"running":o.ok?"ok":"failed";return s.jsxs("li",{"data-step":o.id,className:"wb-browser-step","data-state":a,"data-newest":o.id===t?"true":void 0,"data-focused":o.id===n?"true":void 0,children:[s.jsx("span",{className:"wb-browser-index mono",children:l+1}),s.jsxs("span",{className:"wb-browser-what",children:[s.jsx("strong",{children:o.action}),o.target?s.jsx("span",{className:"muted wb-browser-target",children:o.target}):null,o.error?s.jsx("span",{className:"wb-browser-error",children:o.error}):null]}),s.jsx("span",{className:"wb-browser-outcome","data-state":a,children:a==="awaiting"?"Awaiting approval":a==="running"?"Working":a==="ok"?"Done":"Failed"})]},o.id)})})})}function X_({agentId:e,conversationId:t}){const{data:n,error:r,reload:i}=se(()=>A.host(e,t),[e,t],2e3),[o,l]=d.useState(null),[a,c]=d.useState(!1),u=async v=>{c(!0),l(null);try{await v(),i()}catch(j){l(j instanceof Error?j.message:String(j))}finally{c(!1)}},p=(n==null?void 0:n.permissions)??[],f=(n==null?void 0:n.runs)??[],h=p.some(v=>!v.conversationId)?"Always allowed":p.length?"Conversation auto-mode":"Ask each time";return s.jsx(St,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":h}${f.length?` · ${f.length} running`:""}`,children:s.jsxs(K,{gap:"sm",children:[s.jsx("p",{className:"muted",children:"Commands run as your user, not in a sandbox. Auto-mode covers all commands within its scope. Stop interrupts a command; revoke also ends the permission. Neither undoes completed changes."}),s.jsx(re,{message:o??r}),p.map(v=>s.jsxs(q,{children:[s.jsxs("span",{children:[v.agentId,": ",v.conversationId?"conversation auto-mode":"always allowed"]}),s.jsx(R,{size:"sm",disabled:a,onClick:()=>void u(()=>A.revokeHost(v.id)),children:"Revoke permission"})]},v.id)),p.length?null:s.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),f.map(v=>s.jsxs(K,{gap:"sm",children:[s.jsxs("p",{children:[v.agentId," · ",s.jsx("span",{className:"mono",children:v.cwd})]}),s.jsx(ft,{children:v.command}),s.jsx(ft,{label:"Command output",children:v.stdout||v.stderr?`${v.stdout}
100
- ${v.stderr}`:"Waiting for output…"}),s.jsx(q,{children:s.jsx(R,{size:"sm",variant:"danger",disabled:a,onClick:()=>void u(()=>A.stopHost(v.agentId,v.conversationId)),children:"Stop command"})})]},v.actionId))]})})}const kk="browser.act",Z_="browser.status",Qa=new Set([kk,Z_]);function eO(e,t,n){const r=e==null?void 0:e.session;return!r||!t||!n||r.agentId!==t||r.conversationId!==n?null:{id:`host-browser:${r.id}`,title:e.mode==="computer"?"Computer":"Browser",tool:"Host browser",renderer:"browser",source:"browser",pinned:!0,props:{},at:null,substantial:!1}}function tO(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function nO(e){var r;const t=[],n=new Map;for(const i of e)for(const o of i.blocks??[]){if(o.type==="tool_use"&&o.name===kk){const a={id:o.id,action:sO(o.input)??"act",target:rO(o.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(a),n.set(o.id,a);continue}if(o.type!=="tool_result")continue;const l=n.get(o.toolUseId);if(l){if(((r=o.approval)==null?void 0:r.state)==="pending"){l.awaiting=!0,l.ok=null,l.error=null;continue}l.awaiting=!1,l.ok=o.ok,l.error=o.ok?null:iO(o)}}return t}function Bv(e,t){var r;let n=!1;for(const i of e)for(const o of i.blocks??[])if(o.type==="tool_use"&&o.id===t&&(n=Qa.has(o.name)),o.type==="tool_result"&&o.toolUseId===t&&((r=o.approval)==null?void 0:r.state)==="pending")return null;return n?t:null}function sO(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function rO(e){if(e===null||typeof e!="object")return null;const t=e;for(const r of["url","appId","direction","key","tabId"]){const i=t[r];if(typeof i=="string"&&i!=="")return i}const n=t.target;if(n!==null&&typeof n=="object"){const r=n,i=r.name;if(typeof i=="string"&&i!=="")return i;const o=r.ref;if(typeof o=="string"&&o!=="")return o;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function iO(e){for(const t of[e.error,e.output]){if(typeof t=="string"&&t.trim()!=="")return t.trim();if(t!==null&&typeof t=="object")for(const n of["message","error","reason"]){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function oO({agentId:e,groupId:t,currentId:n,timezone:r,onSelect:i,onNew:o}){const[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(0);return d.useEffect(()=>{let h=!1;return a(null),u(null),(t?ze.groupConversations(t):ze.conversations(e,100)).then(v=>{h||a(v.conversations)}).catch(v=>{h||u(v instanceof Error?v.message:String(v))}),()=>{h=!0}},[e,t,p]),s.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[s.jsxs("div",{className:"ui-toolbar",children:[s.jsx("strong",{children:"Past conversations"}),s.jsx("button",{className:"ui-btn",onClick:o,children:"New conversation"})]}),c?s.jsxs("p",{role:"alert",children:[c," ",s.jsx("button",{className:"ui-btn",onClick:()=>f(h=>h+1),children:"Retry"})]}):l===null?s.jsx("p",{className:"muted",children:"Loading conversations…"}):l.length===0?s.jsx("p",{className:"muted",children:"No conversations yet."}):s.jsx("ul",{children:l.map(h=>s.jsx("li",{children:s.jsxs("a",{href:t?zo(t,h.id):Be(e,h.id),"aria-current":h.id===n?"page":void 0,onClick:v=>{v.button===0&&!v.metaKey&&!v.ctrlKey&&!v.shiftKey&&!v.altKey&&(v.preventDefault(),i(h.id))},children:[s.jsx("span",{children:h.preview||h.opening||"Untitled conversation"}),s.jsxs("small",{children:[Ie(h.lastMessageAt??h.startedAt??h.createdAt??null,r)," · ",h.messageCount," messages",h.id===n?" · Current":""]})]})},h.id))}),s.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(l==null?void 0:l.length)===100?s.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const Sk="buddi.dismissedTabs";function lO(){try{const e=JSON.parse(sessionStorage.getItem(Sk)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(n=>typeof n=="string")))}catch{return{}}}function Wv(e){try{sessionStorage.setItem(Sk,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const aO="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",va="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",cO=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function uO(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(aO);let n;try{n=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(cO(i))return null;throw new Error(va)}try{const i=e.document??document,o=i.createElement("video");o.muted=!0,o.playsInline=!0,o.srcObject=n,await new Promise((p,f)=>{o.onloadedmetadata=()=>p(),o.onerror=()=>f(new Error(va))}),await o.play(),await new Promise(p=>{const f=o.requestVideoFrameCallback;typeof f=="function"?f.call(o,()=>p()):setTimeout(p,120)});const l=i.createElement("canvas");l.width=o.videoWidth,l.height=o.videoHeight;const a=l.getContext("2d");if(!a||l.width===0)throw new Error(va);a.drawImage(o,0,0);const c=await new Promise(p=>l.toBlob(p,"image/png"));if(!c)throw new Error(va);const u=(((r=e.now)==null?void 0:r.call(e))??new Date).toISOString().slice(0,19).replace("T"," ").replace(/:/g,".");return new File([c],`Tab ${u}.png`,{type:"image/png"})}finally{n.getTracks().forEach(i=>i.stop())}}const Hv="Send files once the agent has answered.",dO=d.forwardRef(function({disabled:t,running:n,onSend:r,onStop:i,agentName:o,draft:l,model:a,setupHref:c,thinking:u,onThinking:p,onOpenFile:f,mentions:h,history:v,threadKey:j},w){var Kn;const b=j?`buddi.draft.${j}`:null,x=U=>{if(!U)return"";try{return window.localStorage.getItem(U)??""}catch{return""}},[g,y]=d.useState(()=>x(b)),[m,S]=d.useState([]),[k,N]=d.useState(!1),[C,P]=d.useState(null),[E,O]=d.useState(!1),F=d.useRef(null),D=d.useRef(null),[T,z]=d.useState(null),[Q,Y]=d.useState(0),M=T&&h?h.filter(U=>U.handle.toLowerCase().startsWith(T.query.toLowerCase())||U.name.toLowerCase().startsWith(T.query.toLowerCase())).slice(0,6):[],B=(U,ce)=>{if(!h||h.length===0){z(null);return}const Qe=U.slice(0,ce),Pt=/(^|\s)@([\w-]*)$/.exec(Qe);if(!Pt){z(null);return}z({start:ce-Pt[2].length-1,query:Pt[2]}),Y(0)},$=U=>{if(!T)return;const ce=D.current,Qe=ce?ce.selectionStart:g.length,Pt=`${g.slice(0,T.start)}@${U} ${g.slice(Qe)}`;y(Pt),V<0&&ne(Pt),z(null),window.requestAnimationFrame(()=>{if(!ce)return;const $e=T.start+U.length+2;ce.focus(),ce.setSelectionRange($e,$e),Ae()})},Z=v??[],[V,de]=d.useState(-1),ge=d.useRef(g),je=d.useRef(b);if(je.current!==b){je.current=b;const U=x(b);ge.current=U,U!==g&&(y(U),de(-1),z(null))}const ne=U=>{if(ge.current=U,!!b)try{U===""?window.localStorage.removeItem(b):window.localStorage.setItem(b,U)}catch{}},xe=U=>{y(U),z(null);const ce=D.current;ce&&(ce.value=U,ce.setSelectionRange(U.length,U.length)),window.requestAnimationFrame(Ae)},Se=U=>!U.value.slice(0,U.selectionStart??U.value.length).includes(`
101
- `),Me=()=>g===""||V>=0&&g===Z[V],De=()=>{V<0||(de(-1),xe(ge.current))},he=m.some(U=>U.state==="uploading"),_e=m.length>0,Ce=n&&_e,He=!t&&!he&&!Ce&&g.trim()!=="",_=U=>{for(const ce of Array.from(U??[])){const Qe=`${ce.name}:${ce.size}:${Math.random().toString(36).slice(2,8)}`,Pt=ce.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(ce):null;S($e=>[...$e,{key:Qe,filename:ce.name||"Pasted image",mime:ce.type||"application/octet-stream",sizeBytes:ce.size,thumbnail:Pt,state:"uploading"}]),ze.attach(ce).then($e=>S(In=>In.map(hs=>hs.key===Qe?{...hs,state:"ready",uploaded:$e}:hs))).catch($e=>S(In=>In.map(hs=>hs.key===Qe?{...hs,state:"failed",error:$e instanceof le?$e.message:String($e)}:hs)))}},ue=U=>{U.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(U.thumbnail)},ve=U=>{const ce=m.find(Qe=>Qe.key===U);ce&&(ue(ce),ce.state==="ready"&&ce.uploaded&&ze.discardAttachment(ce.uploaded.artifactId).catch(()=>{})),S(Qe=>Qe.filter(Pt=>Pt.key!==U))};d.useImperativeHandle(w,()=>({addFiles:U=>{var ce;_(U),(ce=D.current)==null||ce.focus()},focus:()=>{var U;return(U=D.current)==null?void 0:U.focus()}}));const qe=d.useRef(m);qe.current=m,d.useEffect(()=>()=>qe.current.forEach(ue),[]);const ct=d.useRef(0);d.useEffect(()=>{if(!l||l.at===ct.current)return;ct.current=l.at,y(ce=>ce.trim()===""?l.text:ce),V<0&&g.trim()===""&&ne(l.text);const U=D.current;U&&(U.focus(),window.requestAnimationFrame(()=>{U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,200)}px`,U.setSelectionRange(U.value.length,U.value.length)}))},[l]);const Ae=()=>{const U=D.current;U&&(U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,200)}px`)},un=()=>{if(!He)return;const U=m.filter(ce=>ce.state==="ready"&&ce.uploaded).map(ce=>ce.uploaded);r(g.trim(),U),m.forEach(ue),de(-1),ne(""),y(""),S([]),window.requestAnimationFrame(Ae)},Rn=U=>{if(T&&M.length>0){if(U.key==="ArrowDown"){U.preventDefault(),Y(ce=>(ce+1)%M.length);return}if(U.key==="ArrowUp"){U.preventDefault(),Y(ce=>(ce-1+M.length)%M.length);return}if(U.key==="Enter"||U.key==="Tab"){U.preventDefault(),$(M[Q].handle);return}if(U.key==="Escape"){U.preventDefault(),z(null);return}}if(U.key==="ArrowUp"&&!U.shiftKey&&!U.altKey&&!U.metaKey&&!U.ctrlKey){const ce=U.currentTarget;if(Z.length>0&&V+1<Z.length&&Se(ce)&&Me()){U.preventDefault(),V<0&&(ge.current=g),de(V+1),xe(Z[V+1]);return}}if(U.key==="ArrowDown"&&!U.shiftKey&&!U.altKey&&!U.metaKey&&!U.ctrlKey&&V>=0&&g===Z[V]){if(U.preventDefault(),V===0){De();return}de(V-1),xe(Z[V-1]);return}if(U.key==="Escape"&&V>=0){U.preventDefault(),De();return}U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),un())},vr=U=>{var Qe;const ce=Array.from(((Qe=U.clipboardData)==null?void 0:Qe.files)??[]);ce.length!==0&&(U.preventDefault(),_(ce))},Ds=m.filter(U=>U.state==="failed"),Pn=Ds.length;return s.jsx("div",{className:"wb-composer","data-testid":"composer",children:s.jsxs("div",{className:"wb-composer-box","data-focused":E,"data-disabled":t,children:[m.length>0?s.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:m.map(U=>s.jsx("span",{role:"listitem",children:s.jsx(Rm,{name:U.filename,mime:U.mime,sizeBytes:U.sizeBytes,thumbnail:U.thumbnail,state:U.state,error:U.error,onRemove:()=>ve(U.key),...f&&U.state==="ready"&&U.uploaded?{onOpen:()=>f(fO(U.uploaded))}:{},size:"sm"})},U.key))}):null,s.jsxs("label",{className:"sr-only",htmlFor:"wb-composer-input",children:["Message ",o]}),s.jsx("textarea",{id:"wb-composer-input",ref:D,value:g,rows:2,placeholder:n?`${o} is working…`:`Message ${o}`,onChange:U=>{y(U.target.value),V<0&&ne(U.target.value),B(U.target.value,U.target.selectionStart??U.target.value.length),Ae()},onFocus:()=>O(!0),onBlur:()=>O(!1),onKeyDown:Rn,onPaste:vr,disabled:t}),T&&M.length>0?s.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:M.map((U,ce)=>s.jsxs("button",{type:"button",role:"option","aria-selected":ce===Q,className:"wb-mention","data-active":ce===Q||void 0,onMouseDown:Qe=>{Qe.preventDefault(),$(U.handle)},children:[s.jsxs("span",{className:"wb-mention-handle",children:["@",U.handle]}),s.jsx("span",{className:"wb-mention-name",children:U.name})]},U.handle))}):null,s.jsxs("div",{className:"wb-composer-row",children:[s.jsx("input",{ref:F,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:U=>{_(U.target.files),U.target.value=""}}),s.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Attach a file",title:"Attach a file — or paste one, or drop it anywhere on the chat",onClick:()=>{var U;return(U=F.current)==null?void 0:U.click()},disabled:t,children:s.jsx(Ue,{name:"clip"})}),s.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Snap a tab",title:"Snap a tab — one picture of another tab in this browser, attached here",onClick:()=>{P(null),N(!0),uO().then(U=>{var ce;U&&(_([U]),(ce=D.current)==null||ce.focus())}).catch(U=>P(U instanceof Error?U.message:String(U))).finally(()=>N(!1))},disabled:t||k,children:s.jsx(Ue,{name:"camera"})}),a?c?s.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):s.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):null,p?s.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":ja(u),disabled:t||n,title:n?`Wait for ${o} to finish — this run started with thinking ${ja(u)?"on":"off"}`:ja(u)?"Reasoning before the answer is on. Click to turn it off — answers come back faster.":"Reasoning before the answer is off. Click to turn it on.",onClick:()=>p(ja(u)?"off":"on"),children:[s.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,s.jsx("span",{className:"wb-hint","data-shown":g!==""&&!n||Pn>0||Ce||C!==null,"data-tone":Pn>0||C!==null?"critical":void 0,children:Pn>0?Pn===1&&((Kn=Ds[0])!=null&&Kn.error)?Ds[0].error:`${Pn} files failed to upload and will not be sent`:C!==null?C:Ce?Hv:"Enter sends, Shift+Enter for a new line"}),n?s.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,s.jsx("button",{className:"wb-send","aria-label":"Send",title:Ce?Hv:he?"Waiting for the upload to finish":n?`Send — ${o} picks it up between steps`:"Send",onClick:un,disabled:!He,children:s.jsx(Ue,{name:"send"})})]})]})})});function ja(e){return(e??"on")==="on"}function fO(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function hO({question:e,disabled:t,onAnswer:n,onSkip:r}){const[i,o]=d.useState("");return d.useEffect(()=>{if(t)return;const l=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),r())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t,r]),s.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),s.jsx(R,{className:"wb-question-skip",variant:"ghost",size:"sm",disabled:t,onClick:r,title:"Skip this question (Esc). The agent carries on without an answer.",children:"Skip"}),s.jsx("strong",{children:e.question})]}),e.options.length>0?s.jsx("div",{className:"wb-question-options",children:e.options.map((l,a)=>s.jsxs("button",{className:"wb-question-option","data-recommended":l.recommended||void 0,disabled:t,onClick:()=>n(l.label,l.id),children:[s.jsx("span",{className:"wb-question-number",children:a+1}),s.jsxs("span",{children:[s.jsxs("span",{className:"wb-question-label",children:[l.label,l.recommended?s.jsx("em",{children:"Recommended"}):null]}),l.hint?s.jsx("small",{children:l.hint}):null]})]},l.id))}):null,e.allowOther?s.jsxs("form",{className:"wb-question-other",onSubmit:l=>{l.preventDefault(),i.trim()&&n(i.trim())},children:[s.jsx("input",{value:i,onChange:l=>o(l.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),s.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,s.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function pO(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function mO(e){const t=e/36e5;if(t>=1&&Number.isInteger(t))return`${t} hour${t===1?"":"s"}`;const n=Math.round(e/6e4);return`${n} minute${n===1?"":"s"}`}function gO(e){const{lifetime:t,startedAt:n,now:r,timezone:i}=e;if(!t||t.messages<=0)return{text:"New conversation",title:"Nothing has been said in this one yet.",tone:"quiet"};const o=`A conversation ends after ${mO(t.idleTimeoutMs)} idle, or once its transcript grows past ${Math.round(t.maxChars/1e3)}k characters. What the agent remembers about you carries over.`,l=`${t.messages} message${t.messages===1?"":"s"}`;if(pO(t,r))return{text:`${l} · your next message starts a fresh one`,title:o,tone:"note"};const a=n?ke(n,r):"";return{text:a===""?l:`${l} · started ${a}`,title:n?`Started ${Ie(n,i)}. ${o}`:o,tone:"quiet"}}const Ja=320,Nk="buddi.chatWidth";function xO({timezone:e,agents:t,agentId:n,defaultAgentId:r=null,group:i=null,onEditGroup:o,onSelectAgent:l,attention:a,agentsInHeader:c,narrow:u,canvasOpen:p,onOpenCanvas:f,onCloseCanvas:h,newConversationSignal:v,requestedConversationId:j,requestedTab:w,onConversationOpened:b}){var gg,xg,vg,jg,yg,wg;const x=Mm(),[g,y]=d.useState([]),[m,S]=d.useState(null),[k,N]=d.useState(null),[C,P]=d.useState(null),[E,O]=d.useState([]),[F,D]=d.useState([]),[T,z]=d.useState(null),[Q,Y]=d.useState(!1),[M,B]=d.useState(new Map),[$,Z]=d.useState(null),[V,de]=d.useState(lO),[ge,je]=d.useState([]),[ne,xe]=d.useState(!1),Se=d.useRef(0),Me=d.useRef(null),[De,he]=d.useState(!1),_e=d.useRef(v??0),Ce=d.useRef(n),He=d.useRef({agentId:n,conversationId:m});He.current={agentId:n,conversationId:m};const _=V[m??""]??[],[ue,ve]=d.useState(null),[qe,ct]=d.useState(null),[Ae,un]=d.useState(null),[Rn,vr]=d.useState([]),[Ds,Pn]=d.useState(!1),[Kn,U]=d.useState(()=>Date.now()),[ce,Qe]=d.useState(vO),Pt=d.useRef(null),[$e,In]=d.useState(null),[hs,Qm]=d.useState(!1),[g1,Nu]=d.useState(null),[x1,v1]=d.useState(null),[j1,Jm]=d.useState(null);d.useEffect(()=>{if(!n)return;const I=bO(n);I&&Nu({text:I,at:Date.now()})},[n]);const jr=i?`group:${i.id}`:n??null,wn=[...t.top,...t.middle,...t.bottom],fe=wn.find(I=>I.id===n)??null,y1=se(()=>A.providerAccounts(),[]),qr=i?i.members.map(I=>wn.find(W=>W.id===I)).filter(I=>!!I):[],[Cu,Xm]=d.useState(null);d.useEffect(()=>{let I=!1;return ze.views().then(W=>{I||y(W.views??[])}).catch(()=>{}),()=>{I=!0}},[]),d.useEffect(()=>{if(!n)return;const I=Ce.current===n;if(Ce.current=n,I&&j&&j===He.current.conversationId)return;let W=!1;return S(null),N(null),P(null),O([]),ve(null),Y(!1),Z(null),je([]),$l(null),he(!1),In(null),j?(j!=="new"?S(j):P(jr),()=>{W=!0}):((i?ze.groupConversations(i.id):ze.conversations(n)).then(ee=>{if(W)return;const ye=[...ee.conversations??[]].sort(jO)[0];ye?(S(ye.id),b==null||b(n,ye.id)):P(jr)}).catch(()=>{W||P(jr)}),()=>{W=!0})},[n,i==null?void 0:i.id,jr,j,b]);const Gn=d.useCallback(I=>ze.conversation(I).then(W=>{if(He.current.conversationId===I){if(W.agentId!==He.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(W),O(ee=>ee.filter(ye=>!$d(W,ye)))}}).catch(W=>{He.current.conversationId===I&&ve(Us(W))}),[]);d.useEffect(()=>{if(!m)return;let I=!1;return B(new Map),D([]),ze.conversation(m).then(W=>{if(!I){if(W.agentId!==n)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(W),O(ee=>ee.filter(ye=>!$d(W,ye)))}}).catch(W=>{I||ve(Us(W))}),()=>{I=!0}},[m,n]),d.useEffect(()=>{if(!m)return;let I=!1;const W=window.setInterval(()=>{ze.conversation(m).then(ee=>{I||ee.agentId!==He.current.agentId||(N(ee),O(ye=>ye.filter(Te=>!$d(ee,Te))))}).catch(()=>{})},3e3);return()=>{I=!0,window.clearInterval(W)}},[m,n]),d.useEffect(()=>{if(!m)return;const I=D0({url:ze.streamUrl(m),onEvent:W=>{switch(W.name){case"run.started":Y(!0),z(null),Xm(Ct(W.data.agentId));break;case"live":{const ee=Ct(W.data.runId)??"",ye=Number(W.data.turn??0),Te=W.data.kind==="thinking"?"thinking":"text",Fe=Ct(W.data.text)??"",ps=Date.now();z(Ls=>{const Zr=Ls&&Ls.runId===ee&&Ls.turn===ye?Ls:{runId:ee,turn:ye,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return Te==="thinking"?{...Zr,thinking:Zr.thinking+Fe,thinkingStartedAt:Zr.thinkingStartedAt??ps}:{...Zr,text:Zr.text+Fe,textStartedAt:Zr.textStartedAt??ps}});break}case"live.snapshot":{const ee=Ct(W.data.runId)??"",ye=Number(W.data.turn??0),Te=Ct(W.data.text)??"",Fe=Ct(W.data.thinking)??"",ps=Number(W.data.startedAt??Date.now());z({runId:ee,turn:ye,text:Te,thinking:Fe,thinkingStartedAt:Fe?ps:null,textStartedAt:Te?ps:null,settled:!1});break}case"live.settle":{const ee=Ct(W.data.runId)??"",ye=Number(W.data.turn??0);z(Te=>Te&&Te.runId===ee&&Te.turn===ye?{...Te,settled:!0}:Te);break}case"tool.called":{const ee=Ct(W.data.toolUseId)??Ct(W.data.id),ye=Ct(W.data.name)??Ct(W.data.tool)??"tool";ee&&D(Te=>[...Te.filter(Fe=>Fe.toolUseId!==ee),{toolUseId:ee,name:ye,startedAt:Date.now()}]);break}case"tool.result":{const ee=Ct(W.data.toolUseId)??Ct(W.data.id);ee&&D(ye=>ye.filter(Te=>Te.toolUseId!==ee)),Gn(m);break}case"message.appended":Gn(m).then(()=>{z(ee=>ee!=null&&ee.settled?null:ee)});break;case"awaiting-approval":{const ee=Ct(W.data.approvalId)??Ct(W.data.actionId),ye=Ct(W.data.toolUseId);ee&&ye&&B(Te=>new Map(Te).set(ye,ee)),D(Te=>Te.filter(Fe=>Fe.toolUseId!==ye)),Gn(m);break}case"run.finished":{Y(!1),D([]),z(null),Xm(null);const ee=Ct(W.data.message);ve(ee??null),Gn(m);break}}}});return()=>I.close()},[m,Gn]),d.useEffect(()=>{const I=window.setInterval(()=>U(Date.now()),F.length===0?6e4:1e3);return()=>window.clearInterval(I)},[F.length]);const Ml=se(()=>n&&m?A.browser({agentId:n,conversationId:m}):Promise.resolve(void 0),[n,m],1500),Qr=Ml.error?void 0:Ml.data,co=Qr!=null&&Qr.session&&Qr.session.agentId===n&&Qr.session.conversationId===m?Qr:void 0,yr=eO(co,n,m),wr=(yr==null?void 0:yr.id)??null,[uo,w1]=d.useState(null),Zm=co==null?void 0:co.mode;d.useEffect(()=>{yr&&n&&m&&w1({agentId:n,conversationId:m,tab:tO(yr,Zm)})},[wr,Zm,n,m]);const b1=uo&&uo.agentId===n&&uo.conversationId===m&&!_.includes(uo.tab.id)?uo.tab:null,It=yr??b1,k1=d.useMemo(()=>nO((k==null?void 0:k.messages)??[]),[k]),[S1,$l]=d.useState(null),N1=d.useMemo(()=>f$({messages:(k==null?void 0:k.messages)??[],descriptors:g}),[k,g]),Jr=v_(N1,m??null),Eu=y_(i?null:n),eg=d.useMemo(()=>j_((k==null?void 0:k.messages)??[]),[k]),dn=d.useMemo(()=>{const W=h$({messages:(k==null?void 0:k.messages)??[],descriptors:g,awaiting:M,served:Jr.served,...It?{folded:Qa}:{}}).filter(ee=>ee.source==="approval"||!_.includes(ee.id));if($&&!_.includes($)&&!W.some(ee=>ee.id===$)){const ee=x$((k==null?void 0:k.messages)??[],$,{redactInputOf:Qa});ee&&!Qa.has(ee.tool)&&W.push(ee)}It&&W.push(It);for(const ee of ge)W.push(tM(ee));return Eu&&W.unshift(w_(Eu,eg)),$e?[...W,b_($e)]:W},[k,g,M,$e,wr,It==null?void 0:It.title,$,V,m,ge,Jr.served,Eu,eg]),C1=d.useMemo(()=>{var W;const I=[];for(const ee of(k==null?void 0:k.messages)??[]){if(ee.role!=="user"||ee.speaker&&ee.speaker!=="owner")continue;const ye=(W=ee.blocks.find(Te=>Te.type==="text"))==null?void 0:W.text.trim();ye&&I.unshift(ye)}return I},[k]),Au=d.useMemo(()=>dn.filter(I=>I.source==="approval"),[dn]),_l=Au.at(-1)??null,Ol=d.useMemo(()=>[...Au.map(I=>({approvalId:I.props.approvalId,toolUseId:I.id})),...((k==null?void 0:k.delegatedApprovals)??[]).map(I=>({approvalId:I.approvalId,toolUseId:I.toolUseId??"",askedBy:CO(I.chain,wn)}))],[Au,k==null?void 0:k.delegatedApprovals]),fo=d.useMemo(()=>{for(let I=dn.length-1;I>=0;I-=1){const W=dn[I];if(W!=null&&W.substantial)return W.id}return null},[dn]),Dl=d.useRef(null),Tu=((gg=dn.filter(I=>(I.source!=="browser"||I.pinned===!0)&&I.id!==kh).at(-1))==null?void 0:gg.id)??((xg=dn.filter(I=>I.id!==kh).at(-1))==null?void 0:xg.id)??null;d.useEffect(()=>{if(fo&&fo!==Dl.current){Dl.current=fo,Z(fo);return}$===null&&Tu&&Z(Tu)},[fo,$,Tu]);const tg=d.useRef(Jr.live);d.useEffect(()=>{const I=tg.current;tg.current=Jr.live;const W=[...Jr.live].filter(Te=>!I.has(Te));if(W.length===0||_l||$!==null&&$!==Dl.current)return;const ye=[...dn].reverse().find(Te=>Te.source==="descriptor"&&Te.renderer==="preview"&&Te.props.target!==null&&W.includes(Ti(Te.props.target)));ye&&Z(ye.id)},[Jr.live,dn,_l,$]);const ng=d.useRef(null);d.useEffect(()=>{wr!==ng.current&&(ng.current=wr,wr&&!_l&&Z(wr))},[wr,_l]);const sg=d.useRef(null),ho=w==="browser"?(It==null?void 0:It.id)??null:null;d.useEffect(()=>{!ho||sg.current===ho||(sg.current=ho,Z(ho))},[ho]);const Ru=(It==null?void 0:It.id)??null;d.useEffect(()=>{!Ru||!$||Bv((k==null?void 0:k.messages)??[],$)!==null&&($l($),Z(Ru))},[Ru,$,k]);const rg=I=>{je(W=>W.some(ee=>ee.artifactId===I.artifactId)?W:[...W,I]),Z(qa(I.artifactId)),u&&(f==null||f())},Ll=!i&&fe&&!fe.available?B0(fe):null,ig=lh(i?null:fe),og=((k==null?void 0:k.offers)??[]).filter(I=>!Rn.includes(I.id)&&Date.parse(I.expiresAt)>Kn),E1=fe&&j1===fe.id?x1:(fe==null?void 0:fe.thinking)??null,A1=I=>{if(!fe)return;const W=fe.id;Jm(W),v1(I),A.setAgentEngine(W,{thinking:I}).catch(ee=>{Jm(null),ve(ee instanceof le?ee.message:String(ee))})},lg=(I,W)=>{if(!n)return;const ee=W.map(Fe=>Fe.artifactId),ye=Q,Te={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:I},...W.map(Fe=>({type:"attachment",artifactId:Fe.artifactId,filename:Fe.filename,mime:Fe.mime,kind:Fe.kind,sizeBytes:Fe.sizeBytes}))],...ye?{speaker:vk}:{}};O(Fe=>ye?[...Fe,Te]:[Te]),ve(null),ct(null),Y(!0),(i?ze.sendToGroup(i.id,{...m?{conversationId:m}:{},text:I,attachmentIds:ee}):ze.send(n,{...m?{conversationId:m}:{},text:I,attachmentIds:ee})).then(async Fe=>{He.current.agentId!==n||He.current.conversationId!==m||(ct(Fe.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),Fe.conversationId!==m?(N(null),S(Fe.conversationId)):await Gn(Fe.conversationId),Fe.queued===!0&&O(ps=>ps.filter(Ls=>Ls.id!==Te.id)),b==null||b(n,Fe.conversationId))}).catch(Fe=>{O(ps=>ps.filter(Ls=>Ls.id!==Te.id)),ve(Us(Fe)),Y(!1)})},T1=I=>{ve(null),un(I),vr(W=>[...W,I]),A.takeOffer(I,m??void 0).then(W=>{W.runId&&(ct(null),Y(!0)),m&&Gn(m)}).catch(W=>{vr(ee=>ee.filter(ye=>ye!==I)),ve(Us(W)),m&&Gn(m)}).finally(()=>un(null))},R1=(I,W)=>ag({answer:I,...W?{optionId:W}:{}}),P1=()=>ag({answer:"",skipped:!0}),ag=I=>{const W=k==null?void 0:k.question;W&&(ve(null),Pn(!0),Y(!0),ze.answerQuestion(W.id,I).then(()=>{if(m)return Gn(m)}).catch(ee=>{ve(Us(ee)),Y(!1)}).finally(()=>Pn(!1)))},I1=()=>{if(n){if($e){In(null);return}Qm(!0),A.agentProfile(n).then(I=>{In(I),Z(Sh(I.id)),u&&(f==null||f())}).catch(I=>ve(Us(I))).finally(()=>Qm(!1))}},M1=I=>{Nu({text:I.prompt,at:Date.now()}),l(I.agentId),u&&(h==null||h())},$1=()=>{m&&ze.cancel(m).catch(I=>ve(Us(I))).finally(()=>{Y(!1),D([])})},Fl=d.useCallback(()=>{if(S(null),N(null),O([]),Y(!1),ve(null),ct(null),D([]),B(new Map),Z(null),je([]),$l(null),Dl.current=null,i){ze.startGroupConversation(i.id).then(({conversationId:I})=>{S(I),n&&(b==null||b(n,I))}).catch(I=>ve(Us(I)));return}P(jr),n&&(b==null||b(n,"new"))},[n,i,jr,b]);d.useEffect(()=>{v&&v!==_e.current&&(_e.current=v,Fl())},[v,Fl]);const cg=I=>{m&&Gn(m),A.overview().catch(()=>{}),I.state!=="pending"&&B(W=>new Map([...W].filter(([,ee])=>ee!==I.id)))},Ul=d.useRef(!1);d.useEffect(()=>{const I=ee=>{if(!Ul.current)return;const ye=Math.max(Ja,Math.min(720,ee.clientX-52));Qe(ye)},W=()=>{if(Ul.current){Ul.current=!1;try{ce!==null&&window.localStorage.setItem(Nk,String(ce))}catch{}}};return window.addEventListener("pointermove",I),window.addEventListener("pointerup",W),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",W)}},[ce]);const _1=((vg=wn.find(I=>I.id===r))==null?void 0:vg.name)??null,ug=i?[]:e2(fe,_1),dg=!(k&&k.conversationId===m)&&!(!m&&C!==null&&C===jr),fg=dg?s.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&fe?s.jsx(Y2,{quiet:!0,still:!0,className:"wb-chat-field",children:s.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[s.jsx(Zt,{agents:wn,id:fe.id,size:"xl"}),s.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${fe.name}.`}),s.jsx("p",{className:"wb-chat-intro",children:t2(fe)}),ug.length>0?s.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${fe.name}`,children:ug.map(I=>s.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var W;Nu({text:I,at:Date.now()}),(W=Me.current)==null||W.focus()},children:I},I))}):null]})}):null,hg=s.jsx(o_,{renderables:dn,activeId:$,onActivate:Z,onClose:I=>{$e&&I===Sh($e.id)?In(null):ge.some(W=>qa(W.artifactId)===I)?je(W=>W.filter(ee=>qa(ee.artifactId)!==I)):m&&de(W=>{const ee={...W,[m]:[...new Set([...W[m]??[],I])]};return Wv(ee),ee}),$===I&&Z(null)},timezone:e,onDecided:cg,onChangeAgent:M1,agents:wn,browserPanel:It?s.jsx(Q_,{status:co,error:Ml.error,reload:Ml.reload,steps:k1,live:yr!==null,focusedStepId:S1},It.id):null,descriptors:g,grantedTools:i?qr.flatMap(I=>I.tools??[]):(fe==null?void 0:fe.tools)??[],...fe?{agentName:fe.name}:{},loading:dg,...!i&&fe?{face:s.jsx(Zt,{agents:wn,id:fe.id,size:"xl"})}:{}}),pg=(yg=(jg=[...(k==null?void 0:k.messages)??[],...E].find(I=>I.role==="user"))==null?void 0:jg.blocks.find(I=>I.type==="text"))==null?void 0:yg.text.trim(),mg=pg?pg.split(`
102
- `)[0]:"New conversation",Xr=gO({lifetime:(k==null?void 0:k.lifetime)??null,startedAt:(k==null?void 0:k.startedAt)??null,now:Kn,timezone:e});return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"wb-chat",ref:Pt,style:u||ce===null?void 0:{width:ce},"data-sized":!u&&ce!==null?"true":void 0,"data-testid":"chat-column","data-dropping":ne||void 0,onDragEnter:I=>{ya(I)&&(I.preventDefault(),Se.current+=1,xe(!0))},onDragOver:I=>{ya(I)&&(I.preventDefault(),I.dataTransfer.dropEffect="copy")},onDragLeave:I=>{ya(I)&&(Se.current=Math.max(0,Se.current-1),Se.current===0&&xe(!1))},onDrop:I=>{var W;ya(I)&&(I.preventDefault(),Se.current=0,xe(!1),n&&((W=Me.current)==null||W.addFiles(I.dataTransfer.files)))},children:[ne?s.jsx("div",{className:"wb-drop","aria-hidden":"true",children:s.jsxs("div",{className:"wb-drop-card",children:[s.jsx(yO,{}),s.jsx("strong",{children:"Drop to attach"}),s.jsx("span",{children:fe?`It goes with your next message to ${fe.name}`:"Pick an agent first"})]})}):null,s.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&fe?Cl(Nl(fe)):{},children:[s.jsxs("div",{className:"wb-head-row",children:[i?s.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:qr.slice(0,3).map(I=>s.jsx(Zt,{agents:wn,id:I.id,size:"sm"},I.id))}):fe?s.jsx("a",{className:"wb-head-face",href:mt(fe.id),"aria-label":`${fe.name}'s page`,children:s.jsx(Zt,{agents:wn,id:fe.id})}):null,s.jsxs("div",{className:"wb-head-text",children:[i?s.jsx("span",{className:"wb-head-title",children:i.name}):s.jsx("span",{className:"wb-head-title",title:mg,children:mg}),s.jsx("span",{className:"wb-head-meta","data-tone":Xr.tone,title:i?`${qr.map(I=>I.name).join(", ")}. Coordinator: ${(fe==null?void 0:fe.name)??i.coordinator}.`:Xr.title,children:i?`${qr.map(I=>I.name).join(", ")} · ${Xr.text}`:fe?s.jsxs(s.Fragment,{children:[s.jsx("a",{className:"wb-head-name",href:mt(fe.id),title:`${fe.name}'s page`,children:fe.name})," ",s.jsxs("span",{className:"wb-head-handle",children:["@",fe.handle]}),` · ${Xr.tone==="quiet"&&Xr.text==="New conversation"?`on ${x}`:Xr.text}`]}):"No agent"})]}),s.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!n,onClick:()=>{he(!1),Fl()},children:s.jsx(Ue,{name:"plus",size:16})}),s.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":De,"data-open":De?"true":void 0,disabled:!n,onClick:()=>he(I=>!I),children:s.jsx(kO,{})}),u?s.jsxs("button",{className:"ui-btn",onClick:f,disabled:dn.length===0,children:["Canvas",dn.length>0?` (${dn.length})`:""]}):null,s.jsx(NO,{disabled:!n,items:i?[...qr.map(I=>({label:I.name,hint:I.id===i.coordinator?"Coordinator · open page":"Member · open page",href:mt(I.id)})),...o?[{label:"Members…",hint:"Name, coordinator, who is in the room",testId:"group-members",onSelect:o}]:[]]:[{label:$e?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:hs,onSelect:I1},...fe?[{label:"Set up",hint:"Identity, model and access",href:mt(fe.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:mt(fe.id)}]:[]]})]}),c?s.jsx(H0,{agents:t,currentId:n,attention:a,onSelect:l,orientation:"horizontal"}):null]}),De&&n?s.jsx(oO,{agentId:n,...i?{groupId:i.id}:{},currentId:m,timezone:e,onNew:()=>{he(!1),Fl()},onSelect:I=>{if(I===m){he(!1);return}he(!1),N(null),O([]),Y(!1),Z(null),ve(null),ct(null),je([]),S(I),b==null||b(n,I,!1)}}):null,n&&m?s.jsx(X_,{agentId:n,conversationId:m},`${n}:${m}`):null,ue?s.jsx("div",{className:"wb-chat-notice",children:s.jsx(re,{message:ue})}):null,qe?s.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:qe}):null,k!=null&&k.carriedOver?s.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:k.carriedOver}):null,s.jsx(jk,{messages:[...(k==null?void 0:k.messages)??[],...E],live:F,now:Kn,working:Q,partial:T,agents:wn,...k!=null&&k.runs?{runs:k.runs}:{},...i?{speakers:wn,coordinatorId:i.coordinator}:{},...Cu?{workingAs:((wg=wn.find(I=>I.id===Cu))==null?void 0:wg.name)??Cu}:{},onOpenFile:rg,onOpen:I=>{if(It){const W=Bv([...(k==null?void 0:k.messages)??[],...E],I);if(W){$l(W),Z(It.id),u&&(f==null||f());return}}m&&de(W=>{const ee={...W,[m]:(W[m]??[]).filter(ye=>ye!==I)};return Wv(ee),ee}),Z(I),u&&(f==null||f())},...fe?{agentName:fe.name}:{},...fg?{empty:fg}:{},emptyHint:fe?`Nothing here yet. Ask ${fe.name} for something.`:"Loading agents…"}),og.length>0?s.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:og.map(I=>s.jsx("button",{className:"ui-btn",disabled:Ae!==null,title:I.prompt,onClick:()=>T1(I.id),children:I.label},I.id))}):null,Ll?s.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:s.jsxs(H,{tone:"warning",role:"status",children:[Ll," ",s.jsx("a",{href:lt(ig.section),children:ig.label})]})}):Ol.length>0?s.jsx(z$,{approvals:Ol,timezone:e,now:Kn,version:k,onDecided:cg,onSay:I=>lg(I,[]),onOpenFull:I=>{Z(I),u&&(f==null||f())}}):null,Ll||Ol.length>0?null:k!=null&&k.question?s.jsx(hO,{question:k.question,disabled:Ds||Q,onAnswer:R1,onSkip:P1},k.question.id):null,Ll?null:s.jsx("div",{hidden:Ol.length>0||!!(k!=null&&k.question),"data-testid":"composer-slot",children:s.jsx(dO,{ref:Me,disabled:!n,running:Q,onSend:lg,onStop:$1,agentName:i?i.name:(fe==null?void 0:fe.name)??"the agent",draft:g1,history:C1,threadKey:m??(i?`group:${i.id}`:n),model:i?null:(fe==null?void 0:fe.model)??null,setupHref:i?null:fe?mt(fe.id,"setup","brain"):null,thinking:E1,...!i&&fe&&Bb(Wb(fe,y1.data))?{onThinking:A1}:{},...i?{mentions:qr.map(I=>({handle:I.handle,name:I.name}))}:{},onOpenFile:rg})})]}),u?p?s.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[s.jsxs("div",{className:"wb-sheet-head",children:[s.jsx("strong",{children:"Canvas"}),s.jsx("button",{className:"ui-btn",onClick:h,children:"Close"})]}),hg]}):null:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:I=>{var W,ee;Ul.current=!0,(ee=(W=I.currentTarget).setPointerCapture)==null||ee.call(W,I.pointerId)},onKeyDown:I=>{const W=ee=>{var ye;return ee??((ye=Pt.current)==null?void 0:ye.offsetWidth)??Ja};I.key==="ArrowLeft"&&Qe(ee=>Math.max(Ja,W(ee)-16)),I.key==="ArrowRight"&&Qe(ee=>Math.min(720,W(ee)+16))}}),hg]})]})}function vO(){try{const e=window.localStorage.getItem(Nk),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Ja?t:null}catch{return null}}function jO(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function Ct(e){return typeof e=="string"&&e!==""?e:null}function Us(e){return e instanceof le||e instanceof Error?e.message:String(e)}function $d(e,t){var r;const n=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!n)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const o=e.messages[i];if(o.role!=="user")continue;const l=o.blocks.find(a=>a.type==="text");if(l)return l.text.trim()===n}return!1}function ya(e){var n;const t=(n=e.dataTransfer)==null?void 0:n.types;return!!(t&&Array.from(t).includes("Files"))}function yO(){return s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),s.jsx("path",{d:"M5 19.5v2a2.5 2.5 0 0 0 2.5 2.5h13a2.5 2.5 0 0 0 2.5-2.5v-2"})]})}const Nh="buddi.chatDraft";function wO(e,t){try{window.sessionStorage.setItem(Nh,JSON.stringify({agentId:e,text:t}))}catch{}}function bO(e){try{const t=window.sessionStorage.getItem(Nh);if(!t)return null;const n=JSON.parse(t);return n.agentId!==e||typeof n.text!="string"?null:(window.sessionStorage.removeItem(Nh),n.text)}catch{return null}}function kO(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),s.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function SO(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[s.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function NO({items:e,disabled:t}){const[n,r]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!n)return;const o=a=>{i.current&&!i.current.contains(a.target)&&r(!1)},l=a=>{a.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",o),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("keydown",l)}},[n]),s.jsxs("div",{className:"wb-head-menu",ref:i,children:[s.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":"More about this agent","aria-haspopup":"menu","aria-expanded":n,"data-open":n?"true":void 0,disabled:t,onClick:()=>r(o=>!o),children:s.jsx(SO,{})}),n?s.jsx("div",{className:"ui-menu wb-head-menu-list",role:"menu",children:e.map(o=>o.href?s.jsxs("a",{className:"ui-menu-item",role:"menuitem",href:o.href,onClick:()=>r(!1),children:[s.jsx("span",{className:"ui-menu-item-text",children:o.label}),o.hint?s.jsx("span",{className:"ui-menu-item-hint",children:o.hint}):null]},o.label):s.jsxs("button",{className:"ui-menu-item",role:"menuitem","data-testid":o.testId,disabled:o.disabled,onClick:()=>{var l;r(!1),(l=o.onSelect)==null||l.call(o)},children:[s.jsx("span",{className:"ui-menu-item-text",children:o.label}),o.hint?s.jsx("span",{className:"ui-menu-item-hint",children:o.hint}):null]},o.label))}):null]})}function CO(e,t){const n=o=>{var l;return`@${((l=t.find(a=>a.id===o))==null?void 0:l.handle)??o}`},[r,...i]=e;return r===void 0?"":[n(r),...i.map(o=>`asked by ${n(o)}`)].join(", ")}const Ck=3;function EO(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function AO(e){return e.state==="shown"&&e.seenAt===null}function TO(e){const[t,n]=d.useState([]),r=d.useRef(new Set),i=d.useRef(new Set),o=d.useCallback(()=>{e&&A.notifications(20).then(({notifications:a})=>{const c=a.filter(u=>AO(u)&&!r.current.has(u.id));n(u=>{const p=new Set(u.map(h=>h.id)),f=c.filter(h=>!p.has(h.id));return f.length===0?u:[...u,...f].sort((h,v)=>v.createdAt.localeCompare(h.createdAt))})}).catch(()=>{})},[e]);d.useEffect(()=>{for(const a of t.slice(0,Ck))i.current.has(a.id)||(i.current.add(a.id),A.notificationSeen(a.id).catch(()=>{}))},[t]);const l=d.useCallback(a=>{r.current.add(a),n(c=>c.filter(u=>u.id!==a))},[]);return{queue:t,refresh:o,dismiss:l}}function RO({queue:e,agents:t,navigate:n,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,Ck),o=e.length-i.length;return s.jsxs("section",{className:"nt-toasts","aria-label":"Notifications",children:[i.map(l=>s.jsxs("div",{className:"ui-toast nt-toast","data-tone":EO(l.kind),role:"status",children:[l.agentId?s.jsx(Zt,{agents:t,id:l.agentId,size:"sm"}):null,s.jsxs("div",{className:"nt-toast-main",children:[s.jsx("div",{className:"ui-toast-title",children:l.title}),l.text?s.jsx("div",{className:"ui-toast-body nt-toast-line",children:PO(l.text)}):null,l.link?s.jsx("a",{className:"nt-toast-link",href:l.link,onClick:a=>{a.preventDefault(),r(l.id),n(l.link)},children:"See"}):null]}),s.jsx("button",{type:"button",className:"nt-toast-x","aria-label":`Dismiss ${l.title}`,onClick:()=>r(l.id),children:"×"})]},l.id)),o>0?s.jsxs("p",{className:"nt-toasts-more",children:["and ",o," more"]}):null]})}function PO(e){var t;return((t=e.split(`
103
- `).find(n=>n.trim()!==""))==null?void 0:t.trim())??""}const IO=3e4,MO=1e3;function $O(e,t,n){const r=d.useRef(t);r.current=t;const i=d.useRef(n);i.current=n,d.useEffect(()=>{if(!e)return;let o=!1,l=-1/0,a=null,c=null,u=!0;const p=()=>document.visibilityState!=="hidden",f=x=>{var g;l=Date.now(),A.presence(x).catch(y=>{var m;y instanceof le&&y.status===401&&(o=!0,(m=i.current)==null||m.call(i))}),x==="active"&&((g=r.current)==null||g.call(r))},h=x=>{if(o||(a=x,c!==null))return;const g=l+MO-Date.now();if(g<=0){a=null,f(x);return}c=window.setTimeout(()=>{if(c=null,o||a===null)return;const y=a;a=null,f(y)},g)},v=()=>{u=!0,p()&&h("active")},j=()=>{u=!1,h("away")},w=()=>h(p()?"active":"away");p()&&h("active");const b=window.setInterval(()=>{p()&&u&&h("active")},IO);return window.addEventListener("focus",v),window.addEventListener("blur",j),document.addEventListener("visibilitychange",w),()=>{o=!0,window.clearInterval(b),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",v),window.removeEventListener("blur",j),document.removeEventListener("visibilitychange",w)}},[e])}function Vv({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:o}){return!t&&!z0(e)?s.jsx(qt,{title:"A new group",onClose:n,children:s.jsxs(H,{children:["A group needs two agents. Make another one with ",JI(e)," first."]})}):s.jsx(OO,{agents:_O(e,t),group:t??null,onClose:n,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...o?{onArchived:o}:{}})}function _O(e,t){const n=U0(e),r=((t==null?void 0:t.members)??[]).filter(i=>!n.some(o=>o.id===i)).map(i=>e.find(o=>o.id===i)).filter(i=>i!==void 0);return[...n,...r]}function OO({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:o}){var C,P;const l=t!==null,[a,c]=d.useState((t==null?void 0:t.name)??""),[u,p]=d.useState((t==null?void 0:t.members)??[]),[f,h]=d.useState((t==null?void 0:t.coordinator)??((C=e.find(E=>E.roles.includes(xm)))==null?void 0:C.id)??((P=e[0])==null?void 0:P.id)??""),[v,j]=d.useState(!1),[w,b]=d.useState(!1),[x,g]=d.useState(null),y=[...new Set([f,...u])].filter(Boolean),m=a.trim()!==""&&f!==""&&y.length>=2,S=E=>p(O=>O.includes(E)?O.filter(F=>F!==E):[...O,E]),k=async()=>{j(!0),g(null);try{t?i==null||i(await ze.updateGroup(t.id,{name:a.trim(),coordinator:f,members:y})):r==null||r(await ze.createGroup({name:a.trim(),coordinator:f,members:y.filter(E=>E!==f)}))}catch(E){g(E instanceof le?E.message:String(E))}finally{j(!1)}},N=async()=>{if(t){j(!0),g(null);try{await ze.archiveGroup(t.id),o==null||o(t.id)}catch(E){g(E instanceof le?E.message:String(E)),j(!1)}}};return s.jsx(qt,{title:l?`${t.name}: members`:"A new group",onClose:n,children:s.jsxs(K,{children:[s.jsx(X,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:s.jsx("input",{value:a,autoFocus:!0,maxLength:80,onChange:E=>c(E.target.value),placeholder:"Household finances"})}),s.jsx(X,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:s.jsx("select",{value:f,onChange:E=>h(E.target.value),children:e.map(E=>s.jsx("option",{value:E.id,children:E.name},E.id))})}),s.jsx(X,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:s.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(E=>E.id!==f).map(E=>s.jsxs("label",{className:"group-pick-row","data-on":u.includes(E.id)||void 0,children:[s.jsx("input",{type:"checkbox",checked:u.includes(E.id),onChange:()=>S(E.id)}),s.jsx(Zt,{agents:e,id:E.id,size:"sm"}),s.jsxs("span",{className:"group-pick-text",children:[s.jsx("span",{className:"group-pick-name",children:E.name}),s.jsx("span",{className:"group-pick-desc",children:E.description})]})]},E.id))})}),s.jsx(H,{children:"Members read what is said in this group and what they recall from shared and group memory. Nothing an agent knows privately is brought in on its own: what enters the room is seen by the room."}),l?s.jsx(H,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,x?s.jsx(H,{tone:"critical",children:x}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:n,children:"Cancel"}),s.jsx(R,{variant:"accent",disabled:!m||v,onClick:()=>void k(),children:v?l?"Saving…":"Creating…":l?"Save":"Create group"})]}),l?s.jsx("div",{className:"group-archive",children:w?s.jsxs(K,{children:[s.jsxs(H,{tone:"warning",children:["Archive ",t.name,"? It leaves the rail and takes no new requests. Everything said in it stays readable."]}),s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:()=>b(!1),children:"Keep it"}),s.jsx(R,{variant:"danger",disabled:v,"data-testid":"group-archive-confirm",onClick:()=>void N(),children:"Archive group"})]})]}):s.jsx(R,{variant:"ghost",disabled:v,"data-testid":"group-archive",onClick:()=>b(!0),children:"Archive group"})}):null]})})}function $m(e){const[t,n]=d.useState(null),[r,i]=d.useState(null),[o,l]=d.useState(null);return{busy:t,note:r,failure:o,decide:async(c,u,p,f)=>{var v,j,w,b;n(c),l(null),i(null);let h;try{const x=f?await A.decide(c,u,p,f):await A.decide(c,u,p);h={decision:u,...(v=x.execution)!=null&&v.state?{state:x.execution.state}:{},...x.execution&&"result"in x.execution?{result:x.execution.result}:{}},i(u==="reject"?`Rejected ${x.action.tool}.`:((j=x.execution)==null?void 0:j.state)==="succeeded"?`Approved and done: ${x.action.tool}.`:`Approved ${x.action.tool}: ${((w=x.execution)==null?void 0:w.state)??"no execution"}${(b=x.execution)!=null&&b.message?` (${x.execution.message})`:""}`)}catch(x){l(x instanceof Error?x.message:String(x))}finally{n(null),e(h)}}}}function _m({action:e,timezone:t,busy:n,onDecide:r,agentName:i}){var p,f;const[o,l]=d.useState(!1),{values:a,controls:c}=Sm(e.choices),u=h=>a?r(e.id,"approve",h,a):r(e.id,"approve",h);return s.jsxs(Ur,{tone:"accent",title:e.tool,meta:s.jsxs(s.Fragment,{children:[s.jsxs(pe,{children:["v",e.toolVersion]}),s.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[s.jsx(ft,{children:e.preview}),s.jsxs("p",{className:"ui-card-meta",children:["Expires ",Ie(e.expiresAt,t)," (",ke(e.expiresAt),"). Policy v",e.policyVersion,", args ",ul(e.argsHash,12),e.jobId?`, job ${ul(e.jobId)}`:"","."]}),c,s.jsxs(q,{children:[s.jsx(R,{variant:"good",disabled:n,onClick:()=>u(),children:(p=e.permissionScopes)!=null&&p.length?"Allow once":"Approve"}),(f=e.permissionScopes)!=null&&f.length?s.jsxs(s.Fragment,{children:[s.jsx(R,{disabled:n,onClick:()=>u("conversation"),children:"Auto: this conversation"}),s.jsx(R,{disabled:n,onClick:()=>u("always"),children:"Always: this agent"})]}):null,s.jsx(R,{variant:"danger",disabled:n,onClick:()=>r(e.id,"reject"),children:"Reject"}),s.jsx(R,{variant:"ghost",onClick:()=>l(h=>!h),"aria-expanded":o,children:o?"Hide envelope":"Show envelope"})]}),o?s.jsxs("div",{className:"ui-card-foot",children:[s.jsx(G,{title:"Envelope: everything that decides what the world will see",children:s.jsx(ft,{children:on(e.envelope)})}),s.jsx(G,{title:"Canonical arguments",children:s.jsx(ft,{children:on(e.canonicalArgs)})})]}):null]})}function Ek(e,t,n){const[r,i]=d.useState(!1),[o,l]=d.useState(null),[a,c]=d.useState(null);return{accept:()=>{e&&(i(!0),c(null),A.acceptPluginAgent(e,t).then(p=>{l(p.agent)}).catch(p=>c(p instanceof le?p.message:String(p))).finally(()=>i(!1)))},busy:r,created:o,failure:a}}function Ak({agent:e}){return s.jsxs(H,{tone:"good",role:"status",children:["@",e.handle," is ready. ",s.jsxs("a",{href:Be(e.id),children:["Talk to @",e.handle]})]})}function Tk(e,t,n){const r=e.canonicalArgs;return e.tool==="platform.accept_plugin_agent"&&(r==null?void 0:r.plugin)===t&&typeof r.agent=="string"&&r.agent.toLowerCase()===n.toLowerCase()}function DO(e,t){var i;const n=se(()=>A.approvals(),[e,t],15e3);return{action:((i=n.data)==null?void 0:i.pending.find(o=>Tk(o,e,t)))??null,reload:n.reload}}function LO({action:e,onDecided:t}){const{busy:n,failure:r,decide:i}=$m(o=>t(o));return s.jsxs(K,{gap:"sm",children:[s.jsx(_m,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:n===e.id,onDecide:(o,l,a,c)=>{i(o,l,a,c)}}),s.jsx(re,{message:r})]})}function Om({plugin:e,agent:t,text:n,label:r,handle:i,onDismiss:o}){var f;const l=Ek(e,t),a=DO(e,t),[c,u]=d.useState(null),p=l.created??c;if(p)return s.jsx(Ak,{agent:p});if(a.action){const h=i??((f=/@(\S+)/.exec(r))==null?void 0:f[1])??t;return s.jsxs(K,{gap:"sm",children:[s.jsx("span",{children:n}),s.jsx(LO,{action:a.action,onDecided:v=>{(v==null?void 0:v.decision)==="approve"&&v.state==="succeeded"?u({id:t,handle:h,name:h}):a.reload()}})]})}return s.jsxs(K,{gap:"sm",children:[s.jsxs(q,{children:[s.jsx("span",{children:n}),s.jsx(io,{}),o?s.jsx(R,{variant:"ghost",disabled:l.busy,onClick:o,children:"Not now"}):null,s.jsx(R,{variant:"accent",disabled:l.busy,onClick:l.accept,children:r})]}),s.jsx(re,{message:l.failure})]})}function Rk(){var t;const e=se(()=>A.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function Pk({offers:e,reload:t}){return e.length===0?null:s.jsx(G,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:s.jsx(K,{gap:"sm",divided:!0,children:e.map(n=>s.jsx(Om,{plugin:n.plugin,agent:n.agent,text:n.text,label:`Create @${n.handle}`,handle:n.handle,onDismiss:()=>{A.dismissAgentOffer(n.plugin,n.agent).then(t,t)}},`${n.plugin}/${n.agent}`))})})}const Dm=d.createContext(null),_c=d.createContext(!1);function Nt(){const e=d.useContext(Dm);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function Ch(e,t=new Set){if(Array.isArray(e))for(const n of e)Ch(n,t);else if(e&&typeof e=="object"){const n=e.query;typeof n=="string"&&t.add(n);for(const r of Object.values(e))Ch(r,t)}return t}function Ik(e,t){if(t.size===0)return!1;for(const n of Ch(e))if(t.has(n))return!0;return!1}function Mk(){const[e,t]=d.useState(!1);return d.useEffect(()=>{if(!e)return;const n=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",n),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",n),window.removeEventListener("blur",n)}},[e]),[e,()=>t(n=>!n)]}function $k({revealed:e,onToggle:t}){return s.jsx(R,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function _k(){return s.jsx("p",{className:"muted",children:"Hidden until you show it."})}function Ok({children:e}){const[t,n]=Mk();return s.jsxs(K,{gap:"sm",children:[s.jsx(q,{align:"end",children:s.jsx($k,{revealed:t,onToggle:n})}),t?s.jsx(_c.Provider,{value:!0,children:e}):s.jsx(_k,{})]})}function Lm(e){return e===void 0||e==="neutral"?void 0:e}function Eh(e){return Lm(e)}function FO(e){const t=Lm(e);return t==="accent"?void 0:t}function rs(e,t){if(!t)return!0;const n=me(e,t.path),r=t.in!==void 0?t.in.includes(n):n===t.equals;return t.not===!0?!r:r}function Fm(e,t,n){if("chat"in t){const o=be(n,t.chat);return o==null?"":Be(String(o))}if("proposals"in t)return RI(e.plugin);const r=e.pages.find(o=>o.id===t.page);if((r==null?void 0:r.place)==="settings")return gm(e.plugin,t.page);const i=t.item===void 0?null:be(n,t.item);return dl(e.plugin,t.page,i==null?null:String(i))}function UO(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(n,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(n,r)=>{const i=me(t.row,r);return i==null?"":String(i)})}function Ah(e,t){if(e===void 0)return;if(typeof e=="string")return e;const n=be(t,e);return n==="good"||n==="warning"||n==="critical"||n==="neutral"?n:void 0}function Dk(e,t,n){const r={};for(const[i,o]of Object.entries(e??{})){let l;"param"in o?l=n.params[o.param]:"route"in o?l=o.route==="plugin"?n.plugin:o.route==="page"?n.page:n.item:l=be(t,o),!(l==null||l==="")&&(r[i]=String(l))}return r}function Bi(e,t){var r,i,o;const n={};for(const[l,a]of Object.entries(e??{}))if("row"in a)n[l]=me(t.row,a.row);else if("field"in a){if((r=t.omit)!=null&&r.has(a.field))continue;const c=(i=t.fields)==null?void 0:i[a.field],u=(o=t.shape)==null?void 0:o.find(p=>p.name===a.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;n[l]=c}else"selected"in a?n[l]=t.selected??[]:"param"in a?n[l]=t.scope.params[a.param]:n[l]=be(t.data,a);return n}function ds(e,t){const n=Nt(),r=e?Dk(e.params,t,n):{},i=JSON.stringify([(e==null?void 0:e.query)??null,r,n.version]),o=se(()=>e?A.pageQuery(n.plugin,e.query,r).then(l=>l.data):Promise.resolve(void 0),[i]);return{data:o.data,error:o.error,loading:o.loading}}function Al(){const e=Nt(),[t,n]=d.useState(null),[r,i]=d.useState(null),[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(null),f=(w,b)=>{if(w.done===void 0)return null;if(typeof w.done=="string")return w.done;const x=be(b,w.done);return x==null?null:String(x)},h=(w,b,x)=>{const g=w??"refresh";if(typeof g=="object"){const y=Fm(e,g.route,b);y===""?e.refresh():e.navigate(y);return}g==="close"&&(x==null||x()),e.refresh()},v=async(w,b,x)=>{n(w.tool),i(null),l(null);try{const g=await A.pageAct(e.plugin,{tool:w.tool,args:b});if(g.approvalId){c(g.approvalId),p({then:w.then,ref:w,...x?{onDone:x}:{}});return}c(null),p(null),l(f(w,g.result)),h(w.then,g.result,x)}catch(g){i(g instanceof Error?g.message:String(g)),e.refresh()}finally{n(null)}},j=w=>{if(!w){e.refresh();return}const b=u;if(c(null),p(null),b&&w.decision==="approve"&&w.state==="succeeded"){l(f(b.ref,w.result)),h(b.then,void 0,b.onDone);return}e.refresh()};return{running:t,busy:t!==null,error:r,done:o,approvalId:a,waiting:(u==null?void 0:u.ref.pending)??null,settle:j,run:v}}function Wi({action:e,args:t,disabled:n,running:r,count:i,row:o,onRun:l}){const[a,c]=d.useState(!1),u=f=>UO(f,{...i===void 0?{}:{count:i},row:o}),p=u(e.label);return a&&e.confirm?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),s.jsx(R,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsxs(R,{variant:e.tone==="danger"?"danger":"accent",disabled:n,onClick:()=>{c(!1),l(e,t)},children:["Yes, ",p.toLowerCase()]})]}):s.jsx(R,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:n,onClick:()=>e.confirm?c(!0):l(e,t),children:r&&e.busy?e.busy:p})}function Th({id:e,onDecided:t}){const n=Nt(),r=se(()=>A.approval(e),[e,n.version]),{busy:i,note:o,failure:l,decide:a}=$m(c=>{t?t(c):n.refresh()});return r.error?s.jsx(re,{message:r.error}):r.data?s.jsxs(K,{children:[s.jsx(_m,{action:r.data,timezone:n.timezone,busy:i===e,onDecide:(c,u,p,f)=>{a(c,u,p,f)}}),o?s.jsx(H,{tone:"good",role:"status",children:o}):null,s.jsx(re,{message:l})]}):s.jsx(ie,{children:"Loading the approval…"})}function lo({act:e}){return e.error?s.jsx(re,{message:e.error}):e.approvalId?e.waiting?s.jsxs(K,{children:[s.jsx(H,{role:"status",children:e.waiting}),s.jsx(Th,{id:e.approvalId,onDecided:e.settle})]}):s.jsx(Th,{id:e.approvalId,onDecided:e.settle}):e.done?s.jsx(H,{tone:"good",role:"status",children:e.done}):null}function Oc(e,t){const n={};for(const r of e){const i=r.from===void 0?void 0:me(t,r.from);n[r.name]=i!==void 0?i:r.type==="checkbox"?!1:(r.type==="number","")}return n}function zO(e,t,n){const r=Nt(),i=e.optionsFrom,o=i?{...Dk(i.query.params,n,r),...Object.fromEntries((i.dependsOn??[]).map(c=>[c,String(t[c]??"")]).filter(([,c])=>c!==""))}:{},l=JSON.stringify([(i==null?void 0:i.query.query)??null,o,r.version]),a=se(()=>i?A.pageQuery(r.plugin,i.query.query,o).then(c=>c.data):Promise.resolve(void 0),[l]);return i?{options:Hi(a.data,i.rows).map(c=>({value:String(me(c,i.value)??""),label:String(me(c,i.label)??"")})),loading:a.loading}:{options:e.options??[],loading:!1}}function BO({field:e,value:t,values:n,data:r,disabled:i,compact:o,onChange:l}){const a=zO(e,n,r),c={id:`f-${e.name}`,required:e.required,name:e.name,disabled:i,...o&&e.hint?{title:e.hint}:{}},u=o?void 0:e.hint;if(e.type==="select")return s.jsx(X,{label:e.label,hint:u,children:s.jsxs("select",{...c,value:String(t??""),onChange:f=>l(f.target.value),children:[s.jsx("option",{value:"",children:a.loading?"Loading…":"—"}),a.options.map(f=>s.jsx("option",{value:f.value,children:f.label},f.value))]})});if(e.type==="textarea")return s.jsx(X,{label:e.label,hint:u,wide:!0,children:s.jsx("textarea",{...c,value:String(t??""),onChange:f=>l(f.target.value),rows:6})});if(e.type==="checkbox")return s.jsx(X,{label:e.label,hint:u,inline:!0,wide:!o,children:s.jsx("input",{...c,type:"checkbox",checked:t===!0,onChange:f=>l(f.target.checked)})});const p=e.type==="secret"?"password":e.type==="number"?"number":e.type;return s.jsx(X,{label:e.label,hint:u,children:s.jsx("input",{...c,type:p,value:t==null?"":String(t),min:e.min,max:e.max,step:e.step,...o&&e.hint?{placeholder:e.hint}:{},onChange:f=>l(e.type==="number"?WO(f.target.value):f.target.value)})})}function WO(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function Lk(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function Fk(e,t,n){const r=Lk(t,n);return new Set(e.filter(i=>i.when!==void 0&&!rs(r,i.when)||i.disabledWhen!==void 0&&rs(r,i.disabledWhen)).map(i=>i.name))}function Um({fields:e,values:t,data:n,disabled:r,compact:i,onChange:o}){const l=Lk(t,n);return s.jsx(Ps,{dense:i,children:e.filter(a=>a.when===void 0||rs(l,a.when)).map(a=>s.jsx(BO,{field:a,compact:i,value:t[a.name],values:t,data:n,disabled:r===!0||a.disabledWhen!==void 0&&rs(l,a.disabledWhen),onChange:c=>o(a.name,c)},a.name))})}const ml=d.createContext(!1),Uk=d.createContext(!1),zk=d.createContext(!1);function Os({title:e,note:t,actions:n,children:r}){const i=d.useContext(ml);return s.jsx(G,{title:e,aside:t,actions:n,panel:i,children:s.jsx(ml.Provider,{value:!1,children:s.jsx(Uk.Provider,{value:i,children:r})})})}function Is({component:e,data:t,choose:n,chosen:r}){const i=Nt(),o=d.useContext(_c);if(!rs(t,e.when))return null;if(e.kind!=="section"&&!o&&Ik(e,i.sensitive))return s.jsx(Ok,{children:s.jsx(Is,{component:e,data:t,...n?{choose:n}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return s.jsx(HO,{component:e,data:t});case"notice":return s.jsx(H,{tone:Lm(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(be(t,e.text)??"")});case"link":return s.jsx(VO,{component:e,data:t});case"stats":return s.jsx(KO,{component:e,data:t});case"list":return s.jsx(YO,{component:e,data:t,...n?{onChoose:n}:{},...r===void 0?{}:{chosen:r}});case"table":return s.jsx(qO,{component:e,data:t});case"detail":return s.jsx(XO,{component:e,data:t});case"form":return s.jsx(ZO,{component:e,data:t});case"search":return s.jsx(nD,{component:e,data:t});case"list-detail":return s.jsx(sD,{component:e,data:t});case"repeat":return s.jsx(rD,{component:e,data:t});case"expand":return s.jsx(iD,{component:e,data:t});case"button":return s.jsx(oD,{component:e,data:t});case"approval":return s.jsx(aD,{component:e,data:t});case"artifact":return s.jsx(cD,{component:e,data:t});case"editor":return s.jsx(uD,{component:e,data:t});case"agent-offer":return s.jsx(lD,{component:e});default:return null}}function HO({component:e,data:t}){const n=Nt(),r=d.useContext(_c),[i,o]=Mk(),l=!r&&Ik(e.body,n.sensitive),a=l&&!i,c=d.useContext(ml);let u=e.body.length;const p=v=>v.kind==="button"||v.kind==="link"||v.kind==="form"&&v.drawer!==void 0&&!v.title;for(;c&&u>0&&p(e.body[u-1]);)u-=1;const f=e.body.slice(0,u),h=[...e.actions??[],...e.body.slice(u)];return s.jsx(Os,{title:e.title,note:e.note,actions:h.length>0||l?s.jsxs(s.Fragment,{children:[h.map((v,j)=>s.jsx(Is,{component:v,data:t},j)),l?s.jsx($k,{revealed:i,onToggle:o}):null]}):void 0,children:s.jsx(K,{gap:"lg",divided:c,children:a?s.jsx(_k,{}):s.jsx(_c.Provider,{value:r||l,children:f.map((v,j)=>s.jsx(Is,{component:v,data:t},j))})})})}function VO({component:e,data:t}){const n=Nt(),r=Fm(n,e.to,t);return r===""?null:s.jsx(q,{children:s.jsx(ln,{href:r,onClick:i=>{i.preventDefault(),n.navigate(r)},children:e.label})})}function KO({component:e,data:t}){const n=ds(e.query,t);return s.jsxs(Os,{title:e.title,note:e.note,children:[s.jsx(re,{message:n.error}),n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsx(vu,{children:e.items.map((r,i)=>s.jsx(es,{label:r.label,value:bt(be(n.data,r.value),r.unit??"text",null),tone:FO(r.tone)},i))})]})}function Bk(e,t,n,r){const i=(t.meta??[]).map(u=>String(be(n,u)??"")).filter(u=>u!==""),o=String(be(n,t.title)??""),l=t.to&&!r?Fm(e,t.to,n):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,p)=>{const f=be(n,u.value);if(f==null||f==="")return null;const h=GO(u,f,n);return s.jsx(pe,{tone:Eh(h.tone),children:h.text},p)});return{text:o,href:l,pills:s.jsx(s.Fragment,{children:c}),meta:i.join(" · "),title:l?s.jsx("a",{href:l,onClick:u=>{u.preventDefault(),e.navigate(l)},children:o}):o,sub:t.sub?String(be(n,t.sub)??""):null,side:s.jsxs(s.Fragment,{children:[c,i.length>0?s.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function GO(e,t,n){const r=String(t),i=e.labels??{},o=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(o,r)?o[r]:Ah(e.tone,n)}}function Hi(e,t){const n=me(e,t);return Array.isArray(n)?n:[]}function Wk(e,t,n){const r=[],i=new Set;return e.forEach((o,l)=>{const a=t===void 0?void 0:me(o,t),c=a==null||a===""?null:String(a);if(c===null){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: row ${l} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:o})}),r}function YO({component:e,data:t,onChoose:n,chosen:r}){var S;const i=Nt(),o=d.useContext(zk),l=ds(e.query,t),a=Al(),[c,u]=d.useState([]),p=o&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,f=Hi(l.data,e.rows),h=e.collapsed?Hi(l.data,e.collapsed.rows):[],v={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},j=Wk([...f,...h],e.key??((S=e.select)==null?void 0:S.key),v),w=new Map(j.map(k=>[k.row,k.key])),b=new Set(j.map(k=>k.row)),x=new Set(j.filter(({row:k})=>{var N;return((N=e.select)==null?void 0:N.disabledWhen)===void 0||!rs(k,e.select.disabledWhen)}).map(({key:k})=>k)),g=c.filter(k=>x.has(k)),y=d.useMemo(()=>{const k=f.filter(C=>b.has(C));if(!e.groupBy)return[{label:null,rows:k}];const N=new Map;for(const C of k){const P=String(me(C,e.groupBy.key)??"");N.set(P,[...N.get(P)??[],C])}return[...N].map(([C,P])=>{var E,O;return{label:((O=(E=e.groupBy)==null?void 0:E.labels)==null?void 0:O[C])??C,rows:P}})},[f,e.groupBy,j.length]),m=k=>k.map(N=>{var F;const C=Bk(i,e.item,N,n),P=w.get(N);if(p&&(n||C.href))return s.jsx(tk,{href:C.href??"#",current:r===P,onClick:()=>n?n(P):i.navigate(C.href),title:C.text,meta:C.meta,sub:C.sub,side:C.pills},P);const E=((F=e.select)==null?void 0:F.disabledWhen)!==void 0&&rs(N,e.select.disabledWhen),O=(e.actions??[]).filter(D=>rs(N,D.when));return s.jsx(Kt,{lead:e.select?s.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(P),onClick:D=>D.stopPropagation(),onChange:D=>u(T=>D.target.checked?[...T,P]:T.filter(z=>z!==P))}):void 0,title:n?s.jsx("a",{href:"#","aria-current":r===P?"true":void 0,onClick:D=>{D.preventDefault(),n(P)},children:C.text}):C.title,sub:C.sub,side:s.jsxs(s.Fragment,{children:[C.side,O.map((D,T)=>s.jsx(Wi,{action:D,args:Bi(D.args,{data:l.data,row:N,scope:i}),disabled:a.busy,running:a.running===D.tool,row:N,onRun:(z,Q)=>void a.run(z,Q)},T))]})},P)});return s.jsxs(Os,{title:e.title,note:e.note,children:[s.jsx(re,{message:l.error}),s.jsx(lo,{act:a}),y.every(k=>k.rows.length===0)?l.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(zm,{text:e.empty??"Nothing here yet."}):s.jsxs(Ft,{children:[e.select?s.jsx(Kt,{lead:s.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:x.size>0&&g.length===x.size,disabled:x.size===0,onChange:k=>u(k.target.checked?[...x]:[])}),title:s.jsxs("span",{className:"muted",children:[x.size," to choose from"]})}):null,y.map((k,N)=>s.jsxs("div",{children:[k.label?s.jsx("div",{className:"ui-list-group",children:k.label}):null,m(k.rows)]},N))]}),e.collapsed&&h.some(k=>b.has(k))?s.jsx(St,{summary:`${e.collapsed.label} (${h.filter(k=>b.has(k)).length})`,children:s.jsx(Ft,{children:m(h.filter(k=>b.has(k)))})}):null,e.bulk&&e.bulk.length>0?s.jsxs(q,{align:"end",children:[s.jsxs("span",{className:"ui-toolbar-note",children:[g.length," selected"]}),e.bulk.map((k,N)=>{const C=g.length>0||k.all!==!0?g:[...x];return s.jsx(Wi,{action:k,args:Bi(k.args,{data:l.data,selected:C,scope:i}),count:C.length,disabled:a.busy||C.length===0,running:a.running===k.tool,onRun:(P,E)=>{u([]),a.run(P,E)}},N)})]}):null]})}function qO({component:e,data:t}){const n=Nt(),r=ds(e.query,t),i=Al(),o=Hi(r.data,e.rows);return s.jsxs(Os,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),s.jsx(lo,{act:i}),o.length===0?r.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(zm,{text:e.empty??"Nothing here yet."}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[e.columns.map(l=>s.jsx("th",{children:l.label},l.key)),e.actions&&e.actions.length>0?s.jsx("th",{"aria-label":"Actions"}):null]})}),s.jsx("tbody",{children:o.map((l,a)=>s.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:bt(me(l,c.key),c.type??"text",null);return s.jsx("td",{"data-fit":c.fit,title:QO(c,l,u),children:c.pill?s.jsx(JO,{column:c,row:l}):c.fit==="truncate"?s.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?s.jsx("td",{children:s.jsx(q,{align:"end",children:e.actions.filter(c=>rs(l,c.when)).map((c,u)=>s.jsx(Wi,{action:c,args:Bi(c.args,{data:r.data,row:l,scope:n}),disabled:i.busy,running:i.running===c.tool,row:l,onRun:(p,f)=>void i.run(p,f)},u))})}):null]},a))})]})]})}function QO(e,t,n){if(e.hint){const r=me(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&n?n:void 0}function JO({column:e,row:t}){var l,a;const n=me(t,e.key);if(Array.isArray(n))return s.jsx(s.Fragment,{children:n.map((c,u)=>{var w;const p=c,f=typeof p=="object"&&p!==null?p.value:c;if(f==null||f==="")return null;const h=typeof p=="object"&&p!==null?p.tone:void 0,v=(w=e.pill)==null?void 0:w.labels,j=v&&Object.prototype.hasOwnProperty.call(v,String(f))?v[String(f)]:bt(f,e.type??"text",null);return s.jsx(pe,{tone:Eh(Ah(typeof h=="string"?h:void 0,t)),children:j},u)})});const r=(l=e.pill)==null?void 0:l.labels,i=String(n),o=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:bt(n,e.type??"text",null);return s.jsx(pe,{tone:Eh(Ah((a=e.pill)==null?void 0:a.tone,t)),children:o})}function XO({component:e,data:t}){const n=ds(e.query,t);return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsx(Os,{title:e.title,note:e.note,children:s.jsxs(K,{gap:"lg",children:[e.fields.length>0?s.jsx(Tt,{items:e.fields.map(r=>({key:r.label,label:r.label,value:bt(be(n.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>s.jsx(Is,{component:r,data:n.data},i))]})})}function ZO({component:e,data:t}){const n=Nt(),r=ds(e.initial,t),i=Al(),[o,l]=d.useState(!1),a=JSON.stringify([r.data??null,n.version]),c=s.jsx(eD,{component:e,data:t,initialData:r.data,act:i,onDone:()=>l(!1)},a);return e.drawer?s.jsxs(G,{title:e.title,aside:e.note,actions:s.jsx(R,{variant:"accent",onClick:()=>l(!0),children:e.drawer.button}),children:[s.jsx(lo,{act:i}),o?s.jsx(qt,{title:e.drawer.title,onClose:()=>l(!1),children:c}):null]}):s.jsxs(Os,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),c]})}function eD({component:e,data:t,initialData:n,act:r,onDone:i}){const o=d.useContext(Uk),l=Nt(),[a,c]=d.useState(()=>Oc(e.fields,n)),u=Fk(e.fields,a,n),p=e.fields.some(f=>f.required&&!u.has(f.name)&&(a[f.name]===""||a[f.name]===void 0));return s.jsxs(K,{children:[s.jsx(Um,{fields:e.fields,values:a,data:n,onChange:(f,h)=>c(v=>({...v,[f]:h}))}),e.drawer?null:s.jsx(lo,{act:r}),s.jsx(q,{align:"end",className:o?"ui-panel-foot":void 0,children:s.jsx(Wi,{action:e.submit,args:Bi(e.submit.args,{data:t,fields:a,shape:e.fields,omit:u,scope:l}),disabled:r.busy||p,running:r.running===e.submit.tool,onRun:(f,h)=>void r.run(f,h,i)})})]})}function tD(e,t){var r;if(e.type==="checkbox")return e.label;const n=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${n?n.label:t}`}function Kv(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function nD({component:e,data:t}){const n=Nt(),[r,i]=d.useState(()=>Oc(e.fields,t)),[o,l]=d.useState(e.auto===!0),[a,c]=d.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),p=ds(o&&u?e.query:void 0,t),f=Hi(p.data,e.rows),h=e.count===void 0?void 0:me(p.data,e.count),v=e.note===void 0?void 0:me(p.data,e.note),j=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==j),b=C=>{n.setParams(Object.fromEntries(e.fields.map(P=>[P.name,String(C[P.name]??"")||null]))),l(!0)},x=(C,P)=>{const E={...r,[C]:P};i(E),e.auto&&b(E)},g=()=>{const C=Oc(e.fields,null);i(C),e.auto?b(C):(n.setParams(Object.fromEntries(e.fields.map(P=>[P.name,null]))),l(!1))},y=o?w.filter(C=>Kv(n.params[C.name])):[],m=j?y.map(C=>s.jsx(dh,{label:C.label,onRemove:()=>{const P={...r,[C.name]:C.type==="checkbox"?!1:""};i(P),b(P)},children:tD(C,String(n.params[C.name]))},C.name)):[],S=w.filter(C=>Kv(r[C.name])).length,k=e.auto&&!e.reset?null:s.jsxs(s.Fragment,{children:[e.reset?s.jsx(R,{variant:"ghost",onClick:g,children:"Clear"}):null,e.auto?null:s.jsx(R,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),N=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return s.jsx(Os,{title:e.title,children:s.jsxs(K,{children:[s.jsx(sk,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&b(r)},main:j?s.jsx("input",{id:`f-${j.name}`,name:j.name,type:j.type==="email"?"email":"search","aria-label":j.label,placeholder:j.hint??j.label,title:j.hint,required:j.required,value:String(r[j.name]??""),onChange:C=>x(j.name,C.target.value)}):void 0,filters:w.length>0?s.jsx(Um,{fields:w,values:r,data:t,compact:!0,onChange:x}):void 0,...j&&w.length>0?{filtersOpen:a,onToggleFilters:()=>c(C=>!C),active:S}:{},chips:m.length>0?m:void 0,actions:k}),s.jsx(re,{message:p.error}),o&&(h!==void 0||v!==void 0)?s.jsxs("p",{className:"ui-card-meta",children:[h===void 0?"":`${bt(h,"number",null)} in all. `,v===void 0?"":String(v)]}):null,o?f.length===0?s.jsx(ie,{children:p.loading?"Searching…":e.empty??"Nothing matches."}):s.jsx("div",{className:"ui-panel","data-flush":"true",children:s.jsx(Ft,{children:f.map((C,P)=>{const E=Bk(n,N,C);return s.jsx(Kt,{title:E.title,sub:E.sub,side:E.side},P)})})}):null]})})}function sD({component:e,data:t}){const n=Nt(),r=e.selection==="local",[i,o]=d.useState(null),l=r?i:n.params[e.param]??n.item,a=r&&i!==null?{...n,params:{...n.params,[e.param]:i}}:null,c=s.jsx(K,{gap:"lg",divided:!0,children:e.detail.map((u,p)=>s.jsx(Is,{component:u,data:t},p))});return s.jsx(ml.Provider,{value:!1,children:s.jsx(nk,{list:s.jsx(zk.Provider,{value:!0,children:s.jsx(Is,{component:e.list,data:t,chosen:l??null,...r?{choose:o}:{}})}),detail:l?a?s.jsx(Dm.Provider,{value:a,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function rD({component:e,data:t}){const n=Nt(),r=ds(e.query,t),i=Hi(r.data,e.rows);return s.jsxs(Os,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),i.length===0?r.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(zm,{text:e.empty??"Nothing here yet."}):s.jsx(K,{gap:"lg",divided:!0,children:Wk(i,e.key,{plugin:n.plugin,page:n.page,component:`repeat "${e.title??e.rows}"`}).map(({key:o,row:l})=>s.jsx(G,{children:s.jsx(K,{children:e.body.map((a,c)=>s.jsx(Is,{component:a,data:l},c))})},o))})]})}function iD({component:e,data:t}){const[n,r]=d.useState(!1),i=ds(n?e.query:void 0,t),o=typeof e.label=="string"?e.label:String(be(t,e.label)??"");return s.jsxs(St,{summary:o,boxed:!0,onToggle:l=>r(l),children:[s.jsx(re,{message:i.error}),i.data===void 0?s.jsx(ie,{children:"Loading…"}):s.jsx(K,{children:e.body.map((l,a)=>s.jsx(Is,{component:l,data:i.data},a))})]})}function oD({component:e,data:t}){const n=Nt(),r=Al();return s.jsxs(s.Fragment,{children:[s.jsx(q,{align:"end",children:s.jsx(Wi,{action:e.action,args:Bi(e.action.args,{data:t,row:t,scope:n}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,o)=>void r.run(i,o)})}),s.jsx(lo,{act:r})]})}function lD({component:e}){const t=Nt();return s.jsx(Om,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function aD({component:e,data:t}){const n=me(t,e.path);return typeof n!="string"||n===""?null:s.jsx(Th,{id:n})}function cD({component:e,data:t}){const n=me(t,e.path);return typeof n!="string"||n===""?null:s.jsx(q,{children:s.jsx("a",{href:El(n),children:e.label})})}function uD({component:e,data:t}){const n=ds(e.query,t),r=Al();return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsxs(s.Fragment,{children:[s.jsx(lo,{act:r}),s.jsx(dD,{component:e,data:t,loaded:n.data,act:r},JSON.stringify(n.data))]})}function dD({component:e,data:t,loaded:n,act:r}){const i=Nt(),[o,l]=d.useState(()=>Oc(e.fields,n)),a={...o,version:me(n,e.version)},c=Fk(e.fields,o,n),u=e.readOnlyWhen!==void 0&&rs(n,e.readOnlyWhen),p=(e.actions??[]).filter(v=>v.placement==="leading"),f=(e.actions??[]).filter(v=>v.placement!=="leading"),h=(v,j)=>s.jsx(Wi,{action:v,args:Bi(v.args,{data:t,fields:a,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===v.tool,onRun:(w,b)=>void r.run(w,b)},`${v.tool}-${j}`);return s.jsx(Os,{title:e.title,note:e.note,children:s.jsxs(K,{children:[s.jsx(Um,{fields:e.fields,values:o,data:n,disabled:u,onChange:(v,j)=>l(w=>({...w,[v]:j}))}),u?null:s.jsxs(q,{align:"end",children:[p.map(h),p.length>0?s.jsx(io,{}):null,h(e.save,-1),f.map(h)]}),e.footnote?s.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function Hk({page:e,item:t,navigate:n,timezone:r,embedded:i,siblings:o}){const[l,a]=d.useState({}),[c,u]=d.useState(0),p={plugin:e.plugin,page:e.id,pages:o??[e],item:t??null,params:{...l,...t?{item:t}:{},...hD(e,t)},setParams:j=>a(w=>{const b={...w};for(const[x,g]of Object.entries(j))g===null?delete b[x]:b[x]=g;return b}),navigate:n,timezone:r,version:c,refresh:()=>u(j=>j+1),sensitive:new Set(e.sensitive??[])},f=e.body[0],h=!i&&(f==null?void 0:f.kind)==="notice"&&typeof f.text=="string"&&f.when===void 0&&f.title===void 0&&(f.tone===void 0||f.tone==="neutral")?f.text:void 0,v=h===void 0?e:{...e,body:e.body.slice(1)};return s.jsx(Dm.Provider,{value:p,children:s.jsx(cn,{embedded:i,title:e.title,lede:h,children:s.jsx(fD,{page:v,boxed:i===!0})})})}function fD({page:e,boxed:t}){const n=Nt();return e.data&&n.sensitive.has(e.data.query)?s.jsx(Ok,{children:s.jsx(Gv,{page:e,boxed:t})}):s.jsx(Gv,{page:e,boxed:t})}function Gv({page:e,boxed:t}){const n=ds(e.data,null);return s.jsxs(K,{gap:"lg",divided:!t,children:[s.jsx(re,{message:n.error}),s.jsx(ml.Provider,{value:t,children:e.body.map((r,i)=>s.jsx(Is,{component:r,data:n.data??null},i))})]})}function hD(e,t){if(!t)return{};const n=[],r=i=>{for(const o of i)o.kind==="list-detail"?(n.push(o.param),r(o.detail)):(o.kind==="section"||o.kind==="detail"||o.kind==="expand")&&r(o.body)};return r(e.body),Object.fromEntries(n.map(i=>[i,t]))}function pD(e){return s.jsx(Hk,{...e,embedded:!0})}function zm({text:e}){const t=e.search(/[.!?]\s/),n=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return s.jsx(kt,{title:n,children:r||null})}function Yv(e,t){return(e??[]).filter(n=>n.place===t).map((n,r)=>({page:n,index:r})).sort((n,r)=>(n.page.order??0)-(r.page.order??0)||n.index-r.index).map(n=>n.page)}function Vk(e=!1){const[t,n]=d.useState([]);return d.useEffect(()=>{if(e)return;let r=!1;return Promise.resolve().then(()=>A.pages()).then(i=>{r||n(Array.isArray(i==null?void 0:i.pages)?i.pages:[])}).catch(()=>{}),()=>{r=!0}},[e]),{all:t,rail:Yv(t,"rail"),settings:Yv(t,"settings"),find:(r,i)=>t.find(o=>o.plugin===r&&o.id===i)}}const qv=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],mD=["","image","pdf","table","text","code","audio","video","archive","file"];function gD({hash:e,timezone:t,navigate:n,agents:r}){var D;const i=SI(e),o=(i==null?void 0:i.artifactId)??null,l=(i==null?void 0:i.filters.origin)??"",a=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,p]=d.useState(c);d.useEffect(()=>{p(c)},[c]);const f=(T,z=!1)=>n(da(o,{q:c,origin:l,family:a,...T}),z);d.useEffect(()=>{if(u===c)return;const T=window.setTimeout(()=>f({q:u},!0),250);return()=>window.clearTimeout(T)},[u]);const[h,v]=d.useState(null),[j,w]=d.useState(null),[b,x]=d.useState(null),[g,y]=d.useState(!1),[m,S]=d.useState(!1),k=T=>{var z;return T?((z=r.find(Q=>Q.id===T))==null?void 0:z.name)??T:""},N=d.useRef(0);d.useEffect(()=>{const T=++N.current;v(null),w(null),y(!1),x(null),A.library({...c?{q:c}:{},...l?{origin:l}:{},...a?{family:a}:{}}).then(z=>{N.current===T&&(v(z.entries),w(z.next))}).catch(z=>{N.current===T&&x(z instanceof le?z.message:String(z))})},[c,l,a]);const C=()=>{if(!j||g)return;y(!0);const T=N.current;A.library({...c?{q:c}:{},...l?{origin:l}:{},...a?{family:a}:{},cursor:j}).then(z=>{N.current===T&&(v(Q=>{const Y=new Set((Q??[]).map(M=>M.id));return[...Q??[],...z.entries.filter(M=>!Y.has(M.id))]}),w(z.next))}).catch(z=>{N.current===T&&x(z instanceof le?z.message:String(z))}).finally(()=>{N.current===T&&y(!1)})},P=(l?1:0)+(a?1:0),E=((D=qv.find(T=>T.id===l))==null?void 0:D.label)??l,O=s.jsxs(s.Fragment,{children:[h===null?s.jsx(ie,{children:"Loading…"}):h.length===0?s.jsx(ie,{children:"No file matches that."}):s.jsx(Ft,{children:h.map(T=>s.jsx(tk,{href:da(T.id,{q:c,origin:l,family:a}),current:T.id===o,onClick:()=>n(da(T.id,{q:c,origin:l,family:a})),lead:s.jsx("span",{className:"files-row-visual","data-family":T.family,children:T.family==="image"&&!T.deleted?s.jsx("img",{src:dr(T.id),alt:"",loading:"lazy"}):s.jsx(Pm,{family:T.family})}),title:T.filename??"Untitled file",meta:s.jsx("span",{title:Ie(T.createdAt,t),children:ke(T.createdAt)}),sub:`${Pr[T.family]} · ${Tn(T.sizeBytes)} · ${Kk(T,k)}${xD(T,k)}`},T.id))}),j?s.jsx("div",{className:"files-more",children:s.jsx(R,{size:"sm",onClick:C,disabled:g,children:g?"Loading…":"Show more"})}):null]}),F=h!==null&&h.length===0&&!c&&!l&&!a&&!u;return s.jsxs("div",{className:"ui-page files","data-selected":o?"true":void 0,children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Files"}),s.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),F?s.jsx(kt,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):s.jsxs(s.Fragment,{children:[s.jsx(sk,{label:"Files",onSubmit:()=>f({q:u},!0),main:s.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:T=>p(T.target.value)}),filters:s.jsxs(Ps,{dense:!0,children:[s.jsx(X,{label:"Origin",children:s.jsx("select",{value:l,"aria-label":"Origin",onChange:T=>f({origin:T.target.value}),children:qv.map(T=>s.jsx("option",{value:T.id,children:T.label},T.id))})}),s.jsx(X,{label:"Kind",children:s.jsx("select",{value:a,"aria-label":"Kind",onChange:T=>f({family:T.target.value}),children:mD.map(T=>s.jsx("option",{value:T,children:T===""?"Any kind":Pr[T]},T))})})]}),filtersOpen:m,onToggleFilters:()=>S(T=>!T),active:P,chips:P>0?s.jsxs(s.Fragment,{children:[l?s.jsx(dh,{label:"Origin",onRemove:()=>f({origin:""}),children:E}):null,a?s.jsx(dh,{label:"Kind",onRemove:()=>f({family:""}),children:Pr[a]}):null]}):void 0}),s.jsx(re,{message:b}),s.jsx(nk,{className:"files-split",label:"Files",list:O,detail:o?s.jsx(vD,{id:o,timezone:t,agents:r,navigate:n,onBack:()=>n(da(null,{q:c,origin:l,family:a}))},o):void 0,empty:"Choose a file to see it here."})]})]})}function xD(e,t){var i,o;const n=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(o=e.context)!=null&&o.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[n,r].filter(Boolean).map(l=>` · ${l}`).join("")}function Kk(e,t){return e.origin==="uploaded"?"You sent it":e.origin==="produced"?`Made by ${t(e.agentId)||"an agent"}`:e.agentId?`Saved by ${t(e.agentId)}`:"Origin unknown"}function vD({id:e,timezone:t,agents:n,navigate:r,onBack:i}){const[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(null);d.useEffect(()=>{let g=!1;return l(null),p(null),A.libraryEntry(e).then(y=>{g||l(y)}).catch(y=>{g||p(y instanceof le&&y.status===404?"This file is no longer in the library.":y instanceof le?y.message:String(y))}),()=>{g=!0}},[e]);const f=g=>{var y;return g?((y=n.find(m=>m.id===g))==null?void 0:y.name)??g:""};if(u)return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(R,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsx(H,{tone:"critical",children:u})]});if(!o)return s.jsx("div",{className:"files-detail-body",children:s.jsx(ie,{children:"Loading…"})});const{entry:h,contexts:v,contextsTotal:j,available:w}=o,b=h.filename??"Untitled file",x=()=>{c(!0),A.libraryEntry(e,v.length).then(g=>l(y=>y&&{...y,contexts:[...y.contexts,...g.contexts],contextsTotal:g.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(R,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsxs("header",{className:"files-detail-head",children:[s.jsx("span",{className:"files-detail-mark","data-family":h.family,"aria-hidden":"true",children:s.jsx(Pm,{family:h.family})}),s.jsxs("div",{className:"files-detail-text",children:[s.jsx("h3",{className:"files-detail-name",children:b}),s.jsxs("p",{className:"files-detail-meta",children:[Pr[h.family]," · ",Tn(h.sizeBytes)," · ",Ie(h.createdAt,t)]})]}),w?s.jsx("a",{className:"ui-btn","data-variant":"accent",href:El(h.id),download:b,children:"Download"}):null]}),w?null:s.jsx(H,{tone:"warning",children:"The file's bytes are no longer on this machine. What is known about it stays here; the download will not work."}),s.jsx(pk,{artifactId:h.id,filename:h.filename,mime:h.mime,family:h.family,available:w}),s.jsx(Tt,{items:[{label:"Origin",value:Kk(h,f)},...h.agentId&&h.origin==="produced"?[{label:"Made by",value:s.jsxs("span",{className:"files-agent",children:[s.jsx(Zt,{agents:n,id:h.agentId,size:"sm"}),f(h.agentId)]})}]:[],{label:"Type",value:s.jsx("span",{className:"mono",children:h.mime})},{label:"Id",value:s.jsx("span",{className:"mono",children:h.id})}]}),s.jsxs("section",{className:"files-conversations",children:[s.jsx("h4",{className:"ui-section-title",children:"Conversations"}),v.length===0?s.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):s.jsx("ul",{className:"files-ctx",role:"list",children:v.map(g=>{const y=g.groupId?zo(g.groupId,g.conversationId):Be(g.conversationAgentId,g.conversationId),m=g.groupId?g.groupName??"a group":f(g.conversationAgentId);return s.jsxs("li",{className:"files-ctx-row",children:[s.jsxs("span",{className:"files-ctx-text",children:[s.jsx("span",{children:g.groupId?`Group: ${m}`:m}),s.jsxs("span",{className:"muted",children:[" · ",g.kind==="produced"?`made by ${f(g.agentId)||"an agent"}`:g.kind==="reused"?"sent again":"sent by you"," · ",ke(g.at)]})]}),s.jsx("a",{className:"ui-btn","data-size":"sm",href:y,onClick:S=>{S.preventDefault(),r(y)},children:"Open conversation"})]},`${g.conversationId}:${g.kind}`)})}),v.length<j?s.jsx(q,{align:"end",children:s.jsx(R,{size:"sm",onClick:x,disabled:a,children:a?"Loading…":`Show ${j-v.length} more`})}):null]})]})}const jD={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe"};function Gk(e){return e&&jD[e]||"plug"}function yD({attention:e,place:t,onNavigate:n,theme:r,onTheme:i,plugins:o=[],updateAvailable:l=!1,version:a}){return s.jsxs("nav",{className:"rail","aria-label":"Places",children:[s.jsx("a",{className:"rail-mark",href:Vt,onClick:c=>{c.preventDefault(),n(Vt)},"aria-label":"buddi home",children:s.jsx(G2,{})}),II.filter(c=>c.route!==Jt).map(c=>s.jsx(_d,{label:c.label,href:c.route,active:t===c.route,badge:c.route===Vt?e:0,onClick:()=>n(c.route),children:Qv[c.route]},c.route)),o.map(c=>{const u=dl(c.plugin,c.id);return s.jsx(_d,{label:c.title,href:u,active:t===u,badge:0,onClick:()=>n(u),children:s.jsx(Ue,{name:Gk(c.icon)})},u)}),s.jsx("div",{className:"rail-spacer"}),s.jsx(_d,{label:"Settings",href:Jt,active:t===Jt,badge:0,dot:l?"a newer buddi is ready":void 0,onClick:()=>n(Jt),children:Qv[Jt]}),s.jsx(bD,{theme:r,onTheme:i,onNavigate:n,version:a})]})}const wD=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function bD({theme:e,onTheme:t,onNavigate:n,version:r}){var a,c;const o=((c=(a=se(()=>A.owner(),[]).data)==null?void 0:a.preferredName)==null?void 0:c.trim())||null,l=(o??"You").slice(0,1).toUpperCase();return s.jsx("div",{className:"rail-owner",children:s.jsxs(om,{modal:!1,children:[s.jsx(lm,{asChild:!0,children:s.jsx("button",{type:"button",className:"rail-owner-btn","aria-label":o?`You: ${o}`:"You",children:s.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:l})})}),s.jsx(am,{children:s.jsxs(cm,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[s.jsxs("div",{className:"rail-owner-head",children:[s.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:l}),s.jsxs("span",{className:"rail-owner-who",children:[s.jsx("span",{className:"rail-owner-name",children:o??"You"}),s.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),s.jsx(Va,{className:"ui-menu-sep"}),s.jsx(um,{className:"ui-menu-label",children:"Theme"}),s.jsx("div",{className:"rail-owner-theme",children:s.jsx(Ga,{label:"Theme",options:wD,value:e,onChange:t})}),s.jsx(Va,{className:"ui-menu-sep"}),s.jsx(ih,{className:"ui-menu-item",onSelect:()=>n(lt("appearance")),children:"Change appearance"}),r?s.jsxs(s.Fragment,{children:[s.jsx(Va,{className:"ui-menu-sep"}),s.jsxs(ih,{className:"ui-menu-item rail-owner-version","data-update":r.updateAvailable?"true":void 0,onSelect:()=>n(lt("system")),children:[s.jsxs("span",{className:"mono",children:["buddi ",r.current]}),r.updateAvailable&&r.latest?s.jsxs("span",{className:"rail-owner-update",children:["A newer buddi is ready: ",r.latest]}):null]})]}):null]})})]})})}function _d({label:e,href:t,active:n,badge:r,dot:i,onClick:o,children:l}){return s.jsxs("a",{className:"rail-link",href:t,"data-active":n?"true":void 0,"aria-current":n?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:i?`${e}, ${i}`:e,onClick:a=>{a.preventDefault(),o()},children:[s.jsxs("span",{className:"rail-icon",children:[l,r>0?s.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null,r===0&&i?s.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"rail-dot","aria-hidden":"true"}):null]}),s.jsx("span",{className:"rail-label",children:e})]})}const Qv={[Fr]:s.jsx(Ue,{name:"files"}),[Vt]:s.jsx(Ue,{name:"home"}),[Ui]:s.jsx(Ue,{name:"chat"}),[rt]:s.jsx(Ue,{name:"agents"}),[st]:s.jsx(Ue,{name:"activity"}),[Jt]:s.jsx(Ue,{name:"settings"})},Yk="buddi.theme";function kD(e=qk()){try{const t=e==null?void 0:e.getItem(Yk);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function SD(e,t=qk()){try{t==null||t.setItem(Yk,e)}catch{}}function ND(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function qk(){try{return window.localStorage}catch{return}}const Qk="buddi.ground",Jk="buddi.pageWidth";function CD(e=eS()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},n=t(Qk),r=t(Jk);return{theme:kD(e),ground:n==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function Xk(e,t=document.documentElement){t&&(ND(e.theme,t),e.ground==="sand"?t.setAttribute("data-ground","sand"):t.removeAttribute("data-ground"),e.width==="wide"?t.removeAttribute("data-width"):t.setAttribute("data-width",e.width))}function ED(e,t=eS()){SD(e.theme,t);try{t==null||t.setItem(Qk,e.ground),t==null||t.setItem(Jk,e.width)}catch{}}let Ri=null;const Rh=new Set;function Ph(){return Ri||(Ri=CD()),Ri}function AD(e){return Rh.add(e),()=>Rh.delete(e)}function TD(e){Ri={...Ph(),...e},Xk(Ri),ED(Ri);for(const t of Rh)t()}function Zk(){return[d.useSyncExternalStore(AD,Ph,Ph),TD]}function eS(){try{return window.localStorage}catch{return}}function RD({timezone:e,embedded:t}){var h,v;const{data:n,error:r,reload:i}=se(()=>A.sentinels(),[],3e4),o=se(()=>A.missions(),[]),[l,a]=d.useState(null),c=((v=(h=o.data)==null?void 0:h.missions.find(j=>j.id==="sentinel-wake"))==null?void 0:v.agentId)??null,u=async(j,w)=>{a(null);try{await A.snoozeAlert(j,w),i()}catch(b){a(b instanceof Error?b.message:String(b))}},p=((n==null?void 0:n.open)??[]).filter(j=>!j.snoozedAt),f=((n==null?void 0:n.open)??[]).filter(j=>j.snoozedAt);return s.jsxs(cn,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[s.jsx(re,{message:r??l}),s.jsx(H,{children:"An alert closes on its own once the fact behind it changes: record the payment, update the balance, and the watcher clears it on its next run. Snooze one you have decided to live with; it stays quiet until it resolves."}),s.jsx(Od,{title:"Open",findings:p,timezone:e,askAgentId:c,onSnooze:j=>u(j,!0),empty:"Nothing open. Your watchers are quiet."}),f.length>0?s.jsx(Od,{title:"Snoozed",findings:f,timezone:e,askAgentId:c,onSnooze:j=>u(j,!1),empty:""}):null,s.jsx(Od,{title:"Resolved",findings:(n==null?void 0:n.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),s.jsx(at,{title:"Waiting for the weekly recap",flush:!0,children:!n||n.digest.length===0?s.jsx(kt,{icon:"bell",title:"Nothing waiting for the recap"}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Title"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Noted"})]})}),s.jsx("tbody",{children:n.digest.map(j=>s.jsxs("tr",{children:[s.jsxs("td",{children:[Fi(j.title),s.jsx(nS,{text:Fi(j.detail)})]}),s.jsx("td",{children:s.jsx(tS,{severity:j.severity})}),s.jsx("td",{className:"nowrap",children:Ie(j.createdAt,e)})]},j.id))})]})})]})}function tS({severity:e}){return s.jsx(pe,{tone:e==="urgent"?"critical":void 0,children:e})}function nS({text:e}){const[t,n]=d.useState(!1),r=e.length>240||e.split(`
104
- `).length>3;return s.jsxs("div",{className:"sub alert-detail","data-clamp":r&&!t?"true":void 0,children:[e,r?s.jsx("button",{type:"button",className:"wb-link alert-more",onClick:()=>n(i=>!i),children:t?"Less":"More"}):null]})}function PD(e){return`About this alert: "${Fi(e.title)}". ${Fi(e.detail)}
105
-
106
- What should I do about it, and what do you need from me to clear it?`}function Od({title:e,findings:t,timezone:n,askAgentId:r,onSnooze:i,empty:o}){const l=e==="Snoozed";return s.jsx(at,{title:e,flush:!0,children:t.length===0?s.jsx(ie,{children:o}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Finding"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Since"}),i?s.jsx("th",{}):null]})}),s.jsx("tbody",{children:t.map(a=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:Fi(a.title)}),s.jsx(nS,{text:Fi(a.detail)}),a.data?s.jsx(St,{summary:"evidence",children:s.jsx(ft,{children:on(a.data)})}):null]}),s.jsx("td",{children:s.jsx(tS,{severity:a.severity})}),s.jsxs("td",{className:"nowrap",children:[Ie(a.firstSeenAt,n),s.jsxs("div",{className:"sub",title:Ie(a.lastSeenAt,n),children:["last seen ",ke(a.lastSeenAt)]})]}),i?s.jsx("td",{children:s.jsxs(q,{align:"end",children:[r?s.jsx(ln,{size:"sm",href:Be(r,"new"),onClick:()=>wO(r,PD(a)),children:"Ask about it"}):null,s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>i(a.key),children:l?"Wake":"Snooze"})]})}):null]},a.key))})]})})}const Jv=5e3,Xv=50;function ID({timezone:e,embedded:t}){var x;const[n,r]=d.useState(""),[i,o]=d.useState(""),[l,a]=d.useState(null),c=se(()=>A.eventKinds(),[]),{data:u,error:p}=se(()=>A.events({kind:n||void 0,q:i||void 0,limit:Xv}),[n,i],Jv),[f,h]=d.useState({events:[],cursor:null,busy:!1,error:null});d.useEffect(()=>{h({events:[],cursor:null,busy:!1,error:null})},[n,i]);const v=f.events.length>0?f.cursor:(u==null?void 0:u.nextCursor)??null,j=async()=>{if(v){h(g=>({...g,busy:!0,error:null}));try{const g=await A.events({kind:n||void 0,q:i||void 0,before:v,limit:Xv});h(y=>({events:[...y.events,...g.events],cursor:g.nextCursor,busy:!1,error:null}))}catch(g){h(y=>({...y,busy:!1,error:g instanceof Error?g.message:String(g)}))}}},w=new Set(((u==null?void 0:u.events)??[]).map(g=>g.id)),b=[...(u==null?void 0:u.events)??[],...f.events.filter(g=>!w.has(g.id))];return s.jsxs(cn,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[s.jsxs(q,{children:[s.jsxs("select",{"aria-label":"Event kind",value:n,onChange:g=>r(g.target.value),children:[s.jsx("option",{value:"",children:"every kind"}),(((x=c.data)==null?void 0:x.kinds)??[]).map(g=>s.jsxs("option",{value:g.kind,children:[g.kind," (",g.count,")"]},g.kind))]}),s.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:g=>o(g.target.value),size:28}),n||i?s.jsx(R,{onClick:()=>{r(""),o("")},children:"Clear"}):null,s.jsxs("span",{className:"muted",children:["refreshes every ",Jv/1e3,"s"]})]}),s.jsx(re,{message:p}),s.jsx(at,{flush:!0,children:!u||b.length===0?s.jsx(ie,{children:"No events match."}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"#"}),s.jsx("th",{children:"When"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Payload"})]})}),s.jsx("tbody",{children:b.map(g=>s.jsxs("tr",{"data-clickable":"true",onClick:()=>a(g),children:[s.jsx("td",{className:"mono muted",children:g.id}),s.jsxs("td",{className:"nowrap",children:[Ie(g.createdAt,e),s.jsx("div",{className:"sub",children:ke(g.createdAt)})]}),s.jsx("td",{className:"mono nowrap",children:g.kind}),s.jsx("td",{className:"mono muted",children:Rs(on(g.payload).replace(/\s+/g," "),120)})]},g.id))})]})}),v||f.error?s.jsxs(q,{children:[s.jsxs("span",{className:"muted",children:[b.length," shown",v?", older ones are kept":"","."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),f.error?s.jsx("span",{className:"critical",children:f.error}):null,v?s.jsx(R,{disabled:f.busy,onClick:()=>void j(),children:f.busy?"Loading…":"Load older"}):null]}):null,l?s.jsxs(qt,{title:l.kind,onClose:()=>a(null),children:[s.jsxs("p",{className:"muted",children:["Event ",l.id," · ",Ie(l.createdAt,e),l.conversationId?s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:`#/conversations/${l.conversationId}`,children:"conversation"})]}):null]}),s.jsx(ft,{children:on(l.payload)})]}):null]})}const MD=["pending","leased","suspended","failed","succeeded","cancelled"],Co=50;function $D({timezone:e,embedded:t,initialState:n}){const[r,i]=d.useState(n??""),[o,l]=d.useState(null),[a,c]=d.useState(null),{data:u,error:p,reload:f}=se(()=>A.jobs({...r?{state:r}:{},limit:String(Co)}),[r],1e4),[h,v]=d.useState({jobs:[],done:!1,busy:!1});d.useEffect(()=>{v({jobs:[],done:!1,busy:!1})},[r]);const j=async()=>{v(N=>({...N,busy:!0}));try{const N=await A.jobs({...r?{state:r}:{},limit:String(Co),offset:String(Co+h.jobs.length)});v(C=>({jobs:[...C.jobs,...N.jobs],done:N.jobs.length<Co,busy:!1}))}catch(N){c(N instanceof Error?N.message:String(N)),v(C=>({...C,busy:!1}))}},w=new Set(((u==null?void 0:u.jobs)??[]).map(N=>N.id)),b=[...(u==null?void 0:u.jobs)??[],...h.jobs.filter(N=>!w.has(N.id))],x=r?(u==null?void 0:u.counts[r])??0:Object.values((u==null?void 0:u.counts)??{}).reduce((N,C)=>N+C,0),g=!h.done&&b.length<x&&((u==null?void 0:u.jobs.length)??0)>=Co,[y,m]=d.useState(null),S=async N=>{c(null),m(N);try{const C=(await A.jobs({state:"failed",limit:"500"})).jobs;for(const P of C)await(N==="retry"?A.retryJob(P.id):A.cancelJob(P.id));f()}catch(C){c(C instanceof Error?C.message:String(C))}finally{m(null)}},k=async N=>{c(null);try{await N,l(null),f()}catch(C){c(C instanceof Error?C.message:String(C))}};return s.jsxs(cn,{embedded:t,title:"Jobs",lede:`${u!=null&&u.paused?"Paused: nothing is being claimed. ":""}Bounded retries with backoff; past the budget a job waits for you.`,actions:t?void 0:s.jsx(R,{size:"sm",variant:u!=null&&u.paused?"accent":void 0,onClick:()=>k(A.setPaused(!((u==null?void 0:u.paused)??!1))),children:u!=null&&u.paused?"Resume the queue":"Pause the queue"}),children:[s.jsxs(q,{children:[s.jsxs("select",{"aria-label":"Job state",value:r,onChange:N=>i(N.target.value),children:[s.jsx("option",{value:"",children:"every state"}),MD.map(N=>s.jsxs("option",{value:N,children:[N," (",(u==null?void 0:u.counts[N])??0,")"]},N))]}),((u==null?void 0:u.counts.failed)??0)>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("span",{className:"muted",children:[u.counts.failed," failed."]}),s.jsx(R,{size:"sm",disabled:y!==null,onClick:()=>void S("retry"),children:y==="retry"?"Retrying…":"Retry all failed"}),s.jsx(R,{size:"sm",variant:"danger",disabled:y!==null,onClick:()=>void S("cancel"),children:y==="cancel"?"Cancelling…":"Cancel all failed"})]}):null]}),s.jsx(re,{message:p??a}),s.jsx(at,{flush:!0,children:!u||b.length===0?s.jsx(ie,{children:"No jobs match."}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"State"}),s.jsx("th",{className:"num",children:"Attempts"}),s.jsx("th",{children:"Last error"}),s.jsx("th",{children:"Updated"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:b.map(N=>s.jsxs("tr",{children:[s.jsxs("td",{className:"clickable",onClick:()=>l(N),children:[N.kind,s.jsx("div",{className:"sub mono",children:ul(N.id)})]}),s.jsxs("td",{children:[s.jsx(xu,{state:N.state}),N.suspendedReason?s.jsx("div",{className:"sub",children:Rs(N.suspendedReason,40)}):null]}),s.jsxs("td",{className:"num",children:[N.attempts,"/",N.maxAttempts]}),s.jsx("td",{className:N.lastError?"critical":"muted",children:N.lastError?Rs(N.lastError,80):"—"}),s.jsxs("td",{className:"nowrap",children:[Ie(N.updatedAt,e),s.jsx("div",{className:"sub",children:ke(N.updatedAt)})]}),s.jsx("td",{children:s.jsxs(q,{align:"end",children:[["failed","cancelled","suspended"].includes(N.state)?s.jsx(R,{size:"sm",onClick:()=>k(A.retryJob(N.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(N.state)?s.jsx(R,{size:"sm",variant:"danger",onClick:()=>k(A.cancelJob(N.id)),children:"Cancel"}):null]})})]},N.id))})]})}),g?s.jsxs(q,{children:[s.jsxs("span",{className:"muted",children:[b.length," of ",x," shown."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{disabled:h.busy,onClick:()=>void j(),children:h.busy?"Loading…":"Load older"})]}):null,o?s.jsxs(qt,{title:o.kind,onClose:()=>l(null),children:[s.jsx("p",{className:"muted mono",children:o.id}),s.jsx(G,{title:"Payload",children:s.jsx(ft,{children:on(o.payload)})}),s.jsx(G,{title:"Result",children:s.jsx(ft,{children:on(o.result)})}),o.conversationId?s.jsx("p",{children:s.jsx("a",{href:`#/conversations/${o.conversationId}`,children:"open the transcript"})}):null]}):null]})}const _D=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function OD({hash:e,timezone:t,navigate:n,agents:r}){var u,p;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),o=f=>{var h;return((h=r.find(v=>v.id===f))==null?void 0:h.name)??f};if(i){let f=i[1];try{f=decodeURIComponent(f)}catch{}return s.jsx(FD,{id:f,timezone:t,navigate:n,nameOf:o})}const l=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",a=(p=/[?&]state=([a-z]+)/.exec(e))==null?void 0:p[1],c=f=>h=>{h.preventDefault(),n(f)};return s.jsxs("div",{className:"ui-page",children:[s.jsx(km,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:s.jsx(BD,{})}),s.jsx(WD,{}),s.jsx(ju,{children:_D.map(f=>{const h=f.id==="conversations"?st:`${st}/${f.id}`;return s.jsx(yu,{href:h,active:l===f.id,onClick:c(h),children:f.label},f.id)})}),l==="conversations"?s.jsx(DD,{timezone:t,navigate:n,nameOf:o,agents:r}):null,l==="jobs"?s.jsx($D,{timezone:t,embedded:!0,initialState:a},a??""):null,l==="approvals"?s.jsx(LD,{timezone:t,nameOf:o}):null,l==="alerts"?s.jsx(RD,{timezone:t,embedded:!0}):null,l==="events"?s.jsx(ID,{timezone:t,embedded:!0}):null]})}function DD({timezone:e,navigate:t,nameOf:n,agents:r}){const{data:i,error:o}=se(()=>A.conversations(),[],3e4);return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:o}),s.jsx(at,{flush:!0,children:i?i.conversations.length===0?s.jsx(kt,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):s.jsx(Ft,{children:i.conversations.map(l=>s.jsx(Kt,{href:zi(l.id),onClick:()=>t(zi(l.id)),lead:s.jsx(Zt,{agents:r,id:l.agentId,size:"sm"}),title:l.opening?Rs(l.opening,100):"Untitled conversation",sub:`${n(l.agentId)}, ${l.messageCount} message${l.messageCount===1?"":"s"}, ${l.runs} run${l.runs===1?"":"s"}, ${Lt(l.usage.input)} in / ${Lt(l.usage.output)} out`,side:s.jsx("span",{title:Ie(l.lastMessageAt??l.createdAt,e),children:ke(l.lastMessageAt??l.createdAt)})},l.id))}):s.jsx(ie,{children:"Loading…"})})]})}function LD({timezone:e,nameOf:t}){const{data:n,error:r}=se(()=>A.approvals(),[],1e4),i=[...(n==null?void 0:n.pending)??[],...(n==null?void 0:n.recent)??[]];return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:r}),s.jsx(at,{flush:!0,children:n?i.length===0?s.jsx(kt,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Tool"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Asked by"}),s.jsx("th",{children:"Decided"}),s.jsx("th",{children:"Created"})]})}),s.jsx("tbody",{children:i.map(o=>s.jsxs("tr",{children:[s.jsxs("td",{children:[o.tool,s.jsx("div",{className:"sub mono",children:ul(o.id)})]}),s.jsx("td",{children:s.jsx(xu,{state:o.state})}),s.jsx("td",{children:t(o.agentId)}),s.jsx("td",{className:"nowrap",children:o.decidedAt?s.jsxs(s.Fragment,{children:[Ie(o.decidedAt,e),s.jsxs("div",{className:"sub",children:["via ",o.decidedVia??"—"]})]}):s.jsx("span",{className:"muted",children:"—"})}),s.jsxs("td",{className:"nowrap",children:[Ie(o.createdAt,e),s.jsx("div",{className:"sub",children:ke(o.createdAt)})]})]},o.id))})]}):s.jsx(ie,{children:"Loading…"})})]})}function FD({id:e,timezone:t,navigate:n,nameOf:r}){const[i,o]=d.useState(null),[l,a]=d.useState(null);d.useEffect(()=>{let u=!1;return A.conversation(e).then(p=>{u||o(p)}).catch(p=>{u||a(p instanceof Error?p.message:String(p))}),()=>{u=!0}},[e]);const c=u=>p=>{p.preventDefault(),n(u)};return s.jsxs("div",{className:"ui-page",children:[s.jsx("p",{className:"page-crumbs",children:s.jsx("a",{href:st,onClick:c(st),children:"Activity"})}),s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[s.jsx(R,{size:"sm",onClick:()=>n(st),children:"← Back"}),s.jsx("span",{children:"Transcript"})]}),i?s.jsx("div",{className:"ui-page-actions",children:s.jsx(ln,{size:"sm",href:Be(i.agentId,e),onClick:c(Be(i.agentId,e)),children:"Open in chat"})}):null]}),s.jsx("p",{className:"ui-page-lede mono",children:e})]}),s.jsx(re,{message:l}),i?s.jsxs(s.Fragment,{children:[s.jsxs(vu,{children:[s.jsx(es,{label:"Agent",value:r(i.agentId),size:"sm"}),s.jsx(es,{label:"Runs",value:i.runs.length}),s.jsx(es,{label:"Tokens",value:`${Lt(i.usage.input)} / ${Lt(i.usage.output)}`,note:"input / output"}),s.jsx(es,{label:"Started",value:Ie(i.createdAt,t),size:"sm"})]}),i.runs.length>0?s.jsx(at,{title:"Runs",flush:!0,children:s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{className:"num",children:"Turns"}),s.jsx("th",{children:"Stopped"}),s.jsx("th",{className:"num",children:"Tokens"})]})}),s.jsx("tbody",{children:i.runs.map((u,p)=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Ie(u.startedAt,t)," ",u.resumed?s.jsx(pe,{children:"resumed"}):null]}),s.jsx("td",{className:"nowrap",children:Ie(u.finishedAt,t)}),s.jsx("td",{className:"num",children:u.turns??"—"}),s.jsxs("td",{children:[u.stopped??"—",u.actionId?s.jsxs("div",{className:"sub mono",children:["action ",ul(u.actionId)]}):null]}),s.jsxs("td",{className:"num muted nowrap",children:[Lt(u.usage.input)," / ",Lt(u.usage.output)]})]},p))})]})}):null,s.jsx(G,{title:"Messages",children:s.jsx(K,{children:i.messages.map(u=>s.jsxs("article",{className:"transcript-msg",children:[s.jsxs("header",{className:"transcript-who",children:[u.speaker===Zv?"approved action, result":u.role,", ",Ie(u.createdAt,t)]}),s.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?s.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===Zv?u.blocks.map((p,f)=>s.jsx(UD,{block:p},f)):u.blocks.map((p,f)=>s.jsx(zD,{block:p},f))]})]},u.id))})})]}):s.jsx(ie,{children:"Loading…"})]})}const Zv="approval:resume";function UD({block:e}){return s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),s.jsx(ft,{children:e.type==="text"?e.text??"":on(e)})]})}function zD({block:e}){return e.type==="text"?s.jsx("div",{className:"transcript-text",children:s.jsx(ur,{text:e.text??""})}):e.type==="thinking"?s.jsxs("details",{className:"transcript-thinking",children:[s.jsx("summary",{children:"Thoughts"}),s.jsx("div",{className:"transcript-thinking-text",children:s.jsx(ur,{text:e.text??""})})]}):e.type==="tool_use"?s.jsxs("div",{className:"transcript-tool",children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),s.jsx(ft,{children:on(e.input)})]}):e.type==="tool_result"?s.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),s.jsx(ft,{children:e.content??""})]}):s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:e.type}),s.jsx(ft,{children:on(e.ref)})]})}function BD(){const{data:e,reload:t}=se(()=>A.overview(),[],1e4),[n,r]=d.useState(!1);if(!e)return null;const i=()=>{r(!0),A.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return s.jsx(R,{size:"sm",variant:e.paused?"accent":void 0,disabled:n,onClick:i,children:e.paused?"Resume all":"Pause all"})}function WD(){const{data:e}=se(()=>A.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,n=t("leased");return s.jsxs(vu,{children:[s.jsx(es,{label:"Jobs done",value:Lt(t("succeeded"))}),s.jsx(es,{label:"Failed",value:Lt(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),s.jsx(es,{label:"Queued",value:Lt(t("pending")),note:`${n} running`}),s.jsx(es,{label:"Approvals",value:Lt(e.approvals.pending),note:"waiting for you"})]})}const HD=["replay-all","coalesce","latest-only","skip-after-deadline"];function sS({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:o}=se(()=>A.missions(),[],3e4),l=((r==null?void 0:r.missions)??[]).filter(p=>!n||p.agentId===n),[a,c]=d.useState(null),u=async p=>{c(null);try{await p,o()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.jsxs(cn,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[s.jsx(re,{message:i??a}),!r||l.length===0?s.jsxs(kt,{icon:"calendar",title:"No missions yet",children:["Run ",s.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):s.jsx(K,{children:l.map(p=>s.jsx(VD,{mission:p,timezone:e,onRun:u},p.id))})]})}function VD({mission:e,timezone:t,onRun:n}){const[r,i]=d.useState(!1);return s.jsxs(Ur,{tone:e.enabled?"good":"muted",title:s.jsxs(s.Fragment,{children:[e.name," ",s.jsx("span",{className:"mono muted",children:e.id})]}),meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{mono:!0,children:e.agentId}),e.alwaysDeliver?s.jsx(pe,{children:"always delivers"}):null,e.enabled?null:s.jsx(pe,{tone:"warning",children:"disabled"})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",onClick:()=>n(A.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>i(o=>!o),"aria-expanded":r,children:r?"Less":"More"})]}),children:[s.jsxs("p",{className:"ui-card-meta",children:[e.schedule?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${Ie(e.nextRun,t)} (${ke(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",s.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${ke(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?s.jsxs("div",{className:"ui-card-foot",children:[e.schedule?s.jsxs(q,{children:[s.jsx(X,{inline:!0,label:"Misfire policy",children:s.jsx("select",{value:e.schedule.misfirePolicy,onChange:o=>n(A.setMisfirePolicy(e.id,o.target.value)),children:HD.map(o=>s.jsx("option",{value:o,children:o},o))})}),s.jsx("span",{className:"muted",children:"What a week asleep does: replay every instant, coalesce into one, keep only the latest, or skip past a deadline."})]}):null,s.jsx(G,{title:"Prompt",children:s.jsx(ft,{children:e.prompt})}),s.jsx(G,{title:"Recent occurrences",children:s.jsx(at,{flush:!0,children:e.occurrences.length===0?s.jsx(ie,{children:"Never run."}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Scheduled"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{children:"Detail"})]})}),s.jsx("tbody",{children:e.occurrences.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"nowrap",children:Ie(o.scheduledAt,t)}),s.jsx("td",{children:s.jsx(xu,{state:o.state})}),s.jsx("td",{className:"nowrap",children:Ie(o.finishedAt,t)}),s.jsxs("td",{className:o.error?"critical":"muted",children:[o.error?Rs(o.error,120):null,o.runConversationId?s.jsx("a",{href:`#/conversations/${o.runConversationId}`,children:"transcript"}):null]})]},o.id))})]})})})]}):null]})}function KD(e,t){const n=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${n}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function rS({ids:e,agentName:t,onDone:n}){const r=e.length,[i,o]=d.useState(!1),[l,a]=d.useState(!1);return r<=0?null:i?s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:KD(r,t)}),s.jsx(R,{size:"sm",variant:"danger",disabled:l,onClick:()=>{a(!0),A.dismissOffers(e).then(()=>{o(!1),n()}).finally(()=>a(!1))},children:`Dismiss ${r}`}),s.jsx(R,{size:"sm",variant:"ghost",disabled:l,onClick:()=>o(!1),children:"Keep them"})]}):s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>o(!0),children:"Dismiss all"})}function iS({embedded:e,agentId:t,agentName:n}){const{data:r,error:i,reload:o}=se(()=>A.offers(),[],2e4),l=x=>!t||x.agentId===t,a=((r==null?void 0:r.offers)??[]).filter(l),c=((r==null?void 0:r.closed)??[]).filter(l),[u,p]=d.useState(null),[f,h]=d.useState(null),[v,j]=d.useState(null),w=async(x,g)=>{p(null),h(x);try{const y=await A.takeOffer(x);j(y.jobId?`On it — ${g}. Started as job ${y.jobId}.`:`Taken — ${g}. No worker is running here, so nothing has started yet.`),o()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(null)}},b=async(x,g)=>{p(null),h(x);try{await A.dismissOffer(x),j(`Dismissed — ${g}. It will not come back.`),o()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(null)}};return s.jsxs(cn,{embedded:e,title:"Offers",lede:"Things an agent already worked out that you might want done. Taking one asks that agent the sentence it wrote. It authorizes nothing, and anything that would leave this machine still comes back to you as an approval.",children:[s.jsx(re,{message:i??u}),v?s.jsx(H,{tone:"good",role:"status",children:v}):null,a.length>0?s.jsxs(q,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(rS,{ids:a.map(x=>x.id),agentName:n,onDone:()=>{j(null),o()}})]}):null,!r||a.length===0?s.jsx(kt,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):s.jsx(K,{children:a.map(x=>s.jsx(Ur,{tone:"accent",title:x.label,meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{mono:!0,children:x.agentId}),s.jsxs("span",{className:"muted",children:["expires ",ke(x.expiresAt)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",variant:"ghost",disabled:f===x.id,onClick:()=>void b(x.id,x.label),children:"Not now"}),s.jsx(R,{variant:"accent",size:"sm",disabled:f===x.id,onClick:()=>void w(x.id,x.label),children:"Take"})]}),children:s.jsx("p",{className:"ui-card-meta",children:x.prompt})},x.id))}),c.length>0?s.jsxs(St,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[s.jsx(at,{flush:!0,children:s.jsx(Ft,{children:c.map(x=>s.jsx(Kt,{title:x.label,sub:`${x.agentId} — ${zT(x)}`,side:ke(x.dismissedAt??x.lapsedAt??x.createdAt)},x.id))})}),s.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const GD=["fact","observation","todo"];function oS({embedded:e,agents:t,timezone:n,agentId:r}){const{data:i,error:o,reload:l}=se(()=>A.memory(r),[r],3e4),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(null),v=m=>{var S;return m==="shared"?"Everyone":((S=t.find(k=>k.id===m))==null?void 0:S.name)??m},j=async m=>{h(null);try{await m,l()}catch(S){h(S instanceof le?S.message:String(S))}},w={nameOf:v,timezone:n,onChangePreference:m=>c({key:m.key,scope:m.scope}),onForgetPreference:m=>void j(A.forgetPreference({key:m.key,scope:m.scope})),onEditNote:m=>p(m),onForgetNote:m=>void j(A.forgetNote(m.id))},b=r?v(r):"",x=r&&i?{preferences:i.preferences.filter(m=>m.scope===r),notes:i.notes.filter(m=>m.scope===r)}:null,g=r&&i?{preferences:i.preferences.filter(m=>m.scope==="shared"),notes:i.notes.filter(m=>m.scope==="shared")}:null,y=s.jsx(R,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return s.jsxs(cn,{embedded:e,title:"Memory",lede:"What your agents have kept about you. Correct anything here; they see the change on their next turn.",children:[s.jsx(re,{message:o??f}),x&&g?s.jsxs(K,{gap:"lg",children:[s.jsx(G,{title:"Preferences",aside:`what you told ${b} alone`,actions:y,panel:!0,flush:!0,children:s.jsx(Dd,{preferences:x.preferences,empty:`Nothing stated to ${b} alone yet.`,...w})}),s.jsx(G,{title:"Notes",aside:`what ${b} wrote down for itself`,panel:!0,flush:!0,children:s.jsx(Ld,{notes:x.notes,empty:`${b} has kept no private notes yet.`,...w})}),s.jsx(St,{summary:`Shared with every agent, which ${b} also reads · ${g.preferences.length} preferences, ${g.notes.length} notes`,children:s.jsxs(K,{gap:"lg",children:[s.jsx(G,{title:"Shared preferences",panel:!0,flush:!0,children:s.jsx(Dd,{preferences:g.preferences,empty:"No shared preferences.",...w})}),s.jsx(G,{title:"Shared notes",panel:!0,flush:!0,children:s.jsx(Ld,{notes:g.notes,empty:"No shared notes.",...w})})]})})]}):s.jsxs(K,{gap:"lg",children:[s.jsx(G,{title:"Preferences",aside:"what you said you want, one current value each",actions:y,panel:!0,flush:!0,children:i?s.jsx(Dd,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...w}):s.jsx(ie,{children:"Loading…"})}),s.jsx(G,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?s.jsx(Ld,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...w}):s.jsx(ie,{children:"Loading…"})})]}),a?s.jsx(YD,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:a,onClose:()=>c(null),onSave:async m=>{await j((async()=>{await A.setPreference(m),a.key===m.key&&a.scope!==m.scope&&await A.forgetPreference({key:a.key,scope:a.scope})})()),c(null)}}):null,u?s.jsx(qD,{note:u,agents:t,onClose:()=>p(null),onSave:m=>j(A.updateNote(u.id,m)).then(()=>p(null))}):null]})}function Dd({preferences:e,empty:t,nameOf:n,onChangePreference:r,onForgetPreference:i}){return e.length===0?s.jsx(ie,{children:t}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Preference"}),s.jsx("th",{children:"Value"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{className:"num",children:"Since"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:o.key}),s.jsx("td",{children:o.value}),s.jsx("td",{children:s.jsx(lS,{scope:o.scope,name:n(o.scope)})}),s.jsxs("td",{className:"num muted",title:o.updatedAt??"",children:[o.updatedAt?ke(o.updatedAt,Date.now()):"",o.revision>1?` · rev ${o.revision}`:""]}),s.jsx("td",{className:"num",children:s.jsxs(q,{align:"end",children:[s.jsx(R,{size:"sm",onClick:()=>r(o),title:"Store a new value for this key",children:"Change"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>i(o),children:"Forget"})]})})]},`${o.scope}:${o.key}`))})]})}function Ld({notes:e,empty:t,nameOf:n,timezone:r,onEditNote:i,onForgetNote:o}){return e.length===0?s.jsx(ie,{children:t}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Note"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{children:"Written by"}),s.jsx("th",{className:"num",children:"When"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{className:"memory-note",children:l.content}),s.jsx("td",{children:s.jsx(pe,{tone:l.kind==="todo"?"warning":l.kind==="fact"?"good":void 0,children:l.kind})}),s.jsx("td",{children:s.jsx(lS,{scope:l.scope,name:n(l.scope)})}),s.jsx("td",{className:"muted",children:l.createdByAgent?n(l.createdByAgent):""}),s.jsxs("td",{className:"num muted",title:l.createdAt??"",children:[l.createdAt?ke(l.createdAt,Date.now()):"",l.expiresAt?s.jsxs("span",{className:"memory-expires",children:[" · until ",new Date(l.expiresAt).toLocaleDateString(void 0,{timeZone:r})]}):null]}),s.jsx("td",{className:"num",children:s.jsxs(q,{align:"end",children:[s.jsx(R,{size:"sm",onClick:()=>i(l),children:"Edit"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>o(l),children:"Forget"})]})})]},l.id))})]})}function lS({scope:e,name:t}){return s.jsx(pe,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function aS({value:e,agents:t,onChange:n}){return s.jsxs("select",{value:e,onChange:r=>n(r.target.value),children:[s.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>s.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function YD({agents:e,existing:t,initial:n,onClose:r,onSave:i}){const o=t.find(g=>g.key===n.key&&g.scope===n.scope),[l,a]=d.useState(n.key),[c,u]=d.useState((o==null?void 0:o.value)??""),[p,f]=d.useState(n.scope),[h,v]=d.useState(!1),j=l.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(g=>g.key===j&&g.scope===p),b=!o||j!==o.key||c.trim()!==o.value||p!==o.scope,x=j!==""&&c.trim()!==""&&b;return s.jsx(qt,{title:"A preference",onClose:r,children:s.jsxs(K,{children:[s.jsx(H,{children:'A preference is a standing choice, in your words: "paid biweekly on Thursdays", "answers short, numbers first". Storing the same key again records a correction and keeps the old value in the history.'}),s.jsx(X,{label:"Key",hint:j&&j!==l?`Stored as ${j}`:"Short and stable, like reporting_currency or tone.",children:s.jsx("input",{value:l,autoFocus:n.key==="",onChange:g=>a(g.target.value),placeholder:"reporting_currency"})}),s.jsx(X,{label:"Value",children:s.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:n.key!=="",onChange:g=>u(g.target.value),placeholder:"EUR"})}),s.jsx(X,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:s.jsx(aS,{value:p,agents:e,onChange:f})}),w&&w!==o?s.jsxs(H,{tone:"warning",children:['This replaces the value already stored for this key here, "',w.value,'" (revision ',w.revision,")."]}):null,o&&p!==o.scope?s.jsxs(H,{children:["It moves: the copy for ",o.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:r,children:"Cancel"}),s.jsx(R,{variant:"accent",disabled:!x||h,onClick:()=>{v(!0),i({key:j,value:c.trim(),scope:p}).finally(()=>v(!1))},children:o?"Save change":"Save"})]})]})})}function qD({note:e,agents:t,onClose:n,onSave:r}){var v;const[i,o]=d.useState(e.content),[l,a]=d.useState(e.scope),[c,u]=d.useState(e.kind),[p,f]=d.useState(!1),h=i.trim()!==e.content||l!==e.scope||c!==e.kind;return s.jsx(qt,{title:"A note",onClose:n,children:s.jsxs(K,{children:[s.jsx(X,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:s.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:j=>o(j.target.value)})}),s.jsxs(Ps,{children:[s.jsx(X,{label:"Kind",children:s.jsx("select",{value:c,onChange:j=>u(j.target.value),children:GD.map(j=>s.jsx("option",{value:j,children:j},j))})}),s.jsx(X,{label:"Who sees it",children:s.jsx(aS,{value:l,agents:t,onChange:a})})]}),e.createdByAgent?s.jsxs("p",{className:"muted",children:["Written by ",((v=t.find(j=>j.id===e.createdByAgent))==null?void 0:v.name)??e.createdByAgent,e.createdAt?`, ${ke(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:n,children:"Cancel"}),s.jsx(R,{variant:"accent",disabled:!h||i.trim()===""||p,onClick:()=>{f(!0);const j={};i.trim()!==e.content&&(j.content=i.trim()),l!==e.scope&&(j.scope=l),c!==e.kind&&(j.kind=c),r(j).finally(()=>f(!1))},children:"Save"})]})]})})}function QD({agentId:e,agentName:t}){const{data:n,error:r,reload:i}=se(()=>A.agentSkills(e),[e],3e4),[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(null),f=async j=>{l(null),c(null),p(j.name);try{const w=await A.removeSkill(e,j.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){l(w instanceof le?w.message:String(w))}finally{p(null)}};if(!n)return r?s.jsx(re,{message:r}):s.jsx(ie,{children:"Loading…"});const h=n.skills.filter(j=>j.learned!==null),v=n.skills.filter(j=>j.learned===null);return s.jsxs(K,{divided:!0,children:[s.jsx(re,{message:r??o}),a?s.jsx(H,{tone:"good",role:"status",children:a}):null,s.jsx(G,{title:"Learned",aside:s.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:h.length===0?s.jsx(kt,{icon:"bulb",title:"Nothing learned yet",children:n.writable?`When ${t} proposes a procedure and you keep it on Settings → Proposals, it appears here.`:`${t} ships with buddi, so it keeps no learned skills of its own until it is yours.`}):s.jsx(at,{flush:!0,children:s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"Version"}),s.jsx("th",{children:"Came from"}),s.jsx("th",{className:"num",children:"Kept"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:h.map(j=>s.jsx(XD,{skill:j,busy:u===j.name,onRemove:()=>void f(j)},j.name))})]})})}),s.jsx(G,{title:"From files and plugins",aside:s.jsx("span",{className:"muted",children:"read-only here"}),children:v.length===0?s.jsx(ie,{children:"No other skills."}):s.jsx(at,{flush:!0,children:s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"What it is for"}),s.jsx("th",{children:"Whose"})]})}),s.jsx("tbody",{children:v.map(j=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(St,{summary:s.jsx("span",{className:"mono",children:j.name}),children:[s.jsx(ft,{children:j.body}),s.jsx("p",{className:"muted mono skill-file",children:j.file})]})}),s.jsx("td",{children:j.description}),s.jsx("td",{children:s.jsxs(K,{gap:"sm",children:[s.jsx(pe,{children:j.scope==="shared"?"shared":`${t} only`}),s.jsx("span",{className:"muted",children:JD(j)})]})})]},`${j.scope}:${j.name}`))})]})})})]})}function JD(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function XD({skill:e,busy:t,onRemove:n}){const r=e.learned;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(St,{summary:s.jsxs("span",{children:[r.title," ",s.jsx("span",{className:"muted mono",children:e.name})]}),children:[s.jsxs("p",{className:"muted",children:["When: ",e.description]}),s.jsx(ft,{children:e.body}),s.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),s.jsx("td",{children:s.jsxs(K,{gap:"sm",children:[s.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?s.jsx(pe,{tone:"warning",children:"untrusted text in view"}):null]})}),s.jsx("td",{children:s.jsxs(K,{gap:"sm",children:[r.conversation?s.jsx("a",{href:zi(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):s.jsx("span",{className:"muted",children:"no conversation"}),s.jsx("a",{href:lt("proposals"),children:"the proposal"}),r.sources.length>0?s.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>s.jsx("li",{className:"mono",children:i},i))}):null]})}),s.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?ke(r.keptAt,Date.now()):""}),s.jsx("td",{className:"num",children:s.jsx(q,{align:"end",children:s.jsx(R,{size:"sm",variant:"ghost",disabled:t,onClick:n,children:"Remove"})})})]})}function cS({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:o}=se(()=>A.reminders(),[],3e4),l=((r==null?void 0:r.reminders)??[]).filter(p=>!n||p.agentId===n),[a,c]=d.useState(null),u=async p=>{c(null);try{await A.cancelReminder(p),o()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.jsxs(cn,{embedded:t,title:"Reminders",lede:"A reminder wakes an agent with a note and the instruction to check before it speaks, never a message queued for delivery.",children:[s.jsx(re,{message:i??a}),s.jsx(at,{flush:!0,children:r?l.length===0?s.jsx(kt,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Due"}),s.jsx("th",{children:"Agent"}),s.jsx("th",{children:"Note"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:l.map(p=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Ie(p.dueAt,e),s.jsx("div",{className:"sub",children:ke(p.dueAt)})]}),s.jsx("td",{className:"mono",children:p.agentId}),s.jsxs("td",{children:[p.text,p.context?s.jsx(St,{summary:"context",children:s.jsx(ft,{children:on(p.context)})}):null]}),s.jsxs("td",{children:[s.jsx(xu,{state:p.state}),p.cancelReason?s.jsx("div",{className:"sub",children:p.cancelReason}):null]}),s.jsx("td",{children:p.state==="pending"?s.jsx(R,{size:"sm",variant:"danger",onClick:()=>u(p.id),children:"Cancel"}):null})]},p.id))})]}):s.jsx(ie,{children:"Loading…"})})]})}function Bm({accountId:e,label:t,value:n,onChange:r,disabled:i=!1}){const[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(""),[f,h]=d.useState(!1),v=d.useRef(0),j=async g=>{if(!e)return;const y=++v.current;c(!0),p("");try{const m=await A.accountModels(e,g);y===v.current&&l(m)}catch(m){y===v.current&&p(m instanceof Error?m.message:"Could not load models. Custom entry is still available.")}finally{y===v.current&&c(!1)}};if(d.useEffect(()=>(l(null),h(!1),p(""),j(!1),()=>{v.current++}),[e]),!e)return s.jsxs(s.Fragment,{children:[s.jsx(X,{label:t,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:g=>r(g.target.value)})}),s.jsx("p",{className:"ui-toolbar-note",children:"Save and connect the account to load its model list. You can enter a model manually now."})]});const w=(o==null?void 0:o.models)??[],b=!!n&&!w.some(g=>g.id===n),x=[o&&!w.length?"This account returned no models. You can enter a custom model.":null,o!=null&&o.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,o?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(X,{label:t,children:s.jsxs("select",{value:f?"__buddi_custom__":n,disabled:i,onChange:g=>{g.target.value==="__buddi_custom__"?h(!0):(h(!1),r(g.target.value))},children:[s.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),b&&s.jsxs("option",{value:n,children:[n," (current",o?", not listed":"",")"]}),w.map(g=>s.jsxs("option",{value:g.id,children:[g.name===g.id?g.id:`${g.name} — ${g.id}`,g.isDefault?" (provider default)":""]},g.id)),s.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),s.jsx(R,{disabled:i||a,onClick:()=>void j(!0),children:a?"Loading models…":"Refresh models"}),f&&s.jsx(X,{label:`Custom ${t.toLowerCase()}`,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:g=>r(g.target.value)})}),u&&s.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),x.length>0&&s.jsx("p",{className:"ui-toolbar-note",children:x.join(" ")})]})}function ZD(e,t){const n=new Set(t),r=[],i=new Set;for(const o of e){for(const a of o.tools)i.add(a.name);const l=o.tools.filter(a=>n.has(a.name));l.length!==0&&(o.glob&&l.length===o.tools.length?r.push(o.glob):r.push(...l.map(a=>a.name)))}return r.push(...t.filter(o=>!i.has(o))),r}function eL(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const tL="This agent will not remember anything between conversations.";function nL({view:e,chosen:t,onChange:n,disabled:r}){var S;const[i,o]=d.useState(""),[l,a]=d.useState(null),[c,u]=d.useState(()=>new Set),p=k=>u(N=>{const C=new Set(N);return C.has(k)?C.delete(k):C.add(k),C}),f=k=>{o(k),u(new Set)},h=d.useId(),v=new Set(t),j=new Set(e.groups.flatMap(k=>k.tools.filter(N=>N.core).map(N=>N.name))),w=(k,N)=>{const C=N.filter(P=>v.has(P));if(C.length!==0){if(C.some(P=>j.has(P))){a({plugin:k,names:C});return}n(t.filter(P=>!C.includes(P)))}},b=k=>{n([...t,...k.filter(N=>!v.has(N))])},x=i.trim().toLowerCase(),g=(k,N)=>x===""||k.toLowerCase().includes(x)||N.toLowerCase().includes(x),y=e.groups.map(k=>({group:k,tools:k.tools.filter(N=>g(N.name,N.description))})).filter(k=>k.tools.length>0),m=(((S=e.suggested)==null?void 0:S.tools)??[]).filter(k=>!v.has(k.name));return s.jsxs("div",{className:"tool-picker",children:[e.suggested&&m.length>0?s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${h}-suggested`,children:[s.jsx("div",{className:"tool-picker-head",children:s.jsx("span",{id:`${h}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),s.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:m.map(k=>s.jsxs("li",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title mono",children:k.name}),s.jsx("span",{className:"ui-list-sub",children:k.description})]}),s.jsx(R,{size:"sm",disabled:r,"aria-label":`Add ${k.name}`,onClick:()=>b([k.name]),children:"Add"})]},k.name))})]}):null,s.jsxs("label",{className:"tool-picker-search",children:[s.jsx("span",{className:"ui-field-label",children:"Find a tool"}),s.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:k=>f(k.target.value)})]}),y.length===0?s.jsxs(ie,{children:["No installed tool matches “",i.trim(),"”."]}):null,y.map(({group:k,tools:N})=>{const C=k.tools.filter(T=>T.grantable).map(T=>T.name),P=k.tools.filter(T=>v.has(T.name)).length,E=!!k.glob&&P===k.tools.length,O=`${h}-${k.plugin}`,F=`${h}-${k.plugin}-list`,D=x!==""?!c.has(k.plugin):c.has(k.plugin);return s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":O,"data-open":D?"true":void 0,children:[s.jsxs("div",{className:"tool-picker-head",children:[s.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":D,"aria-controls":F,onClick:()=>p(k.plugin),children:[s.jsx(sL,{}),s.jsx("span",{id:O,className:"tool-picker-plugin",children:k.plugin}),s.jsx("span",{className:"muted",children:E?`all ${k.tools.length}`:`${P} of ${k.tools.length} granted`})]}),s.jsx(R,{size:"sm",variant:"ghost","aria-label":`All ${k.plugin} tools`,disabled:r||C.every(T=>v.has(T)),onClick:()=>b(C),children:"all"}),s.jsx(R,{size:"sm",variant:"ghost","aria-label":`No ${k.plugin} tools`,disabled:r||!C.some(T=>v.has(T)),onClick:()=>w(k.plugin,C),children:"none"})]}),(l==null?void 0:l.plugin)===k.plugin?s.jsx(H,{tone:"warning",role:"alert",children:s.jsxs("div",{className:"tool-picker-confirm",children:[s.jsx("span",{children:tL}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{size:"sm",onClick:()=>a(null),children:"Keep"}),s.jsx(R,{size:"sm",variant:"danger",onClick:()=>{n(t.filter(T=>!l.names.includes(T))),a(null)},children:"Remove"})]})}):null,s.jsx("ul",{id:F,className:"ui-list tool-picker-list",hidden:!D,children:N.map(T=>{const z=`${h}-${T.name}`;return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:z,checked:v.has(T.name),disabled:r||!T.grantable,onChange:Q=>Q.target.checked?b([T.name]):w(k.plugin,[T.name])}),s.jsxs("label",{htmlFor:z,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[s.jsx("span",{className:"mono",children:T.name}),T.core?s.jsx(pe,{tone:"accent",children:"core"}):null,T.gated?s.jsx(pe,{tone:"warning",children:"asks you"}):null]}),s.jsx("span",{className:"ui-list-sub",children:T.grantable?T.description:`${T.description} Granted only by editing the file by hand.`})]})]},T.name)})})]},k.plugin)})]})}function sL(){return s.jsx("svg",{className:"tool-picker-chevron",viewBox:"0 0 11 11","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const rL="buddi",iL=["core","coding","finance","garage","mail","maker","playground","research"],Tl=e=>`./mascot/${e}.png`,oL=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],lL="Introduce yourself by name, say one thing you can do today, and ask one question.",L={opening:["Hi. I'm buddi. I live on this computer, and I'm about to introduce you to your first assistant.","Nothing you tell me leaves this machine, except what your assistant sends to the AI you pick in a minute."],later:"Set up later",name:{ask:"First, what should we call you?",placeholder:"Your first name",submit:"That's me"},clock:{ask:(e,t)=>`Nice to meet you, ${e}. I'll set your clock to ${t}, which is what this browser says. Right?`,yes:"Yes",another:"Pick another",label:"Your clock",answer:e=>e},brain:{ask:"Your assistant needs a brain: an AI it thinks with. Which of these do you already have?",cards:{claude:{title:"Claude",line:"I pay for Claude",know:"Uses your Claude plan's monthly Agent SDK credits; after them, an API key."},chatgpt:{title:"ChatGPT",line:"I pay for ChatGPT",know:"Uses your ChatGPT plan through OpenAI's Codex backend. Sign in with a code."},key:{title:"A key from Anthropic or OpenAI",line:"I have an API key"},ollama:{title:"Ollama",line:"Free, on this computer"},cloud:{title:"Ollama Cloud, one tap",line:"Free to start, no key"},service:{title:"Another service, or Ollama Cloud with a key",line:"I have an address and a key"}},claude:{start:"Sign in with Claude",open:"Open the Claude sign-in page",paste:"Paste what Claude gave you",finish:"Done",waiting:"Sign in, then paste the code Claude shows you."},chatgpt:{label:"ChatGPT",codeBefore:"Here is your code: ",codeAfter:". Open the link, enter it, and approve buddi on openai.com.",code:"Your code",open:"Open openai.com",again:"Try again",failed:"The sign-in did not finish. Try again."},cloud:{label:"Ollama Cloud",waiting:"Press Connect on the ollama.com page. Sign in there first if it asks. I will notice.",open:"Open the ollama.com page",again:"Try again"},key:{field:"Your key",placeholder:"Paste it here",submit:"Use this key",which:"Not right?",anthropic:"Anthropic",openai:"OpenAI",refused:"That key was refused. Check it and paste it again."},ollama:{found:"Found it, running now",missing:"Install Ollama, then come back",connect:"Use Ollama",download:"Get Ollama",looking:"Looking for it on this computer…"},model:{ask:"Which one should it think with?",label:"The model",submit:"Use this one",change:"Think with another"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking Ollama…",cloud:"Asking Ollama Cloud…",claude:"Checking with Claude…",chatgpt:"Asking ChatGPT…"},back:"Back",service:{address:"Address",addressPlaceholder:"The address they gave you",key:"Key",submit:"Connect it"},works:e=>`That works. Your assistant will think with ${e}.`,refused:e=>e,answer:e=>e},browser:{chrome:"Your assistant will browse with Google Chrome.",chromium:"Your assistant will browse with its own Chromium.",needs:"Your assistant needs a browser of its own to look at websites. I am fetching one now, about 150 MB.",installing:"Fetching the browser…",launching:"Making sure it opens…",installed:"Installed.",skip:"Skip for now",skipped:"Skipped. Settings → Computer & browser can install it whenever you like.",missing:"No browser for your assistant yet. Settings → Computer & browser can install one.",failed:e=>`That did not work: ${e}`,retry:"Try again"},assistant:{ask:"Last thing: your assistant. I've picked a name and a face; change either, or keep them.",name:"Name",face:"A face",mascot:e=>e==="core"?"Buddi Blob":`Buddi Blob, ${e}`,purpose:"What should it help you with?",purposeValue:["You're not a chatbot. You're becoming someone this person can count on.","","Some starting truths:","",`- Help for real. No "Great question", no "I'd be happy to". Do the thing, then say what you did.`,"- Have a view. Prefer things, disagree when you should, say when something is a bad idea. A search engine with manners is not a colleague.","- Look before you ask. Read the file, check what you remember, try it. Come back with an answer and one question at most.","- You are a guest here. You can see messages, files and a calendar. Treat that with care, keep what you learn to yourself, and never lecture.","- Remember what matters. Names, preferences, the things they said once and expect you to keep.","- When you change how you work, say so. This file is yours to grow, and the owner should always know what it says."].join(`
107
- `),submit:"Introduce us"},restore:{offer:"I have a backup from another buddi",file:"The backup file",passphrase:"Its passphrase",passphraseHint:"Only if it was locked with one.",submit:"Restore",cancel:"Never mind",started:"Right. Give me a couple of minutes.",phases:{stopping:"Putting everything down for a moment.",snapshot:"Keeping a copy of what is here now, just in case.",database:"Bringing back your conversations and everything you told it to remember.",recovery:"Almost there. Nothing will run on its own until you say so.",files:"Bringing back your files.",starting:"Starting back up.",done:"That is everything.","rolled-back":"That did not work, so I put everything back the way it was.",failed:"That did not work."},welcome:e=>`Welcome back, ${e}.`,keys:"A backup never carries keys, so the AI you think with needs its key one more time."},tagline:"Setting up, on this Mac.",taglineElsewhere:"Setting up, on this computer.",handover:{waiting:"One moment.",looking:e=>`${e} is looking around…`,slow:"Still waking up. A brain on this computer takes a minute the first time.",silent:"Your assistant isn't answering. The AI you picked may be down; try again, or pick another brain above.",again:"Pick another brain"},offers:{phone:"Talk to me from your phone",notNow:"Not now"},done:{said:"You're all set. This conversation carries on in your dashboard.",leaving:"Opening buddi…",ready:"Ready when you are.",open:"Open buddi"},telegram:{how:"Two minutes: open Telegram, message @BotFather, send /newbot, paste the token it gives you here.",field:"The token",submit:"Save it",restart:"Saved. It will be ready the next time buddi starts.",scan:"Scan this with your phone and press Start.",expired:"That code has run out. I can make you another one.",newCode:"Show a new code",paired:"That is your phone, talking to me. You can close this and carry on there."},change:"change"},aL=(e,t)=>!!e&&!!t&&e.kind===t.kind&&(e.kind==="mascot"?e.role===t.role:e.kind==="emoji"?e.value===t.value:!0);async function uS(e){const t=await fetch(Tl(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const n=await t.blob();return new File([n],`buddi-blob-${e}.png`,{type:"image/png"})}function dS({face:e,onPick:t,label:n=L.assistant.face,kept:r,disabled:i,disableEmoji:o,children:l}){return s.jsxs("div",{className:"meet-faces",role:"group","aria-label":n,children:[s.jsxs("div",{className:"meet-face-row",children:[r?s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":(e==null?void 0:e.kind)==="kept"?"true":void 0,"aria-pressed":(e==null?void 0:e.kind)==="kept","aria-label":"The current picture",disabled:i,onClick:()=>t({kind:"kept",url:r}),children:s.jsx("img",{src:r,alt:""})}):null,iL.map(a=>{const c={kind:"mascot",role:a},u=aL(e,c);return s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":L.assistant.mascot(a),disabled:i,onClick:()=>t(c),children:s.jsx("img",{src:Tl(a),alt:""})},a)})]}),s.jsx("div",{className:"meet-face-row",children:oL.map(a=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===a;return s.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||o,onClick:()=>t({kind:"emoji",value:a}),children:a},a)})}),l]})}const cL=["mirror","en","fr"],fS=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"access",label:"Access"}],ej=e=>{var t;return((t=fS.find(n=>n.id===e))==null?void 0:t.id)??"identity"};function uL({agentId:e,section:t,navigate:n}){var w,b,x;const{data:r,error:i,reload:o}=se(()=>A.agents(),[]),[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(ej(t));d.useEffect(()=>f(ej(t)),[t]);const h=g=>{f(g),n==null||n(mt(e,"setup",g))},v=async g=>{a(null),u(null);try{const y=await g;u(y.changed.length===0?`No file change needed. ${y.note}.`:`Changed ${y.changed.join(", ")}. ${y.note}.`),o()}catch(y){a(y instanceof Error?y.message:String(y))}},j=r==null?void 0:r.agents.find(g=>g.id===e);return s.jsxs(K,{gap:"lg",children:[s.jsx(ju,{level:"secondary",label:"Setup",children:fS.map(g=>s.jsx(yu,{href:mt(e,"setup",g.id),active:p===g.id,onClick:y=>{y.preventDefault(),h(g.id)},children:g.label},g.id))}),s.jsx(re,{message:i??l}),c?s.jsx(H,{tone:"good",role:"status",children:c}):null,r?j?s.jsx(dL,{agent:j,all:r.agents,engine:r.engines.find(g=>g.id===j.id),providers:r.providers,accounts:r.providerAccounts,shown:p,onShow:h,onRun:v,onSaved:o},`${j.id}:${(w=r.engines.find(g=>g.id===j.id))==null?void 0:w.model}:${(x=(b=r.providerAccounts)==null?void 0:b.bindings.find(g=>g.agentId===j.id))==null?void 0:x.accountId}`):s.jsx(ie,{children:"This agent is not installed as a file."}):s.jsx(ie,{children:"Loading…"})]})}function dL({agent:e,all:t,engine:n,providers:r,accounts:i,shown:o,onShow:l,onRun:a,onSaved:c}){const u=(n==null?void 0:n.provider)??e.provider.kind,p=r.find(m=>m.kind===u),f=(n==null?void 0:n.model)??e.model,[h,v]=d.useState(String((n==null?void 0:n.maxTurns)??e.maxTurns)),j=m=>{a(A.setAgentEngine(e.id,m))},w=m=>{const S=r.find(k=>k.kind===m);j({provider:m,model:(S==null?void 0:S.defaultModel)??f})},b=(p==null?void 0:p.models.map(m=>m.id))??[],x=b.includes(f)?b:[f,...b],g=n?n.available:!0,y=(n==null?void 0:n.unavailableReason)??"no credential";return s.jsxs(s.Fragment,{children:[s.jsx("div",{hidden:o!=="identity",children:s.jsxs(K,{gap:"lg",children:[g?null:s.jsxs(H,{tone:"warning",children:["This agent cannot run right now."," ",s.jsx("a",{href:mt(e.id,"setup","brain"),onClick:m=>{m.preventDefault(),l("brain")},children:"See Brain."})]}),s.jsx(fL,{agent:e,onSaved:c})]})}),s.jsx("div",{hidden:o!=="brain",children:s.jsxs(K,{gap:"lg",children:[g?null:s.jsxs(H,{tone:"warning",children:["This agent cannot run right now: ",y,"."]}),s.jsx(G,{panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsxs(G,{title:"Runs on",children:[i?s.jsx(gL,{agentId:e.id,accounts:i,onRun:a}):s.jsxs(Ps,{children:[s.jsx(X,{label:"Provider",children:s.jsx("select",{value:u,onChange:m=>w(m.target.value),children:r.map(m=>s.jsxs("option",{value:m.kind,children:[m.kind,m.usable?"":" (no credential)"]},m.kind))})}),s.jsxs(X,{label:"Model",children:[s.jsx("input",{list:`models-${e.id}`,defaultValue:f,onBlur:m=>{m.target.value.trim()!==""&&m.target.value.trim()!==f&&j({model:m.target.value.trim()})}}),s.jsx("datalist",{id:`models-${e.id}`,children:x.map(m=>s.jsx("option",{value:m},m))})]})]}),i?null:s.jsxs("p",{className:"ui-card-meta",children:[(n==null?void 0:n.credentialKind)??e.provider.credentialKind," from"," ",s.jsx("span",{className:"mono",children:(n==null?void 0:n.credentialEnv)??e.provider.credentialEnv}),p&&!p.usable?` · default model ${p.defaultModel} (${p.defaultFrom})`:""]}),n!=null&&n.restartRequired?s.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),s.jsx(G,{title:"Behaviour",aside:"saved as you change them",children:s.jsxs(Ps,{children:[s.jsx(X,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:s.jsx("input",{type:"number",min:1,value:h,onChange:m=>v(m.target.value),onBlur:()=>{const m=Number(h);Number.isInteger(m)&&m>=1&&m!==((n==null?void 0:n.maxTurns)??e.maxTurns)&&j({maxTurns:m})}})}),s.jsx(X,{label:"Language",hint:"Mirror answers in whatever language you write.",children:s.jsx("select",{value:(n==null?void 0:n.language)??e.language,onChange:m=>j({language:m.target.value}),children:cL.map(m=>s.jsx("option",{value:m,children:m},m))})}),Bb(Wb(n??{id:e.id,provider:u},i))?s.jsx(X,{label:"Thinking",hint:"Reasoning before the answer. Off is faster and cheaper.",children:s.jsxs("select",{"aria-label":"Thinking",value:(n==null?void 0:n.thinking)??"default",onChange:m=>j({thinking:m.target.value==="default"?null:m.target.value}),children:[s.jsx("option",{value:"default",children:"Model default"}),s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})}):s.jsx(X,{label:"Thinking",hint:WT,children:s.jsx("span",{className:"ui-card-meta",children:"Up to the model"})})]})})]})})]})}),s.jsx("div",{hidden:o!=="access",children:s.jsxs(K,{gap:"lg",children:[s.jsx(hL,{agent:e,all:t,onSaved:c}),s.jsx(jL,{agent:e,all:t,onSaved:c}),s.jsx(St,{summary:"Built-in context",boxed:!0,children:s.jsx("p",{className:"ui-card-meta",children:"Every agent receives current time, owner timezone and server-host information. system.time and system.info are always available, without grants or approval. Host and browser access still require their own permissions."})})]})})]})}function hS({dirty:e,busy:t,failure:n,label:r,onSave:i}){return s.jsxs(s.Fragment,{children:[n?s.jsx("span",{className:"critical save-error",role:"alert",children:n}):s.jsx("span",{className:e?"warning":"muted",children:e?"Not saved yet.":"Saved. Applies to new runs."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{variant:"accent",disabled:!e||t,onClick:i,children:r})]})}const pS=s.jsx(H,{tone:"warning",children:"This agent ships with buddi, so its file is read-only here. Ask Agent Father to make it yours, then these fields can change."});function fL({agent:e,onSaved:t}){var D;const[n,r]=d.useState(e.name),[i,o]=d.useState(e.handle),[l,a]=d.useState(e.description),[c,u]=d.useState(e.avatar??""),[p,f]=d.useState(!1),h=se(()=>A.agentFile(e.id),[e.id]),[v,j]=d.useState(null),w=((D=h.data)==null?void 0:D.persona.trim())??"",b=v??w,x=h.data!==void 0&&v!==null&&v.trim()!==w,[g,y]=d.useState(!1),[m,S]=d.useState(null),[k,N]=d.useState(null),C=n.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||l.trim()!==e.description||c.trim()!==(e.avatar??"")||x,P=c.trim()!==""&&(c.trim()!==(e.avatar??"")||!e.picture),E=Ih(P?{...e,avatar:c.trim()}:e),O={...E?{avatar:E}:{},...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...!P&&e.picture?{picture:e.picture}:{}},F=async()=>{y(!0),S(null),N(null);try{const T=await A.updateAgentFile(e.id,{name:n.trim(),handle:i.trim().replace(/^@/,""),description:l.trim(),...c.trim()===""?{}:{avatar:c.trim()},...x&&b.trim()!==""?{persona:b.trim()}:{}});e.picture&&c.trim()!==""&&c.trim()!==(e.avatar??"")&&(await A.removeAgentPicture(e.id),window.dispatchEvent(new Event(cl))),j(null),h.reload(),N(T.message),t()}catch(T){S(T instanceof Error?T.message:String(T))}finally{y(!1)}};return s.jsx(G,{title:"Who it is",aside:s.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:s.jsx(hS,{dirty:C,busy:g,failure:m,label:"Save who it is",onSave:()=>void F()}),children:s.jsxs(K,{children:[e.isExample?pS:null,k?s.jsx(H,{tone:"good",role:"status",children:k}):null,s.jsxs(Ps,{children:[s.jsx(X,{label:"Name",hint:"What it is called, everywhere.",children:s.jsx("input",{value:n,disabled:g||e.isExample,onChange:T=>r(T.target.value)})}),s.jsx(X,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:s.jsx("input",{value:i,disabled:g||e.isExample,onChange:T=>o(T.target.value)})})]}),s.jsxs(q,{children:[s.jsx(us,{id:e.id,name:n.trim()||e.name,size:"xl",face:O}),s.jsx(R,{"aria-expanded":p,onClick:()=>f(T=>!T),children:p?"Hide faces":"Change face"})]}),p?s.jsx(pL,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:g}):null,s.jsx(X,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:s.jsx("textarea",{rows:2,value:l,disabled:g||e.isExample,onChange:T=>a(T.target.value)})}),s.jsx(X,{label:"Persona",hint:s.jsxs(s.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",s.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:h.error?s.jsx(re,{message:h.error}):h.data?s.jsx("textarea",{className:"setup-persona",value:b,rows:Math.max(6,b.split(`
108
- `).length+1),disabled:g||e.isExample,onChange:T=>j(T.target.value)}):s.jsx(ie,{children:"Reading its file…"})})]})})}function hL({agent:e,all:t,onSaved:n}){var P;const r=se(()=>A.agentTools(e.id),[e.id]),[i,o]=d.useState(null),[l,a]=d.useState(()=>new Set((e.roles??[]).filter(pv))),[c,u]=d.useState((e.roles??[]).filter(E=>!pv(E)).join(", ")),[p,f]=d.useState(!1),[h,v]=d.useState(null),[j,w]=d.useState(null),b=(E,O)=>E.split(O).map(F=>F.trim()).filter(F=>F!==""),x=((P=r.data)==null?void 0:P.granted)??e.tools,g=i??x,y=r.data!==void 0&&!eL(g,x),m=mv(l,b(c,/[\n,]/)),S=E=>a(O=>{const F=new Set(O);return F.has(E)?F.delete(E):F.add(E),F}),N=y||!((E,O)=>E.join(",")===O.join(","))(m,mv(new Set(e.roles??[]),e.roles??[])),C=async()=>{f(!0),v(null),w(null);try{const E=await A.updateAgentFile(e.id,{...y&&r.data?{tools:ZD(r.data.groups,g)}:{},roles:m});w(E.message),o(null),r.reload(),n()}catch(E){v(E instanceof Error?E.message:String(E))}finally{f(!1)}};return s.jsx(G,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:s.jsx(hS,{dirty:N,busy:p,failure:h,label:"Save roles and tools",onSave:()=>void C()}),children:s.jsxs(K,{children:[e.isExample?pS:null,j?s.jsx(H,{tone:"good",role:"status",children:j}):null,s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",id:`roles-${e.id}`,children:"Roles"}),s.jsx("div",{className:"role-chips",role:"group","aria-labelledby":`roles-${e.id}`,children:vm.map(E=>{const O=LI(t,E.id),F=O&&O.id!==e.id?O:void 0;return s.jsxs("button",{type:"button",className:"role-chip","aria-pressed":l.has(E.id),"data-on":l.has(E.id)?"true":void 0,disabled:p||e.isExample,onClick:()=>S(E.id),children:[s.jsx("span",{className:"role-chip-label",children:E.label}),s.jsx("span",{className:"role-chip-meaning",children:E.meaning}),F?s.jsxs("span",{className:"role-chip-holder",children:["Held by ",F.name,". If both claim it, the one listed first keeps it."]}):null]},E.id)})}),s.jsx("span",{className:"ui-field-hint",children:"Where buddi sends things when you do not say who. Tools are granted below."})]}),s.jsx(X,{label:"Other roles",hint:"Only a plugin that asks for a role by name reads these. Comma separated.",children:s.jsx("input",{value:c,disabled:p||e.isExample,onChange:E=>u(E.target.value)})}),s.jsxs("div",{className:"ui-field",children:[s.jsxs("span",{className:"ui-field-label",children:["Tools · ",x.length," granted"]}),r.error?s.jsx(re,{message:r.error}):r.data?s.jsx(nL,{view:r.data,chosen:g,onChange:o,disabled:p||e.isExample}):s.jsx(ie,{children:"Loading the installed tools…"})]})]})})}function Ih(e){if(e.avatar)return/^[A-Za-z0-9_-]+\.(png|jpe?g|gif|webp)$/i.test(e.avatar)?{kind:"image",url:`/api/agents/${encodeURIComponent(e.id)}/avatar`}:{kind:"emoji",value:e.avatar.slice(0,8)}}function pL({agent:e,avatar:t,onEmoji:n,onChanged:r,disabled:i}){const[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(null),f=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),h=o??(f?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),v=async j=>{if(p(null),j.kind==="emoji"){n(j.value);return}if(j.kind==="kept"){n(e.avatar??"");return}l(j),c(!0);try{await A.uploadAgentPicture(e.id,await uS(j.role)),n(e.avatar??""),r(),window.dispatchEvent(new Event(cl))}catch(w){p(w instanceof Error?w.message:String(w))}finally{l(null),c(!1)}};return s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Face"}),s.jsx(dS,{face:h,label:"Face",kept:e.picture,disabled:i||a,disableEmoji:e.isExample,onPick:j=>void v(j),children:s.jsx(mL,{agent:e,onChanged:r})}),u?s.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function mL({agent:e,onChanged:t}){const[n,r]=d.useState(null),[i,o]=d.useState(null),[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null),[h,v]=d.useState(0);d.useEffect(()=>{if(!n)return o(null);const N=URL.createObjectURL(n);return o(N),()=>URL.revokeObjectURL(N)},[n]);const j=N=>{r(null),v(C=>C+1),f(N),t(),window.dispatchEvent(new Event(cl))},w=async N=>{a(!0),u(null),f(null);try{j(await N())}catch(C){u(C instanceof Error?C.message:String(C))}finally{a(!1)}},b=()=>w(async()=>(await A.uploadAgentPicture(e.id,n)).note??null),x=()=>w(async()=>(await A.removeAgentPicture(e.id),null)),g={avatar:Ih(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[y,m]=d.useState(!1),S=d.useRef(null),k=N=>{u(null),f(null),r(N??null)};return s.jsxs("div",{className:"setup-upload","data-dragging":y?"true":void 0,onDragOver:N=>{N.preventDefault(),l||m(!0)},onDragLeave:()=>m(!1),onDrop:N=>{var C;N.preventDefault(),m(!1),l||k((C=N.dataTransfer.files)==null?void 0:C[0])},children:[s.jsxs(q,{children:[s.jsx(us,{id:e.id,name:e.name,size:"xl",face:g}),s.jsx("input",{ref:S,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:l,onChange:N=>{var C;return k((C=N.target.files)==null?void 0:C[0])}},h),s.jsx(R,{disabled:l,onClick:()=>{var N;return(N=S.current)==null?void 0:N.click()},children:"Upload a picture"}),s.jsx("span",{className:"setup-upload-name",children:n?n.name:"or drop one here"}),s.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!n?s.jsx(R,{variant:"ghost",disabled:l,onClick:()=>void x(),children:"Remove picture"}):null,s.jsx(R,{variant:"accent",disabled:!n||l,onClick:()=>void b(),children:"Save picture"})]}),c?s.jsx("span",{className:"critical save-error",role:"alert",children:c}):s.jsx("span",{className:"ui-field-hint",children:p??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function gL({agentId:e,accounts:t,onRun:n}){const r=t.bindings.find(v=>v.agentId===e),[i,o]=d.useState((r==null?void 0:r.accountId)??""),[l,a]=d.useState((r==null?void 0:r.model)??""),[c,u]=d.useState(!1),p=t.accounts.find(v=>v.id===i),f=i!==((r==null?void 0:r.accountId)??"")||l!==((r==null?void 0:r.model)??""),h=t.accounts.find(v=>v.id===(r==null?void 0:r.accountId));return s.jsxs("div",{className:"ui-stack",children:[s.jsxs(q,{valign:"end",children:[s.jsx(X,{label:"Account",children:s.jsxs("select",{value:i,disabled:c,onChange:v=>{var j;o(v.target.value),a(((j=t.accounts.find(w=>w.id===v.target.value))==null?void 0:j.defaultModel)??"")},children:[s.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(v=>s.jsxs("option",{value:v.id,disabled:!v.enabled,children:[v.label,v.enabled?v.configured?"":" (needs credential)":" (disabled)"]},v.id))]})}),s.jsx(Bm,{accountId:p!=null&&p.configured?i:void 0,label:"Model",value:l,onChange:a,disabled:c},`${i}:${p==null?void 0:p.revision}`)]}),s.jsxs(q,{children:[f&&i&&l.trim()?s.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",h?`${h.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):s.jsx("span",{className:"muted",children:h?`Running on ${h.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{variant:"accent",disabled:c||!i||!l.trim()||!f,onClick:()=>{u(!0),n(A.assignProviderAccount(e,i,l).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const xL=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],vL=e=>e.tools.some(t=>xL.includes(t));function jL({agent:e,all:t,onSaved:n}){const[r,i]=d.useState(e.delegates),[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(!1),[f,h]=d.useState(e.delegates),v=t.filter(g=>g.id!==e.id),j=[...r].sort().join(",")!==[...f].sort().join(","),w=t.filter(g=>g.id!==e.id&&g.delegates.includes(e.id)),b=g=>i(y=>y.includes(g)?y.filter(m=>m!==g):[...y,g]),x=async()=>{l(!0),c(null),p(!1);try{const g=await A.setDelegates(e.id,r);h(g.delegates),i(g.delegates),p(!0),n()}catch(g){c(g instanceof Error?g.message:String(g))}finally{l(!1)}};return s.jsx(G,{title:"Delegation",aside:e.tools.includes("agent.delegate")?"holds agent.delegate":"no agent.delegate tool: it cannot ask anyone until granted",panel:!0,foot:e.isExample?void 0:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:j?"warning":"muted",children:j?"Not saved yet.":u?"Saved. Applies to the next run.":r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{variant:"accent",disabled:!j||o,onClick:()=>void x(),children:"Save who it can ask"})]}),children:s.jsxs(K,{divided:!0,children:[s.jsxs(G,{title:"Can ask",children:[e.isExample?s.jsx(H,{tone:"warning",children:"This agent ships with buddi, so its allowlist is read-only here. Ask Agent Father to make it yours, then it can change."}):null,s.jsx(re,{message:a}),v.length===0?s.jsx(ie,{children:"Nobody else is installed."}):s.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:v.map(g=>{const y=vL(g);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${g.id}`,checked:r.includes(g.id),disabled:y||e.isExample||o,onChange:()=>b(g.id)}),s.jsxs("label",{htmlFor:`can-ask-${e.id}-${g.id}`,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[g.name," ",s.jsxs("span",{className:"mono muted",children:["@",g.handle]})]}),s.jsx("span",{className:"ui-list-sub",children:y?"Makes and changes agents. Never reachable by delegation.":g.description})]})]},g.id)})})]}),s.jsx(G,{title:"Asked by",children:w.length===0?s.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):s.jsx(V2,{children:w.map(g=>s.jsx(pe,{children:g.name},g.id))})})]})})}const yL=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],wL=[{id:"conversations",label:"Conversations"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"},{id:"memory",label:"Memory"},{id:"skills",label:"Skills"},{id:"setup",label:"Setup"}];function bL({hash:e,timezone:t,navigate:n,agents:r,attention:i,defaultAgentId:o}){var b,x,g,y,m;const l=CI(e),a=((b=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:b[1])??"team",c=S=>k=>{k.preventDefault(),n(S)},u=se(()=>A.agents(),[]),p=Mm(),f=se(()=>A.offers(),[],2e4),h=Rk(),v=(((x=f.data)==null?void 0:x.offers.length)??0)+h.offers.length,j=((y=(g=u.data)==null?void 0:g.default)==null?void 0:y.defaultAgentId)??o??null,w=r.find(S=>S.roles.includes(jm));return s.jsxs("div",{className:"ui-page",children:[s.jsx(km,{title:"Agents",lede:`Your team. Each one is a file on ${p} — what it can reach is listed on its page.`,actions:w?s.jsx(ln,{variant:"accent",href:Be(w.id),onClick:c(Be(w.id)),children:"Add an agent"}):null}),s.jsx(ju,{children:yL.map(S=>s.jsx(yu,{href:S.id==="team"?rt:`${rt}?tab=${S.id}`,active:a===S.id,count:S.id==="offers"?v:void 0,onClick:c(S.id==="team"?rt:`${rt}?tab=${S.id}`),children:S.label},S.id))}),a==="missions"?s.jsx(sS,{timezone:t,embedded:!0}):null,a==="offers"?s.jsx(Pk,{offers:h.offers,reload:h.reload}):null,a==="offers"?s.jsx(iS,{embedded:!0}):null,a==="reminders"?s.jsx(cS,{timezone:t,embedded:!0}):null,a==="team"?s.jsx(kL,{data:u.data,error:u.error,reload:u.reload}):null,a==="team"?r.length===0?s.jsx(kt,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):s.jsx("div",{className:"agents-grid",children:F0(r,j).map(S=>{const k=gu(i.get(S.id));return s.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...Cl(Nl(S)),"data-unavailable":S.available?void 0:"true",children:[s.jsx("div",{className:"agent-card-top"}),s.jsx("div",{className:"agent-card-face",children:s.jsx(us,{id:S.id,name:S.name,size:"xl",unavailable:!S.available,face:S})}),s.jsxs("div",{children:[s.jsxs("div",{className:"ui-card-title",children:[s.jsx("a",{className:"agent-card-link",href:mt(S.id,"conversations"),onClick:c(mt(S.id,"conversations")),children:S.name}),s.jsxs("span",{className:"agent-card-handle mono faint",children:["@",S.handle]})]}),s.jsx("p",{className:"ui-card-meta agent-card-desc",children:S.description})]}),s.jsxs("div",{className:"ui-row",children:[S.id===j?s.jsx(Ka,{children:"front desk"}):null,k?s.jsx(pe,{tone:"critical",dot:!0,children:"waiting for you"}):S.available?s.jsx(pe,{tone:"good",dot:!0,children:"ready"}):s.jsx(pe,{tone:"warning",children:Rs(S.unavailableReason??"cannot run",60)}),s.jsx(pe,{mono:!0,children:S.model}),s.jsx(ln,{className:"agent-card-talk",size:"sm",href:Be(S.id),onClick:c(Be(S.id)),"aria-label":`Talk to ${S.name}`,children:"Talk"})]})]},S.id)})}):null,l?s.jsx(qt,{title:((m=r.find(S=>S.id===l.agentId))==null?void 0:m.name)??l.agentId,size:"wide",onClose:()=>n(rt),children:s.jsx(SL,{agentId:l.agentId,agent:r.find(S=>S.id===l.agentId),agents:r,tab:l.tab??"conversations",...l.section?{section:l.section}:{},timezone:t,navigate:n,attention:i})}):null]})}function kL({data:e,error:t,reload:n}){const r=e==null?void 0:e.default,[i,o]=d.useState(null),[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null);if(t)return s.jsx(re,{message:t});if(!r||r.choices.length===0)return null;const h=r.defaultAgentId,v=i??h??"",j=v!==""&&v!==h,w=r.problem,b=g=>g.map(y=>{var m;return((m=r.choices.find(S=>S.id===y))==null?void 0:m.name)??y}).join(" and "),x=async()=>{a(!0),u(null),f(null);try{const g=await A.setDefaultAgent(v);f(g.note),o(null),n()}catch(g){u(g instanceof Error?g.message:String(g))}finally{a(!1)}};return s.jsx(at,{children:s.jsxs("div",{className:"ui-stack",children:[s.jsx(re,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?s.jsx(H,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${b(w.agents)}. The one chosen here wins.`}):(w==null?void 0:w.code)==="no-default-agent"?s.jsx(H,{tone:"warning",role:"status",children:"No agent file claims the default and this installation has not recorded one. Choose who answers when you name nobody."}):null,p?s.jsx(H,{tone:"good",role:"status",children:p}):null,s.jsxs(q,{children:[s.jsxs("div",{className:"default-agent-text",children:[s.jsx("h3",{className:"default-agent-title",children:"Default agent"}),s.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("select",{"aria-label":"Default agent",value:v,disabled:l,onChange:g=>o(g.target.value),children:[v===""?s.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(g=>s.jsxs("option",{value:g.id,disabled:!g.available,children:[g.name," @",g.handle,g.available?"":" (cannot run)"]},g.id))]}),s.jsx(R,{variant:"accent",disabled:l||!j,onClick:()=>void x(),children:"Save"})]})]})})}function SL({agentId:e,agent:t,agents:n,tab:r,section:i,timezone:o,navigate:l,attention:a}){const c=f=>h=>{h.preventDefault(),l(f)},u=gu(a.get(e)),p=(t==null?void 0:t.name)??e;return s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[s.jsxs("header",{className:"agent-head",children:[s.jsx(us,{id:e,name:p,size:"xl",unavailable:t?!t.available:!1,face:t}),s.jsxs("div",{className:"agent-head-text",children:[s.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),s.jsxs("div",{className:"ui-row",children:[t?s.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?s.jsx("span",{className:"muted",children:t.model}):null,u?s.jsx(pe,{tone:"critical",children:u}):t&&!t.available?s.jsx(pe,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),s.jsx("div",{className:"ui-page-actions",children:s.jsxs(ln,{variant:"accent",href:Be(e),onClick:c(Be(e)),children:["Talk to ",p]})})]}),t&&!t.available?s.jsxs(H,{tone:"warning",role:"status",children:[B0(t)," ",s.jsx("a",{href:lt(lh(t).section),children:lh(t).label})]}):null,s.jsx(ju,{children:wL.map(f=>s.jsx(yu,{href:mt(e,f.id),active:r===f.id,onClick:c(mt(e,f.id)),children:f.label},f.id))}),r==="conversations"?s.jsx(NL,{agentId:e,navigate:l}):null,r==="missions"?s.jsx(sS,{timezone:o,embedded:!0,agentId:e}):null,r==="offers"?s.jsx(iS,{embedded:!0,agentId:e,agentName:p}):null,r==="reminders"?s.jsx(cS,{timezone:o,embedded:!0,agentId:e}):null,r==="memory"?s.jsx(oS,{embedded:!0,agents:n,timezone:o,agentId:e}):null,r==="skills"?s.jsx(QD,{agentId:e,agentName:p}):null,r==="setup"?s.jsx(uL,{agentId:e,section:i,navigate:l}):null]})}function NL({agentId:e,navigate:t}){const{data:n,error:r}=se(()=>ze.conversations(e,50),[e]);if(r)return s.jsx(ie,{children:r});const i=(n==null?void 0:n.conversations)??[];return s.jsx(at,{flush:!0,children:n?i.length===0?s.jsx(kt,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):s.jsx(Ft,{children:i.map(o=>s.jsx(Kt,{href:Be(e,o.id),onClick:()=>t(Be(e,o.id)),title:Rs(o.preview||o.opening||"Untitled conversation",90),sub:`${o.messageCount} message${o.messageCount===1?"":"s"}`,side:ke(o.lastMessageAt??o.startedAt??o.createdAt??null)},o.id))}):s.jsx(ie,{children:"Loading…"})})}function CL({timezone:e,navigate:t,agents:n,defaultAgentId:r,attention:i,update:o}){var V,de,ge,je,ne,xe,Se,Me,De,he,_e,Ce,He;const l=se(()=>A.overview(),[],15e3),a=se(()=>A.approvals(),[],1e4),c=se(()=>A.missions(),[],6e4),u=se(()=>A.reminders(),[],6e4),p=se(()=>A.conversations(),[],3e4),f=se(()=>A.offers(),[],3e4),h=se(()=>A.proposals(),[],6e4),v=se(()=>A.agentOffers(),[],6e4),j=se(()=>A.owner(),[]),w=se(()=>A.notifications(20),[],3e4),b=d.useMemo(()=>F0(n,r??null),[n,r]),{busy:x,note:g,failure:y,decide:m}=$m(()=>{a.reload(),l.reload()}),S=l.data,k=_=>{var ue;return((ue=n.find(ve=>ve.id===_))==null?void 0:ue.name)??_},N=_=>ue=>{ue.preventDefault(),t(_)},C=((V=a.data)==null?void 0:V.pending)??[],P=((de=S==null?void 0:S.jobs)==null?void 0:de.failed)??0,E=((ge=S==null?void 0:S.sentinels)==null?void 0:ge.openUrgent)??0,O=((je=h.data)==null?void 0:je.open.length)??0,F=(((ne=v.data)==null?void 0:ne.offers)??[]).filter(_=>!C.some(ue=>Tk(ue,_.plugin,_.agent))),D=TL(((xe=w.data)==null?void 0:xe.notifications)??[],C),[T,z]=d.useState(new Set),Q=C.length+(P>0?1:0)+(E>0?1:0)+(S!=null&&S.paused?1:0)+(O>0?1:0)+F.length+D.length,Y=d.useMemo(()=>{var _,ue;return ML(((_=c.data)==null?void 0:_.missions)??[],((ue=u.data)==null?void 0:ue.reminders)??[])},[c.data,u.data]),M=(((Se=p.data)==null?void 0:Se.conversations)??[]).slice(0,5),B=((Me=f.data)==null?void 0:Me.offers)??[],$=B.slice(0,RL),Z=B.length-$.length;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"home-band",children:s.jsxs("header",{className:"home-hero",children:[s.jsxs("div",{className:"home-hero-text",children:[s.jsx("p",{className:"home-date",children:OL(S==null?void 0:S.now,e)}),s.jsx("h1",{className:"home-greeting",children:_L(S==null?void 0:S.now,e,((De=j.data)==null?void 0:De.preferredName)||((he=j.data)==null?void 0:he.displayName))}),s.jsx("p",{className:"home-lede",children:LL(Q,C.length,P,E,(S==null?void 0:S.paused)??!1,O,F.length,D.length)})]}),s.jsx(K0,{size:"lg"})]})}),s.jsxs("div",{className:"home",children:[o&&o.updateAvailable&&!o.checkout&&o.latest?s.jsxs(H,{tone:"accent",children:["A newer buddi is ready: ",s.jsx("span",{className:"mono",children:o.latest}),"."," ",s.jsx("a",{href:lt("system"),onClick:N(lt("system")),children:"Upgrade from Settings → Version."})]}):null,s.jsx(re,{message:l.error??a.error??y}),g?s.jsx(H,{tone:"good",role:"status",children:g}):null,Q>0?s.jsx(G,{title:"Needs you",children:s.jsxs(K,{children:[S!=null&&S.paused?s.jsxs(H,{tone:"warning",title:"The installation is paused.",children:["Nothing is being claimed until you resume it."," ",s.jsx(R,{size:"sm",onClick:()=>{A.setPaused(!1).then(()=>l.reload())},children:"Resume"})]}):null,C.map(_=>s.jsx(_m,{action:_,timezone:e,busy:x===_.id,onDecide:m,agentName:k(_.agentId)},_.id)),D.length>0?s.jsx(at,{flush:!0,children:s.jsx(Ft,{children:D.filter(_=>!T.has(_.id)).map(_=>s.jsx(Kt,{href:_.link??void 0,onClick:()=>{z(ue=>new Set(ue).add(_.id)),A.notificationSeen(_.id).catch(()=>{}),_.link&&t(_.link)},lead:_.agentId?s.jsx(Zt,{agents:n,id:_.agentId,size:"sm"}):void 0,title:_.title,sub:_.agentId?k(_.agentId):_.pluginId??AL[_.kind],side:_.state==="held"?"today":ke(_.createdAt)},_.id))})}):null,P>0?s.jsx(H,{tone:"critical",children:s.jsxs("a",{href:`${st}/jobs?state=failed`,onClick:N(`${st}/jobs?state=failed`),children:[P," failed job",P===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,E>0?s.jsx(H,{tone:"critical",children:s.jsxs("a",{href:`${st}/alerts`,onClick:N(`${st}/alerts`),children:[E," urgent alert",E===1?"":"s"," from your watchers."]})}):null,F.map(_=>s.jsx(at,{children:s.jsx(Om,{plugin:_.plugin,agent:_.agent,text:_.text,label:`Create @${_.handle}`,handle:_.handle,onDismiss:()=>{A.dismissAgentOffer(_.plugin,_.agent).then(()=>v.reload())}})},`${_.plugin}/${_.agent}`)),O>0?s.jsx(H,{tone:"accent",children:s.jsxs("a",{href:lt("proposals"),onClick:N(lt("proposals")),children:[O," proposal",O===1?"":"s"," from your agents to keep or discard."]})}):null,(((_e=S==null?void 0:S.sentinels)==null?void 0:_e.errors)??[]).map(_=>s.jsxs(H,{tone:"warning",children:["Watcher ",_.sentinelId," failed: ",_.error]},_.sentinelId)),((S==null?void 0:S.mail)??[]).filter(_=>_.lastError).map(_=>s.jsxs(H,{tone:"warning",children:["Source ",_.sourceId,": ",_.lastError]},_.sourceId))]})}):null,s.jsx(G,{title:"Your team",aside:s.jsx("a",{href:rt,onClick:N(rt),children:"All agents"}),children:n.length===0?s.jsx(ie,{mascot:!0,children:"No agents yet. Add one under Agents."}):s.jsx("div",{className:"home-team",children:b.map(_=>{const ue=gu(i.get(_.id));return s.jsxs("a",{className:"home-face",...Cl(Nl(_)),href:Be(_.id),onClick:N(Be(_.id)),"data-waiting":ue?"true":void 0,"data-unavailable":_.available?void 0:"true",children:[s.jsx(us,{id:_.id,name:_.name,size:"lg",unavailable:!_.available,face:_}),s.jsxs("span",{className:"home-face-text",children:[s.jsx("span",{className:"home-face-name",children:_.name}),s.jsx("span",{className:"home-face-status",children:ue?mS(ue):_.available?Rs(_.description,60):_.unavailableReason??"Cannot run right now."})]})]},_.id)})})}),$.length>0?s.jsx(G,{title:"On offer",aside:s.jsxs("span",{className:"ui-row",children:[Z>0?s.jsxs("a",{href:`${rt}?tab=offers`,onClick:N(`${rt}?tab=offers`),children:[Z," more"]}):null,s.jsx(rS,{ids:B.map(_=>_.id),onDone:()=>f.reload()})]}),children:s.jsx("div",{className:"home-offers",children:$.map(_=>s.jsx(IL,{offer:_,agents:n,open:N(mt(_.agentId,"offers")),onDismissed:()=>f.reload()},_.id))})}):null,(He=(Ce=h.data)==null?void 0:Ce.digest)!=null&&He.latest?s.jsx(DL,{digest:h.data.digest.latest,go:N}):null,s.jsxs("div",{className:"home-columns",children:[s.jsx(G,{title:"Coming up",aside:s.jsx("a",{href:`${rt}?tab=missions`,onClick:N(`${rt}?tab=missions`),children:"All missions"}),children:s.jsx(at,{flush:!0,children:Y.length===0?s.jsx(ie,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):s.jsx(Ft,{children:Y.map(_=>s.jsx(Kt,{href:_.route,onClick:()=>t(_.route),lead:s.jsx(Zt,{agents:n,id:_.agentId,size:"sm"}),title:_.title,sub:`${_.kind} for ${k(_.agentId)}`,side:ke(_.at)},_.key))})})}),s.jsx(G,{title:"Lately",aside:s.jsx("a",{href:st,onClick:N(st),children:"All activity"}),children:s.jsx(at,{flush:!0,children:M.length===0?s.jsx(ie,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):s.jsx(Ft,{children:M.map(_=>s.jsx(Kt,{href:Be(_.agentId,_.id),onClick:()=>t(Be(_.agentId,_.id)),lead:s.jsx(Zt,{agents:n,id:_.agentId,size:"sm"}),title:_.opening?Rs(_.opening,80):"Untitled conversation",sub:`${k(_.agentId)}, ${_.messageCount} message${_.messageCount===1?"":"s"}`,side:ke(_.lastMessageAt??_.createdAt)},_.id))})})})]}),((S==null?void 0:S.home)??[]).map(_=>s.jsx(FL,{block:_},_.id)),S!=null&&S.jobs&&S.missions?s.jsxs("p",{className:"home-foot muted",children:[Lt(S.jobs.pending??0)," queued, ",Lt(S.jobs.leased??0)," running, ",Lt(S.missions.enabled)," of ",Lt(S.missions.total)," missions on."," ",S.paused?s.jsx(pe,{tone:"warning",children:"paused"}):s.jsx(pe,{tone:"good",children:"running"})," ",s.jsx("a",{href:zi("").replace(/\/conversations\/$/,""),onClick:N(st),children:"Activity"})," · ",s.jsx("a",{href:lt("system"),onClick:N(lt("system")),children:"System"})]}):null]})]})}const EL=new Set(["watcher","reminder","failure","recap","plugin"]),AL={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin"};function TL(e,t){const n=new Set(t.map(r=>r.id));return e.filter(r=>EL.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&n.has(r.actionId)))}const RL=6,PL=500;function IL({offer:e,agents:t,open:n,onDismissed:r}){const[i,o]=d.useState(!1),l=d.useRef(null),a=d.useRef(!1),c=()=>{i||(o(!0),A.dismissOffer(e.id).then(r).finally(()=>o(!1)))},u=()=>{l.current!==null&&clearTimeout(l.current),l.current=null};return s.jsxs("span",{className:"home-offer-chip",children:[s.jsxs("a",{className:"home-offer",href:mt(e.agentId,"offers"),onClick:p=>{if(a.current){a.current=!1,p.preventDefault();return}n(p)},title:e.prompt,onTouchStart:()=>{a.current=!1,u(),l.current=setTimeout(()=>{a.current=!0,c()},PL)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[s.jsx(Zt,{agents:t,id:e.agentId,size:"sm"}),s.jsx("span",{children:e.label})]}),s.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function ML(e,t){const n=[];for(const r of e)r.enabled&&r.nextRun&&n.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:mt(r.agentId,"missions")});for(const r of t)r.state==="pending"&&n.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:mt(r.agentId,"reminders")});return n.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function $L(e,t){try{const n=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(n)}catch{return new Date().getHours()}}function _L(e,t,n){const r=$L(e,t),i=n!=null&&n.trim()?`, ${n.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function OL(e,t){try{const n=e?new Date(e):new Date,r=new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:t}).format(n),i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",timeZone:t}).format(n);return`${r}, ${i}`}catch{return Ie(e??null,t)}}function wa(e,t,n){return e.count===0?null:`${e.count} ${e.count===1?t:n}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function DL({digest:e,go:t}){const n=[wa(e.memory,"memory note","memory notes"),wa(e.skills,"skill kept","skills kept"),wa(e.rules,"rule kept","rules kept"),wa(e.changes,"change to an agent kept","changes to agents kept")].filter(i=>i!==null),r=e.stopped===null?"Not measured yet.":e.stopped.total>0?`Rules you kept acted ${e.stopped.total} time${e.stopped.total===1?"":"s"} (${Object.entries(e.stopped.byPlugin).filter(([,i])=>i>0).map(([i,o])=>`${i} ${o}`).join(", ")}).`:"No rule you kept acted this week.";return s.jsx(G,{title:"What buddi learned this week",aside:s.jsx("span",{className:"muted",children:ke(e.at)}),children:s.jsx(at,{children:s.jsxs(K,{divided:!0,children:[s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Learned"}),n.length===0?s.jsx("p",{children:"Nothing new."}):s.jsx("ul",{className:"home-digest-list",children:n.map(i=>s.jsx("li",{children:i},i))})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Proposes"}),s.jsx("p",{children:e.open>0?s.jsxs("a",{href:lt("proposals"),onClick:t(lt("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),s.jsx("p",{children:r})]})]})})})}function LL(e,t,n,r,i,o=0,l=0,a=0){if(e===0)return"Nothing needs you. Your agents are on it.";const c=[];t>0&&c.push(`${t} approval${t===1?"":"s"} waiting`),n>0&&c.push(`${n} failed job${n===1?"":"s"}`),r>0&&c.push(`${r} urgent alert${r===1?"":"s"}`),i&&c.push("the installation is paused"),o>0&&c.push(`${o} proposal${o===1?"":"s"} to review`),l>0&&c.push(`${l===1?"an agent":`${l} agents`} to set up`),a>0&&c.push(`${a} message${a===1?"":"s"} for you`);const u=c.length<=1?c.join(""):`${c.slice(0,-1).join(", ")} and ${c[c.length-1]}`;return`${mS(u)}.`}function mS(e){return e.charAt(0).toUpperCase()+e.slice(1)}function FL({block:e}){const[t,n]=d.useState(!1),r=e.sensitive===!0&&!t;d.useEffect(()=>{if(!e.sensitive||!t)return;const o=()=>{document.visibilityState==="hidden"&&n(!1)};return document.addEventListener("visibilitychange",o),window.addEventListener("blur",o),()=>{document.removeEventListener("visibilitychange",o),window.removeEventListener("blur",o)}},[e.sensitive,t]);const i=s.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?s.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?s.jsx(R,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>n(o=>!o),children:r?"Show":"Hide"}):null]});return s.jsxs(G,{title:e.title,aside:i,children:[e.note?s.jsx(H,{tone:"warning",children:e.note}):null,e.stats.length>0?s.jsx(vu,{children:e.stats.map(o=>s.jsx(es,{label:o.label,value:r?"••••":o.value,note:r?void 0:o.note,tone:r?void 0:o.tone},o.label))}):null,e.rows.length>0?r?s.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):s.jsx(at,{flush:!0,children:s.jsx(Ft,{children:e.rows.map((o,l)=>s.jsx(Kt,{title:o.title,sub:o.sub,side:o.side?s.jsx("span",{className:o.tone==="critical"?"critical":o.tone==="good"?"good":void 0,children:o.side}):void 0},`${o.title}-${l}`))})}):null]})}const gS="(max-width: 900px)";function Mh(e){const[t,n]=d.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return d.useEffect(()=>{var o;let r;try{r=window.matchMedia(e)}catch{return}const i=l=>n(l.matches);return(o=r.addEventListener)==null||o.call(r,"change",i),()=>{var l;return(l=r.removeEventListener)==null?void 0:l.call(r,"change",i)}},[e]),t}const UL=3e4;function xS(){const{data:e,reload:t}=se(()=>A.recovery(),[],UL);return{data:e,reload:t}}const zL="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function BL({active:e,onNavigate:t}){return e?s.jsxs("div",{className:"recovery-banner",role:"status",children:[s.jsx("span",{children:zL}),s.jsx("a",{href:hv,onClick:n=>{n.preventDefault(),t(hv)},children:"Finish the checklist"})]}):null}function WL({view:e,onLeft:t}){const{secrets:n,plugins:r,pending:i,grants:o}=e.checklist,[l,a]=d.useState(!0),[c,u]=d.useState([]),[p,f]=d.useState(!1),[h,v]=d.useState(null),[j,w]=d.useState(!1),b=r.filter(m=>!m.installed),x=i.jobs+i.missions+i.approvals+i.telegramChats,g=m=>{u(S=>S.includes(m)?S.filter(k=>k!==m):[...S,m])},y=()=>{f(!0),v(null),A.leaveRecovery({dropPending:l,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(m=>v(m instanceof le?m.message:String(m))).finally(()=>f(!1))};return s.jsx(at,{title:"Back from a backup",children:s.jsxs(K,{divided:!0,children:[s.jsxs(G,{children:[s.jsx(Tt,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:s.jsx("span",{className:"mono",children:e.archive??"—"})}]}),s.jsx("p",{className:"ui-card-meta",children:"Nothing runs on its own yet: no schedules, no watchers, no phone. Chat works. Go through what is below, then turn this buddi back on."})]}),s.jsx(G,{title:"Keys to paste again",children:n.length===0?s.jsx(ie,{children:"Nothing is missing."}):s.jsx("ul",{className:"recovery-list",children:n.map(m=>s.jsxs("li",{children:[m.settingsRoute?s.jsx("a",{href:m.settingsRoute,children:m.name}):m.name," ",s.jsx("span",{className:"ui-card-meta",children:m.kind})]},`${m.kind}:${m.name}`))})}),s.jsx(G,{title:"Add-ons to install again",children:b.length===0?s.jsx(ie,{children:"Everything the backup named is installed."}):s.jsx("ul",{className:"recovery-list",children:b.map(m=>s.jsxs("li",{children:[s.jsx("span",{className:"mono",children:m.name})," ",m.version," ",s.jsx("span",{className:"ui-card-meta",children:m.source})]},m.name))})}),s.jsx(G,{title:"Work that was waiting",children:x===0?s.jsx(ie,{children:"Nothing was in flight when the backup was taken."}):s.jsxs(K,{gap:"sm",children:[s.jsx(Tt,{items:[{label:"Jobs",value:String(i.jobs)},{label:"Missions",value:String(i.missions)},{label:"Waiting for an answer",value:String(i.approvals)},{label:"Phones",value:String(i.telegramChats)}]}),s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:m=>a(m.target.checked)}),s.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),s.jsx(G,{title:"Standing permissions",children:o.length===0?s.jsx(ie,{children:"No agent had a standing permission."}):s.jsxs(K,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),s.jsx("ul",{className:"recovery-list",children:o.map(m=>s.jsx("li",{children:s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:c.includes(m.id),onChange:()=>g(m.id),"aria-label":`Keep ${m.tool} for ${m.agent}`}),s.jsxs("span",{children:[s.jsx("span",{className:"mono",children:m.tool})," for ",m.agent," ",s.jsx("span",{className:"ui-card-meta",children:m.scope}),m.description?s.jsxs("span",{className:"ui-card-meta",children:[" — ",m.description]}):null]})]})},m.id))})]})}),s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:h}),j?s.jsx(H,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):s.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),s.jsx(q,{align:"end",children:s.jsx(R,{variant:"accent",disabled:p||j,onClick:y,children:"Leave recovery mode"})})]})})]})})}const HL=2e3,VL={queued:"Getting started.",stopping:"Stopping the gateway. The database stays up.",snapshot:"Taking a copy of what is here now, first.",database:"Putting the database back.",recovery:"Marking this installation as restored.",files:"Putting the files back.",starting:"Starting back up.",encrypt:"Locking it with your passphrase.",done:"Done.",failed:"That did not work.","rolled-back":"That did not work, so everything was put back as it was."};function tj(e){return VL[e.phase]??e.detail??e.phase}const KL=new Set(["done","failed","rolled-back"]);function vS(e){return e!==void 0&&(KL.has(e.phase)||!!e.finishedAt)}function GL(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(!1),[o,l]=d.useState(null),a=d.useRef(!1);return d.useEffect(()=>{if(!e){n(void 0),i(!1),a.current=!1;return}let c=!1;const u=()=>{A.backupJob(e).then(f=>{if(!c){if(a.current){window.location.reload();return}n(f),l(null),vS(f)&&(c=!0)}}).catch(f=>{if(!c){if(f instanceof le&&f.status!==0&&f.status<500){l(f.message);return}a.current=!0,i(!0)}})};u();const p=window.setInterval(u,HL);return()=>{c=!0,window.clearInterval(p)}},[e]),{job:t,away:r,error:o}}function YL({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.jsx(H,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="rolled-back"||e.phase==="failed"?s.jsxs(H,{tone:"critical",role:"alert",children:[tj(e)," ",e.error??""]}):s.jsxs(H,{tone:e.phase==="done"?"good":void 0,role:"status",children:[tj(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function qL(){var b,x,g,y,m,S,k;const e=se(()=>A.backups(),[],3e4),t=xS(),n=se(()=>A.service(),[]),[r,i]=d.useState(null),o=GL(r),[l,a]=d.useState(null),[c,u]=d.useState(!1),[p,f]=d.useState(null),h=((b=e.data)==null?void 0:b.supervised)??((x=n.data)==null?void 0:x.supervised),v=p!==null||h===!1,j=((g=e.data)==null?void 0:g.archives)??[],w=N=>{u(!0),a(null),N.then(C=>{var P;return i(((P=C.job)==null?void 0:P.id)??null)}).catch(C=>{C instanceof le&&C.status===409?f(C.message):a(C instanceof le?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return d.useEffect(()=>{vS(o.job)&&e.reload()},[(y=o.job)==null?void 0:y.phase]),s.jsxs(K,{gap:"lg",children:[(m=t.data)!=null&&m.active?s.jsx(WL,{view:t.data,onLeft:t.reload}):null,s.jsx(re,{message:e.error??l}),s.jsx(YL,{...o}),s.jsx(JL,{onSaved:()=>e.reload()}),s.jsx(G,{title:"Backups",panel:!0,actions:s.jsx(R,{variant:"accent",size:"sm",disabled:c,onClick:()=>w(A.startBackup(!0)),children:"Back up now"}),children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsxs("p",{className:"ui-card-meta",children:["Kept in ",s.jsx("span",{className:"mono",children:((S=e.data)==null?void 0:S.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),s.jsx(G,{children:e.data&&j.length===0?s.jsx(kt,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?s.jsxs(an,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Taken"}),s.jsx("th",{children:"Size"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:j.map(N=>{var C;return s.jsx(XL,{archive:N,busy:c,database:(C=e.data)==null?void 0:C.database,checkout:v,onVerify:()=>w(A.verifyArchive(N.name)),onRestore:(P,E)=>w(A.restoreArchive({name:N.name,...P?{passphrase:P}:{},...E?{confirm:E}:{}}))},N.name)})})]}):s.jsx(ie,{children:"Loading…"})})]})}),s.jsx(ZL,{}),s.jsx(eF,{busy:c,checkout:v,checkoutSaid:p,database:(k=e.data)==null?void 0:k.database,onRestore:(N,C,P)=>w(A.restoreUpload(N,{passphrase:C,confirm:P}))})]})}const QL={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function JL({onSaved:e}){var v;const t=se(()=>A.backupSchedule(),[]),[n,r]=d.useState(null),[i,o]=d.useState(!1),[l,a]=d.useState(null),[c,u]=d.useState(!1);d.useEffect(()=>{t.data&&r(t.data)},[t.data]);const p={...QL,...n??t.data??{}};if(((v=t.data)==null?void 0:v.supervised)===!1)return s.jsx(G,{title:"Every night",panel:!0,children:s.jsx(G,{children:s.jsx(H,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const f=j=>{u(!1),r({...p,...j})},h=()=>{o(!0),a(null),A.setBackupSchedule(p).then(j=>{r(j),u(!0),e()}).catch(j=>a(j instanceof le?j.message:String(j))).finally(()=>o(!1))};return s.jsx(G,{title:"Every night",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:i,onClick:h,children:"Save"}),children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:l}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:p.enabled,onChange:j=>f({enabled:j.target.checked})}),s.jsx("span",{children:"Back this buddi up on its own"})]}),s.jsxs(Ps,{children:[s.jsx(X,{label:"At",children:s.jsx("input",{type:"time",value:p.time,onChange:j=>f({time:j.target.value})})}),s.jsx(X,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:s.jsx("input",{type:"number",min:1,max:365,value:p.keep,onChange:j=>f({keep:Number(j.target.value)||1})})})]}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:p.encryptLocal,onChange:j=>f({encryptLocal:j.target.checked})}),s.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(X,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:s.jsx("input",{type:"text",value:p.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:j=>f({copyTo:j.target.value===""?null:j.target.value})})}),c?s.jsxs(H,{tone:"good",role:"status",children:["Saved.",p.lastRunAt?` Last run ${ke(p.lastRunAt)}.`:""]}):null]})})]})})}function XL({archive:e,busy:t,database:n,checkout:r,onVerify:i,onRestore:o}){const[l,a]=d.useState(!1),[c,u]=d.useState(""),[p,f]=d.useState("");return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:e.name}),s.jsx("td",{children:ke(e.createdAt)}),s.jsx("td",{children:Tn(e.bytes)}),s.jsxs("td",{children:[e.encrypted?s.jsx(pe,{tone:"good",children:"locked"}):s.jsx(pe,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?s.jsx(pe,{tone:"critical",children:"damaged"}):null]}),s.jsx("td",{children:s.jsxs(q,{align:"end",children:[s.jsx(R,{size:"sm",disabled:t,onClick:i,children:"Verify"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>a(!l),children:"Restore…"})]})})]}),l?s.jsx("tr",{children:s.jsx("td",{colSpan:5,children:r?s.jsx(H,{tone:"warning",children:jS}):s.jsx(yS,{what:`${e.name}, taken ${ke(e.createdAt)}, ${Tn(e.bytes)}`,database:n,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:p,onConfirm:f,busy:t,onCancel:()=>a(!1),onGo:()=>o(c,p)})})}):null]})}const jS="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function yS({what:e,database:t,needsPassphrase:n,passphrase:r,onPassphrase:i,confirm:o,onConfirm:l,busy:a,onCancel:c,onGo:u}){const p=t??"",f=p===""?o.trim()!=="":o.trim()===p;return s.jsxs(K,{gap:"sm",children:[s.jsxs(H,{tone:"warning",children:["This replaces everything in this buddi with ",e,". What is here now is copied first, so a restore that fails puts it back."]}),n?s.jsx(X,{label:"The passphrase this one was locked with",children:s.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:h=>i(h.target.value)})}):null,s.jsx(X,{label:p?`Type ${p} to confirm`:"Type the name of this database to confirm",hint:p?void 0:"The same name buddi shows on the System tab.",children:s.jsx("input",{value:o,onChange:h=>l(h.target.value)})}),s.jsxs(q,{align:"end",children:[s.jsx(R,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(R,{variant:"danger",disabled:a||!f||n&&r==="",onClick:u,children:"Restore"})]})]})}function ZL(){const[e,t]=d.useState(null),[n,r]=d.useState(""),[i,o]=d.useState(!1),[l,a]=d.useState(null),[c,u]=d.useState(!1),p=()=>{o(!0),a(null),A.backupPassphrase().then(h=>t(h.passphrase)).catch(h=>a(h instanceof le?h.message:String(h))).finally(()=>o(!1))},f=()=>{o(!0),a(null),A.setBackupPassphrase(n.trim()).then(h=>{t(h.passphrase),r(""),u(!0)}).catch(h=>a(h instanceof le?h.message:String(h))).finally(()=>o(!1))};return s.jsx(G,{title:"The passphrase",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:l}),s.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?s.jsx("p",{className:"backup-phrase mono",children:e}):s.jsx(q,{align:"end",children:s.jsx(R,{disabled:i,onClick:p,children:"Show it"})}),c?s.jsx(H,{tone:"good",role:"status",children:"Saved. Backups made from now on use it; older ones keep the one they were made with."}):null]})}),s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(X,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:s.jsx("input",{type:"text",autoComplete:"off",value:n,onChange:h=>{u(!1),r(h.target.value)}})}),s.jsx(q,{align:"end",children:s.jsx(R,{variant:"accent",disabled:i||n.trim()==="",onClick:f,children:"Use this one"})})]})})]})})}function eF({busy:e,checkout:t,checkoutSaid:n,database:r,onRestore:i}){const[o,l]=d.useState(null),[a,c]=d.useState(""),[u,p]=d.useState(""),[f,h]=d.useState(!1);return t?s.jsx(G,{title:"Restore from a file",panel:!0,children:s.jsx(G,{children:s.jsx(H,{tone:"warning",children:n??jS})})}):s.jsx(G,{title:"Restore from a file",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),s.jsxs(Ps,{children:[s.jsx(X,{label:"The backup file",children:s.jsx("input",{type:"file",onChange:v=>{var j;h(!1),l(((j=v.target.files)==null?void 0:j[0])??null)}})}),s.jsx(X,{label:"Its passphrase",hint:"Only if it was locked with one.",children:s.jsx("input",{type:"password",autoComplete:"off",value:a,onChange:v=>c(v.target.value)})})]}),f?null:s.jsx(q,{align:"end",children:s.jsx(R,{variant:"accent",disabled:e||!o,onClick:()=>h(!0),children:"Restore"})})]})}),f&&o?s.jsx(G,{children:s.jsx(yS,{what:`${o.name}, ${Tn(o.size)}`,database:r,needsPassphrase:!1,passphrase:a,onPassphrase:c,confirm:u,onConfirm:p,busy:e,onCancel:()=>h(!1),onGo:()=>i(o,a,u)})}):null]})})}function wS({code:e,label:t="Your code"}){const[n,r]=d.useState(!1),i=async()=>{var o;try{await((o=navigator.clipboard)==null?void 0:o.writeText(e)),r(!0)}catch{}};return s.jsxs(q,{valign:"end",children:[s.jsx(X,{label:t,grow:!0,children:s.jsx("input",{readOnly:!0,value:e,spellCheck:!1,onFocus:o=>o.currentTarget.select()})}),s.jsx(R,{onClick:()=>void i(),children:n?"Copied":"Copy"})]})}function tF({embedded:e}={}){const{data:t,error:n,reload:r,loading:i}=se(()=>A.providerAccounts(),[]),[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(""),[f,h]=d.useState(!1),[v,j]=d.useState(!1),[w,b]=d.useState(null),x=t==null?void 0:t.accounts.some(S=>{var k;return((k=S.login)==null?void 0:k.state)==="pending"&&S.login.expiresAt&&Date.parse(S.login.expiresAt)>Date.now()});d.useEffect(()=>{if(!x)return;const S=setInterval(r,2e3);return()=>clearInterval(S)},[x,r]);const g=async(S,k)=>{l(!0),c(null),p(""),j(!1);try{const N=await S();return p((N==null?void 0:N.warning)??k),r(),!0}catch(N){return c(N instanceof Error?N.message:"Could not apply change."),r(),!1}finally{l(!1)}},y=(t==null?void 0:t.accounts)??[],m=y.find(S=>S.id===w)??y[0];return s.jsxs(cn,{embedded:e,title:"Model accounts",lede:"Give each API key or subscription a name, then pick one per agent. An account never falls back to another credential on its own.",children:[s.jsx(re,{message:n??a}),u&&s.jsx(H,{tone:"good",role:"status",children:u}),v&&s.jsx(H,{role:"status",children:i?"Refreshing account status…":n?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!t&&!n&&s.jsx(ie,{children:"Loading accounts…"}),n&&s.jsx(q,{children:s.jsx(R,{onClick:r,children:"Retry"})}),t&&s.jsxs(s.Fragment,{children:[(t.vault.locked||t.vault.kind==="none")&&s.jsx(H,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),f&&s.jsx(qt,{title:"Add an account",onClose:()=>h(!1),children:s.jsx("div",{id:"new-provider-account",children:s.jsx(lF,{accounts:y,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:o,run:g,onDone:S=>{h(!1),S&&b(S)}})})}),s.jsx(G,{title:"Accounts",aside:`Secrets live in the ${nF(t.vault.kind)}; Postgres holds names and assignments only.`,actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",size:"sm",disabled:o||i,onClick:()=>{c(null),p(""),j(!0),r()},children:i?"Refreshing…":"Refresh status"}),s.jsx(R,{variant:"accent",size:"sm",disabled:o,"aria-expanded":f,"aria-controls":"new-provider-account",onClick:()=>h(!f),children:"Add account"})]}),panel:!0,flush:!0,children:y.length===0?s.jsx(kt,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):s.jsxs("div",{className:"accounts",children:[s.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:y.map(S=>s.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(m==null?void 0:m.id)===S.id,onClick:()=>b(S.id),children:[s.jsx(sF,{kind:S.kind,auth:S.auth}),s.jsxs("span",{className:"accounts-row-text",children:[s.jsx("span",{className:"accounts-row-name",children:S.label}),s.jsxs("span",{className:"accounts-row-sub",children:[Wm(S)," · ",S.assignedAgents.length===0?"no agents":`${S.assignedAgents.length} agent${S.assignedAgents.length===1?"":"s"}`]})]}),s.jsx(kS,{account:S})]},S.id))}),m?s.jsx(iF,{account:m,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:o,run:g},`${m.id}:${m.revision}`):null]})})]})]})}function nF(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function Wm(e){return e.kind==="codex"?"ChatGPT subscription":e.kind==="anthropic"?e.auth==="anthropic-oauth"?"Claude subscription":e.auth==="legacy-subscription-token"?"Claude setup token":"Anthropic API":e.kind==="openai"?"OpenAI API":e.auth==="device-key"?"Ollama Cloud":"OpenAI-compatible"}function bS(e){return e.detectedContextWindowSource!=="provider"?"assumed":e.kind==="codex"?"from ChatGPT":"from the provider"}function sF({kind:e,auth:t}){const n=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return s.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:n})}function rF(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function kS({account:e}){const t=e.enabled?e.configured?"good":"warning":void 0,n=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return s.jsx(pe,{tone:t,children:n})}function SS(e){return{id:e.id,revision:e.revision,label:e.label,kind:e.kind,auth:e.auth,baseUrl:e.baseUrl,defaultModel:e.defaultModel,enabled:e.enabled,contextWindowTokens:e.contextWindowTokens??null}}function iF({account:e,busy:t,run:n,anthropicOAuthEnabled:r}){const[i,o]=d.useState(!1),[l,a]=d.useState(!1);return s.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:e.label}),s.jsx(kS,{account:e})]}),s.jsx(Tt,{items:[{label:"Provider",value:Wm(e)},{label:"Default model",value:s.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:s.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":` (${bS(e)})`}`})},...e.baseUrl?[{label:"Endpoint",value:s.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?s.jsx("span",{className:"ui-row",children:e.assignedAgents.map(c=>s.jsx("a",{href:mt(c,"setup","brain"),children:c},c))}):s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:"No agents"}),s.jsx("a",{href:rt,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${new Date(e.tokenExpiresAt).toLocaleString()} (not your subscription renewal date)`}]:[]]}),e.removalPending&&s.jsx(H,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&s.jsxs(H,{tone:"warning",children:["Token refresh did not finish. Reconnect this ",e.kind==="codex"?"ChatGPT":"Claude"," account."]}),e.auth==="anthropic-oauth"&&s.jsx(ES,{account:e,enabled:!!r,busy:t,run:n}),e.kind==="codex"&&s.jsx(NS,{account:e,busy:t,run:n}),e.auth==="device-key"&&s.jsx(CS,{account:e,busy:t,run:n}),s.jsxs(q,{children:[s.jsx(R,{disabled:t||e.removalPending,onClick:()=>o(!0),children:"Edit account"}),s.jsx(R,{disabled:t||e.removalPending,onClick:()=>void n(()=>A.saveProviderAccount({...SS(e),enabled:!e.enabled}),e.enabled?"Account disabled. Subsequent model calls will stop; already-sent requests cannot be recalled.":"Account enabled."),children:e.enabled?"Disable":"Enable"}),e.kind!=="codex"&&s.jsx(R,{disabled:t||!e.enabled||!e.configured,onClick:()=>void n(()=>A.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),s.jsx(R,{variant:"danger",disabled:t||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>a(!0),children:"Remove account"})]}),e.test&&s.jsxs(s.Fragment,{children:[s.jsxs(H,{role:"status",tone:rF(e.test.state),children:[s.jsx("p",{children:e.test.message}),e.test.retryAt?s.jsxs("p",{children:["Provider suggested retry time: ",new Date(e.test.retryAt).toLocaleString(),". This is retry advice, not a guaranteed quota reset."]}):["rate-limited","quota-exhausted"].includes(e.test.state)&&s.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),s.jsxs("p",{className:"muted",children:["Tested at ",new Date(e.test.checkedAt).toLocaleString(),e.test.httpStatus?` · HTTP ${e.test.httpStatus}`:"",". This is not a quota reset or subscription renewal date."]})]}),i&&s.jsx(qt,{title:`Edit ${e.label}`,onClose:()=>o(!1),children:s.jsx(oF,{account:e,busy:t,run:n,onDone:()=>o(!1)})}),l&&s.jsxs(H,{tone:"critical",children:[s.jsxs("p",{children:["Remove “",e.label,"” and its stored credential from Buddi? This does not revoke it at the provider or remove it from backups."]}),s.jsxs(q,{children:[s.jsx(R,{variant:"danger",disabled:t,onClick:()=>void n(()=>A.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),s.jsx(R,{disabled:t,onClick:()=>a(!1),children:"Cancel"})]})]}),s.jsx(St,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[e.auth==="legacy-subscription-token"&&s.jsx("p",{children:"Legacy subscription token: not refreshable, token expiry and subscription renewal date unknown."}),e.kind==="codex"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Talks to OpenAI’s Codex backend directly with your ChatGPT sign-in. The credential stays in buddi’s vault; buddi refreshes it and never reads your own Codex login."}),s.jsx("p",{children:"Native tool-step usage reporting is incomplete. Do not use Buddi’s token or API-cost estimates as subscription billing or remaining quota."}),s.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):s.jsx("p",{children:"Testing sends a small fixed prompt and may incur a charge. No conversation or files are sent. Configured does not mean verified."}),e.auth==="device-key"&&s.jsx("p",{children:"Ollama Cloud with a device key: buddi made a key pair and keeps it in the vault; ollama.com only ever saw the public half and this computer’s name. Each request to ollama.com is signed with the key, and nothing else is sent with it. Disconnect asks ollama.com to forget the device and removes the key from buddi either way."}),e.auth==="anthropic-oauth"&&s.jsx("p",{children:"Claude subscription sign-in. Tokens remain in Buddi’s vault and refresh before use. Uses your plan’s monthly Agent SDK credits; after them, an API key. Remaining credits are unknown here."}),s.jsx("p",{children:"Subscription login is separate from API-key access. Existing Claude setup tokens remain legacy accounts, without automatic refresh or a known expiry."})]})})]})}function NS({account:e,busy:t,run:n}){var r,i,o;return s.jsxs(s.Fragment,{children:[s.jsxs(q,{children:[s.jsx(R,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void n(()=>A.codexAccountAction(e.id,"login",e.revision),"Complete device sign-in below."),children:e.configured?"Reconnect ChatGPT":"Connect ChatGPT"}),((i=e.login)==null?void 0:i.state)==="pending"&&s.jsx(R,{disabled:t,onClick:()=>void n(()=>A.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),s.jsx(R,{disabled:t||!e.configured,onClick:()=>void n(()=>A.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((o=e.login)==null?void 0:o.state)==="pending"&&s.jsxs(H,{tone:"accent",role:"status",children:[s.jsxs("p",{children:["Here is your code: ",s.jsx("strong",{children:e.login.userCode}),". Open the link, enter it, and approve buddi on openai.com."]}),e.login.userCode&&s.jsx(wS,{code:e.login.userCode}),e.login.verificationUrl&&s.jsx(q,{children:s.jsx(ln,{variant:"accent",href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open openai.com"})}),e.login.expiresAt&&s.jsxs("p",{className:"muted",children:["The code works until ",new Date(e.login.expiresAt).toLocaleTimeString(),". Start again after that; this is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&s.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function oF({account:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:o}){const[l,a]=d.useState((e==null?void 0:e.label)??""),[c,u]=d.useState((e==null?void 0:e.kind)??"anthropic"),[p,f]=d.useState((e==null?void 0:e.auth)??"api-key"),[h,v]=d.useState((e==null?void 0:e.baseUrl)??""),[j,w]=d.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[b,x]=d.useState(""),[g,y]=d.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),m=k=>{u(k),f(k==="codex"?"chatgpt":"api-key"),x(""),v(k==="openai-compatible"?"http://localhost:11434/v1":""),w(k==="anthropic"?"claude-sonnet-5":k==="openai"?"gpt-5":"")},S=!l.trim()||!j.trim();return s.jsxs("form",{className:"ui-stack",onSubmit:k=>{k.preventDefault();const N=b;x(""),n(()=>A.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:l,kind:c,auth:p,baseUrl:h,defaultModel:j,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:g.trim()?Number(g):null,...N.trim()?{secret:N}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(X,{label:"Account name",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:l,onChange:k=>a(k.target.value),placeholder:"Anthropic — Personal"})}),s.jsx(X,{label:"Provider",children:s.jsxs("select",{disabled:!!e,value:p==="anthropic-oauth"?"anthropic-oauth":p==="device-key"?"ollama-cloud":c,onChange:k=>{k.target.value==="anthropic-oauth"?(m("anthropic"),f("anthropic-oauth")):m(k.target.value)},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(e==null?void 0:e.auth)==="device-key"&&s.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),(o||(e==null?void 0:e.auth)==="anthropic-oauth")&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),(i||(e==null?void 0:e.kind)==="codex")&&s.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),c==="openai-compatible"&&p!=="device-key"&&s.jsxs(s.Fragment,{children:[s.jsx(X,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:h,onChange:k=>v(k.target.value)})}),s.jsx(X,{label:"Authentication",children:s.jsxs("select",{disabled:!!e,value:p,onChange:k=>{f(k.target.value),x("")},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),s.jsx(q,{valign:"end",children:s.jsx(Bm,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:j,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),s.jsx(X,{label:"Context window",hint:"Tokens this endpoint actually serves. Leave blank unless you run the model yourself and set a window of your own — a conversation is ended once its history would fill half of this.",children:s.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:g,placeholder:e!=null&&e.detectedContextWindowTokens?`${e.detectedContextWindowTokens} (${bS(e)})`:"assumed from the model",onChange:k=>y(k.target.value)})}),c==="codex"&&s.jsx("p",{className:"muted",children:"Pick a model from the list once the account is connected."}),p==="anthropic-oauth"&&s.jsx("p",{className:"muted",children:"Save this account, then choose Connect Claude. You will approve in your browser and paste the authorization code here, not in chat. No existing agent assignment changes."}),p==="api-key"&&s.jsx(X,{label:e?"Replacement API key (leave blank to keep)":"API key",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:b,onChange:k=>x(k.target.value)})}),e&&s.jsx("p",{className:"muted",children:"Saving changes stops an active run at its next model call. Start a new turn afterward. Changing the default model does not change existing agent assignments."}),s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:r,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",disabled:S,children:"Save account"})]})]}),S&&s.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function CS({account:e,busy:t,run:n}){var a;const r=((a=e.login)==null?void 0:a.state)==="pending"&&e.login.attemptId?e.login:null,i=d.useRef(n);i.current=n,d.useEffect(()=>{if(!(r!=null&&r.attemptId))return;let c=!1,u=!1;const p=setInterval(()=>{c||u||(u=!0,A.ollamaPoll(e.id,r.attemptId).then(f=>{c||f.state==="waiting"||(c=!0,f.state==="connected"?i.current(async()=>{},`Connected as ${f.username}, device ${f.deviceName}.`):i.current(async()=>{throw new Error(f.message)},""))}).catch(()=>{}).finally(()=>{u=!1}))},2e3);return()=>{c=!0,clearInterval(p)}},[e.id,r==null?void 0:r.attemptId]);const o=()=>{const c=typeof window.open=="function"?window.open("","_blank"):null;n(async()=>{try{const u=await A.ollamaConnect(e.id,e.revision);return c&&(c.location.href=u.verificationUrl),u}catch(u){throw c==null||c.close(),u}},"Press Connect on the ollama.com page. This card notices on its own.")},l=e.device;return s.jsxs(s.Fragment,{children:[l&&s.jsx("p",{className:"muted",role:"status",children:l.connectedAt?`Connected as ${l.username||"an ollama.com account"}, device ${l.deviceName}.`:`Not connected yet. Device ${l.deviceName}.`}),s.jsxs(q,{children:[s.jsx(R,{disabled:t||!e.enabled||e.removalPending||!!r,onClick:o,children:e.configured?"Reconnect Ollama":"Connect Ollama"}),s.jsx(R,{disabled:t||!l||e.removalPending,onClick:()=>void n(async()=>({warning:(await A.ollamaDisconnect(e.id,e.revision)).note}),"Disconnected."),children:"Disconnect"})]}),r&&s.jsxs(H,{tone:"accent",role:"status",children:[s.jsxs("p",{children:[s.jsx("a",{href:r.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open the ollama.com page"})," and press Connect. Sign in there first if it asks."]}),s.jsxs("p",{className:"muted",children:["buddi stops waiting at ",r.expiresAt&&new Date(r.expiresAt).toLocaleTimeString(),"."]})]})]})}function ES({account:e,enabled:t,busy:n,run:r}){var l,a,c,u,p;const[i,o]=d.useState("");return d.useEffect(()=>{o("")},[(l=e.login)==null?void 0:l.attemptId,(a=e.login)==null?void 0:a.state]),s.jsxs(s.Fragment,{children:[!t&&s.jsx(H,{tone:"warning",children:"Claude subscription sign-in is turned off on this host."}),s.jsxs(q,{children:[s.jsx(R,{disabled:n||!t||!e.enabled||e.removalPending||((c=e.login)==null?void 0:c.state)==="pending",onClick:()=>void r(()=>A.anthropicAccountAction(e.id,"login",e.revision),"Open the Claude consent link below. Existing credentials remain until sign-in succeeds."),children:e.configured?"Reconnect Claude":"Connect Claude"}),((u=e.login)==null?void 0:u.state)==="pending"&&s.jsx(R,{disabled:n,onClick:()=>{o(""),r(()=>A.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),s.jsx(R,{disabled:n||!e.configured||e.removalPending,onClick:()=>{o(""),r(()=>A.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((p=e.login)==null?void 0:p.state)==="pending"&&s.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:f=>{f.preventDefault();const h=i;o(""),r(()=>A.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:h}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[s.jsx("p",{children:s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),s.jsxs("p",{className:"muted",children:["Use the Claude account you want to connect. Paste the entire code including #state. This attempt expires at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),"; restarting Buddi also ends it."]}),s.jsx(X,{label:"Claude authorization code",children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:f=>o(f.target.value),disabled:n})}),s.jsx(q,{align:"end",children:s.jsx(R,{type:"submit",variant:"accent",disabled:n||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const Fd={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5.5"};function Ud(e,t,n){const r=e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":t==="device-key"?"Ollama Cloud":"Local endpoint",i=new Set(n.map(o=>o.trim().toLowerCase()));if(!i.has(r.toLowerCase()))return r;for(let o=2;o<100;o+=1)if(!i.has(`${r} ${o}`.toLowerCase()))return`${r} ${o}`;return r}function lF({accounts:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:o}){const l=e.map(ne=>ne.label),[a,c]=d.useState(null),[u,p]=d.useState("anthropic"),[f,h]=d.useState("api-key"),[v,j]=d.useState(()=>Ud("anthropic","api-key",l)),[w,b]=d.useState(!1),[x,g]=d.useState(""),[y,m]=d.useState(""),[S,k]=d.useState(null),[N,C]=d.useState(!1),[P,E]=d.useState(""),[O,F]=d.useState(""),[D,T]=d.useState(!1),[z,Q]=d.useState(!1),Y=(ne,xe,Se=!1)=>{p(ne),h(xe),m(""),k(null),E(""),F(""),T(!1),Q(Se),g(Se?"":ne==="openai-compatible"?"http://localhost:11434/v1":""),w||j(Se?Ud(ne,"device-key",l):Ud(ne,xe,l))},M=ne=>{Y("openai-compatible",ne?"api-key":"device-key",!0),ne&&A.ollama().then(xe=>g(xe.cloudBaseUrl)).catch(()=>{})},B=a?e.find(ne=>ne.id===a):void 0;if(a)return B?s.jsx(aF,{account:B,busy:t,run:n,anthropicOAuthEnabled:o,onDone:()=>r(B.id)}):s.jsx(ie,{children:"Saving…"});const $=u==="openai-compatible"&&f!=="device-key",Z=u==="codex"||f==="anthropic-oauth"||f==="device-key",V=!Z&&(f==="none"||y.trim()!=="")&&(!$||x.trim()!==""),de=async()=>{var ne,xe;C(!0),E("");try{const Se=await A.probeModels({kind:u,auth:f,...$?{baseUrl:x}:{},...y.trim()?{secret:y}:{}});k(Se),O||F(((ne=Se.models.find(Me=>Me.isDefault))==null?void 0:ne.id)??((xe=Se.models[0])==null?void 0:xe.id)??"")}catch(Se){E(Se instanceof Error?Se.message:"Could not load models. You can still enter a custom model.")}finally{C(!1)}},ge=O.trim(),je=!v.trim()||$&&!x.trim()||$&&!ge;return s.jsxs("form",{className:"ui-stack",onSubmit:ne=>{ne.preventDefault();const xe=y;m("");const Se=ge||(f==="device-key"?Ba:Fd[u])||"claude-sonnet-5";(async()=>{let Me;!await n(async()=>(Me=await A.saveProviderAccount({label:v,kind:u,auth:f,baseUrl:x,defaultModel:Se,enabled:!0,...xe.trim()?{secret:xe}:{}}),Me),"Account saved.")||!Me||(ge||!Z?r(Me.id):c(Me.id))})()},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(X,{label:"Provider",children:s.jsxs("select",{value:f==="anthropic-oauth"?"anthropic-oauth":z?"ollama-cloud":u,onChange:ne=>{if(ne.target.value==="anthropic-oauth")Y("anthropic","anthropic-oauth");else if(ne.target.value==="ollama-cloud")Y("openai-compatible","device-key",!0);else{const xe=ne.target.value;Y(xe,xe==="codex"?"chatgpt":"api-key")}},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),o&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),i&&s.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),s.jsx(X,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:v,onChange:ne=>{j(ne.target.value),b(!0)},placeholder:"Anthropic — Personal"})}),z&&s.jsxs("label",{className:"ui-row",children:[s.jsx("input",{type:"checkbox",checked:f==="api-key",onChange:ne=>M(ne.target.checked)}),s.jsx("span",{children:"Use a key instead"})]}),$&&s.jsxs(s.Fragment,{children:[s.jsx(X,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:x,onChange:ne=>{g(ne.target.value),k(null)}})}),s.jsx(X,{label:"Authentication",children:s.jsxs("select",{value:f,onChange:ne=>{h(ne.target.value),m(""),k(null)},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),f==="api-key"&&s.jsx(X,{label:"API key",hint:"Stored in the vault, never shown again.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:y,onChange:ne=>{m(ne.target.value),k(null)}})}),Z?s.jsx("p",{className:"muted",children:u==="codex"?"You will connect your ChatGPT subscription on the next step, with a code you enter on openai.com, and pick a model then.":f==="device-key"?"You will connect on the next step: ollama.com opens, you press Connect, and no key is typed. Free to start.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Model"}),S?s.jsxs("div",{className:"ui-row",children:[s.jsxs("select",{"aria-label":"Model",value:D?"__custom__":O,onChange:ne=>{ne.target.value==="__custom__"?(T(!0),F("")):(T(!1),F(ne.target.value))},children:[S.models.map(ne=>s.jsxs("option",{value:ne.id,children:[ne.name===ne.id?ne.id:`${ne.name} — ${ne.id}`,ne.isDefault?" (provider default)":"",ne.thinks?" · thinks":""]},ne.id)),s.jsx("option",{value:"__custom__",children:"Custom model…"})]}),s.jsx(R,{size:"sm",disabled:N||!V,onClick:()=>void de(),children:N?"Loading…":"Reload"})]}):s.jsxs("div",{className:"ui-row",children:[s.jsx(R,{disabled:N||!V,onClick:()=>void de(),children:N?"Loading models…":"Load models"}),$?s.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):s.jsxs("span",{className:"muted",children:["Optional now: ",Fd[u]," is used until you pick one."]})]}),D||$&&!S?s.jsx("input",{"aria-label":"Custom model",required:$,maxLength:150,value:O,onChange:ne=>F(ne.target.value),placeholder:$?"qwen3:8b":Fd[u]}):null,P?s.jsx("span",{className:"ui-field-hint critical",role:"alert",children:P}):null,S!=null&&S.truncated?s.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:()=>r(),children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",disabled:je,children:"Save account"})]})]}),je&&s.jsxs("p",{className:"muted",children:["Enter an account name",$?", an endpoint and a model":""," to enable Save account."]})]})}function aF({account:e,busy:t,run:n,anthropicOAuthEnabled:r,onDone:i}){const[o,l]=d.useState(e.defaultModel),a=e.configured;return s.jsxs(K,{gap:"lg",children:[s.jsxs(H,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!a?s.jsx(ES,{account:e,enabled:!!r,busy:t,run:n}):null,e.kind==="codex"&&!a?s.jsx(NS,{account:e,busy:t,run:n}):null,e.auth==="device-key"&&!a?s.jsx(CS,{account:e,busy:t,run:n}):null,a?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-page-lede",children:"Pick the model this account offers by default. An agent can still choose another when you assign it."}),s.jsx(q,{valign:"end",children:s.jsx(Bm,{accountId:e.enabled?e.id:void 0,label:"Default model",value:o,onChange:l,disabled:t},`${e.id}:${e.revision}`)}),s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:i,children:"Skip for now"}),s.jsx(R,{variant:"accent",disabled:t||!o.trim(),onClick:()=>{if(o===e.defaultModel){i();return}n(()=>A.saveProviderAccount({...SS(e),defaultModel:o}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):s.jsx(q,{children:s.jsx(R,{onClick:i,children:"Finish later"})})]})}const nj=new Set(["co.uk","org.uk","me.uk","ltd.uk","plc.uk","net.uk","sch.uk","ac.uk","gov.uk","nhs.uk","police.uk","mod.uk","gov.ie","co.at","or.at","ac.at","gv.at","com.pl","net.pl","org.pl","info.pl","biz.pl","edu.pl","gov.pl","waw.pl","com.es","org.es","nom.es","gob.es","edu.es","com.pt","org.pt","gov.pt","edu.pt","com.gr","org.gr","net.gr","edu.gr","gov.gr","com.cy","org.cy","net.cy","gov.cy","ac.cy","com.mt","org.mt","net.mt","edu.mt","gov.mt","co.hu","org.hu","info.hu","com.ro","org.ro","info.ro","nom.ro","co.rs","org.rs","edu.rs","gov.rs","in.rs","com.ua","org.ua","net.ua","gov.ua","edu.ua","in.ua","kiev.ua","com.ru","org.ru","net.ru","msk.ru","spb.ru","co.no","priv.no","com.hr","from.hr","iz.hr","name.hr","co.it","gov.it","edu.it","asso.fr","com.fr","gouv.fr","nom.fr","prd.fr","tm.fr","co.je","net.je","org.je","co.gg","net.gg","org.gg","co.im","net.im","org.im","gc.ca","on.ca","qc.ca","bc.ca","ab.ca","com.mx","org.mx","net.mx","edu.mx","gob.mx","ny.us","ca.us","tx.us","fl.us","wa.us","k12.ca.us","lib.ca.us","com.br","net.br","org.br","gov.br","edu.br","art.br","blog.br","eco.br","emp.br","ind.br","inf.br","tv.br","app.br","dev.br","com.ar","org.ar","net.ar","gob.ar","edu.ar","int.ar","tur.ar","com.co","org.co","net.co","edu.co","gov.co","nom.co","com.pe","org.pe","net.pe","gob.pe","edu.pe","nom.pe","com.ve","org.ve","net.ve","gob.ve","co.ve","com.uy","org.uy","net.uy","gub.uy","edu.uy","com.ec","org.ec","net.ec","gob.ec","edu.ec","fin.ec","com.bo","org.bo","net.bo","gob.bo","edu.bo","com.py","org.py","net.py","gov.py","edu.py","gob.cl","gov.cl","co.cl","com.do","org.do","net.do","gob.do","edu.do","com.gt","org.gt","net.gt","gob.gt","edu.gt","co.cr","or.cr","fi.cr","go.cr","ac.cr","com.pa","org.pa","net.pa","gob.pa","com.sv","org.sv","gob.sv","edu.sv","com.ni","org.ni","gob.ni","com.hn","org.hn","net.hn","gob.hn","com.cu","org.cu","net.cu","gob.cu","com.jm","org.jm","net.jm","gov.jm","com.tt","org.tt","net.tt","gov.tt","co.tt","com.pr","org.pr","net.pr","gov.pr","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","co.nz","net.nz","org.nz","ac.nz","govt.nz","school.nz","geek.nz","gen.nz","kiwi.nz","maori.nz","co.jp","ne.jp","or.jp","ac.jp","ad.jp","ed.jp","go.jp","gr.jp","lg.jp","com.cn","net.cn","org.cn","gov.cn","edu.cn","ac.cn","com.hk","net.hk","org.hk","edu.hk","gov.hk","idv.hk","com.tw","net.tw","org.tw","edu.tw","gov.tw","idv.tw","co.kr","or.kr","ne.kr","go.kr","ac.kr","re.kr","pe.kr","co.in","net.in","org.in","firm.in","gen.in","ind.in","ac.in","edu.in","gov.in","res.in","nic.in","com.sg","net.sg","org.sg","edu.sg","gov.sg","per.sg","com.my","net.my","org.my","edu.my","gov.my","name.my","co.id","or.id","ac.id","go.id","web.id","my.id","biz.id","net.id","sch.id","co.th","in.th","ac.th","go.th","or.th","net.th","com.vn","net.vn","org.vn","edu.vn","gov.vn","com.ph","net.ph","org.ph","edu.ph","gov.ph","com.pk","net.pk","org.pk","edu.pk","gov.pk","com.bd","org.bd","net.bd","gov.bd","edu.bd","com.lk","org.lk","gov.lk","edu.lk","com.np","org.np","gov.np","edu.np","com.kh","org.kh","gov.kh","com.mm","org.mm","gov.mm","com.fj","org.fj","gov.fj","ac.fj","com.pg","org.pg","gov.pg","ac.pg","com.kz","org.kz","gov.kz","edu.kz","com.tr","net.tr","org.tr","gov.tr","edu.tr","gen.tr","biz.tr","info.tr","av.tr","bel.tr","k12.tr","co.il","org.il","net.il","ac.il","gov.il","muni.il","com.sa","net.sa","org.sa","gov.sa","edu.sa","med.sa","co.ae","net.ae","org.ae","gov.ae","ac.ae","com.qa","org.qa","net.qa","gov.qa","edu.qa","com.kw","org.kw","net.kw","gov.kw","edu.kw","com.bh","org.bh","net.bh","gov.bh","edu.bh","com.om","org.om","net.om","gov.om","co.om","com.jo","org.jo","net.jo","gov.jo","edu.jo","com.lb","org.lb","net.lb","gov.lb","edu.lb","com.eg","org.eg","net.eg","gov.eg","edu.eg","eun.eg","co.ir","ac.ir","gov.ir","org.ir","net.ir","co.za","org.za","net.za","gov.za","ac.za","web.za","edu.za","nom.za","com.ng","org.ng","net.ng","gov.ng","edu.ng","name.ng","co.ke","or.ke","ne.ke","go.ke","ac.ke","sc.ke","co.tz","or.tz","ne.tz","go.tz","ac.tz","co.ug","or.ug","ne.ug","go.ug","ac.ug","com.gh","org.gh","gov.gh","edu.gh","co.ma","net.ma","org.ma","gov.ma","ac.ma","press.ma","com.tn","org.tn","gov.tn","ens.tn","fin.tn","com.dz","org.dz","net.dz","gov.dz","edu.dz","com.et","org.et","gov.et","edu.et","co.zw","org.zw","gov.zw","ac.zw","co.zm","org.zm","gov.zm","ac.zm","co.bw","org.bw","ac.bw","com.na","org.na","co.na","co.mz","org.mz","gov.mz","com.cm","co.cm","net.cm","gov.cm","com.sn","org.sn","edu.sn","gouv.sn","com.ci","co.ci","or.ci","go.ci","ac.ci","com.tg","gouv.tg","co.rw","gov.rw","ac.rw","*.ck","*.er","*.fk","*.jm","*.kh","*.mm","*.np","*.pg","*.bd","github.io","githubusercontent.com","gitlab.io","bitbucket.io","pages.dev","workers.dev","trycloudflare.com","vercel.app","vercel.dev","now.sh","netlify.app","netlify.com","herokuapp.com","herokussl.com","cloudfront.net","amazonaws.com","s3.amazonaws.com","elasticbeanstalk.com","awsapprunner.com","amplifyapp.com","azurewebsites.net","azurestaticapps.net","cloudapp.net","azureedge.net","azurefd.net","blob.core.windows.net","trafficmanager.net","appspot.com","firebaseapp.com","web.app","run.app","cloudfunctions.net","blogspot.com","fly.dev","onrender.com","up.railway.app","deno.dev","deno.net","glitch.me","repl.co","replit.dev","replit.app","ngrok.io","ngrok.app","ngrok-free.app","ngrok.dev","ngrok-free.dev","surge.sh","readthedocs.io","myshopify.com","wixsite.com","webflow.io","framer.app","framer.website","ondigitalocean.app","digitaloceanspaces.com","supabase.co","fastly.net","global.ssl.fastly.net","edgecompute.app","duckdns.org","dyndns.org","ddns.net","no-ip.org","hopto.org","zapto.org","eu.org","us.org","neocities.org","codeberg.page","sourceforge.io","pythonanywhere.com","streamlit.app","hf.space"]);function cF(e){const t=e.toLowerCase().replace(/\.$/,"");if(!t.includes(".")||nj.has(t))return!0;const n=t.slice(t.indexOf(".")+1);return nj.has(`*.${n}`)}function uF(e){return typeof e=="string"&&e.includes("*")}function dF(e){const t=/^(https?):\/\/([^/?#@\s]+)(?:[/?#]\S*)?$/i.exec(e.trim());if(t===null)return{ok:!1,reason:"invalid"};const[,n,r]=t;if(!r.startsWith("*.")||r.slice(2).includes("*"))return{ok:!1,reason:"placement"};let i;try{i=new URL(`${n.toLowerCase()}://${r.slice(2)}`)}catch{return{ok:!1,reason:"invalid"}}const o=i.hostname;return o===""||o.startsWith("[")||/^[\d.]+$/.test(o)||o.startsWith(".")||o.includes("..")?{ok:!1,reason:"invalid"}:cF(o)?{ok:!1,reason:"public-suffix"}:{ok:!0,value:{pattern:`${i.protocol}//*.${i.host}`,protocol:i.protocol,suffix:o,port:i.port}}}const sj=["every-time","first-time","pre-approved"],AS={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function fF(e){const t=sj.indexOf(e);return sj.slice(0,t<0?1:t+1)}function TS(e){return e.endsWith(".account")}const hF="This account’s process holds the value for as long as its connection lives.",Hm="Stored, not usable until it has a binding.";function pF(e){return e==="browser.field"?"the origin of the site that holds the field, e.g. https://en.wikipedia.org or *.wikimedia.org":e==="browser.form.data"?"the origin, then the field name — e.g. https://localhost:8443 card-number":e==="browser.native.type"?"the app’s bundle id, e.g. com.bank.app":e==="http.header"?"the host, then the header name — e.g. localhost:9200 Authorization":e==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":TS(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const RS={"browser.form.data":{hint:"an origin, then the field name",build:(e,t)=>({origin:e,field:t})},"http.header":{hint:"a host, then the header name",build:(e,t)=>({host:e,header:t})},"developer.env":{hint:"a workspace, then the variable name",build:(e,t)=>({workspace:e,variable:t})}},mF="A wildcard may only stand for the leftmost part of a site, like *.wikimedia.org.",gF=e=>`That is a public suffix; ${e} would match every site.`,rj="Give the site as an origin, like https://en.wikipedia.org.";function ij(e){const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:["https:","//",e].join("");if(uF(e)){const n=dF(t);if(n.ok)return{ok:!0,target:n.value.pattern};if(n.reason==="placement")return{ok:!1,error:mF};if(n.reason==="public-suffix"){const r=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/[/?#:].*$/,"").toLowerCase();return{ok:!1,error:gF(r)}}return{ok:!1,error:rj}}try{const n=new URL(t);if(n.origin==="null"||n.protocol!=="https:"&&n.protocol!=="http:")throw new Error("not an origin");return{ok:!0,target:n.origin}}catch{return{ok:!1,error:rj}}}function xF(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const n=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&n?[r,n]:null}function PS(e,t){const n=t.trim();if(n==="")return{ok:!1,error:"Give the exact place this value may go."};if(n.startsWith("{"))try{const o=JSON.parse(n);return o!==null&&typeof o=="object"&&!Array.isArray(o)?{ok:!0,target:o}:{ok:!1,error:'A target in JSON is an object, like {"host":"localhost","header":"Authorization"}.'}}catch{return{ok:!1,error:"That opens like JSON but does not parse."}}if(e==="browser.field")return ij(n);if(e==="browser.native.type"||TS(e))return{ok:!0,target:n};const r=RS[e];if(r===void 0)return{ok:!0,target:n};const i=xF(n);if(i===null)return{ok:!1,error:`${e} needs both: ${r.hint}.`};if(e==="browser.form.data"){const o=ij(i[0]);return o.ok?{ok:!0,target:r.build(o.target,i[1])}:o}return{ok:!0,target:r.build(i[0],i[1])}}function vF(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function jF(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const n=t,r=RS[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),o=i.map(l=>n[l]);if(i.every(l=>typeof n[l]=="string"))return o.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const IS="accounts.provider";function yF(e,t){for(const n of e)if(n.kind===IS&&typeof n.target=="string"){const r=t.get(n.target);if(r)return r}}function $h(e,t,n){if(e===IS&&typeof t=="string"){const r=n.get(t);if(r)return r.label}return jF(e,t)}function MS(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function $S(e,t){if(typeof e!="object"||e===null)return[];const n=e[t];return Array.isArray(n)?n.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,o=r.count;return typeof i!="string"||typeof o!="number"||!(o>0)?[]:[{place:i,count:o}]}):[]}function _S(e){const t=e.map(({place:n,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?n.replace(/s$/,""):n}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function wF(e){const t=$S(e,"found");return t.length?`The value already sits in ${_S(t)}.`:""}function bF(e){const t=$S(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${_S(t)}.`:""}async function zr(e,t,n,r){n(!0),r(null);try{return(await A.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{n(!1)}}function kF({embedded:e,timezone:t}={}){const n=se(()=>A.secrets(),[]),r=se(()=>A.providerAccounts(),[]),i=d.useMemo(()=>{var c;return new Map((((c=r.data)==null?void 0:c.accounts)??[]).map(u=>[u.id,{label:u.label,provider:Wm(u)}]))},[r.data]),[o,l]=d.useState(!1),a=n.data;return s.jsxs(cn,{embedded:e,title:"Keys and secrets",lede:"What the agents may use and never see: a name, a value buddi keeps, and the exact places the value may go.",children:[s.jsxs(K,{gap:"lg",children:[!a&&!n.error?s.jsx(ie,{children:"Opening the vault…"}):null,n.error?s.jsx(q,{children:s.jsx(R,{onClick:n.reload,children:"Retry"})}):null,a?s.jsx(G,{title:"Secrets",aside:"A value the agents use and never see: bound to where it may go, never shown again.",actions:s.jsx(R,{variant:"accent",size:"sm",onClick:()=>l(!0),children:"Add a secret"}),panel:!0,children:s.jsx(K,{divided:!0,children:a.secrets.length===0?s.jsx(kt,{icon:"key",title:"Nothing stored yet",children:"Add one — a site password, an API token — and bind it to the places an agent may use it."}):a.secrets.map(c=>s.jsx(SF,{secret:c,accounts:i,destinations:a.destinations,timezone:t,onChanged:n.reload},c.name))})}):null,a?s.jsx(G,{title:"buddi’s own keys",aside:"Read-only.",children:s.jsxs(K,{gap:"sm",children:[a.ownKeys.length===0?s.jsx(ie,{children:"No keys of buddi’s own right now."}):s.jsx("div",{className:"ui-list",children:a.ownKeys.map(c=>s.jsx("div",{className:"ui-list-row",children:s.jsx("span",{className:"ui-list-main",children:s.jsx("span",{className:"mono",children:c})})},c))}),s.jsx("p",{className:"ui-card-meta",children:"These are the keys buddi itself runs on. They cannot be bound or replaced here, and the scrubber replaces them in what buddi sends out, exactly like your own secrets."})]})}):null]}),o&&a?s.jsx(CF,{destinations:a.destinations,onClose:()=>l(!1),onChanged:n.reload}):null]})}function SF({secret:e,accounts:t,destinations:n,timezone:r,onChanged:i}){const[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(!1),[v,j]=d.useState(!1),w=async()=>{await zr("secrets.delete",{name:e.name},l,c)!==null&&(h(!1),i())},b=e.lastUse,x=yF(e.bindings,t);return s.jsxs(K,{gap:"sm",children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:x?x.label:e.name}),x?s.jsx(Ka,{children:x.provider}):null,e.totp?s.jsx(Ka,{children:"TOTP"}):null,b?s.jsx(pe,{tone:MS(b.outcome),children:b.outcome}):null]}),x?s.jsx("p",{className:"ui-card-meta mono",children:e.name}):null,e.bindings.length===0?s.jsx("p",{className:"ui-card-meta",children:Hm}):s.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((g,y)=>s.jsxs("div",{className:"ui-row",children:[s.jsx(Ka,{children:g.kind}),s.jsx("span",{className:"mono",children:$h(g.kind,g.target,t)}),s.jsx(pe,{tone:"muted",children:AS[g.rule]??g.rule})]},y))}),e.bindings.some(g=>g.heldByPlugin)?s.jsx("p",{className:"ui-card-meta",children:hF}):null,s.jsx("p",{className:"ui-card-meta",children:b?`Last used ${ke(b.at)}${b.agentId?` by ${b.agentId}`:""} — ${b.kind}, ${$h(b.kind,b.target,t)}.`:"Never used."}),s.jsx(re,{message:a}),f?s.jsxs(H,{tone:"critical",role:"alert",children:[s.jsxs("p",{children:["Delete “",e.name,"”? The value and its bindings go; the use log stays, under the name."]}),s.jsxs(q,{children:[s.jsx(R,{variant:"danger",disabled:o,onClick:()=>void w(),children:"Delete it"}),s.jsx(R,{disabled:o,onClick:()=>h(!1),children:"Cancel"})]})]}):null,s.jsxs(q,{children:[s.jsx(R,{size:"sm",disabled:o,onClick:()=>p("replace"),children:"Replace value"}),s.jsx(R,{size:"sm",disabled:o,onClick:()=>p("rename"),children:"Rename"}),s.jsx(R,{size:"sm",disabled:o,onClick:()=>p("rebind"),children:e.bindings.length===0?"Add a binding":"Rebind"}),s.jsx(R,{size:"sm",variant:"danger",disabled:o,onClick:()=>h(!0),children:"Delete"}),s.jsx(R,{size:"sm",variant:"ghost","aria-expanded":v,onClick:()=>j(!v),children:"Use log"})]}),v?s.jsx(NF,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?s.jsx(EF,{secret:e,onClose:()=>p(null),onChanged:i}):null,u==="rename"?s.jsx(AF,{secret:e,onClose:()=>p(null),onChanged:i}):null,u==="rebind"?s.jsx(TF,{secret:e,destinations:n,onClose:()=>p(null),onChanged:i}):null]})}function NF({name:e,accounts:t,timezone:n}){const r=se(()=>A.secretUses(e,50),[e]);if(r.error)return s.jsx(re,{message:r.error});if(!r.data)return s.jsx(ie,{children:"Reading the log…"});const i=r.data.uses;return i.length===0?s.jsx(ie,{children:"No uses yet."}):s.jsx("div",{className:"ui-list",children:i.map((o,l)=>s.jsxs("div",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[Ie(o.at,n??"UTC")," — ",o.kind,", ",$h(o.kind,o.target,t)]}),s.jsxs("span",{className:"ui-list-sub",children:[o.agent?o.agent:"the owner",o.plugin?` · ${o.plugin}`:"",o.detail?` · ${o.detail}`:""]})]}),s.jsx("span",{className:"ui-list-side",children:s.jsx(pe,{tone:MS(o.outcome),children:o.outcome})})]},l))})}function OS({name:e,result:t,scrubbed:n,busy:r,failure:i,onScrub:o,onDone:l}){const a=wF(t);return s.jsxs(K,{gap:"sm",children:[s.jsxs(H,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),s.jsx("p",{className:"ui-card-meta",children:a||"Nothing of the value sits where buddi already holds text."}),s.jsx(re,{message:i}),a?s.jsx(q,{children:s.jsx(R,{variant:"accent",disabled:r||n!==null,onClick:o,children:n===null?"Scrub the history":bF(n)||"Nothing of it was left to replace."})}):null,s.jsx(q,{align:"end",children:s.jsx(R,{onClick:l,children:"Done"})})]})}function DS({destinations:e,bindings:t,disabled:n,onChange:r}){const i=(o,l)=>{r(t.map((a,c)=>c===o?{...a,...l}:a))};return s.jsx(K,{gap:"sm",children:t.map((o,l)=>{const a=e.find(u=>u.kind===o.kind),c=(a==null?void 0:a.maxRule)??o.rule;return s.jsxs(q,{valign:"end",children:[s.jsx(X,{label:"Kind",inline:!0,children:s.jsx("select",{value:o.kind,disabled:n,onChange:u=>{var f;const p=u.target.value;i(l,{kind:p,rule:((f=e.find(h=>h.kind===p))==null?void 0:f.maxRule)??o.rule})},children:(a?e:[...e,{kind:o.kind,plugin:"",maxRule:o.rule}]).map(u=>s.jsx("option",{value:u.kind,children:u.kind},u.kind))})}),s.jsx(X,{label:"Target",inline:!0,grow:!0,children:s.jsx("input",{type:"text",spellCheck:!1,disabled:n,value:o.target,placeholder:pF(o.kind),onChange:u=>i(l,{target:u.target.value})})}),s.jsx(X,{label:"Rule",inline:!0,children:s.jsx("select",{value:o.rule,disabled:n,onChange:u=>i(l,{rule:u.target.value}),children:fF(c).map(u=>s.jsx("option",{value:u,children:AS[u]},u))})}),s.jsx(R,{size:"sm",variant:"ghost",disabled:n,onClick:()=>r(t.filter((u,p)=>p!==l)),children:"Remove"})]},l)})})}function CF({destinations:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[o,l]=d.useState(""),[a,c]=d.useState(!1),[u,p]=d.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:e[0].maxRule}]:[]),[f,h]=d.useState(!1),[v,j]=d.useState(null),[w,b]=d.useState(null),[x,g]=d.useState(null),y=async()=>{const S=u.map(P=>PS(P.kind,P.target)),k=S.findIndex(P=>!P.ok);if(k!==-1){j(`Binding ${k+1}: ${S[k].error}`);return}const N=o;l("");const C=await zr("secrets.put",{name:r.trim(),value:N,totp:a,bindings:u.map((P,E)=>({kind:P.kind,target:S[E].target,rule:P.rule}))},h,j);C!==null&&(b({name:r.trim(),result:C}),n())},m=async()=>{const S=await zr("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},h,j);S!==null&&(g(S),n())};return s.jsx(qt,{title:"Add a secret",onClose:t,children:w?s.jsx(OS,{name:w.name,result:w.result,scrubbed:x,busy:f,failure:v,onScrub:()=>void m(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:S=>{S.preventDefault(),y()},children:s.jsxs("fieldset",{disabled:f,className:"ui-stack","data-gap":"sm",children:[s.jsx(X,{label:"Name",hint:"What an agent calls it. Saving a name that exists replaces that secret’s value.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:S=>i(S.target.value),placeholder:"PNC password"})}),s.jsx(X,{label:"Value",hint:"Kept in the vault, never shown again — not even here.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:o,onChange:S=>l(S.target.value)})}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:S=>c(S.target.checked)}),s.jsx("span",{children:"The code comes from this secret"})]}),s.jsx("p",{className:"ui-field-hint",children:"The seed and the code are one thing buddi holds — the owner’s explicit choice per secret."}),s.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[s.jsx("span",{className:"ui-field-label",children:"Bindings — the places this value may go"}),s.jsx(DS,{destinations:e,bindings:u,disabled:f,onChange:p}),u.length===0?s.jsx("p",{className:"ui-field-hint",children:Hm}):null,e.length?s.jsx(q,{children:s.jsx(R,{size:"sm",onClick:()=>p([...u,{kind:e[0].kind,target:"",rule:e[0].maxRule}]),children:"Add a binding"})}):s.jsx("p",{className:"ui-field-hint",children:"No destination is registered on this installation yet, so there is nothing to bind to."})]}),v?s.jsx(H,{tone:"critical",role:"alert",children:v}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:t,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",children:"Save secret"})]})]})})})}function EF({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(null),v=async()=>{const w=r;i("");const b=await zr("secrets.put",{name:e.name,value:w,totp:e.totp,bindings:e.bindings.map(({kind:x,target:g,rule:y})=>({kind:x,target:g,rule:y}))},l,c);b!==null&&(p(b),n())},j=async()=>{const w=await zr("secrets.scrub_history",{name:e.name},l,c);w!==null&&(h(w),n())};return s.jsx(qt,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?s.jsx(OS,{name:e.name,result:u,scrubbed:f,busy:o,failure:a,onScrub:()=>void j(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:w=>{w.preventDefault(),v()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(X,{label:"New value",hint:"Replaces what is stored. The bindings stay as they are.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,value:r,onChange:w=>i(w.target.value)})}),a?s.jsx(H,{tone:"critical",role:"alert",children:a}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:t,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",children:"Save value"})]})]})})})}function AF({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(e.name),[o,l]=d.useState(!1),[a,c]=d.useState(null),u=async()=>{await zr("secrets.rename",{name:e.name,to:r.trim()},l,c)!==null&&(n(),t())};return s.jsx(qt,{title:`Rename “${e.name}”`,onClose:t,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:p=>{p.preventDefault(),u()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(X,{label:"New name",hint:"The vault entry never moves; only the name the agents ask for does.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:p=>i(p.target.value)})}),a?s.jsx(H,{tone:"critical",role:"alert",children:a}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:t,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",disabled:!r.trim()||r.trim()===e.name,children:"Save name"})]})]})})})}function TF({secret:e,destinations:t,onClose:n,onChanged:r}){const[i,o]=d.useState(()=>e.bindings.map(f=>({kind:f.kind,target:vF(f.target),rule:f.rule}))),[l,a]=d.useState(!1),[c,u]=d.useState(null),p=async()=>{const f=i.map(j=>PS(j.kind,j.target)),h=f.findIndex(j=>!j.ok);if(h!==-1){u(`Binding ${h+1}: ${f[h].error}`);return}await zr("secrets.rebind",{name:e.name,bindings:i.map((j,w)=>({kind:j.kind,target:f[w].target,rule:j.rule}))},a,u)!==null&&(r(),n())};return s.jsx(qt,{title:`Rebind “${e.name}”`,onClose:n,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:f=>{f.preventDefault(),p()},children:s.jsxs("fieldset",{disabled:l,className:"ui-stack","data-gap":"sm",children:[s.jsx(DS,{destinations:t,bindings:i,disabled:l,onChange:o}),i.length===0?s.jsx("p",{className:"ui-field-hint",children:Hm}):null,t.length?s.jsx(q,{children:s.jsx(R,{size:"sm",onClick:()=>o([...i,{kind:t[0].kind,target:"",rule:t[0].maxRule}]),children:"Add a binding"})}):null,c?s.jsx(H,{tone:"critical",role:"alert",children:c}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{onClick:n,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",children:"Save bindings"})]})]})})})}function RF({timezone:e,embedded:t}){const{data:n,error:r,reload:i}=se(()=>A.sentinels(),[],3e4),[o,l]=d.useState(null),[a,c]=d.useState(null),u=(n==null?void 0:n.installed)??[],p=((n==null?void 0:n.runs)??[]).filter(v=>v.lastError),f=u.filter(v=>!v.enabled),h=(v,j)=>{l(v),c(null),A.setSentinelEnabled(v,j).catch(w=>c(w instanceof le?w.message:String(w))).finally(()=>{l(null),i()})};return s.jsxs(cn,{embedded:t,title:"Watchers",children:[s.jsx(re,{message:r??a}),s.jsx(H,{children:"Watchers are small checks that run on their own, with no model involved. An urgent finding wakes an agent, which verifies it before it tells you. The rest waits for the weekly recap."}),p.length>0?s.jsx(H,{tone:"warning",children:p.length===1?"One watcher failed on its last run.":`${p.length} watchers failed on their last run.`}):null,f.length>0?s.jsxs(H,{tone:"warning",children:[f.length===1?"One watcher is off.":`${f.length} watchers are off.`," A watcher that is off does not run, and what it already found stays as it was."]}):null,s.jsx(G,{title:"Installed",aside:s.jsx("a",{href:`${st}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:n?u.length===0?s.jsx(kt,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):s.jsx(Ft,{children:u.map(v=>{const j=n.runs.find(w=>w.sentinelId===v.id);return s.jsx(Kt,{lead:s.jsx(pe,{tone:v.enabled?j!=null&&j.lastError?"critical":j?"good":void 0:"muted",children:v.enabled?j!=null&&j.lastError?"failed":j?"ok":"never ran":"off"}),title:v.description,sub:`${v.id}, every ${PF(v.every)}${j!=null&&j.lastError?`. ${j.lastError}`:""}`,side:s.jsxs(s.Fragment,{children:[s.jsx("span",{title:j?Ie(j.lastRunAt,e):void 0,children:j?ke(j.lastRunAt):"never ran"}),s.jsx(R,{size:"sm",disabled:o===v.id,onClick:()=>h(v.id,!v.enabled),children:v.enabled?"Turn off":"Turn on"})]})},v.id)})}):s.jsx(ie,{children:"Loading…"})})]})}function PF(e){if(e%86400===0){const n=e/86400;return n===1?"day":`${n} days`}if(e%3600===0){const n=e/3600;return n===1?"hour":`${n} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}function IF({embedded:e}){const{data:t,error:n,reload:r}=se(()=>A.owner(),[]);return s.jsxs(cn,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[s.jsx(re,{message:n}),t?s.jsx(MF,{initial:t,onSaved:r}):null]})}function MF({initial:e,onSaved:t}){const[n,r]=d.useState(e.preferredName??""),[i,o]=d.useState(e.timezone??""),[l,a]=d.useState(e.language??""),[c,u]=d.useState(e.about??""),[p,f]=d.useState(!1),[h,v]=d.useState(!1),[j,w]=d.useState(null);d.useEffect(()=>{r(e.preferredName??""),o(e.timezone??""),a(e.language??""),u(e.about??"")},[e]);const b=n.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||l.trim()!==(e.language??"")||c.trim()!==(e.about??""),x=async()=>{f(!0),w(null);try{await A.setOwner({preferredName:n.trim()===""?null:n.trim(),timezone:i===""?null:i,language:l.trim()===""?null:l.trim(),about:c.trim()===""?null:c.trim()}),v(!0),t()}catch(y){w(y instanceof le?y.message:String(y))}finally{f(!1)}},g=e.zones.length>0?e.zones:[e.detectedTimezone];return s.jsx(G,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:s.jsxs(s.Fragment,{children:[h&&!b?s.jsx("span",{className:"muted",children:"Saved"}):null,s.jsx(R,{variant:"accent",disabled:!b||p,onClick:()=>void x(),children:p?"Saving…":"Save"})]}),children:s.jsxs(K,{divided:!0,gap:"lg",children:[s.jsx(G,{title:"Name and place",children:s.jsxs(Ps,{children:[s.jsx(X,{label:"What the agents call you",children:s.jsx("input",{value:n,maxLength:80,placeholder:e.displayName??"Your name",onChange:y=>{v(!1),r(y.target.value)}})}),s.jsx(X,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:s.jsxs("select",{value:i,onChange:y=>{v(!1),o(y.target.value)},children:[s.jsx("option",{value:"",children:"Not set (use the host's)"}),g.map(y=>s.jsx("option",{value:y,children:y},y))]})}),s.jsx(X,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:s.jsx("input",{value:l,maxLength:40,placeholder:"English, français…",onChange:y=>{v(!1),a(y.target.value)}})})]})}),s.jsxs(G,{title:"About you",children:[s.jsx(X,{label:"In your own words",hint:"Who you are, how you like answers, anything every agent should keep in mind. A few lines is plenty.",children:s.jsx("textarea",{rows:4,maxLength:1e3,value:c,placeholder:"I run a small studio and prefer short answers with the numbers first. Call me by my first name.",onChange:y=>{v(!1),u(y.target.value)}})}),j?s.jsx(H,{tone:"critical",children:j}):null]})]})})}const $F=2e6;function oj(e,t){const n=e.replace(/\r\n/g,`
109
- `).replace(/\n+$/,"").split(`
110
- `),r=t.replace(/\r\n/g,`
111
- `).replace(/\n+$/,"").split(`
112
- `);if(e.trim()===t.trim())return"(no change)";if(n.length*r.length>$F)return[...n.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
113
- `);const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let c=n.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=n[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const o=[];let l=0,a=0;for(;l<n.length&&a<r.length;)n[l]===r[a]?(o.push(` ${n[l]}`),l++,a++):i[l+1][a]>=i[l][a+1]?o.push(`-${n[l++]}`):o.push(`+${r[a++]}`);for(;l<n.length;)o.push(`-${n[l++]}`);for(;a<r.length;)o.push(`+${r[a++]}`);return o.join(`
114
- `)}const _F={skill:"skill",policy:"rule",change:"change to itself"};function OF(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,n])=>!/Id$/.test(t)&&n!==null&&n!==void 0&&n!=="").map(([t,n])=>`${t} ${typeof n=="object"?JSON.stringify(n):String(n)}`).join(" · ")}function _h(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function DF(e,t){const n=e.change;if(!n||n.part!=="tools")return[];if(t===e.editable)return n.added;const r=new Set(_h(n.current??""));return _h(t).filter(i=>!r.has(i))}function lj(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function LF({embedded:e,plugin:t}){const{data:n,error:r,reload:i}=se(()=>A.proposals(),[],3e4),[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState({}),v=async(x,g,y=!1)=>{l(null),c(null),p(x),h(({[x]:m,...S})=>S);try{c(await g()),i()}catch(m){const S=m instanceof Error?m.message:String(m);y?h(k=>({...k,[x]:S})):l(S)}finally{p(null)}},j=Rk(),w=((n==null?void 0:n.open)??[]).filter(x=>lj(x,t)),b=((n==null?void 0:n.closed)??[]).filter(x=>lj(x,t));return s.jsxs(cn,{embedded:e,title:"Proposals",lede:"What your agents learned and would like to keep: a procedure, a rule, a change to their own instructions. Nothing here applies itself. Keep what is right, correct what is nearly right, discard the rest.",children:[s.jsx(re,{message:r??o}),t?s.jsxs(H,{role:"status",children:["Showing the rules ",t," proposes. ",s.jsx("a",{href:lt("proposals"),children:"Show every proposal"})]}):null,a?s.jsx(H,{tone:"good",role:"status",children:a}):null,t?null:s.jsx(Pk,{offers:j.offers,reload:j.reload}),!n||w.length===0?s.jsx(G,{title:"Waiting",panel:!0,children:n?t?s.jsx(kt,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):s.jsx(kt,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):s.jsx(ie,{children:"Loading…"})}):s.jsx(G,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(x=>s.jsx(BF,{proposal:x,busy:u===x.id,refusal:f[x.id]??null,onKeep:g=>void v(x.id,async()=>{const y=await A.keepProposal(x.id,g);return`${x.title}: ${y.note}`},!0),onDiscard:g=>void v(x.id,async()=>(await A.discardProposal(x.id,g),`Discarded: ${x.title}. ${x.agent} will be told once and will not propose it again for 90 days.`))},x.id))}),b.length>0?s.jsx(G,{title:`Kept, discarded and expired (${b.length})`,aside:"These stop being shown a week after they were decided.",panel:!0,flush:!0,children:s.jsx(Ft,{children:b.map(x=>{var g;return s.jsx(Kt,{title:x.title,sub:`${x.agent}: ${FF(x)}`,side:x.kind==="skill"&&x.state==="kept"&&((g=x.skill)!=null&&g.live)?s.jsxs(q,{align:"end",children:[s.jsx("span",{className:"muted",children:ke(x.decidedAt??x.createdAt)}),s.jsx(R,{size:"sm",variant:"ghost",disabled:u===x.id,onClick:()=>void v(x.id,async()=>{const y=x.skill;return await A.removeSkill(x.agent,y.name),`Removed ${y.name} from ${x.agent}. Its versions are kept, and ${x.agent} will not propose it again for 90 days.`}),children:"Remove this skill"})]}):ke(x.decidedAt??x.createdAt)},x.id)})})}):null,!t&&(n!=null&&n.digest)?s.jsx(zF,{schedule:n.digest.schedule,onSaved:i}):null]})}function FF(e){switch(e.state){case"kept":return e.kind==="skill"&&e.skill?e.skill.live?`Kept as ${e.skill.name}, version ${e.skill.version}; it loads on the agent's next run.`:`Kept; ${e.skill.name} has a newer version now (${e.skill.version}).`:e.note??"Kept.";case"discarded":return e.reason?`Discarded: ${e.reason}`:"Discarded.";case"expired":return`Expired: ${e.reason??"not decided in 30 days"}.`;default:return"Waiting."}}const UF=Array.from({length:24},(e,t)=>t),aj=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function zF({schedule:e,onSaved:t}){const[n,r]=d.useState(e.day),[i,o]=d.useState(e.hour),[l,a]=d.useState(!1),[c,u]=d.useState(null),p=n!==e.day||i!==e.hour,f=async()=>{a(!0),u(null);try{await A.setDigestSchedule(n,i),u({tone:"good",text:`The digest now runs on ${aj[n]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(h){u({tone:"critical",text:h instanceof Error?h.message:String(h)})}finally{a(!1)}};return s.jsx(G,{title:"Weekly digest",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:l||!p,onClick:()=>void f(),children:"Save"}),children:s.jsxs(K,{children:[s.jsxs("p",{className:"muted",children:["Once a week, one message on Telegram and a card on Home: what your agents learned, what waits here, and what the rules you kept stopped them doing. No message when nothing was learned and nothing waits.",e.next?` Next: ${ke(e.next)}.`:""]}),s.jsxs(q,{children:[s.jsx(X,{label:"Day",children:s.jsx("select",{value:n,disabled:l,onChange:h=>r(Number(h.target.value)),children:aj.map((h,v)=>s.jsx("option",{value:v,children:h},h))})}),s.jsx(X,{label:`Hour (${e.timezone})`,children:s.jsx("select",{value:i,disabled:l,onChange:h=>o(Number(h.target.value)),children:UF.map(h=>s.jsxs("option",{value:h,children:[String(h).padStart(2,"0"),":00"]},h))})})]}),c?s.jsx(H,{tone:c.tone,role:"status",children:c.text}):null]})})}function cj(e,t){return e==="tools"?_h(t).join(`
115
- `):t}function BF({proposal:e,busy:t,refusal:n,onKeep:r,onDiscard:i}){const[o,l]=d.useState(e.editable??""),[a,c]=d.useState(""),u=e.editable!==null&&o!==e.editable,p=e.payload,f=e.echoes??[],h=e.kind==="change"?e.change??null:null,v=DF(e,o);return s.jsx(Ur,{tone:e.untrusted?"warning":"accent",title:e.title,meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{children:_F[e.kind]}),s.jsx(pe,{mono:!0,children:e.agent}),e.untrusted?s.jsx(pe,{tone:"warning",children:"untrusted text in view"}):null,v.length>0?s.jsx(pe,{tone:"warning",children:"widens its tools"}):null]}),foot:s.jsxs(q,{align:"end",children:[n?s.jsx("span",{className:"proposal-refusal",role:"alert",children:n}):null,s.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:a,maxLength:300,disabled:t,onChange:j=>c(j.target.value)}),s.jsx(R,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(a.trim()||void 0),children:"Discard"}),s.jsx(R,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&o.trim()==="",onClick:()=>r(u?o:void 0),children:u?"Keep my version":"Keep"})]}),children:s.jsxs(K,{gap:"sm",children:[e.why?s.jsx("p",{children:e.why}):null,s.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",ke(e.createdAt),e.conversationId?s.jsxs(s.Fragment,{children:[" in ",s.jsx("a",{href:zi(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?s.jsxs(H,{tone:"warning",title:e.kind==="policy"?"Learned from mail you received.":"Made with untrusted text in view.",children:[e.kind==="policy"?"The plugin counted this rule from your own triage decisions; no instruction in that mail can change what it does.":"Something written by someone other than you was in the agent's context when it proposed this. Read it for instructions that came from there rather than from you.",s.jsx("ul",{className:"proposal-sources",children:e.sources.map(j=>s.jsx("li",{className:"mono",children:j},j))}),f.length>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),s.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:f.map(j=>s.jsx("li",{children:s.jsx("mark",{className:"wb-diff-mark",children:j})},j))})]}):null]}):null,e.kind==="skill"?s.jsxs(s.Fragment,{children:[typeof p.when=="string"?s.jsxs("p",{className:"ui-card-meta",children:["When: ",p.when]}):null,e.skill?s.jsxs(K,{gap:"sm",children:[s.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",s.jsxs("a",{href:mt(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),s.jsx(Pc,{text:oj(e.skill.steps,o),marks:f,label:`Version ${e.skill.version} against this proposal`})]}):null,s.jsx(X,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:s.jsx("textarea",{rows:8,value:o,disabled:t,onChange:j=>l(j.target.value)})})]}):null,e.kind==="change"?s.jsxs(s.Fragment,{children:[v.length>0?s.jsxs(H,{tone:"warning",title:`Adds: ${v.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,h!=null&&h.refusal&&!u?s.jsx(H,{tone:"warning",title:"Keeping this as proposed will be refused.",children:h.refusal}):null,h&&h.current!==null?s.jsx(Pc,{text:oj(cj(h.part,h.current),cj(h.part,o)),marks:f,label:`${e.agent}'s ${h.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof p.before=="string"?s.jsx(St,{summary:`What its ${p.part==="tools"?"tool list":"instructions"} said when proposed`,children:s.jsx(ft,{children:p.before})}):null,s.jsx(X,{label:p.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:s.jsx("textarea",{rows:8,value:o,disabled:t,onChange:j=>l(j.target.value)})})]}):null,e.kind==="policy"?s.jsx(Tt,{items:[{label:"Plugin",value:s.jsx("span",{className:"mono",children:String(p.plugin??"")})},{label:"Matches",value:s.jsx("span",{className:"mono",children:OF(p.matcher??{})})},{label:"Does",value:String(p.action??"")},{label:"Learned from",value:(()=>{const j=Array.isArray(p.verdicts)?p.verdicts.length:0;return`${j} ${j===1?"decision":"decisions"}`})()}]}):null]})})}const WF=1500,HF={fetching:"Fetching the package.","installing-dependencies":"Installing its dependencies. Nothing of the plugin has run.",reading:"Reading what it says it is.",done:"Read. Nothing has been imported yet.",failed:"That did not work."},VF="Restart buddi to load it. In a checkout, stop it and run: buddi serve",LS=[{id:"npm",label:"From npm"},{id:"file",label:"A file"},{id:"directory",label:"A directory I built"}],FS="buddi.plugins.install-mode";function KF(){try{const e=window.localStorage.getItem(FS);if(LS.some(t=>t.id===e))return e}catch{}return"npm"}function GF(e){try{window.localStorage.setItem(FS,e)}catch{}}const ba=".tgz";function YF(e){const t=[],n=(r,i,o)=>{r>0&&t.push(`${r} ${r===1?i:o}`)};return n(e.tools,"tool","tools"),n(e.sentinels,"watcher","watchers"),n(e.views,"view","views"),n(e.agents,"agent","agents"),t.length===0?"nothing on its own":t.join(", ")}function US(e){return e.kind==="registry"?`npm · ${e.name}@${e.version}`:e.kind==="tarball"?`a file on this machine · ${e.path}`:`a directory on this machine · ${e.path}`}function qF(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function QF(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(null);return d.useEffect(()=>{if(!e){n(void 0),i(null);return}let o=!1;const l=()=>{A.pluginJob(e).then(c=>{o||(n(c),(c.phase==="done"||c.phase==="failed")&&(o=!0))}).catch(c=>{o||(i(c instanceof le?c.message:String(c)),o=!0)})};l();const a=window.setInterval(l,WF);return()=>{o=!0,window.clearInterval(a)}},[e]),{job:t,error:r}}function JF(){const e=se(()=>A.plugins(),[],2e4),[t,n]=d.useState(null),{job:r,error:i}=QF(t),[o,l]=d.useState(null),[a,c]=d.useState(null);d.useEffect(()=>{((r==null?void 0:r.phase)==="done"||(r==null?void 0:r.phase)==="failed")&&e.reload()},[r==null?void 0:r.phase]);const u=e.data,p=(u==null?void 0:u.checkout)??!0;return s.jsxs(K,{gap:"lg",children:[s.jsx(re,{message:e.error??o??i}),u!=null&&u.unavailable?s.jsx(H,{tone:"warning",children:u.unavailable}):null,s.jsx(G,{title:"Plugins",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsx(H,{tone:"warning",children:(u==null?void 0:u.trust)??""})}),s.jsx(G,{children:s.jsx(ZF,{busy:r!==void 0&&r.phase!=="done"&&r.phase!=="failed",onStaged:f=>{l(null),c(null),n(f)},onFailed:l})}),r?s.jsx(G,{children:s.jsxs(H,{tone:r.phase==="failed"?"critical":r.phase==="done"?"good":void 0,role:"status",children:[HF[r.phase]," ",r.error??""]})}):null]})}),((u==null?void 0:u.staged)??[]).map(f=>s.jsx(t4,{staged:f,onInstalled:h=>{c(h),n(null),e.reload()},onGone:()=>e.reload()},f.id)),a||u!=null&&u.restartNeeded?s.jsx(n4,{checkout:p,name:a}):null,s.jsx(G,{title:"Installed",panel:!0,children:u?u.installed.length===0?s.jsx(kt,{icon:"plug",title:"Nothing installed yet",children:"Only what buddi ships with is here."}):s.jsx(K,{divided:!0,children:u.installed.map(f=>s.jsx(G,{children:s.jsx(r4,{plugin:f,onChanged:()=>e.reload(),onFailed:l})},f.name))}):s.jsx(ie,{children:"Loading…"})}),((u==null?void 0:u.builtIn)??[]).length>0?s.jsx(G,{title:"Ships with buddi",panel:!0,children:s.jsx(K,{divided:!0,children:((u==null?void 0:u.builtIn)??[]).map(f=>s.jsx(G,{children:s.jsx(XF,{plugin:f})},f.name))})}):null]})}function XF({plugin:e}){return s.jsxs(K,{gap:"sm",children:[s.jsx(Tt,{items:[{label:s.jsx("span",{children:e.name}),value:s.jsxs("span",{children:[e.version," · ",YF(e.contribution)]})}]}),e.description?s.jsx("p",{className:"ui-card-meta",children:e.description}):null]})}function ZF({busy:e,onStaged:t,onFailed:n}){const[r,i]=d.useState(KF),[o,l]=d.useState(""),[a,c]=d.useState(!1),[u,p]=d.useState(null),[f,h]=d.useState(null),[v,j]=d.useState(!1),w=d.useRef(null),b=m=>n(m instanceof le?m.message:String(m)),x=m=>{i(m),GF(m),h(null)},g=()=>{c(!0),A.stagePlugin(o.trim()).then(m=>{t(m.job.id),l("")}).catch(b).finally(()=>c(!1))},y=m=>{if(m){if(!m.name.toLowerCase().endsWith(ba)){p(null),h(`${m.name} is not a ${ba}. A packed plugin is the file npm pack writes.`);return}h(null),p(m.name),c(!0),A.uploadPlugin(m).then(S=>t(S.job.id)).catch(b).finally(()=>c(!1))}};return s.jsxs(K,{gap:"sm",children:[s.jsx("div",{className:"plugin-modes",role:"radiogroup","aria-label":"Where it comes from",children:LS.map(m=>s.jsx("button",{type:"button",role:"radio","aria-checked":r===m.id,className:"plugin-mode","data-chosen":r===m.id?"true":void 0,onClick:()=>x(m.id),children:m.label},m.id))}),r==="file"?s.jsxs("div",{className:"plugin-drop",role:"group","aria-label":"A plugin file","data-state":v?"over":f?"refused":u?"chosen":void 0,onDragOver:m=>{m.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:m=>{var S,k;m.preventDefault(),j(!1),y((k=(S=m.dataTransfer)==null?void 0:S.files)==null?void 0:k[0])},children:[s.jsx("p",{className:"ui-card-meta",children:f??(u?`${u} — reading it.`:`Drop a ${ba} here, or choose one.`)}),s.jsx(q,{align:"end",children:s.jsx(R,{variant:"accent",disabled:e||a,onClick:()=>{var m;return(m=w.current)==null?void 0:m.click()},children:"Choose a file"})}),s.jsx("input",{ref:w,type:"file",accept:ba,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:m=>{var S;y((S=m.target.files)==null?void 0:S[0]),m.target.value=""}})]}):s.jsxs(s.Fragment,{children:[s.jsx(X,{label:r==="npm"?"Install a plugin":"The directory it is in",hint:r==="npm"?"A package name, or a name@version.":"The folder with its package.json, already built.",children:s.jsx("input",{type:"text",value:o,placeholder:r==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:m=>l(m.target.value)})}),s.jsx(q,{align:"end",children:s.jsx(R,{variant:"accent",disabled:e||a||o.trim()==="",onClick:g,children:"Read it first"})})]})]})}function e4({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],n=((i=e.uses)==null?void 0:i.dropped)??[];return s.jsx(G,{title:"What it reaches in buddi",children:s.jsxs(K,{gap:"sm",children:[t.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nothing beyond its own tables, its own folder and its own tools' approvals."}):s.jsx("ul",{className:"plugin-uses",children:t.map(o=>s.jsxs("li",{children:["It ",o.words,"."," ",o.added?s.jsxs(pe,{tone:"warning",children:["new in ",e.version]}):null]},o.use))}),n.length>0?s.jsxs("p",{className:"ui-card-meta",children:["No longer: ",n.map(o=>o.words).join("; "),"."]}):null]})})}function t4({staged:e,onInstalled:t,onGone:n}){const[r,i]=d.useState(e.plan??null),[o,l]=d.useState(!1),[a,c]=d.useState(null),u=h=>{l(!0),c(null),A.approveStaged(e.id,{integrity:e.integrity??"",...h?{acknowledgeDrift:!0}:{}}).then(v=>{v.installed?t(e.name):v.plan&&i(v.plan)}).catch(v=>c(v instanceof le?v.message:String(v))).finally(()=>l(!1))},p=()=>{l(!0),c(null),A.rejectStaged(e.id).then(()=>n()).catch(h=>c(h instanceof le?h.message:String(h))).finally(()=>l(!1))},f=(r==null?void 0:r.drift)??[];return s.jsxs(K,{gap:"lg",children:[s.jsx(Ur,{tone:"accent",title:`${e.name} ${e.version}`,meta:s.jsx(pe,{tone:"muted",children:"read, not installed"}),children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:a}),s.jsx(Tt,{items:[{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:US(e.source)},{label:"Published by",value:e.publisher??"nobody npm will name"},{label:"Integrity",value:s.jsx("span",{className:"mono",children:e.integrity===void 0||e.integrity===""?"none — this came off a disk":e.integrity})},...e.stagedHash?[{label:"Files on disk",value:s.jsx("span",{className:"mono",children:e.stagedHash})}]:[],{label:"Dependencies",value:e.dependencies.count===0?"none":`${e.dependencies.count}${e.dependencies.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${e.dependencies.withScripts.join(", ")}`}`}]}),s.jsx(e4,{staged:e}),s.jsx(G,{title:"What the package says about itself",children:s.jsxs(K,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"This is its claim, taken from its own buddi.md. Nothing has checked it yet."}),s.jsx(Tt,{items:[{label:"Schema it owns",value:e.claims.schema??"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":e.claims.hosts.join(", ")}]}),e.claims.missing?s.jsx("p",{className:"ui-card-meta",children:"It ships no buddi.md, so it says nothing about itself at all."}):s.jsx("p",{className:"ui-card-meta",children:e.claims.text})]})}),s.jsxs(q,{align:"end",children:[s.jsx(R,{variant:"ghost",disabled:o,onClick:p,children:"Not this one"}),s.jsx(R,{variant:"accent",disabled:o||f.length>0,onClick:()=>u(!1),children:"Install"})]})]})}),f.length>0?s.jsx(Ur,{tone:"warning",title:"What it said, and what it does",meta:s.jsx(pe,{tone:"warning",children:"read this first"}),children:s.jsxs(K,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),s.jsx("ul",{className:"plugin-drift",children:f.map(h=>s.jsx("li",{children:h},h))}),s.jsx(zS,{unlocks:(r==null?void 0:r.agents)??[]}),s.jsxs(q,{align:"end",children:[s.jsx(R,{variant:"ghost",disabled:o,onClick:p,children:"Not this one"}),s.jsx(R,{variant:"danger",disabled:o,onClick:()=>u(!0),children:"Install anyway"})]})]})}):null]})}function n4({checkout:e,name:t}){const[n,r]=d.useState(!1),[i,o]=d.useState(null),l=t?`${t} is installed.`:"Something is installed that this buddi has not loaded.";return s.jsx(G,{title:"Restart to load it",panel:!0,children:s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:i}),s.jsxs(H,{tone:e?"warning":void 0,role:"status",children:[l," ",e?VF:"Its tools appear once buddi restarts. That closes this dashboard for a few seconds."]}),e?null:s.jsx(q,{align:"end",children:s.jsx(R,{variant:"accent",disabled:n,onClick:()=>{r(!0),o(null),A.serviceAction("restart").catch(a=>o(a instanceof le?a.message:String(a))).finally(()=>r(!1))},children:"Restart to load it"})})]})})})}function zS({plugin:e,unlocks:t}){return t.length===0?null:s.jsx(G,{title:"Agents it would unlock",children:s.jsxs(K,{gap:"sm",divided:!0,children:[t.map(n=>s.jsx(s4,{plugin:e,unlock:n},n.id)),s.jsxs("p",{className:"ui-card-meta",children:["Nothing here is created by installing. Accept creates the agent with the tools listed. You can change or remove it ",s.jsx("a",{href:rt,children:"on the Agents page"}),"."]})]})})}function s4({plugin:e,unlock:t}){const n=Ek(e,t.id),r=t.drift.state!=="not-accepted";return s.jsxs(K,{gap:"sm",children:[s.jsxs(q,{children:[s.jsxs("span",{className:"mono",children:["@",t.handle]}),s.jsx(pe,{tone:t.drift.state==="up-to-date"?"good":"warning",children:t.drift.state}),s.jsx("span",{className:"ui-card-meta",children:t.drift.message}),s.jsx(io,{}),e&&!r&&!n.created?s.jsx(R,{size:"sm",disabled:n.busy,onClick:n.accept,children:"Accept"}):null]}),s.jsx(re,{message:n.failure}),n.created?s.jsx(Ak,{agent:n.created}):null]})}function r4({plugin:e,onChanged:t,onFailed:n}){const[r,i]=d.useState(!1),[o,l]=d.useState(!1),[a,c]=d.useState(""),[u,p]=d.useState(!1),f=v=>{p(!0),v.then(()=>{i(!1),l(!1),c(""),t()}).catch(j=>n(j instanceof le?j.message:String(j))).finally(()=>p(!1))},h=e.contribution;return s.jsxs(K,{gap:"sm",children:[s.jsx(Ur,{tone:e.loaded?void 0:"critical",title:`${e.name} ${e.version}`,meta:e.loaded?s.jsx(pe,{tone:"good",children:"loaded"}):s.jsx(pe,{tone:"critical",children:"did not load"}),actions:s.jsxs(q,{align:"end",children:[s.jsx(R,{size:"sm",variant:"ghost",disabled:u,onClick:()=>i(!r),children:"Remove…"}),s.jsx(R,{size:"sm",disabled:u,onClick:()=>f(A.updatePlugin(e.name)),children:"Update"})]}),children:s.jsxs(K,{gap:"sm",children:[e.error?s.jsx(H,{tone:"critical",children:e.error}):null,s.jsx(Tt,{items:[{label:"From",value:US(e.source)},{label:"Published by",value:qF(e.source,e.publisher)},{label:"Installed",value:ke(e.installedAt)},{label:"Contributes",value:`${h.tools} tool${h.tools===1?"":"s"}, ${h.sentinels} on a timer, ${h.views} view${h.views===1?"":"s"}, ${h.agents} agent${h.agents===1?"":"s"} proposed`}]}),s.jsx(zS,{plugin:e.name,unlocks:e.unlocks})]})}),r?s.jsxs(K,{gap:"sm",children:[s.jsx(H,{tone:"warning",children:"Removing it stops its code loading and leaves its tables exactly where they are, so installing it again picks up where it left off."}),s.jsxs("label",{className:"plugin-check",children:[s.jsx("input",{type:"checkbox",checked:o,onChange:v=>{l(v.target.checked),c("")}}),s.jsx("span",{children:"Also drop its data. Its tables are not recoverable afterwards."})]}),o?s.jsx(X,{label:`Type ${e.name} to confirm`,children:s.jsx("input",{value:a,onChange:v=>c(v.target.value)})}):null,s.jsxs(q,{align:"end",children:[s.jsx(R,{variant:"ghost",disabled:u,onClick:()=>{i(!1),l(!1),c("")},children:"Cancel"}),s.jsx(R,{variant:"danger",disabled:u||o&&a.trim()!==e.name,onClick:()=>f(A.uninstallPlugin(e.name,o?{purge:!0,confirm:a.trim()}:{})),children:o?"Remove and drop its data":"Remove"})]})]}):null]})}var Rl={},i4=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},BS={},yn={};let Vm;const o4=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];yn.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};yn.getSymbolTotalCodewords=function(t){return o4[t]};yn.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};yn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Vm=t};yn.isKanjiModeEnabled=function(){return typeof Vm<"u"};yn.toSJIS=function(t){return Vm(t)};var wu={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(wu);function WS(){this.buffer=[],this.length=0}WS.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var l4=WS;function Pl(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Pl.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};Pl.prototype.get=function(e,t){return this.data[e*this.size+t]};Pl.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Pl.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var a4=Pl,HS={};(function(e){const t=yn.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,o=t(r),l=o===145?26:Math.ceil((o-13)/(2*i-2))*2,a=[o-7];for(let c=1;c<i-1;c++)a[c]=a[c-1]-l;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],o=e.getRowColCoords(r),l=o.length;for(let a=0;a<l;a++)for(let c=0;c<l;c++)a===0&&c===0||a===0&&c===l-1||a===l-1&&c===0||i.push([o[a],o[c]]);return i}})(HS);var VS={};const c4=yn.getSymbolSize,uj=7;VS.getPositions=function(t){const n=c4(t);return[[0,0],[n-uj,0],[0,n-uj]]};var KS={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const o=i.size;let l=0,a=0,c=0,u=null,p=null;for(let f=0;f<o;f++){a=c=0,u=p=null;for(let h=0;h<o;h++){let v=i.get(f,h);v===u?a++:(a>=5&&(l+=t.N1+(a-5)),u=v,a=1),v=i.get(h,f),v===p?c++:(c>=5&&(l+=t.N1+(c-5)),p=v,c=1)}a>=5&&(l+=t.N1+(a-5)),c>=5&&(l+=t.N1+(c-5))}return l},e.getPenaltyN2=function(i){const o=i.size;let l=0;for(let a=0;a<o-1;a++)for(let c=0;c<o-1;c++){const u=i.get(a,c)+i.get(a,c+1)+i.get(a+1,c)+i.get(a+1,c+1);(u===4||u===0)&&l++}return l*t.N2},e.getPenaltyN3=function(i){const o=i.size;let l=0,a=0,c=0;for(let u=0;u<o;u++){a=c=0;for(let p=0;p<o;p++)a=a<<1&2047|i.get(u,p),p>=10&&(a===1488||a===93)&&l++,c=c<<1&2047|i.get(p,u),p>=10&&(c===1488||c===93)&&l++}return l*t.N3},e.getPenaltyN4=function(i){let o=0;const l=i.data.length;for(let c=0;c<l;c++)o+=i.data[c];return Math.abs(Math.ceil(o*100/l/5)-10)*t.N4};function n(r,i,o){switch(r){case e.Patterns.PATTERN000:return(i+o)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(i+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return i*o%2+i*o%3===0;case e.Patterns.PATTERN110:return(i*o%2+i*o%3)%2===0;case e.Patterns.PATTERN111:return(i*o%3+(i+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,o){const l=o.size;for(let a=0;a<l;a++)for(let c=0;c<l;c++)o.isReserved(c,a)||o.xor(c,a,n(i,c,a))},e.getBestMask=function(i,o){const l=Object.keys(e.Patterns).length;let a=0,c=1/0;for(let u=0;u<l;u++){o(u),e.applyMask(u,i);const p=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),p<c&&(c=p,a=u)}return a}})(KS);var bu={};const Gs=wu,ka=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Sa=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];bu.getBlocksCount=function(t,n){switch(n){case Gs.L:return ka[(t-1)*4+0];case Gs.M:return ka[(t-1)*4+1];case Gs.Q:return ka[(t-1)*4+2];case Gs.H:return ka[(t-1)*4+3];default:return}};bu.getTotalCodewordsCount=function(t,n){switch(n){case Gs.L:return Sa[(t-1)*4+0];case Gs.M:return Sa[(t-1)*4+1];case Gs.Q:return Sa[(t-1)*4+2];case Gs.H:return Sa[(t-1)*4+3];default:return}};var GS={},ku={};const Bo=new Uint8Array(512),Dc=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Bo[n]=t,Dc[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Bo[n]=Bo[n-255]})();ku.log=function(t){if(t<1)throw new Error("log("+t+")");return Dc[t]};ku.exp=function(t){return Bo[t]};ku.mul=function(t,n){return t===0||n===0?0:Bo[Dc[t]+Dc[n]]};(function(e){const t=ku;e.mul=function(r,i){const o=new Uint8Array(r.length+i.length-1);for(let l=0;l<r.length;l++)for(let a=0;a<i.length;a++)o[l+a]^=t.mul(r[l],i[a]);return o},e.mod=function(r,i){let o=new Uint8Array(r);for(;o.length-i.length>=0;){const l=o[0];for(let c=0;c<i.length;c++)o[c]^=t.mul(i[c],l);let a=0;for(;a<o.length&&o[a]===0;)a++;o=o.slice(a)}return o},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let o=0;o<r;o++)i=e.mul(i,new Uint8Array([1,t.exp(o)]));return i}})(GS);const YS=GS;function Km(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Km.prototype.initialize=function(t){this.degree=t,this.genPoly=YS.generateECPolynomial(this.degree)};Km.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=YS.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r};var u4=Km,qS={},xr={},Gm={};Gm.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var fs={};const QS="[0-9]+",d4="[A-Z $%*+\\-./:]+";let gl="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";gl=gl.replace(/u/g,"\\u");const f4="(?:(?![A-Z0-9 $%*+\\-./:]|"+gl+`)(?:.|[\r
116
- ]))+`;fs.KANJI=new RegExp(gl,"g");fs.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");fs.BYTE=new RegExp(f4,"g");fs.NUMERIC=new RegExp(QS,"g");fs.ALPHANUMERIC=new RegExp(d4,"g");const h4=new RegExp("^"+gl+"$"),p4=new RegExp("^"+QS+"$"),m4=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");fs.testKanji=function(t){return h4.test(t)};fs.testNumeric=function(t){return p4.test(t)};fs.testAlphanumeric=function(t){return m4.test(t)};(function(e){const t=Gm,n=fs;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(o,l){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?o.ccBits[0]:l<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return n.testNumeric(o)?e.NUMERIC:n.testAlphanumeric(o)?e.ALPHANUMERIC:n.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(o,l){if(e.isValid(o))return o;try{return r(o)}catch{return l}}})(xr);(function(e){const t=yn,n=bu,r=wu,i=xr,o=Gm,l=7973,a=t.getBCHDigit(l);function c(h,v,j){for(let w=1;w<=40;w++)if(v<=e.getCapacity(w,j,h))return w}function u(h,v){return i.getCharCountIndicator(h,v)+4}function p(h,v){let j=0;return h.forEach(function(w){const b=u(w.mode,v);j+=b+w.getBitsLength()}),j}function f(h,v){for(let j=1;j<=40;j++)if(p(h,j)<=e.getCapacity(j,v,i.MIXED))return j}e.from=function(v,j){return o.isValid(v)?parseInt(v,10):j},e.getCapacity=function(v,j,w){if(!o.isValid(v))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=i.BYTE);const b=t.getSymbolTotalCodewords(v),x=n.getTotalCodewordsCount(v,j),g=(b-x)*8;if(w===i.MIXED)return g;const y=g-u(w,v);switch(w){case i.NUMERIC:return Math.floor(y/10*3);case i.ALPHANUMERIC:return Math.floor(y/11*2);case i.KANJI:return Math.floor(y/13);case i.BYTE:default:return Math.floor(y/8)}},e.getBestVersionForData=function(v,j){let w;const b=r.from(j,r.M);if(Array.isArray(v)){if(v.length>1)return f(v,b);if(v.length===0)return 1;w=v[0]}else w=v;return c(w.mode,w.getLength(),b)},e.getEncodedBits=function(v){if(!o.isValid(v)||v<7)throw new Error("Invalid QR Code version");let j=v<<12;for(;t.getBCHDigit(j)-a>=0;)j^=l<<t.getBCHDigit(j)-a;return v<<12|j}})(qS);var JS={};const Oh=yn,XS=1335,g4=21522,dj=Oh.getBCHDigit(XS);JS.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;Oh.getBCHDigit(i)-dj>=0;)i^=XS<<Oh.getBCHDigit(i)-dj;return(r<<10|i)^g4};var ZS={};const x4=xr;function Vi(e){this.mode=x4.NUMERIC,this.data=e.toString()}Vi.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Vi.prototype.getLength=function(){return this.data.length};Vi.prototype.getBitsLength=function(){return Vi.getBitsLength(this.data.length)};Vi.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const o=this.data.length-n;o>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,o*3+1))};var v4=Vi;const j4=xr,zd=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ki(e){this.mode=j4.ALPHANUMERIC,this.data=e}Ki.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Ki.prototype.getLength=function(){return this.data.length};Ki.prototype.getBitsLength=function(){return Ki.getBitsLength(this.data.length)};Ki.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=zd.indexOf(this.data[n])*45;r+=zd.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(zd.indexOf(this.data[n]),6)};var y4=Ki;const w4=xr;function Gi(e){this.mode=w4.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Gi.getBitsLength=function(t){return t*8};Gi.prototype.getLength=function(){return this.data.length};Gi.prototype.getBitsLength=function(){return Gi.getBitsLength(this.data.length)};Gi.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var b4=Gi;const k4=xr,S4=yn;function Yi(e){this.mode=k4.KANJI,this.data=e}Yi.getBitsLength=function(t){return t*13};Yi.prototype.getLength=function(){return this.data.length};Yi.prototype.getBitsLength=function(){return Yi.getBitsLength(this.data.length)};Yi.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=S4.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
117
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var N4=Yi,e1={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var o={},l={};l[r]=0;var a=t.PriorityQueue.make();a.push(r,0);for(var c,u,p,f,h,v,j,w,b;!a.empty();){c=a.pop(),u=c.value,f=c.cost,h=n[u]||{};for(p in h)h.hasOwnProperty(p)&&(v=h[p],j=f+v,w=l[p],b=typeof l[p]>"u",(b||w>j)&&(l[p]=j,a.push(p,j),o[p]=u))}if(typeof i<"u"&&typeof l[i]>"u"){var x=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(x)}return o},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],o=r;o;)i.push(o),n[o],o=n[o];return i.reverse(),i},find_path:function(n,r,i){var o=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(o,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},o;n=n||{};for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(e1);var C4=e1.exports;(function(e){const t=xr,n=v4,r=y4,i=b4,o=N4,l=fs,a=yn,c=C4;function u(x){return unescape(encodeURIComponent(x)).length}function p(x,g,y){const m=[];let S;for(;(S=x.exec(y))!==null;)m.push({data:S[0],index:S.index,mode:g,length:S[0].length});return m}function f(x){const g=p(l.NUMERIC,t.NUMERIC,x),y=p(l.ALPHANUMERIC,t.ALPHANUMERIC,x);let m,S;return a.isKanjiModeEnabled()?(m=p(l.BYTE,t.BYTE,x),S=p(l.KANJI,t.KANJI,x)):(m=p(l.BYTE_KANJI,t.BYTE,x),S=[]),g.concat(y,m,S).sort(function(N,C){return N.index-C.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function h(x,g){switch(g){case t.NUMERIC:return n.getBitsLength(x);case t.ALPHANUMERIC:return r.getBitsLength(x);case t.KANJI:return o.getBitsLength(x);case t.BYTE:return i.getBitsLength(x)}}function v(x){return x.reduce(function(g,y){const m=g.length-1>=0?g[g.length-1]:null;return m&&m.mode===y.mode?(g[g.length-1].data+=y.data,g):(g.push(y),g)},[])}function j(x){const g=[];for(let y=0;y<x.length;y++){const m=x[y];switch(m.mode){case t.NUMERIC:g.push([m,{data:m.data,mode:t.ALPHANUMERIC,length:m.length},{data:m.data,mode:t.BYTE,length:m.length}]);break;case t.ALPHANUMERIC:g.push([m,{data:m.data,mode:t.BYTE,length:m.length}]);break;case t.KANJI:g.push([m,{data:m.data,mode:t.BYTE,length:u(m.data)}]);break;case t.BYTE:g.push([{data:m.data,mode:t.BYTE,length:u(m.data)}])}}return g}function w(x,g){const y={},m={start:{}};let S=["start"];for(let k=0;k<x.length;k++){const N=x[k],C=[];for(let P=0;P<N.length;P++){const E=N[P],O=""+k+P;C.push(O),y[O]={node:E,lastCount:0},m[O]={};for(let F=0;F<S.length;F++){const D=S[F];y[D]&&y[D].node.mode===E.mode?(m[D][O]=h(y[D].lastCount+E.length,E.mode)-h(y[D].lastCount,E.mode),y[D].lastCount+=E.length):(y[D]&&(y[D].lastCount=E.length),m[D][O]=h(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,g))}}S=C}for(let k=0;k<S.length;k++)m[S[k]].end=0;return{map:m,table:y}}function b(x,g){let y;const m=t.getBestModeForData(x);if(y=t.from(g,m),y!==t.BYTE&&y.bit<m.bit)throw new Error('"'+x+'" cannot be encoded with mode '+t.toString(y)+`.
118
- Suggested mode is: `+t.toString(m));switch(y===t.KANJI&&!a.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new n(x);case t.ALPHANUMERIC:return new r(x);case t.KANJI:return new o(x);case t.BYTE:return new i(x)}}e.fromArray=function(g){return g.reduce(function(y,m){return typeof m=="string"?y.push(b(m,null)):m.data&&y.push(b(m.data,m.mode)),y},[])},e.fromString=function(g,y){const m=f(g,a.isKanjiModeEnabled()),S=j(m),k=w(S,y),N=c.find_path(k.map,"start","end"),C=[];for(let P=1;P<N.length-1;P++)C.push(k.table[N[P]].node);return e.fromArray(v(C))},e.rawSplit=function(g){return e.fromArray(f(g,a.isKanjiModeEnabled()))}})(ZS);const Su=yn,Bd=wu,E4=l4,A4=a4,T4=HS,R4=VS,Dh=KS,Lh=bu,P4=u4,Lc=qS,I4=JS,M4=xr,Wd=ZS;function $4(e,t){const n=e.size,r=R4.getPositions(t);for(let i=0;i<r.length;i++){const o=r[i][0],l=r[i][1];for(let a=-1;a<=7;a++)if(!(o+a<=-1||n<=o+a))for(let c=-1;c<=7;c++)l+c<=-1||n<=l+c||(a>=0&&a<=6&&(c===0||c===6)||c>=0&&c<=6&&(a===0||a===6)||a>=2&&a<=4&&c>=2&&c<=4?e.set(o+a,l+c,!0,!0):e.set(o+a,l+c,!1,!0))}}function _4(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function O4(e,t){const n=T4.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],o=n[r][1];for(let l=-2;l<=2;l++)for(let a=-2;a<=2;a++)l===-2||l===2||a===-2||a===2||l===0&&a===0?e.set(i+l,o+a,!0,!0):e.set(i+l,o+a,!1,!0)}}function D4(e,t){const n=e.size,r=Lc.getEncodedBits(t);let i,o,l;for(let a=0;a<18;a++)i=Math.floor(a/3),o=a%3+n-8-3,l=(r>>a&1)===1,e.set(i,o,l,!0),e.set(o,i,l,!0)}function Hd(e,t,n){const r=e.size,i=I4.getEncodedBits(t,n);let o,l;for(o=0;o<15;o++)l=(i>>o&1)===1,o<6?e.set(o,8,l,!0):o<8?e.set(o+1,8,l,!0):e.set(r-15+o,8,l,!0),o<8?e.set(8,r-o-1,l,!0):o<9?e.set(8,15-o-1+1,l,!0):e.set(8,15-o-1,l,!0);e.set(r-8,8,1,!0)}function L4(e,t){const n=e.size;let r=-1,i=n-1,o=7,l=0;for(let a=n-1;a>0;a-=2)for(a===6&&a--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,a-c)){let u=!1;l<t.length&&(u=(t[l]>>>o&1)===1),e.set(i,a-c,u),o--,o===-1&&(l++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function F4(e,t,n){const r=new E4;n.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),M4.getCharCountIndicator(c.mode,e)),c.write(r)});const i=Su.getSymbolTotalCodewords(e),o=Lh.getTotalCodewordsCount(e,t),l=(i-o)*8;for(r.getLengthInBits()+4<=l&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const a=(l-r.getLengthInBits())/8;for(let c=0;c<a;c++)r.put(c%2?17:236,8);return U4(r,e,t)}function U4(e,t,n){const r=Su.getSymbolTotalCodewords(t),i=Lh.getTotalCodewordsCount(t,n),o=r-i,l=Lh.getBlocksCount(t,n),a=r%l,c=l-a,u=Math.floor(r/l),p=Math.floor(o/l),f=p+1,h=u-p,v=new P4(h);let j=0;const w=new Array(l),b=new Array(l);let x=0;const g=new Uint8Array(e.buffer);for(let N=0;N<l;N++){const C=N<c?p:f;w[N]=g.slice(j,j+C),b[N]=v.encode(w[N]),j+=C,x=Math.max(x,C)}const y=new Uint8Array(r);let m=0,S,k;for(S=0;S<x;S++)for(k=0;k<l;k++)S<w[k].length&&(y[m++]=w[k][S]);for(S=0;S<h;S++)for(k=0;k<l;k++)y[m++]=b[k][S];return y}function z4(e,t,n,r){let i;if(Array.isArray(e))i=Wd.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const p=Wd.rawSplit(e);u=Lc.getBestVersionForData(p,n)}i=Wd.fromString(e,u||40)}else throw new Error("Invalid data");const o=Lc.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`
119
- The chosen QR Code version cannot contain this amount of data.
120
- Minimum version required to store current data is: `+o+`.
121
- `);const l=F4(t,n,i),a=Su.getSymbolSize(t),c=new A4(a);return $4(c,t),_4(c),O4(c,t),Hd(c,n,0),t>=7&&D4(c,t),L4(c,l),isNaN(r)&&(r=Dh.getBestMask(c,Hd.bind(null,c,n))),Dh.applyMask(r,c),Hd(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}BS.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=Bd.M,i,o;return typeof n<"u"&&(r=Bd.from(n.errorCorrectionLevel,Bd.M),i=Lc.from(n.version),o=Dh.from(n.maskPattern),n.toSJISFunc&&Su.setToSJISFunction(n.toSJISFunc)),z4(t,i,r,o)};var t1={},Ym={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(o){return[o,o]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,o=r.width&&r.width>=21?r.width:void 0,l=r.scale||4;return{width:o,scale:o?4:l,margin:i,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},e.getImageWidth=function(r,i){const o=e.getScale(r,i);return Math.floor((r+i.margin*2)*o)},e.qrToImageData=function(r,i,o){const l=i.modules.size,a=i.modules.data,c=e.getScale(l,o),u=Math.floor((l+o.margin*2)*c),p=o.margin*c,f=[o.color.light,o.color.dark];for(let h=0;h<u;h++)for(let v=0;v<u;v++){let j=(h*u+v)*4,w=o.color.light;if(h>=p&&v>=p&&h<u-p&&v<u-p){const b=Math.floor((h-p)/c),x=Math.floor((v-p)/c);w=f[a[b*l+x]?1:0]}r[j++]=w.r,r[j++]=w.g,r[j++]=w.b,r[j]=w.a}}})(Ym);(function(e){const t=Ym;function n(i,o,l){i.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=l,o.width=l,o.style.height=l+"px",o.style.width=l+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,l,a){let c=a,u=l;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),l||(u=r()),c=t.getOptions(c);const p=t.getImageWidth(o.modules.size,c),f=u.getContext("2d"),h=f.createImageData(p,p);return t.qrToImageData(h.data,o,c),n(f,u,p),f.putImageData(h,0,0),u},e.renderToDataURL=function(o,l,a){let c=a;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),c||(c={});const u=e.render(o,l,c),p=c.type||"image/png",f=c.rendererOpts||{};return u.toDataURL(p,f.quality)}})(t1);var n1={};const B4=Ym;function fj(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function Vd(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function W4(e,t,n){let r="",i=0,o=!1,l=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),u=Math.floor(a/t);!c&&!o&&(o=!0),e[a]?(l++,a>0&&c>0&&e[a-1]||(r+=o?Vd("M",c+n,.5+u+n):Vd("m",i,0),i=0,o=!1),c+1<t&&e[a+1]||(r+=Vd("h",l),l=0)):i++}return r}n1.render=function(t,n,r){const i=B4.getOptions(n),o=t.modules.size,l=t.modules.data,a=o+i.margin*2,c=i.color.light.a?"<path "+fj(i.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",u="<path "+fj(i.color.dark,"stroke")+' d="'+W4(l,o,i.margin)+'"/>',p='viewBox="0 0 '+a+" "+a+'"',h='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+p+' shape-rendering="crispEdges">'+c+u+`</svg>
122
- `;return typeof r=="function"&&r(null,h),h};const H4=i4,Fh=BS,s1=t1,V4=n1;function qm(e,t,n,r,i){const o=[].slice.call(arguments,1),l=o.length,a=typeof o[l-1]=="function";if(!a&&!H4())throw new Error("Callback required as last argument");if(a){if(l<2)throw new Error("Too few arguments provided");l===2?(i=n,n=t,t=r=void 0):l===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(l<1)throw new Error("Too few arguments provided");return l===1?(n=t,t=r=void 0):l===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(c,u){try{const p=Fh.create(n,r);c(e(p,t,r))}catch(p){u(p)}})}try{const c=Fh.create(n,r);i(null,e(c,t,r))}catch(c){i(c)}}Rl.create=Fh.create;Rl.toCanvas=qm.bind(null,s1.render);Rl.toDataURL=qm.bind(null,s1.renderToDataURL);Rl.toString=qm.bind(null,function(e,t,n){return V4.render(e,n)});async function K4(e){const t=await Rl.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const hj=10*6e4,G4=2e3;function r1(e,t){const[n,r]=d.useState(null),[i,o]=d.useState(null),[l,a]=d.useState(!1),[c,u]=d.useState(!1),p=d.useRef(e);p.current=e;const f=d.useRef(t);f.current=t;const h=d.useCallback(async()=>{const v=await A.telegramPairing();r(v),u(!1),a(!1),o(await K4(v.link).catch(()=>""))},[]);return d.useEffect(()=>{if(!n||l||c)return;let v=!1;const j=Math.min(Date.parse(n.expiresAt)||Date.now()+hj,Date.now()+hj),w=window.setInterval(()=>{if(Date.now()>=j){u(!0);return}p.current().then(b=>{var x;v||!b||(a(!0),(x=f.current)==null||x.call(f))}).catch(()=>{})},G4);return()=>{v=!0,window.clearInterval(w)}},[n,l,c]),{offer:n,square:i,paired:l,stale:c,ask:h}}function i1({offer:e,square:t,children:n}){return s.jsxs("div",{className:"meet-pair",children:[t?s.jsx("img",{className:"meet-qr",src:t,alt:e.link}):null,s.jsx("a",{className:"meet-link",href:e.link,target:"_blank",rel:"noreferrer",children:e.link}),n]})}const o1=new Set(["approval","question"]),Na={approval:{label:"Approvals",hint:"A run nobody is watching wants to do something gated."},question:{label:"Questions",hint:"A run asked you something and waits."},watcher:{label:"Watchers",hint:"A watcher or a source found something."},reminder:{label:"Reminders",hint:"A reminder an agent promised you came due."},failure:{label:"Failures",hint:"Background jobs died and will not be retried."},recap:{label:"Reports",hint:"Mission reports, the weekly recap, answers to actions you tapped."},plugin:{label:"Plugins",hint:"A plugin that may send you messages has something to say."}};function Y4({timezone:e}){var w,b;const t=se(()=>A.notificationSettings(),[]),n=se(()=>A.notifications(20),[],3e4),[r,i]=d.useState(null),[o,l]=d.useState(!1),[a,c]=d.useState(!1),[u,p]=d.useState(null),f=((w=t.data)==null?void 0:w.channels)??[],h=r??((b=t.data)==null?void 0:b.settings),v=x=>{h&&(c(!1),i({...h,...x}))},j=()=>{h&&(l(!0),c(!1),p(null),A.saveNotificationSettings(h).then(()=>{c(!0),i(null),t.reload()}).catch(x=>p(x instanceof le?x.message:String(x))).finally(()=>l(!1)))};return s.jsxs(K,{gap:"lg",children:[s.jsx(q4,{timezone:e,onChange:t.reload}),s.jsx(G,{title:"Notifications",aside:"What buddi tells you when you are not looking at this page.",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:o||!h,onClick:j,children:"Save"}),children:s.jsxs(K,{divided:!0,children:[s.jsx(re,{message:t.error??u}),s.jsx(G,{title:"Where buddi reaches you",children:h?f.length===0?s.jsx("p",{className:"ui-card-meta",children:"No channel yet, so everything waits for you here. Pair Telegram and buddi can reach you on your phone."}):s.jsx(K,{gap:"sm",children:f.map(x=>{var g;return s.jsx(X4,{channel:x,checked:(h.defaultChannel??((g=f[0])==null?void 0:g.kind))===x.kind,onPick:()=>v({defaultChannel:x.kind})},x.kind)})}):s.jsx(ie,{children:"Loading…"})}),s.jsx(G,{title:"By kind",children:h?s.jsxs(K,{gap:"sm",children:[BT.map(x=>s.jsxs("div",{className:"pref-row nt-kind",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:Na[x].label}),s.jsx("span",{className:"ui-field-hint",children:Na[x].hint})]}),s.jsxs("select",{"aria-label":Na[x].label,value:Z4(h,x,f),onChange:g=>{const y={...h.perKind};g.target.value==="default"?delete y[x]:y[x]=g.target.value,v({perKind:y})},children:[s.jsx("option",{value:"default",children:"Default"}),f.map(g=>s.jsx("option",{value:g.kind,children:g.label},g.kind)),o1.has(x)?null:s.jsx("option",{value:"off",children:"Off"})]})]},x)),s.jsx("p",{className:"ui-field-hint",children:"Off keeps it in the list below and never sends it."})]}):null}),s.jsx(G,{title:"Quiet hours",children:h?s.jsxs(K,{gap:"sm",children:[s.jsxs("div",{className:"nt-times",children:[s.jsx(X,{label:"From",children:s.jsx("input",{type:"time",value:h.quietStart??"",onChange:x=>v({quietStart:x.target.value||null})})}),s.jsx(X,{label:"Until",children:s.jsx("input",{type:"time",value:h.quietEnd??"",onChange:x=>v({quietEnd:x.target.value||null})})}),s.jsx(X,{label:"End of the day",children:s.jsx("input",{type:"time",value:h.endOfDay,onChange:x=>v({endOfDay:x.target.value})})})]}),s.jsxs("p",{className:"ui-field-hint",children:["Messages wait until quiet hours end. Approvals and questions still come through. At the end of the day, what could wait goes out as one message. Times are on your clock (",e,")."]})]}):null}),a?s.jsx(H,{tone:"good",role:"status",children:"Saved."}):null]})}),s.jsxs(G,{title:"The last twenty",panel:!0,flush:!0,children:[s.jsx(re,{message:n.error}),n.data?n.data.notifications.length===0?s.jsx(ie,{children:"Nothing yet. What buddi tells you will be listed here."}):s.jsx(Ft,{children:n.data.notifications.map(x=>s.jsx(Kt,{title:x.title,sub:`${Ie(x.createdAt,e)} · ${Na[x.kind].label.toLowerCase()} · ${e3(x,f)}`,side:s.jsx(t3,{row:x})},x.id))}):s.jsx(ie,{children:"Loading…"})]})]})}function q4({timezone:e,onChange:t}){var C,P;const n=se(()=>A.telegramBot(),[]),r=se(()=>A.telegramDevices(),[]),[i,o]=d.useState(!1),[l,a]=d.useState(""),[c,u]=d.useState(!1),[p,f]=d.useState(null),[h,v]=d.useState(null),j=d.useRef(new Set),w=r1(()=>A.telegramDevices().then(E=>E.devices.some(O=>!j.current.has(O.id))),()=>{r.reload(),t()}),b=((C=n.data)==null?void 0:C.configured)??!1,x=!b||i,g=()=>{var O;if(l.trim()===""||c)return;u(!0),f(null);const E=i&&(((O=n.data)==null?void 0:O.running)??!1);A.saveTelegramToken(l.trim()).then(F=>{a(""),o(!1),f(F.restartNeeded?{ok:!1,text:F.note??"Saved. It will be ready the next time buddi starts."}:E?{ok:!0,text:"Saved. The new bot takes over the next time buddi starts."}:{ok:!0,text:"Saved."}),n.reload(),t()}).catch(F=>f({ok:!1,text:F instanceof le?F.message:String(F)})).finally(()=>u(!1))},y=()=>{var E;v(null),j.current=new Set((((E=r.data)==null?void 0:E.devices)??[]).map(O=>O.id)),w.ask().catch(O=>v(O instanceof le?O.message:String(O)))},{offer:m,square:S,paired:k,stale:N}=w;return s.jsx(G,{title:"Telegram",aside:"Talk to buddi from your phone.",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{title:"The bot",foot:x?s.jsxs(s.Fragment,{children:[i?s.jsx(R,{variant:"ghost",onClick:()=>{o(!1),a("")},children:"Cancel"}):null,s.jsx(R,{variant:"accent",disabled:c||l.trim()==="",onClick:g,children:"Save token"})]}):void 0,children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:n.error}),!n.data&&!n.error?s.jsx(ie,{children:"Loading…"}):b&&!i?s.jsxs("div",{className:"nt-channel",children:[s.jsx("span",{className:"pref-label",children:(P=n.data)!=null&&P.username?`Bot: @${n.data.username}`:"A bot token is saved."}),s.jsx(R,{variant:"ghost",size:"sm",onClick:()=>{o(!0),f(null)},children:"Replace token"})]}):null,x?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-card-meta",children:"Ask @BotFather for a bot and paste its token here."}),s.jsx(X,{label:"Bot token",grow:!0,children:s.jsx("input",{type:"password",value:l,autoComplete:"off",spellCheck:!1,onChange:E=>a(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),g())}})})]}):null,p?s.jsx(H,{tone:p.ok?"good":"warning",role:"status",children:p.text}):null]})}),s.jsxs(G,{title:"Your devices",children:[s.jsx(re,{message:r.error}),r.data?r.data.devices.length===0?s.jsx("p",{className:"ui-card-meta",children:"No phone is paired yet."}):s.jsx(Ft,{children:r.data.devices.map(E=>s.jsx(Kt,{title:E.name??`Telegram user ${E.userId}`,sub:`Paired ${Ie(E.pairedAt,e)} · ${E.lastSeenAt?`last spoke ${ke(E.lastSeenAt)}`:"has not spoken yet"}`,side:s.jsx(Q4,{id:E.id,onGone:()=>{r.reload(),t()}})},E.id))}):r.error?null:s.jsx(ie,{children:"Loading…"})]}),s.jsx(G,{title:"Pair a device",foot:b&&(!m||k)?s.jsx(R,{variant:m?void 0:"accent",onClick:y,children:"Pair a phone"}):b&&N?s.jsx(R,{variant:"accent",onClick:y,children:"New code"}):void 0,children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:h}),b?k?s.jsx(H,{tone:"good",role:"status",children:"Paired."}):m&&N?s.jsx("p",{className:"ui-card-meta",children:"That code has run out."}):m?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-card-meta",children:"Open this on your phone, then send /start to the bot."}),s.jsx(i1,{offer:m,square:S,children:s.jsx(J4,{text:m.link})}),s.jsxs("p",{className:"ui-field-hint",children:["The code works until ",Ie(m.expiresAt,e),"."]})]}):s.jsx("p",{className:"ui-card-meta",children:"Pair another phone, or the first one if you skipped it."}):s.jsx("p",{className:"ui-card-meta",children:"Save a bot token first."})]})})]})})}function Q4({id:e,onGone:t}){const[n,r]=d.useState(!1),[i,o]=d.useState(!1),[l,a]=d.useState(null);if(!n)return s.jsx(R,{size:"sm",onClick:()=>r(!0),children:"Unpair"});const c=()=>{o(!0),a(null),A.unpairTelegramDevice(e).then(t).catch(u=>a(u instanceof le?u.message:String(u))).finally(()=>o(!1))};return s.jsxs("span",{className:"nt-channel",children:[s.jsx("span",{className:"ui-field-hint",role:l?"alert":void 0,children:l??"It will no longer reach your agents."}),s.jsx(R,{size:"sm",variant:"ghost",disabled:i,onClick:()=>r(!1),children:"Keep"}),s.jsx(R,{size:"sm",variant:"danger",disabled:i,onClick:c,children:"Unpair"})]})}function J4({text:e}){const[t,n]=d.useState(null),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("Select the link to copy it.");return}navigator.clipboard.writeText(e).then(()=>n("Copied."),()=>n("Select the link to copy it."))};return s.jsxs("span",{className:"nt-channel",children:[s.jsx(R,{size:"sm",onClick:r,children:"Copy"}),t?s.jsx("span",{className:"ui-field-hint",role:"status",children:t}):null]})}function X4({channel:e,checked:t,onPick:n}){const[r,i]=d.useState(!1),[o,l]=d.useState(null),a=()=>{i(!0),l(null),A.testChannel(e.kind).then(()=>l({ok:!0,text:"Sent. Check that it arrived."})).catch(c=>l({ok:!1,text:c instanceof le?c.message:String(c)})).finally(()=>i(!1))};return s.jsxs("div",{className:"nt-channel",children:[s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"nt-default-channel",checked:t,onChange:n}),s.jsxs("span",{className:"nt-channel-text",children:[s.jsxs("span",{className:"pref-label",children:[e.label,e.where?`, ${e.where}`:""]}),s.jsxs("span",{className:"ui-field-hint",children:["The title and a few lines of each message go to ",e.label,"."]}),o?s.jsx("span",{className:"nt-channel-sent","data-tone":o.ok?void 0:"critical",role:"status",children:o.text}):null]})]}),s.jsx(R,{size:"sm",disabled:r,onClick:a,children:"Send a test"})]})}function Z4(e,t,n){const r=e.perKind[t];return r==="off"?o1.has(t)?"default":"off":r&&n.some(i=>i.kind===r)?r:"default"}function e3(e,t){var n;return e.channel&&e.channel!=="dashboard"?((n=t.find(r=>r.kind===e.channel))==null?void 0:n.label)??e.channel:"dashboard"}function t3({row:e}){return e.state==="failed"?s.jsxs("span",{className:"nt-state","data-tone":"critical",children:["Failed: ",e.error??"no reason given"]}):e.actedAt?s.jsx("span",{className:"nt-state",children:"Acted on"}):e.seenAt?s.jsx("span",{className:"nt-state",children:"Seen"}):e.state==="held"?s.jsx("span",{className:"nt-state",children:"Waiting"}):e.state==="stored"?s.jsx("span",{className:"nt-state",children:"Kept"}):e.state==="sent"?s.jsx("span",{className:"nt-state",children:"Sent"}):s.jsx("span",{className:"nt-state",children:"Not seen"})}const n3={you:"person",appearance:"sun",notifications:"bell",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function s3(e){const t=$I.map(r=>({id:r.id,route:lt(r.id),label:r.label,icon:n3[r.id],group:r.group})),n=[...e].sort((r,i)=>r.title.localeCompare(i.title,void 0,{sensitivity:"base"})||r.plugin.localeCompare(i.plugin)||r.id.localeCompare(i.id)).map(r=>({id:_0(r.plugin,r.id),route:gm(r.plugin,r.id),label:r.title,icon:Gk(r.icon),group:"plugins"}));return[...t,...n]}function l1(e){return MI.map(t=>({id:t.id,label:t.label,entries:e.filter(n=>n.group===t.id)})).filter(t=>t.entries.length>0)}function a1(e,t){return t?`${e}, ${t} open`:e}function r3({entries:e,active:t,counts:n={},navigate:r}){var c;const i=d.useRef(null),o=l1(e),l=e.some(u=>u.id===t)?t:(c=e[0])==null?void 0:c.id,a=u=>{var v;const p=[...((v=i.current)==null?void 0:v.querySelectorAll("a.settings-nav-link"))??[]],f=p.indexOf(document.activeElement);if(f===-1)return;const h=j=>{var w;u.preventDefault(),(w=p[Math.max(0,Math.min(p.length-1,j))])==null||w.focus()};if(u.key==="ArrowDown")h(f+1);else if(u.key==="ArrowUp")h(f-1);else if(u.key==="Home")h(0);else if(u.key==="End")h(p.length-1);else if(u.key==="Enter"||u.key===" "){u.preventDefault();const j=p[f].getAttribute("href");j&&r(j)}};return s.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:i,onKeyDown:a,children:o.map(u=>s.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${u.id}`,children:[s.jsx("div",{className:"settings-nav-label",id:`settings-nav-${u.id}`,children:u.label}),u.entries.map(p=>{const f=p.id===t,h=n[p.id];return s.jsxs("a",{className:"settings-nav-link",href:p.route,"data-active":f?"true":void 0,"aria-current":f?"page":void 0,"aria-label":h?a1(p.label,h):void 0,tabIndex:p.id===l?0:-1,onClick:v=>{v.preventDefault(),r(p.route)},children:[s.jsx(Ue,{name:p.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:p.label}),h?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:h>99?"99+":h}):null]},p.id)})]},u.id))})}function i3({entries:e,active:t,counts:n={},navigate:r}){const i=l1(e),o=e.find(l=>l.id===t)??e[0];return s.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:s.jsxs(om,{modal:!1,children:[s.jsx(lm,{asChild:!0,children:s.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(o==null?void 0:o.label)??""}`,children:[o?s.jsx(Ue,{name:o.icon,className:"settings-nav-icon"}):null,s.jsx("span",{className:"settings-nav-text",children:o==null?void 0:o.label}),s.jsx(Ue,{name:"chevron-down",className:"settings-menu-chevron"})]})}),s.jsx(am,{children:s.jsx(cm,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:s.jsx(QP,{value:t,onValueChange:l=>{const a=e.find(c=>c.id===l);a&&r(a.route)},children:i.map((l,a)=>s.jsxs(qP,{children:[a>0?s.jsx(Va,{className:"ui-menu-sep"}):null,s.jsx(um,{className:"ui-menu-label",children:l.label}),l.entries.map(c=>{const u=n[c.id];return s.jsxs(JP,{value:c.id,className:"ui-menu-item settings-menu-item","data-active":c.id===t?"true":void 0,"aria-label":u?a1(c.label,u):void 0,children:[s.jsxs("span",{className:"settings-menu-entry",children:[s.jsx(Ue,{name:c.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:c.label})]}),u?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:u>99?"99+":u}):null]},c.id)})]},l.id))})})})]})})}function o3({hash:e,timezone:t,navigate:n,agents:r,pluginPages:i}){var w,b;const o=_I(e),l=Vk(i!==void 0),a=i??l,c=TI(e),u=c?a.find(c.plugin,c.page):void 0,p=Mh(gS),f=s3(a.settings),v={proposals:((b=(w=se(()=>Promise.resolve().then(()=>A.proposals()),[],3e4).data)==null?void 0:w.open)==null?void 0:b.length)??0},j={entries:f,active:o,counts:v,navigate:x=>n(x)};return s.jsxs("div",{className:"settings",children:[p?null:s.jsx(r3,{...j}),s.jsx("div",{className:"settings-body",children:s.jsxs("div",{className:"ui-page",children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Settings"}),s.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),p?s.jsx(i3,{...j}):null,u?s.jsx(pD,{page:u,navigate:n,timezone:t,siblings:a.all.filter(x=>x.plugin===u.plugin)}):null,o==="you"?s.jsx(IF,{embedded:!0}):null,o==="appearance"?s.jsx(l3,{}):null,o==="notifications"?s.jsx(Y4,{timezone:t}):null,o==="memory"?s.jsx(oS,{embedded:!0,agents:r,timezone:t}):null,o==="proposals"?s.jsx(LF,{embedded:!0,plugin:PI(e)}):null,o==="accounts"?s.jsx(tF,{embedded:!0}):null,o==="computer"?s.jsx($_,{embedded:!0,timezone:t}):null,o==="secrets"?s.jsx(kF,{embedded:!0,timezone:t}):null,o==="watchers"?s.jsx(RF,{timezone:t,embedded:!0}):null,o==="backup"?s.jsx(qL,{}):null,o==="plugins"?s.jsx(JF,{}):null,o==="system"?s.jsx(a3,{timezone:t}):null]})})]})}function l3(){const[e,t]=Zk();return s.jsx(G,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:s.jsxs(K,{divided:!0,gap:"lg",children:[s.jsx(Kd,{label:"Theme",hint:"System follows your Mac.",children:s.jsx(Ga,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:e.theme,onChange:n=>t({theme:n})})}),s.jsx(Kd,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:s.jsx(Ga,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:e.ground,onChange:n=>t({ground:n})})}),s.jsx(Kd,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:s.jsx(Ga,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:e.width,onChange:n=>t({width:n})})})]})})}function Kd({label:e,hint:t,children:n}){return s.jsxs("div",{className:"pref-row ui-section",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:e}),s.jsx("span",{className:"ui-field-hint",children:t})]}),n]})}function a3({timezone:e}){const t=se(()=>A.overview(),[],15e3),n=se(()=>A.session(),[]),r=se(()=>A.providerAccounts(),[]),i=t.data;return s.jsxs(K,{gap:"lg",children:[s.jsx(re,{message:t.error}),s.jsx(b3,{}),i?s.jsx(G,{title:"The queue",panel:!0,actions:s.jsx(R,{size:"sm",variant:i.paused?"accent":void 0,onClick:()=>{A.setPaused(!i.paused).then(()=>t.reload())},children:i.paused?"Resume the queue":"Pause the queue"}),children:s.jsxs("p",{className:"ui-card-meta",children:[i.paused?"Paused. Nothing is being claimed until you resume.":"Running. Jobs are claimed as they come due."," ",i.paused?s.jsx(pe,{tone:"warning",children:"paused"}):s.jsx(pe,{tone:"good",children:"running"})]})}):null,s.jsxs(G,{title:"This host",panel:!0,children:[s.jsx(Tt,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?Ie(i.now,e):"…"},{label:"Bound to",value:n.data?`${n.data.host}:${n.data.port}`:"…"},{label:"Credential vault",value:r.data?f3(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?s.jsx(H,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),s.jsx(d3,{}),s.jsx(c3,{}),s.jsx(G,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?s.jsx(ie,{children:"No sources are installed."}):s.jsx(Tt,{items:i.mail.map(o=>({key:o.sourceId,label:s.jsx("span",{className:"mono",children:o.sourceId}),value:o.lastError?s.jsx("span",{className:"critical",children:o.lastError}):s.jsxs("span",{children:["polled ",ke(o.lastRunAt)]})}))}):s.jsx(ie,{children:"Loading…"})})]})}function c3(){var v;const e=se(()=>A.tailscale(),[]),[t,n]=d.useState(null),[r,i]=d.useState(!1),[o,l]=d.useState(null),[a,c]=d.useState(!1),u=e.data,p=t??((u==null?void 0:u.login)||((v=u==null?void 0:u.self)==null?void 0:v.login)||""),f=(u==null?void 0:u.proxied)===!0,h=j=>{i(!0),l(null),c(!1),A.setTailscale({enabled:j,login:p.trim()}).then(()=>{c(!0)}).catch(w=>l(w instanceof le?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return s.jsx(G,{title:"Sign in through Tailscale",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:r||!u||f,onClick:()=>h((u==null?void 0:u.enabled)??!1),children:"Save"}),children:s.jsx(K,{divided:!0,children:s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:e.error??o}),s.jsx("p",{className:"ui-card-meta",children:u?u.available&&u.self?`Tailscale is running on this machine as ${u.self.login}.`:u.available?"Tailscale is running on this machine.":"Tailscale is not running here.":"…"}),f?s.jsxs(s.Fragment,{children:[s.jsx(H,{tone:"warning",children:"Change this from the computer buddi runs on."}),s.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${p}`:"Off"})]}):null,s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||f,onChange:j=>h(j.target.checked)}),s.jsx("span",{children:"Let this Tailscale login sign in"})]}),s.jsx(X,{label:"Tailscale login",children:s.jsx("input",{type:"text",value:p,placeholder:"you@example.com",disabled:r||!u||f,onChange:j=>n(j.target.value)})}),s.jsx("p",{className:"ui-card-meta",children:"Anyone signed in to Tailscale as this login, on any device in your tailnet, is signed in to buddi. The proxy must run on this machine:"}),s.jsxs("div",{className:"tailscale-command",children:[s.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),s.jsx(R,{size:"sm",disabled:r||!u,onClick:()=>{u3((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),s.jsx("p",{className:"ui-card-meta",children:"This gives your tailnet the trust this machine already has: buddi cannot tell the Tailscale proxy from another program running here, and any program that can reach the dashboard on this machine can already read buddi’s files."}),a?s.jsx(H,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function u3(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function d3(){var u;const e=se(()=>A.service(),[],1e4),[t,n]=d.useState(null),[r,i]=d.useState(!1),[o,l]=d.useState(null),a=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!a)return null;const c=p=>{i(!0),l(null),A.serviceAction(p).then(()=>{n(null)}).catch(f=>{l(f.message)}).finally(()=>{i(!1),e.reload()})};return s.jsx(G,{title:"Service",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsx(Tt,{items:[{label:"Database",value:s.jsx(pj,{state:a.database,pid:a.databasePid})},{label:"Gateway",value:s.jsx(pj,{state:a.gateway,pid:a.gatewayPid})},{label:"Supervisor",value:s.jsxs("span",{className:"mono",children:["pid ",a.supervisorPid]})}]})}),s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:o}),t?s.jsx(H,{tone:"warning",role:"alert",children:t==="stop"?"Stopping the gateway closes this dashboard. The database keeps running; run buddi in a terminal to bring the dashboard back.":"Restarting the gateway closes this dashboard for a few seconds. If it does not come back on its own, run buddi in a terminal."}):s.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),s.jsx(q,{align:"end",children:t?s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",disabled:r,onClick:()=>{n(null),l(null)},children:"Cancel"}),s.jsx(R,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>{n("stop")},children:"Stop gateway"}),s.jsx(R,{variant:"accent",onClick:()=>{n("restart")},children:"Restart gateway"})]})})]})})]})})}function pj({state:e,pid:t}){return s.jsxs("span",{children:[s.jsx(pe,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?s.jsx("span",{className:"ui-card-meta",children:"no process"}):s.jsxs("span",{className:"mono",children:["pid ",t]})]})}function f3(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const h3=2e3,mj={starting:"Getting started.",backup:"Taking a backup first, so there is a way back.",stopping:"Stopping the gateway. The database stays up.",installing:"Installing the new version.",restarting:"Restarting buddi on the new version.",migrating:"Bringing the database up to date.",done:"Done.",failed:"That did not work."},p3=new Set(["done","failed","rolled-back"]),m3="The check asks the npm registry for the newest version and sends nothing else.",g3="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",x3="A checkout upgrades with git pull, then buddi upgrade in a terminal.",v3=10*6e4,j3="buddi did not come back. Run buddi doctor in a terminal.";function y3(e){const t=e.step==="starting"?"while starting":`at ${e.step??"an unknown step"}`;return`The upgrade to ${e.to} failed ${t}: ${e.error??"no reason given"}. The backup taken first is ${e.backup??"not available"}. Run buddi doctor in a terminal; it prints the way back.`}function w3(e,t,n,r){const[i,o]=d.useState(void 0),[l,a]=d.useState(!1),[c,u]=d.useState(null),p=d.useRef(!1),f=d.useRef(n),h=d.useRef(r);return f.current=n,h.current=r,d.useEffect(()=>{if(!e){o(void 0),a(!1),p.current=!1;return}let v=!1,j=0;const w=()=>{p.current=!0,j=Date.now()+v3,a(!0)},b=()=>{if(Date.now()<j){A.session().then(y=>{v||y.version!==void 0&&y.version===t||(v=!0,f.current())}).catch(()=>{}),A.version().then(y=>{const m=y.history[y.history.length-1];v||(m==null?void 0:m.outcome)!=="failed"||(v=!0,a(!1),u(y3(m)))}).catch(()=>{});return}v=!0,a(!1),u(j3)},x=()=>{if(!v){if(p.current)return b();A.upgradeJob(e).then(y=>{var m;v||(o(y),u(null),(p3.has(y.phase)||y.finishedAt)&&(v=!0,y.phase==="failed"&&((m=h.current)==null||m.call(h,y))))}).catch(y=>{v||(y instanceof le&&y.status!==0&&y.status<500?u(y.message):w())})}};x();const g=window.setInterval(x,h3);return()=>{v=!0,window.clearInterval(g)}},[e,t]),{job:i,away:l,error:c}}function b3({reload:e}){var m;const t=se(()=>A.version(),[]),[n,r]=d.useState(null),[i,o]=d.useState(!1),[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null),h=(m=t.data)==null?void 0:m.current,v=e??(()=>window.location.reload()),j=d.useCallback(S=>{r(null),f(S)},[]),w=w3(n,h,v,j),b=t.data,x=()=>{a(!0),u(null),A.checkVersion().catch(S=>u(S instanceof le?S.message:String(S))).finally(()=>{a(!1),t.reload()})},g=S=>{a(!0),u(null),A.setVersionCheck(S).catch(k=>u(k instanceof le?k.message:String(k))).finally(()=>{a(!1),t.reload()})},y=()=>{a(!0),u(null),f(null),A.startUpgrade(b==null?void 0:b.latest).then(S=>{var k;o(!1),r(((k=S.job)==null?void 0:k.id)??null)}).catch(S=>u(S instanceof le?S.message:String(S))).finally(()=>a(!1))};return b!=null&&b.checkout?s.jsx(G,{title:"Version",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsx(Tt,{items:[{label:"Running",value:s.jsx("span",{className:"mono",children:b.current})}]})}),s.jsx(G,{children:s.jsx("p",{className:"ui-card-meta",children:x3})})]})}):s.jsx(G,{title:"Version",panel:!0,children:s.jsxs(K,{divided:!0,children:[s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(re,{message:t.error??c}),s.jsx(Tt,{items:[{label:"Running",value:b?s.jsx("span",{className:"mono",children:b.current}):"…"},{label:"Newest",value:b?b.updateAvailable&&b.latest?s.jsxs("span",{children:["A newer buddi is available: ",s.jsx("span",{className:"mono",children:b.latest})]}):b.checkedAt?s.jsxs("span",{children:["This is the latest, as of ",ke(b.checkedAt),"."]}):s.jsx("span",{children:"Not checked yet."}):"…"}]}),b!=null&&b.error?s.jsxs(H,{tone:"warning",children:["The last check did not get an answer: ",b.error]}):null,s.jsx(q,{align:"end",children:s.jsx(R,{disabled:l,onClick:x,children:"Check now"})})]})}),s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(b==null?void 0:b.checkEnabled)??!1,disabled:l||!b,onChange:S=>g(S.target.checked)}),s.jsx("span",{children:"Check once a day"})]}),s.jsx("p",{className:"ui-card-meta",children:m3})]})}),b!=null&&b.updateAvailable&&b.latest&&b.latestNotes?s.jsx(G,{title:`What changes in ${b.latest}`,children:s.jsx(ur,{text:b.latestNotes})}):null,s.jsx(G,{children:s.jsxs(K,{gap:"sm",children:[s.jsx(k3,{...w,job:w.job??p??void 0}),i?s.jsx(H,{tone:"warning",role:"alert",children:g3}):null,s.jsx(q,{align:"end",children:i?s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",disabled:l,onClick:()=>o(!1),children:"Cancel"}),s.jsxs(R,{variant:"accent",disabled:l,onClick:y,children:["Upgrade to ",b==null?void 0:b.latest]})]}):s.jsx(R,{variant:"accent",disabled:l||n!==null||!(b!=null&&b.updateAvailable),onClick:()=>o(!0),children:b!=null&&b.updateAvailable&&b.latest?`Upgrade to ${b.latest}`:"Upgrade"})})]})}),b&&b.history.length>0?s.jsx(G,{title:"Upgrades so far",children:s.jsx(Tt,{items:b.history.slice().reverse().map(S=>({key:S.startedAt,label:s.jsxs("span",{className:"mono",children:[S.from," → ",S.to]}),value:s.jsx(S3,{attempt:S})}))})}):null]})})}function k3({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.jsx(H,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="failed"?s.jsxs(H,{tone:"critical",role:"alert",children:[mj.failed," ",e.error??""," buddi is still running on the version it had."]}):s.jsx(H,{tone:e.phase==="done"?"good":void 0,role:"status",children:mj[e.phase]??e.detail??e.phase}):null}function S3({attempt:e}){return s.jsxs("span",{children:[s.jsx(pe,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",ke(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?s.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",s.jsx("span",{className:"mono",children:e.backup})]}):null]})}const Uh=["name","clock","brain","browser","assistant","handover"],c1={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function N3(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function C3(e){var o,l,a;const t=N3(e.accounts),n=e.assistant?(((o=e.accounts)==null?void 0:o.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(n==null?void 0:n.accountId)??((a=(l=e.onboarding)==null?void 0:l.details)==null?void 0:a.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(n==null?void 0:n.model)??i.defaultModel}}function u1(e){var r,i,o;const t=C3(e),n=e.onboarding&&!e.onboarding.needs.agent?e.assistant:void 0;return{...(r=e.owner)!=null&&r.preferredName?{name:e.owner.preferredName}:{},...(i=e.owner)!=null&&i.timezone?{clock:e.owner.timezone}:{},...t?{brain:t}:{},...(o=e.onboarding)!=null&&o.stepsDone.includes("browser")||n?{browser:e.browser??"other"}:{},...n?{assistant:n}:{}}}function E3(e,t){return t==="name"?typeof e.name=="string"&&e.name!=="":t==="clock"?typeof e.clock=="string"&&e.clock!=="":t==="brain"?e.brain!==void 0:t==="browser"?e.browser!==void 0:t==="assistant"?e.assistant!==void 0:!1}function zh(e){return Uh.find(t=>!E3(e,t))??"handover"}function A3(e,t){const n=Uh.indexOf(t);return Uh.filter((r,i)=>i<n||r===t)}function T3(e,t){const n={...e};return delete n[t],n}const Bh="buddi.firstRun.restore";function Gd(e){try{e===null?window.sessionStorage.removeItem(Bh):window.sessionStorage.setItem(Bh,e)}catch{}}function d1(){try{return window.sessionStorage.getItem(Bh)}catch{return null}}function R3(e){const t=u1(e),n=zh(t);return{answers:t,open:n,stay:n!=="handover"}}function P3(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function I3(e){const t=e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,20).replace(/-+$/,"");return t===""?"assistant":t}const M3=550,$3=6e4,_3=5*6e4,f1=1500,O3=3e3;function Il(){const e=d.useRef(null);return d.useEffect(()=>{let t=0,n=0;const r=l=>{const a=l.ownerDocument.activeElement;return a===null||a===l.ownerDocument.body||a===l.ownerDocument.documentElement},i=()=>{const l=e.current;l&&r(l)&&l.focus()},o=()=>{i(),n=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(o):o(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(n),window.removeEventListener("focus",i)}},[]),e}function h1(){const[e,t]=d.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}});return d.useEffect(()=>{var i;let n;try{n=window.matchMedia("(prefers-reduced-motion: reduce)")}catch{return}const r=o=>t(o.matches);return(i=n.addEventListener)==null||i.call(n,"change",r),()=>{var o;return(o=n.removeEventListener)==null?void 0:o.call(n,"change",r)}},[]),e}function Re({children:e,at:t=0}){const n=h1(),[r,i]=d.useState(n||t===0);return d.useEffect(()=>{if(n){i(!0);return}const o=window.setTimeout(()=>i(!0),M3*t);return()=>window.clearTimeout(o)},[n,t]),r?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:e})}):s.jsx(ls,{})}function ls({line:e}){return s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[e,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})})}function Ee({children:e}){return s.jsxs("div",{className:"meet-turn",children:[s.jsxs("div",{className:"wb-msg-who",children:[s.jsx("img",{className:"meet-turn-mark",src:Tl("core"),alt:"","aria-hidden":"true"}),s.jsx("span",{children:"buddi"})]}),e]})}const p1=d.createContext({body:null,actions:null});function m1({children:e,actions:t}){const n=d.useContext(p1),r=e==null?null:n.body?Li.createPortal(e,n.body):e,i=t==null?null:n.actions?Li.createPortal(t,n.actions):t;return s.jsxs(s.Fragment,{children:[r,i]})}function Ca({text:e,onChange:t}){return s.jsxs("div",{className:"wb-msg","data-role":"user",children:[s.jsx("div",{className:"wb-bubble",children:e}),s.jsx("button",{type:"button",className:"meet-change",onClick:t,children:L.change})]})}function xt({children:e,actions:t}){return s.jsx(m1,{actions:t?s.jsx("span",{className:"meet-actions",children:t}):null,children:e?s.jsx("div",{className:"meet-ask",children:e}):null})}function ao({onClick:e,disabled:t}){return s.jsxs(R,{variant:"ghost",onClick:e,disabled:t,children:[s.jsx(Ue,{name:"chevron-left"}),L.brain.back]})}function D3({navigate:e,timezone:t}){var De;const[n,r]=d.useState(void 0);d.useEffect(()=>{A.session().then(he=>r(he.platform)).catch(()=>{})},[]);const[i,o]=d.useState({}),[l,a]=d.useState(null),[c,u]=d.useState(void 0),[p,f]=d.useState(void 0),[h,v]=d.useState([]),[j,w]=d.useState(null),[b,x]=d.useState(null),[g,y]=d.useState(!1),[m,S]=d.useState(null),[k,N]=d.useState(null),[C,P]=d.useState(null),[E,O]=d.useState(null),F=d.useMemo(()=>({body:C,actions:E}),[C,E]),[D,T]=d.useState(null),[z,Q]=d.useState(!1),Y=d.useCallback(()=>Q(!0),[]),[M,B]=d.useState(()=>d1()?"running":"idle"),$=d.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),Z=d.useRef(e);Z.current=e;const V=d.useCallback(async(he=!0,_e=!1)=>{var vr,Ds,Pn,Kn,U,ce,Qe,Pt;const[Ce,He,_,ue,ve,qe]=await Promise.all([A.onboarding().catch(()=>{}),A.owner().catch(()=>{}),A.providerAccounts().catch(()=>{}),ze.agents().catch(()=>{}),A.browser().catch(()=>{}),A.providers().catch(()=>{})]);u(_);const ct=(Ds=(vr=qe==null?void 0:qe.providers.find($e=>$e.kind==="anthropic"))==null?void 0:vr.defaultModel)==null?void 0:Ds.trim();f(ct||void 0),v((He==null?void 0:He.zones)??[]),S(((Pn=Ce==null?void 0:Ce.details)==null?void 0:Pn.conversationId)??null);const Ae=(ue==null?void 0:ue.agents.find($e=>$e.id===ue.defaultAgentId))??(ue==null?void 0:ue.agents[0]);Ae&&w(Ae),N(Ce&&!Ce.needs.agent&&Ae?{id:Ae.id,name:Ae.name,avatar:((Kn=Ae.avatar)==null?void 0:Kn.kind)==="emoji"?Ae.avatar.value:"",description:Ae.description,...Ae.picture?{picture:Ae.picture}:{}}:null);const un={onboarding:Ce,owner:He,accounts:_,browser:(U=ve==null?void 0:ve.browser)==null?void 0:U.engine,...Ae?{assistant:{id:Ae.id,name:Ae.name,avatar:((ce=Ae.avatar)==null?void 0:ce.kind)==="emoji"?Ae.avatar.value:""}}:{}},Rn=u1(un);if(_e){const $e=R3(un);if(o($e.answers),a($e.open),!$e.stay){const In=(Qe=Ce==null?void 0:Ce.details)==null?void 0:Qe.conversationId;Z.current(In&&Ae?Be(Ae.id,In):Vt,!0)}return}if(he&&(Ce==null?void 0:Ce.state)==="done"){const $e=(Pt=Ce.details)==null?void 0:Pt.conversationId;Z.current($e&&Ae?Be(Ae.id,$e):Vt,!0);return}he&&(o(Rn),a($e=>$e??zh(Rn)))},[]);d.useEffect(()=>{V()},[V]);const de=(he,_e={})=>{A.onboardingStep(c1[he],_e).catch(()=>{})},ge=(he,_e)=>{x(null),o(_e),de(he,he==="brain"&&_e.brain?{accountId:_e.brain.accountId}:{}),a(zh(_e))},je=he=>{x(null),o(_e=>T3(_e,he)),a(he)},ne=()=>{y(!0),A.skipOnboarding().then(()=>e(Vt)).catch(he=>x(he instanceof le?he.message:String(he))).finally(()=>y(!1))},xe=M==="form"||M==="running"?[]:l?A3(i,l):[],Se=se(()=>A.version().catch(()=>({current:""})),[]),Me=d.useRef(null);return d.useEffect(()=>{const he=Me.current;if(!he)return;const _e=()=>{he.scrollTop=he.scrollHeight};_e();let Ce;try{Ce=new ResizeObserver(_e),he.firstElementChild&&Ce.observe(he.firstElementChild)}catch{}return()=>Ce==null?void 0:Ce.disconnect()},[xe.length,l,i,b]),s.jsx(p1.Provider,{value:F,children:s.jsx("div",{className:"meet",children:s.jsxs("div",{className:"meet-stack",children:[s.jsxs("header",{className:"meet-head",children:[s.jsx("img",{className:"meet-head-mascot",src:Tl("core"),alt:"","aria-hidden":"true"}),s.jsxs("span",{className:"meet-head-who",children:[s.jsx("span",{className:"meet-head-name",children:"buddi"}),s.jsx("span",{className:"meet-head-line",children:n===void 0||n==="darwin"?L.tagline:L.taglineElsewhere}),(De=Se.data)!=null&&De.current?s.jsxs("span",{className:"meet-head-version mono",children:["buddi ",Se.data.current]}):null]})]}),s.jsxs("div",{className:"meet-board",children:[s.jsx("div",{className:"meet-scroll thin-scroll",ref:Me,children:s.jsxs("div",{className:"meet-thread","data-testid":"meet-thread",children:[s.jsx(Ee,{children:L.opening.map((he,_e)=>s.jsx(Re,{at:_e,children:he},he))}),s.jsx(L3,{state:M,offered:l==="name"&&i.name===void 0,name:i.name,onState:B,onDone:()=>{B("idle"),V(!0,!0)},onTrouble:x}),xe.map(he=>s.jsx(F3,{id:he,openNow:l===he,answers:i,accounts:c,claudeModel:p,zones:h,browserZone:$,assistantAgent:j,met:m,onMet:S,existing:k,navigate:e,onCarriesOn:T,onClosed:Y,onSettled:_e=>ge(he,_e),onChange:()=>je(he),onTrouble:x,onReload:()=>void V(!1),onPickAnotherBrain:()=>je("brain")},he)),b?s.jsx(Ee,{children:s.jsx(Re,{children:b})}):null]})}),s.jsxs("footer",{className:"meet-dock",children:[s.jsx("div",{className:"meet-dock-ask",ref:P}),s.jsxs("div",{className:"meet-dock-row",children:[z?s.jsx("span",{}):D?s.jsx("a",{className:"meet-later",href:D,onClick:he=>{he.preventDefault(),e(D,!0)},children:L.done.open}):s.jsx("button",{className:"meet-later",type:"button",disabled:g,onClick:ne,children:L.later}),s.jsx("div",{className:"meet-dock-actions",ref:O})]})]})]})]})})})}function L3({state:e,offered:t,name:n,onState:r,onDone:i,onTrouble:o}){const[l,a]=d.useState(()=>d1()),[c,u]=d.useState([]),[p,f]=d.useState(!1),[h,v]=d.useState(null),[j,w]=d.useState(""),[b,x]=d.useState(!1);d.useEffect(()=>{if(!l)return;let m=!1;const S=()=>{A.backupJob(l).then(N=>{m||(u(C=>C.includes(N.phase)?C:[...C,N.phase]),N.phase==="done"?(m=!0,Gd(null),f(!0),i()):(N.phase==="rolled-back"||N.phase==="failed")&&(m=!0,Gd(null),a(null),o(N.error??L.restore.phases[N.phase]),r("idle")))}).catch(()=>{})};S();const k=window.setInterval(S,f1);return()=>{m=!0,window.clearInterval(k)}},[l]);const g=()=>{!h||b||(x(!0),o(null),A.firstRunRestore(h,j.trim()).then(m=>{Gd(m.job.id),a(m.job.id),r("running")}).catch(m=>o(m instanceof le?m.message:String(m))).finally(()=>x(!1)))},y=c.filter(m=>m in L.restore.phases);return s.jsxs(s.Fragment,{children:[t&&e==="idle"&&!p?s.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:L.restore.offer}):null,e==="form"?s.jsxs(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>r("idle"),children:L.restore.cancel}),s.jsx(R,{variant:"accent",disabled:b||!h,onClick:g,children:L.restore.submit})]}),children:[s.jsx(X,{label:L.restore.file,grow:!0,children:s.jsx("input",{type:"file",onChange:m=>{var S;return v(((S=m.target.files)==null?void 0:S[0])??null)}})}),s.jsx(X,{label:L.restore.passphrase,hint:L.restore.passphraseHint,children:s.jsx("input",{type:"password",autoComplete:"off",value:j,onChange:m=>w(m.target.value)})})]}):null,e==="running"||p?s.jsxs(Ee,{children:[s.jsx(Re,{children:L.restore.started}),y.map(m=>s.jsx(Re,{children:L.restore.phases[m]},m))]}):null,p?s.jsxs(Ee,{children:[n?s.jsx(Re,{children:L.restore.welcome(n)}):null,s.jsx(Re,{children:L.restore.keys})]}):null]})}function F3(e){var o,l,a,c;const{id:t,openNow:n,answers:r,onChange:i}=e;if(t==="name")return s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{at:1,children:L.name.ask})}),n?s.jsx(U3,{...e}):s.jsx(Ca,{text:r.name??"",onChange:i})]});if(t==="clock")return s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{at:1,children:L.clock.ask(r.name??"",r.clock??e.browserZone)})}),n?s.jsx(z3,{...e}):s.jsx(Ca,{text:L.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{at:1,children:L.brain.ask})}),n?s.jsx(B3,{...e}):s.jsxs(s.Fragment,{children:[s.jsx(Ca,{text:L.brain.answer(((o=r.brain)==null?void 0:o.label)??""),onChange:i}),s.jsxs(Ee,{children:[s.jsx(Re,{children:L.brain.works(((l=r.brain)==null?void 0:l.model)??"")}),s.jsx(Z3,{...e})]})]})]});if(t==="browser"){if(n)return s.jsx(o6,{...e});const u=i6(r.browser);return u?s.jsx(Ee,{children:s.jsx(Re,{children:u})}):null}return t==="assistant"?s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{at:1,children:L.assistant.ask})}),n?s.jsx(a6,{...e}):s.jsx(Ca,{text:`${((a=r.assistant)==null?void 0:a.avatar)??""} ${((c=r.assistant)==null?void 0:c.name)??""}`.trim(),onChange:i})]}):s.jsx(c6,{...e})}function U3({answers:e,onSettled:t,onTrouble:n}){const r=Il(),[i,o]=d.useState(e.name??""),[l,a]=d.useState(!1),c=()=>{const u=i.trim();u===""||l||(a(!0),A.setOwner({preferredName:u}).then(()=>t({...e,name:u})).catch(p=>n(p instanceof le?p.message:String(p))).finally(()=>a(!1)))};return s.jsx(xt,{actions:s.jsx(R,{variant:"accent",disabled:l||i.trim()==="",onClick:c,children:L.name.submit}),children:s.jsx("input",{ref:r,className:"meet-input","aria-label":L.name.placeholder,placeholder:L.name.placeholder,maxLength:80,value:i,onChange:u=>o(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function z3({answers:e,zones:t,browserZone:n,onSettled:r,onTrouble:i}){const[o,l]=d.useState(!1),[a,c]=d.useState(n),[u,p]=d.useState(!1),f=h=>{p(!0),A.setOwner({timezone:h}).then(()=>r({...e,clock:h})).catch(v=>i(v instanceof le?v.message:String(v))).finally(()=>p(!1))};return o?s.jsx(xt,{actions:s.jsx(R,{variant:"accent",disabled:u,onClick:()=>f(a),children:L.clock.yes}),children:s.jsx("select",{className:"meet-input","aria-label":L.clock.label,value:a,onChange:h=>c(h.target.value),children:(t.includes(a)?t:[a,...t]).map(h=>s.jsx("option",{value:h,children:h},h))})}):s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>l(!0),children:L.clock.another}),s.jsx(R,{variant:"accent",disabled:u,onClick:()=>f(n),children:L.clock.yes})]})})}function B3(e){const{accounts:t,answers:n,onSettled:r,onReload:i}=e,[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(!1),[f,h]=d.useState(null),[v,j]=d.useState(null),w=(t==null?void 0:t.anthropicOAuthEnabled)===!0,b=(t==null?void 0:t.codexEnabled)===!0,[x,g]=d.useState(null);d.useEffect(()=>{let k=!1;const N=()=>{A.ollama().then(P=>{k||h(P)}).catch(()=>{})};N();const C=window.setInterval(N,4e3);return()=>{k=!0,window.clearInterval(C)}},[]);const y=async k=>{if(n.assistant)try{await A.bindBrain({accountId:k.accountId,model:k.model})}catch(C){return C instanceof le?C.message:String(C)}return i(),r({...n,brain:k}),null},m=async(k,N)=>{p(!0),c(null);try{const C=await A.saveProviderAccount(k),P=await A.testProviderAccount(C.id);if(P.state!=="connected"){try{const O=(await A.providerAccounts()).accounts.find(F=>F.id===C.id);O&&await A.removeProviderAccount(C.id,O.revision)}catch{}c(P.message);return}const E=await y({accountId:C.id,label:N,model:k.defaultModel});E&&c(E)}catch(C){c(C instanceof le?C.message:String(C))}finally{p(!1)}},S=(k,N,C)=>{if(k.length<=1){m(N(k[0]??""),C);return}j({models:k,make:N,label:C})};return v?s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{children:L.brain.model.ask})}),u?s.jsx(Ee,{children:s.jsx(ls,{line:L.brain.checking.service})}):a?s.jsx(Ee,{children:s.jsx(Re,{children:a})}):null,s.jsx(G3,{busy:u,models:v.models,onUse:k=>void m(v.make(k),v.label)})]}):o==="key"?s.jsx(Y3,{busy:u,problem:a,onBack:()=>l(null),onUse:m}):o==="service"?s.jsx(Q3,{busy:u,problem:a,address:(f==null?void 0:f.cloudBaseUrl)??"",onBack:()=>l(null),onOffer:S}):o==="ollama"?s.jsx(q3,{busy:u,problem:a,probe:f,onBack:()=>l(null),onOffer:S}):o==="cloud"?s.jsx(X3,{busy:u,consent:x,onBack:()=>{x==null||x.close(),g(null),l(null)},onConnected:y,...e}):o==="chatgpt"?s.jsx(t6,{busy:u,consent:x,onBack:()=>{x==null||x.close(),g(null),l(null)},onConnected:y,...e}):o==="claude"?s.jsx(s6,{busy:u,problem:a,onBack:()=>l(null),onConnected:y,...e}):s.jsx(m1,{children:s.jsxs("div",{className:"meet-cards",role:"group","aria-label":L.brain.ask,children:[w?s.jsx(oi,{mark:s.jsx(W3,{}),card:L.brain.cards.claude,onPick:()=>l("claude")}):null,b?s.jsx(oi,{mark:s.jsx(H3,{}),card:L.brain.cards.chatgpt,onPick:()=>{g(typeof window.open=="function"?window.open("","_blank"):null),l("chatgpt")}}):null,s.jsx(oi,{mark:s.jsx(V3,{}),card:L.brain.cards.key,onPick:()=>l("key")}),s.jsx(oi,{mark:s.jsx(K3,{}),card:L.brain.cards.ollama,note:f===null?L.brain.ollama.looking:f.running?L.brain.ollama.found:L.brain.ollama.missing,onPick:()=>l("ollama")}),s.jsx(oi,{mark:s.jsx(gj,{}),card:L.brain.cards.cloud,onPick:()=>{g(typeof window.open=="function"?window.open("","_blank"):null),l("cloud")}}),s.jsx(oi,{mark:s.jsx(gj,{}),card:L.brain.cards.service,onPick:()=>l("service")})]})})}function oi({mark:e,card:t,note:n,onPick:r}){return s.jsxs("button",{type:"button",className:"meet-card",onClick:r,children:[s.jsx("span",{className:"meet-card-mark","aria-hidden":"true",children:e}),s.jsxs("span",{className:"meet-card-words",children:[s.jsx("span",{className:"meet-card-title",children:t.title}),s.jsx("span",{className:"meet-card-line",children:n??t.line}),t.know?s.jsx("span",{className:"meet-card-know",children:t.know}):null]})]})}function W3(){const e=[0,45,90,135,180,225,270,315];return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",children:e.map(t=>s.jsx("rect",{x:"11.1",y:"2.6",width:"1.8",height:"8.6",rx:"0.9",fill:"currentColor",transform:`rotate(${t} 12 12)`},t))})}function H3(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M5.4 4.6h13.2a2 2 0 0 1 2 2v8.2a2 2 0 0 1-2 2h-7.4l-4.4 3.4v-3.4H5.4a2 2 0 0 1-2-2V6.6a2 2 0 0 1 2-2Z"}),s.jsx("path",{d:"M8 9.4h8"}),s.jsx("path",{d:"M8 12.6h5"})]})}function V3(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"8",cy:"8",r:"3.6"}),s.jsx("path",{d:"M10.6 10.6 19.4 19.4"}),s.jsx("path",{d:"M13.8 13.8 11.9 15.7"}),s.jsx("path",{d:"M16.6 16.6 14.7 18.5"})]})}function K3(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3.2",y:"4.6",width:"17.6",height:"11.2",rx:"2"}),s.jsx("path",{d:"M9.4 19.4h5.2"}),s.jsx("path",{d:"M12 15.8v3.6"})]})}function gj(){return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7.2 18.3h9.6a3.8 3.8 0 0 0 .5-7.6 5.4 5.4 0 0 0-10.3-1.2 3.9 3.9 0 0 0 .2 8.8Z"})})}function G3({busy:e,models:t,onUse:n}){const[r,i]=d.useState(t[0]??"");return s.jsx(xt,{actions:s.jsx(R,{variant:"accent",disabled:e||r==="",onClick:()=>n(r),children:L.brain.model.submit}),children:s.jsx(X,{label:L.brain.model.label,grow:!0,children:s.jsx("select",{value:r,onChange:o=>i(o.target.value),children:t.map(o=>s.jsx("option",{value:o,children:o},o))})})})}function Y3({busy:e,problem:t,onBack:n,onUse:r}){const i=Il(),[o,l]=d.useState(""),[a,c]=d.useState(null),[u,p]=d.useState(!1),f=e||u,h=a??P3(o),v=()=>{const j=o.trim();j===""||f||(p(!0),(async()=>{var b;let w=h==="anthropic"?"claude-sonnet-5":"gpt-5";try{w=((b=(await A.probeModels({kind:h,auth:"api-key",secret:j})).models.find(g=>g.isDefault))==null?void 0:b.id)??w}catch{}p(!1),await r({label:h==="anthropic"?L.brain.key.anthropic:L.brain.key.openai,kind:h,auth:"api-key",baseUrl:"",defaultModel:w,enabled:!0,secret:j},h==="anthropic"?L.brain.key.anthropic:L.brain.key.openai)})())};return s.jsxs(s.Fragment,{children:[f?s.jsx(Ee,{children:s.jsx(ls,{line:L.brain.checking.key})}):t?s.jsx(Ee,{children:s.jsx(Re,{children:L.brain.key.refused})}):null,s.jsxs(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ao,{onClick:n,disabled:f}),s.jsx(R,{variant:"accent",disabled:f||o.trim()==="",onClick:v,children:L.brain.key.submit})]}),children:[s.jsx(X,{label:L.brain.key.field,grow:!0,children:s.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:L.brain.key.placeholder,value:o,onChange:j=>l(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),v())}})}),s.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(h==="anthropic"?"openai":"anthropic"),children:[h==="anthropic"?L.brain.key.anthropic:L.brain.key.openai," · ",L.brain.key.which]})]})]})}function q3({busy:e,problem:t,probe:n,onBack:r,onOffer:i}){const o=(n==null?void 0:n.models)??[],l=()=>{n&&i(o,a=>({label:L.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:n.baseUrl,defaultModel:a,enabled:!0}),L.brain.cards.ollama.title)};return s.jsxs(s.Fragment,{children:[e?s.jsx(Ee,{children:s.jsx(ls,{line:L.brain.checking.ollama})}):t?s.jsx(Ee,{children:s.jsx(Re,{children:t})}):null,s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ao,{onClick:r,disabled:e}),n!=null&&n.running?s.jsx(R,{variant:"accent",disabled:e||o.length===0,onClick:l,children:L.brain.ollama.connect}):n?s.jsx(ln,{variant:"accent",href:n.downloadUrl,target:"_blank",rel:"noreferrer",children:L.brain.ollama.download}):null]}),children:s.jsx("span",{className:"meet-line",children:n===null?L.brain.ollama.looking:n.running?L.brain.ollama.found:L.brain.ollama.missing})})]})}function Q3({busy:e,problem:t,address:n,onBack:r,onOffer:i}){const o=Il(),[l,a]=d.useState(n),[c,u]=d.useState(""),[p,f]=d.useState(!1),h=e||p,v=()=>{l.trim()===""||h||(f(!0),(async()=>{var g;const j=c.trim()?"api-key":"none",w=y=>({label:L.brain.cards.service.title,kind:"openai-compatible",auth:j,baseUrl:l.trim(),defaultModel:y,enabled:!0,...c.trim()?{secret:c.trim()}:{}});let b=[],x;try{const y=await A.probeModels({kind:"openai-compatible",auth:j,baseUrl:l.trim(),...c.trim()?{secret:c.trim()}:{}});b=y.models.map(m=>m.id),x=(g=y.models.find(m=>m.isDefault))==null?void 0:g.id}catch{}f(!1),i(x?[x]:b,w,L.brain.cards.service.title)})())};return s.jsxs(s.Fragment,{children:[h?s.jsx(Ee,{children:s.jsx(ls,{line:L.brain.checking.service})}):t?s.jsx(Ee,{children:s.jsx(Re,{children:t})}):null,s.jsxs(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ao,{onClick:r,disabled:h}),s.jsx(R,{variant:"accent",disabled:h||l.trim()==="",onClick:v,children:L.brain.service.submit})]}),children:[s.jsx(X,{label:L.brain.service.address,grow:!0,children:s.jsx("input",{ref:o,value:l,placeholder:L.brain.service.addressPlaceholder,onChange:j=>a(j.target.value)})}),s.jsx(X,{label:L.brain.service.key,children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:c,onChange:j=>u(j.target.value)})})]})]})}const J3=2e3;function X3({busy:e,consent:t,onBack:n,onConnected:r,accounts:i}){const[o,l]=d.useState(!0),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(0),v=d.useRef(-1),j=d.useRef(null),w=L.brain.cloud.label;d.useEffect(()=>{if(v.current===f)return;v.current=f,l(!0),c(null);const x=f===0?t:j.current;(async()=>{try{const g=((i==null?void 0:i.accounts)??[]).find(k=>k.auth==="device-key"),y=g?{id:g.id}:await A.saveProviderAccount({label:w,kind:"openai-compatible",auth:"device-key",baseUrl:"",defaultModel:Ba,enabled:!0}),m=(await A.providerAccounts()).accounts.find(k=>k.id===y.id),S=await A.ollamaConnect(m.id,m.revision);p({id:m.id,attemptId:S.attemptId,url:S.verificationUrl}),x&&(x.location.href=S.verificationUrl)}catch(g){x==null||x.close(),c(g instanceof le?g.message:String(g))}finally{l(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let x=!1,g=!1;const y=async()=>{if(!(x||g)){g=!0;try{const S=await A.ollamaPoll(u.id,u.attemptId);if(x||S.state==="waiting")return;if(x=!0,p(null),S.state==="failed"){c(S.message);return}l(!0),c(await b(u.id)),l(!1)}catch{}finally{g=!1}}},m=window.setInterval(()=>void y(),J3);return()=>{x=!0,window.clearInterval(m)}},[u]);const b=async x=>{try{const g=(await A.accountModels(x).catch(()=>({models:[]}))).models.map(k=>k.id),y=g.length===0||g.includes(Ba)?Ba:g[0],m=(await A.providerAccounts()).accounts.find(k=>k.id===x);m&&m.defaultModel!==y&&await A.saveProviderAccount({id:m.id,revision:m.revision,label:m.label,kind:m.kind,auth:m.auth,baseUrl:m.baseUrl,defaultModel:y,enabled:m.enabled});const S=await A.testProviderAccount(x);return S.state!=="connected"?S.message:await r({accountId:x,label:w,model:y})}catch(g){return g instanceof le?g.message:String(g)}};return s.jsxs(s.Fragment,{children:[o||e?s.jsx(Ee,{children:s.jsx(ls,{line:L.brain.checking.cloud})}):a?s.jsx(Ee,{children:s.jsx(Re,{children:a})}):u?s.jsx(Ee,{children:s.jsx(Re,{children:L.brain.cloud.waiting})}):null,s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ao,{onClick:n,disabled:o||e}),u?s.jsx(ln,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:L.brain.cloud.open}):a?s.jsx(R,{variant:"accent",disabled:o||e,onClick:()=>{j.current=typeof window.open=="function"?window.open("","_blank"):null,h(x=>x+1)},children:L.brain.cloud.again}):null]})})]})}function Z3({answers:e,accounts:t,onSettled:n,onTrouble:r}){const i=e.brain,o=i?((t==null?void 0:t.accounts)??[]).find(h=>h.id===i.accountId):void 0,[l,a]=d.useState([]),[c,u]=d.useState(!1),p=(o==null?void 0:o.auth)==="device-key"||(o==null?void 0:o.kind)==="codex";if(d.useEffect(()=>{if(!p||!o)return;let h=!1;return A.accountModels(o.id).then(v=>{h||a(v.models.map(j=>j.id))}).catch(()=>{}),()=>{h=!0}},[p,o==null?void 0:o.id]),!p||!o||!i||l.length<2)return null;const f=h=>{h===i.model||c||(u(!0),r(null),(async()=>{try{await A.saveProviderAccount({id:o.id,revision:o.revision,label:o.label,kind:o.kind,auth:o.auth,baseUrl:o.baseUrl,defaultModel:h,enabled:o.enabled}),e.assistant&&await A.bindBrain({accountId:o.id,model:h}),n({...e,brain:{...i,model:h}})}catch(v){r(v instanceof le?v.message:String(v))}finally{u(!1)}})())};return s.jsx(Re,{children:s.jsx(X,{label:L.brain.model.change,children:s.jsx("select",{value:i.model,disabled:c,onChange:h=>f(h.target.value),children:(l.includes(i.model)?l:[i.model,...l]).map(h=>s.jsx("option",{value:h,children:h},h))})})})}const xj="gpt-5.5",e6=2e3;function t6({busy:e,consent:t,onBack:n,onConnected:r,accounts:i}){const[o,l]=d.useState(!0),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(0),v=d.useRef(-1),j=d.useRef(null),w=d.useRef(null),b=L.brain.chatgpt.label;d.useEffect(()=>()=>{const y=w.current;w.current=null,y&&A.codexAccountAction(y.id,"cancel-login",y.revision).catch(()=>{})},[]),d.useEffect(()=>{if(v.current===f)return;v.current=f,l(!0),c(null);const y=f===0?t:j.current;(async()=>{try{const m=((i==null?void 0:i.accounts)??[]).find(C=>C.kind==="codex"),S=m?{id:m.id}:await A.saveProviderAccount({label:b,kind:"codex",auth:"chatgpt",baseUrl:"",defaultModel:xj,enabled:!0}),k=(await A.providerAccounts()).accounts.find(C=>C.id===S.id),N=await A.codexAccountAction(k.id,"login",k.revision);if(!(N!=null&&N.verificationUrl)||!N.userCode)throw new Error((N==null?void 0:N.message)??L.brain.chatgpt.failed);w.current={id:k.id,revision:k.revision},p({id:k.id,revision:k.revision,url:N.verificationUrl,code:N.userCode}),y&&(y.location.href=N.verificationUrl)}catch(m){y==null||y.close(),c(m instanceof le||m instanceof Error?m.message:String(m))}finally{l(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let y=!1,m=!1;const S=async()=>{if(!(y||m)){m=!0;try{const N=(await A.providerAccounts()).accounts.find(P=>P.id===u.id);if(y)return;const C=N==null?void 0:N.login;if(!C||C.state==="pending")return;if(y=!0,w.current=null,p(null),C.state!=="connected"){c(C.message??L.brain.chatgpt.failed);return}l(!0),c(await x(u.id)),l(!1)}catch{}finally{m=!1}}},k=window.setInterval(()=>void S(),e6);return()=>{y=!0,window.clearInterval(k)}},[u]);const x=async y=>{var m,S;try{const k=(await A.accountModels(y).catch(()=>({models:[]}))).models,N=((m=k.find(P=>P.isDefault))==null?void 0:m.id)??((S=k[0])==null?void 0:S.id)??xj,C=(await A.providerAccounts()).accounts.find(P=>P.id===y);return C&&C.defaultModel!==N&&await A.saveProviderAccount({id:C.id,revision:C.revision,label:C.label,kind:C.kind,auth:C.auth,baseUrl:C.baseUrl,defaultModel:N,enabled:C.enabled}),await r({accountId:y,label:b,model:N})}catch(k){return k instanceof le?k.message:String(k)}},g=()=>{const y=w.current;w.current=null,y&&A.codexAccountAction(y.id,"cancel-login",y.revision).catch(()=>{}),n()};return s.jsxs(s.Fragment,{children:[o||e?s.jsx(Ee,{children:s.jsx(ls,{line:L.brain.checking.chatgpt})}):a?s.jsx(Ee,{children:s.jsx(Re,{children:a})}):u?s.jsx(Ee,{children:s.jsxs(Re,{children:[L.brain.chatgpt.codeBefore,s.jsx("strong",{children:u.code}),L.brain.chatgpt.codeAfter]})}):null,s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ao,{onClick:g,disabled:o||e}),u?s.jsx(ln,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:L.brain.chatgpt.open}):a?s.jsx(R,{variant:"accent",disabled:o||e,onClick:()=>{j.current=typeof window.open=="function"?window.open("","_blank"):null,h(y=>y+1)},children:L.brain.chatgpt.again}):null]}),children:u?s.jsx(wS,{code:u.code,label:L.brain.chatgpt.code}):null})]})}const n6="claude-sonnet-5";function s6({busy:e,problem:t,onBack:n,onConnected:r,accounts:i,claudeModel:o}){const[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null),[h,v]=d.useState(""),j=o??n6,w=()=>{a(!0),u(null);const x=typeof window.open=="function"?window.open("","_blank"):null;(async()=>{try{const g=((i==null?void 0:i.accounts)??[]).find(N=>N.auth==="anthropic-oauth"),y=g?{id:g.id}:await A.saveProviderAccount({label:L.brain.cards.claude.title,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:j,enabled:!0}),S=(await A.providerAccounts()).accounts.find(N=>N.id===y.id),k=await A.anthropicAccountAction(S.id,"login",S.revision);f({id:S.id,revision:S.revision+1,url:k.verificationUrl??"",attemptId:k.attemptId??""}),x&&k.verificationUrl?x.location.href=k.verificationUrl:x==null||x.close()}catch(g){x==null||x.close(),u(g instanceof le?g.message:String(g))}finally{a(!1)}})()},b=()=>{!p||h.trim()===""||(a(!0),(async()=>{try{await A.anthropicAccountAction(p.id,"complete-login",p.revision,{attemptId:p.attemptId,code:h.trim()});const x=await A.testProviderAccount(p.id);if(x.state!=="connected"){u(x.message);return}u(await r({accountId:p.id,label:L.brain.cards.claude.title,model:j}))}catch(x){u(x instanceof le?x.message:String(x))}finally{a(!1)}})())};return s.jsxs(s.Fragment,{children:[l||e?s.jsx(Ee,{children:s.jsx(ls,{line:L.brain.checking.claude})}):t??c?s.jsx(Ee,{children:s.jsx(Re,{children:t??c})}):null,p?s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{children:L.brain.claude.waiting})}),s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ln,{href:p.url,target:"_blank",rel:"noreferrer",children:L.brain.claude.open}),s.jsx(R,{variant:"accent",disabled:l||h.trim()==="",onClick:b,children:L.brain.claude.finish})]}),children:s.jsx(X,{label:L.brain.claude.paste,grow:!0,children:s.jsx(r6,{value:h,onChange:v})})})]}):s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ao,{onClick:n,disabled:e||l}),s.jsx(R,{variant:"accent",disabled:e||l,onClick:w,children:L.brain.claude.start})]})})]})}function r6({value:e,onChange:t}){const n=Il();return s.jsx("input",{ref:n,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function i6(e){switch(e){case"chrome":return L.browser.chrome;case"chromium":return L.browser.chromium;case"installed":return L.browser.installed;case"skipped":return L.browser.skipped;case"none":return L.browser.missing;default:return null}}function o6({answers:e,onSettled:t}){const[n,r]=d.useState("checking"),[i,o]=d.useState(null),[l,a]=d.useState(null),[c,u]=d.useState(void 0),[p,f]=d.useState(0),h=d.useRef(!1),v=d.useRef(!1),j=d.useRef(()=>{});if(j.current=b=>{v.current||(v.current=!0,t({...e,browser:b}))},d.useEffect(()=>{let b=!1,x;const g=k=>{b||j.current(k)},y=(k,N)=>{b||(h.current=!1,r("failed"),o(k),a(N??null))},m=async k=>{r("launching");let N;try{N=await A.browserCheck()}catch(C){return y(C instanceof le?C.message:String(C))}if(!b)return N.ok?g(h.current?"installed":k):y(N.message,N.command)},S=async()=>{var C,P;let k;try{k=await A.browser()}catch{return g("other")}if(b)return;const N=k.browser;if(!N)return g("other");if(((C=N.install)==null?void 0:C.state)==="running"){r("installing"),u(N.install.progress),x=window.setTimeout(()=>void S(),1e3);return}if(N.engine!=="none")return m(N.engine);if(h.current)return y(((P=N.install)==null?void 0:P.line)??"");h.current=!0,r("installing"),u(void 0);try{await A.browserInstall()}catch(E){return y(E instanceof le?E.message:String(E))}b||(x=window.setTimeout(()=>void S(),1e3))};return S(),()=>{b=!0,window.clearTimeout(x)}},[p]),n==="checking")return s.jsx(ls,{});const w=n==="installing"||n==="launching";return s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{children:[h.current||n==="installing"?s.jsx(Re,{children:L.browser.needs}):null,n==="installing"?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:s.jsx(bk,{progress:c})})}):n==="launching"?s.jsx(ls,{line:L.browser.launching}):s.jsx(Re,{children:L.browser.failed(i??"")})]}),s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>j.current("skipped"),children:L.browser.skip}),s.jsx(R,{variant:"accent",disabled:w,onClick:()=>{r("launching"),a(null),f(b=>b+1)},children:w?L.browser.installing:L.browser.retry})]}),children:n==="failed"&&l?s.jsx(l6,{command:l}):null})]})}function l6({command:e}){const[t,n]=d.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("failed");return}navigator.clipboard.writeText(e).then(()=>n("done"),()=>n("failed"))};return s.jsxs(K,{gap:"sm",children:[s.jsx(ft,{label:"The command to run",children:e}),s.jsxs(q,{align:"end",children:[t==="failed"?s.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,s.jsx(R,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function a6({answers:e,existing:t,onSettled:n,onTrouble:r,onReload:i}){const[o,l]=d.useState(()=>(t==null?void 0:t.name)??rL),[a,c]=d.useState(()=>t!=null&&t.picture?{kind:"kept",url:t.picture}:t!=null&&t.avatar?{kind:"emoji",value:t.avatar}:{kind:"mascot",role:"core"}),[u,p]=d.useState(t?null:L.assistant.purposeValue),[f,h]=d.useState(t?"":L.assistant.purposeValue);d.useEffect(()=>{if(!t)return;let b=!1;return A.firstAgentPersona().then(x=>{b||(p(x.persona),h(x.persona))},x=>{b||r(x instanceof le?x.message:String(x))}),()=>{b=!0}},[t==null?void 0:t.id]);const[v,j]=d.useState(!1),w=()=>{if(o.trim()===""||v)return;j(!0);const b=a.kind==="emoji"?{avatar:a.value}:{},x=!t||u!==null&&f.trim()!==""&&f.trim()!==u.trim()?{instructions:f.trim()}:{},g=t?A.updateFirstAgent({name:o.trim(),...x,...b}):A.createFirstAgent({name:o.trim(),handle:I3(o),description:"",...x,...b,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let y;try{y=await g}catch(S){r(S instanceof le?S.message:String(S)),j(!1);return}let m=null;try{a.kind==="mascot"?await A.uploadAgentPicture(y.id,await uS(a.role)):a.kind==="emoji"&&(t!=null&&t.picture)&&await A.removeAgentPicture(y.id)}catch(S){m=S instanceof le?S.message:String(S)}j(!1),i(),n({...e,assistant:{id:y.id,name:o.trim(),avatar:a.kind==="emoji"?a.value:""}}),m&&r(m)})()};return s.jsxs(xt,{actions:s.jsx(R,{variant:"accent",disabled:v||o.trim()===""||u===null,onClick:w,children:L.assistant.submit}),children:[s.jsx("span",{className:"meet-chosen-face","data-kind":a.kind==="emoji"?"emoji":"image","aria-hidden":"true",children:a.kind==="emoji"?a.value:s.jsx("img",{src:a.kind==="mascot"?Tl(a.role):a.url,alt:""})}),s.jsx(X,{label:L.assistant.name,children:s.jsx("input",{value:o,maxLength:60,onChange:b=>l(b.target.value)})}),s.jsx(dS,{face:a,onPick:c}),s.jsx(X,{label:L.assistant.purpose,wide:!0,children:s.jsx("textarea",{className:"meet-purpose",value:f,maxLength:8e3,rows:Math.max(4,f.split(`
123
- `).length+1),onChange:b=>h(b.target.value)})})]})}function c6({answers:e,assistantAgent:t,met:n,onMet:r,onCarriesOn:i,onClosed:o,navigate:l,onPickAnotherBrain:a}){const c=e.assistant,[u,p]=d.useState(n),[f,h]=d.useState([]),[v,j]=d.useState(!1),[w,b]=d.useState(!1),[x,g]=d.useState(!0),[y,m]=d.useState("open"),[S,k]=d.useState(!1),N=h1(),C=d.useRef(!1),P=d.useMemo(()=>t?[t]:[],[t]);d.useEffect(()=>{if(!c||C.current)return;if(C.current=!0,n){p(n);return}let D=!1;return(async()=>{try{const T=await ze.startConversation(c.id);if(D)return;p(T.conversationId),r(T.conversationId),await A.onboardingStep(c1.handover,{conversationId:T.conversationId}).catch(()=>{}),await ze.send(c.id,{conversationId:T.conversationId,text:lL,opening:!0})}catch{D||(g(!1),j(!0))}})(),()=>{D=!0}},[c==null?void 0:c.id,n]),d.useEffect(()=>{if(!u)return;let D=!1;const T=Date.now(),z=()=>{ze.conversation(u).then(Y=>{if(D)return;h(Y.messages);const M=Date.now()-T;if(Y.messages.some(vj)){g(!1),j(!1),b(!1);return}const B=Y.runs??[],$=B.some(V=>V.finishedAt===null),Z=B.length>0&&!$;b($&&M>=$3),(Z||M>=_3)&&(g(!1),j(!0))}).catch(()=>{})};z();const Q=window.setInterval(z,f1);return()=>{D=!0,window.clearInterval(Q)}},[u]);const E=c&&u?Be(c.id,u):null,O=f.some(vj);d.useEffect(()=>{O&&E&&i(E)},[O,E,i]),d.useEffect(()=>{if(!S||!E||N)return;const D=window.setTimeout(()=>l(E,!0),O3);return()=>window.clearTimeout(D)},[S,E,N,l]);const F=S&&E!==null;return d.useEffect(()=>{F&&o()},[F,o]),s.jsxs(s.Fragment,{children:[s.jsx(jk,{messages:f,live:[],now:Date.now(),onOpen:()=>{},working:x,agents:P,agentName:(c==null?void 0:c.name)??"",emptyHint:L.handover.waiting,plain:!0,workingLine:L.handover.looking((c==null?void 0:c.name)??"")}),w&&!v?s.jsx(Ee,{children:s.jsx(Re,{children:L.handover.slow})}):null,v?s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{children:L.handover.silent})}),s.jsx(xt,{actions:s.jsx(R,{variant:"accent",onClick:a,children:L.handover.again})})]}):null,S?s.jsx(Ee,{children:s.jsx(Re,{children:L.done.said})}):null,O&&y==="open"?s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{onClick:()=>m("phone"),children:L.offers.phone}),s.jsx(R,{variant:"accent",onClick:()=>{m("gone"),k(!0)},children:L.offers.notNow})]})}):null,O&&y==="phone"?s.jsx(u6,{onPaired:()=>k(!0),onDismiss:()=>{m("gone"),k(!0)}}):null,F&&E?s.jsx(xt,{actions:s.jsx(ln,{variant:"accent",href:E,onClick:D=>{D.preventDefault(),l(E,!0)},children:L.done.open}),children:s.jsx("span",{className:"meet-line",children:N?L.done.ready:L.done.leaving})}):null]})}function vj(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function u6({onPaired:e,onDismiss:t}){const n=Il(),[r,i]=d.useState(""),[o,l]=d.useState(!1),[a,c]=d.useState(null),{offer:u,square:p,paired:f,stale:h,ask:v}=r1(()=>A.telegram().then(b=>b.paired),e),j=()=>{r.trim()===""||o||(l(!0),c(null),(async()=>{try{const b=await A.saveTelegramToken(r.trim());if(i(""),b.restartNeeded){c(b.note??L.telegram.restart);return}await v()}catch(b){c(b instanceof le?b.message:String(b))}finally{l(!1)}})())},w=()=>{c(null),v().catch(b=>c(b instanceof le?b.message:String(b)))};return f?s.jsx(Ee,{children:s.jsx(Re,{children:L.telegram.paired})}):u?s.jsxs(s.Fragment,{children:[s.jsx(Ee,{children:s.jsx(Re,{children:h?L.telegram.expired:L.telegram.scan})}),s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:t,children:L.offers.notNow}),h?s.jsx(R,{variant:"accent",onClick:w,children:L.telegram.newCode}):null]}),children:h?null:s.jsx(i1,{offer:u,square:p})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{children:[s.jsx(Re,{children:L.telegram.how}),a?s.jsx(Re,{children:a}):null]}),s.jsx(xt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:t,children:L.offers.notNow}),s.jsx(R,{variant:"accent",disabled:o||r.trim()==="",onClick:j,children:L.telegram.submit})]}),children:s.jsx(X,{label:L.telegram.field,grow:!0,children:s.jsx("input",{ref:n,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),j())}})})})]})}const d6="(max-width: 1080px)";function f6(){const[e,t]=d.useState(()=>window.location.hash||Vt);d.useEffect(()=>{const r=()=>t(window.location.hash||Vt);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const n=d.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,n]}function h6(){const[e,t]=Zk();d.useEffect(()=>{Xk(e)},[e]);const n=d.useCallback(r=>t({theme:r}),[t]);return[e.theme,n]}function p6(){var Ce,He;const[e,t]=f6(),[n,r]=d.useState("UTC"),[i,o]=d.useState({approvals:0,failed:0}),[l,a]=h6(),c=Mh(gS),[u,p]=d.useState(!1),[f,h]=d.useState([]),[v,j]=d.useState(null),[w,b]=d.useState(null),[x,g]=d.useState([]),[y,m]=d.useState(!1),[S,k]=d.useState(null),N=QI(),C=Mh(d6),P=xS(),E=Vk(),O=se(()=>Promise.resolve().then(()=>A.version()),[],60*6e4).data,F=O&&!O.checkout&&O.updateAvailable?O:null,[D,T]=d.useState(new Map);d.useEffect(()=>{const _=()=>{A.conversations().then(ve=>{const qe=new Map;for(const ct of ve.conversations){const Ae=ct.lastMessageAt??ct.createdAt,un=qe.get(ct.agentId);(!un||Ae>un)&&qe.set(ct.agentId,Ae)}T(qe)}).catch(()=>{})};_();const ue=window.setInterval(_,3e4);return()=>window.clearInterval(ue)},[e]);const[z,Q]=d.useState(!1);d.useEffect(()=>{if(z)return;let _=!1;return A.onboarding().then(ue=>{_||(Q(!0),ue.state==="pending"&&ue.needs.model&&!fv(window.location.hash)&&t(kI,!0))}).catch(()=>{_||Q(!0)}),()=>{_=!0}},[z,t]),d.useEffect(()=>{const _=OI(e);_&&t(_,!0)},[e,t]),d.useEffect(()=>{let _=!1;const ue=()=>{ze.agents().then(qe=>{_||(h(qe.agents),BI(qe.defaultAgentId??null),j(qe.defaultAgentId??null),b(ct=>{var Ae;return ct??qe.defaultAgentId??((Ae=qe.agents[0])==null?void 0:Ae.id)??null}))}).catch(()=>{})};ue();const ve=window.setInterval(ue,15e3);return window.addEventListener("focus",ue),window.addEventListener(cl,ue),()=>{_=!0,window.clearInterval(ve),window.removeEventListener("focus",ue),window.removeEventListener(cl,ue)}},[e]),d.useEffect(()=>{let _=!1;const ue=()=>{ze.groups().then(qe=>{_||g(qe.groups)}).catch(()=>{})};ue();const ve=window.setInterval(ue,3e4);return()=>{_=!0,window.clearInterval(ve)}},[e]);const Y=L0(f,v),M=NI(e),B=$0(e),$=B?x.find(_=>_.id===B.groupId)??null:null,Z=B?null:(M==null?void 0:M.agentId)??w;d.useEffect(()=>{M&&b(M.agentId)},[M==null?void 0:M.agentId]);const V=_=>{b(_),t(Be(_))},de=_=>t(zo(_)),ge=d.useCallback((_,ue,ve=!0)=>t(B?zo(B.groupId,ue):Be(_,ue),ve),[t,B==null?void 0:B.groupId]),[je,ne]=d.useState(!1);d.useEffect(()=>{A.session().then(_=>{r(_.timezone),ne(!0)}).catch(()=>{})},[]);const xe=TO(je);$O(je,xe.refresh,()=>ne(!1)),d.useEffect(()=>{const _=()=>{A.overview().then(ve=>o({approvals:ve.approvals.pending,failed:ve.jobs.failed??0})).catch(()=>{})};_();const ue=window.setInterval(_,2e4);return()=>window.clearInterval(ue)},[]);const Se=fv(e),Me=DI(e),De=Me===Ui,he=S?x.find(_=>_.id===S)??null:null,_e=y?s.jsx(Vv,{agents:f,onClose:()=>m(!1),onCreated:_=>{g(ue=>[...ue,_]),m(!1),t(zo(_.id))}}):he?s.jsx(Vv,{agents:f,group:he,onClose:()=>k(null),onSaved:_=>{g(ue=>ue.map(ve=>ve.id===_.id?_:ve)),k(null)},onArchived:_=>{g(ue=>ue.filter(ve=>ve.id!==_)),k(null),t(Ui)}}):null;return Se?s.jsx(Zx,{delayDuration:400,children:s.jsxs(Ux,{swipeDirection:"right",children:[s.jsx(D3,{navigate:t,timezone:n}),s.jsx(zx,{className:"ui-toasts"})]})}):s.jsx(u2,{picture:(Ce=f.find(_=>_.id===v))==null?void 0:Ce.picture,children:s.jsx(Zx,{delayDuration:400,children:s.jsxs(Ux,{swipeDirection:"right",children:[_e,s.jsxs("div",{className:"wb-shell",children:[s.jsx(BL,{active:((He=P.data)==null?void 0:He.active)===!0,onNavigate:t}),s.jsxs("div",{className:"wb",children:[s.jsx(yD,{attention:i.approvals+i.failed,place:Me,onNavigate:t,theme:l,onTheme:a,plugins:E.rail,updateAvailable:F!==null,version:O&&!O.checkout?{current:O.current,latest:O.latest,updateAvailable:O.updateAvailable}:O?{current:O.current,updateAvailable:!1}:void 0}),De&&!C?s.jsx(H0,{agents:Y,currentId:Z,attention:N,onSelect:V,lastActivity:D,groups:x,currentGroupId:($==null?void 0:$.id)??null,onSelectGroup:de,onNewGroup:()=>m(!0)}):null,De?s.jsx(xO,{timezone:n,agents:Y,agentId:$?$.coordinator:Z,defaultAgentId:v,group:$,onEditGroup:$?()=>k($.id):void 0,requestedConversationId:(B==null?void 0:B.conversationId)??(M==null?void 0:M.conversationId),requestedTab:M==null?void 0:M.tab,onConversationOpened:ge,onSelectAgent:V,attention:N,agentsInHeader:C,narrow:c,canvasOpen:u,onOpenCanvas:()=>p(!0),onCloseCanvas:()=>p(!1)}):s.jsx("main",{"data-ground":m6(Me,e)?"plain":void 0,"data-layout":Me===Jt?"split":void 0,children:s.jsx(g6,{hash:e,place:Me,timezone:n,navigate:t,agents:f,defaultAgentId:v,attention:N,pluginPages:E,update:F})})]})]}),s.jsx(RO,{queue:xe.queue,agents:f,navigate:t,onDismiss:xe.dismiss}),s.jsx(zx,{className:"ui-toasts"})]})})})}function m6(e,t){return mm(t)!==null}function g6({place:e,pluginPages:t,...n}){const r={...n,pluginPages:t},i=mm(n.hash);if(i){const o=t.find(i.plugin,i.page);if(o)return s.jsx(Hk,{page:o,item:i.item??null,navigate:n.navigate,timezone:n.timezone,siblings:t.all.filter(l=>l.plugin===i.plugin)});if(t.all.length===0)return s.jsx(s.Fragment,{})}switch(e){case rt:return s.jsx(bL,{...n});case st:return s.jsx(OD,{...n});case Jt:return s.jsx(o3,{...r});case Fr:return s.jsx(gD,{...n});default:return s.jsx(CL,{...n})}}const jj=document.getElementById("root");jj&&Iw(jj).render(s.jsx(d.StrictMode,{children:s.jsx(p6,{})}));