@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37

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 (522) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/README.md +417 -219
  3. package/dist/adapters.d.ts +12 -2
  4. package/dist/adapters.js +27 -2
  5. package/dist/agent-rows.d.ts +2 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +9 -4
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +79 -7
  13. package/dist/archil-settings.js +140 -14
  14. package/dist/attach-conformance-cli.d.ts +1 -0
  15. package/dist/attach-conformance-cli.js +18 -0
  16. package/dist/attach-conformance.d.ts +25 -0
  17. package/dist/attach-conformance.js +343 -0
  18. package/dist/attach-images.d.ts +15 -0
  19. package/dist/attach-images.js +59 -0
  20. package/dist/background.d.ts +0 -6
  21. package/dist/background.js +0 -28
  22. package/dist/box-image.d.ts +1 -97
  23. package/dist/box-image.js +4 -284
  24. package/dist/box-paths.d.ts +2 -7
  25. package/dist/box-paths.js +7 -13
  26. package/dist/box-settings.d.ts +0 -11
  27. package/dist/box-settings.js +4 -29
  28. package/dist/browser-commands.js +1 -1
  29. package/dist/browser-computer.d.ts +47 -3
  30. package/dist/browser-computer.js +286 -18
  31. package/dist/browser-cost.d.ts +1 -1
  32. package/dist/browser-live.d.ts +20 -8
  33. package/dist/browser-live.js +50 -27
  34. package/dist/browser-person.d.ts +19 -2
  35. package/dist/browser-person.js +55 -6
  36. package/dist/browser-wait-ended.d.ts +23 -0
  37. package/dist/browser-wait-ended.js +42 -0
  38. package/dist/cap.d.ts +12 -57
  39. package/dist/cap.js +20 -160
  40. package/dist/catalog.d.ts +1 -12
  41. package/dist/catalog.js +3 -33
  42. package/dist/cli.js +17 -26
  43. package/dist/composio-preset.d.ts +36 -0
  44. package/dist/composio-preset.js +179 -0
  45. package/dist/computer-attach.d.ts +125 -0
  46. package/dist/computer-attach.js +330 -0
  47. package/dist/computer-calls.d.ts +48 -0
  48. package/dist/computer-calls.js +126 -0
  49. package/dist/computer-channel.d.ts +57 -0
  50. package/dist/computer-channel.js +115 -0
  51. package/dist/computer-commands.d.ts +1 -1
  52. package/dist/computer-held-routes.d.ts +35 -0
  53. package/dist/computer-held-routes.js +106 -0
  54. package/dist/computer-held.d.ts +48 -0
  55. package/dist/computer-held.js +87 -0
  56. package/dist/computer-keys.d.ts +21 -1
  57. package/dist/computer-keys.js +53 -11
  58. package/dist/computer-live.d.ts +160 -0
  59. package/dist/computer-live.js +643 -0
  60. package/dist/computer-routes.d.ts +1 -4
  61. package/dist/computer-routes.js +3 -5
  62. package/dist/computer-setting.d.ts +2 -0
  63. package/dist/computer-setting.js +38 -1
  64. package/dist/computer-view.d.ts +24 -2
  65. package/dist/computer-view.js +51 -3
  66. package/dist/computer-viewer.d.ts +6 -0
  67. package/dist/computer-viewer.js +297 -0
  68. package/dist/computers.d.ts +79 -12
  69. package/dist/computers.js +147 -28
  70. package/dist/console/assets/index-Cn6JX1uH.js +563 -0
  71. package/dist/console/assets/index-DRN62V5v.css +1 -0
  72. package/dist/console/index.html +2 -2
  73. package/dist/docker-daemon.d.ts +2 -2
  74. package/dist/docker-daemon.js +2 -2
  75. package/dist/errors.js +5 -5
  76. package/dist/faux-computers.d.ts +9 -20
  77. package/dist/faux-computers.js +56 -24
  78. package/dist/files.d.ts +1 -9
  79. package/dist/files.js +1 -9
  80. package/dist/github-connection.d.ts +10 -2
  81. package/dist/github-connection.js +65 -2
  82. package/dist/github-faux.js +1 -1
  83. package/dist/github.d.ts +22 -2
  84. package/dist/github.js +42 -8
  85. package/dist/gpu-words.d.ts +14 -0
  86. package/dist/gpu-words.js +21 -0
  87. package/dist/graph-view.d.ts +3 -1
  88. package/dist/graph-view.js +25 -1
  89. package/dist/handed-values.d.ts +1 -1
  90. package/dist/handed-values.js +1 -1
  91. package/dist/harness-install.d.ts +60 -3
  92. package/dist/harness-install.js +322 -34
  93. package/dist/harness.d.ts +1 -0
  94. package/dist/harness.js +36 -2
  95. package/dist/host-tools.d.ts +9 -10
  96. package/dist/host-tools.js +7 -7
  97. package/dist/hosted-search.d.ts +5 -4
  98. package/dist/hosted-search.js +2 -7
  99. package/dist/import-sources.d.ts +10 -0
  100. package/dist/import-sources.js +44 -2
  101. package/dist/import.d.ts +3 -3
  102. package/dist/import.js +37 -6
  103. package/dist/index.d.ts +1 -3
  104. package/dist/index.js +1 -2
  105. package/dist/key-refusal.d.ts +1 -1
  106. package/dist/key-refusal.js +2 -2
  107. package/dist/learn/check.d.ts +11 -2
  108. package/dist/learn/check.js +124 -6
  109. package/dist/learn/commit.d.ts +43 -7
  110. package/dist/learn/commit.js +166 -22
  111. package/dist/learn/folder.d.ts +11 -0
  112. package/dist/learn/folder.js +37 -1
  113. package/dist/learn/general.d.ts +66 -0
  114. package/dist/learn/general.js +73 -0
  115. package/dist/learn/grade.d.ts +22 -1
  116. package/dist/learn/grade.js +107 -16
  117. package/dist/learn/index.d.ts +1 -1
  118. package/dist/learn/index.js +1 -1
  119. package/dist/learn/learning.sh +12 -1
  120. package/dist/learn/notes.d.ts +3 -0
  121. package/dist/learn/notes.js +3 -0
  122. package/dist/learn/reflect.d.ts +14 -2
  123. package/dist/learn/reflect.js +54 -30
  124. package/dist/learn/skills.d.ts +37 -5
  125. package/dist/learn/skills.js +60 -7
  126. package/dist/learned-nodes.d.ts +6 -2
  127. package/dist/learned-workflow.d.ts +43 -9
  128. package/dist/learned-workflow.js +128 -37
  129. package/dist/learning-batch.d.ts +283 -0
  130. package/dist/learning-batch.js +574 -0
  131. package/dist/learning-cost.d.ts +79 -0
  132. package/dist/learning-cost.js +69 -0
  133. package/dist/learning-evals.d.ts +33 -0
  134. package/dist/learning-evals.js +98 -0
  135. package/dist/learning-routes.d.ts +32 -4
  136. package/dist/learning-routes.js +48 -12
  137. package/dist/learning-words.d.ts +9 -0
  138. package/dist/learning-words.js +12 -2
  139. package/dist/learning.d.ts +39 -19
  140. package/dist/learning.js +88 -46
  141. package/dist/live/stream.js +6 -3
  142. package/dist/live/translate.d.ts +4 -3
  143. package/dist/live/translate.js +8 -4
  144. package/dist/live-reach.d.ts +37 -0
  145. package/dist/live-reach.js +62 -0
  146. package/dist/mcp-gateway.d.ts +9 -0
  147. package/dist/mcp-gateway.js +60 -11
  148. package/dist/mcp-oauth.d.ts +57 -7
  149. package/dist/mcp-oauth.js +133 -18
  150. package/dist/mcp-private-hosts.d.ts +4 -4
  151. package/dist/mcp-private-hosts.js +20 -12
  152. package/dist/mcp-probe.d.ts +27 -3
  153. package/dist/mcp-probe.js +106 -29
  154. package/dist/mcp-secret-writes.js +8 -0
  155. package/dist/mcp-servers-store.d.ts +38 -15
  156. package/dist/mcp-servers-store.js +120 -23
  157. package/dist/mcp-store.d.ts +10 -4
  158. package/dist/mcp-store.js +17 -6
  159. package/dist/model-form.d.ts +26 -0
  160. package/dist/model-form.js +80 -0
  161. package/dist/model.d.ts +5 -5
  162. package/dist/model.js +29 -16
  163. package/dist/openapi.d.ts +2 -0
  164. package/dist/openapi.js +586 -64
  165. package/dist/owner.d.ts +0 -1
  166. package/dist/owner.js +0 -2
  167. package/dist/page.d.ts +18 -0
  168. package/dist/page.js +48 -20
  169. package/dist/paid-calls.d.ts +1 -1
  170. package/dist/paid-calls.js +1 -1
  171. package/dist/place-offers.d.ts +96 -0
  172. package/dist/place-offers.js +202 -0
  173. package/dist/place.d.ts +9 -13
  174. package/dist/place.js +21 -32
  175. package/dist/port-models.d.ts +2 -1
  176. package/dist/port-models.js +5 -3
  177. package/dist/print.d.ts +16 -9
  178. package/dist/print.js +15 -17
  179. package/dist/propose.d.ts +4 -0
  180. package/dist/propose.js +34 -11
  181. package/dist/provider.js +3 -2
  182. package/dist/reflect-range.d.ts +8 -1
  183. package/dist/reflect-range.js +1 -1
  184. package/dist/run-cut.d.ts +5 -0
  185. package/dist/run-cut.js +19 -0
  186. package/dist/run-launch.d.ts +28 -3
  187. package/dist/run-launch.js +14 -4
  188. package/dist/run-learning-served.d.ts +2 -2
  189. package/dist/run-manifest.d.ts +2 -2
  190. package/dist/run-manifest.js +2 -2
  191. package/dist/run-reads-over-store.d.ts +1 -1
  192. package/dist/run-repo.d.ts +20 -0
  193. package/dist/run-repo.js +63 -0
  194. package/dist/run-secrets.js +3 -3
  195. package/dist/run-timeline-served.d.ts +1 -1
  196. package/dist/run-timeline-served.js +56 -44
  197. package/dist/run-view.d.ts +8 -5
  198. package/dist/run-view.js +18 -10
  199. package/dist/runnable.d.ts +2 -2
  200. package/dist/runnable.js +6 -2
  201. package/dist/runner/adapter-loop.d.ts +39 -8
  202. package/dist/runner/adapter-loop.js +770 -83
  203. package/dist/runner/adapter-run-spec.d.ts +36 -7
  204. package/dist/runner/adapter-run-spec.js +171 -37
  205. package/dist/runner/adapters/pi-computer.d.ts +7 -0
  206. package/dist/runner/adapters/pi-computer.js +43 -0
  207. package/dist/runner/adapters/pi.d.ts +20 -7
  208. package/dist/runner/adapters/pi.js +111 -26
  209. package/dist/runner/beside.d.ts +7 -3
  210. package/dist/runner/beside.js +26 -12
  211. package/dist/runner/claim-secrets.d.ts +4 -0
  212. package/dist/runner/claim-secrets.js +6 -1
  213. package/dist/runner/cli-run-spec.d.ts +27 -3
  214. package/dist/runner/cli-run-spec.js +198 -74
  215. package/dist/runner/commands.d.ts +8 -2
  216. package/dist/runner/commands.js +31 -6
  217. package/dist/runner/computer-channel.d.ts +34 -0
  218. package/dist/runner/computer-channel.js +61 -0
  219. package/dist/runner/conformance/harness.d.ts +0 -1
  220. package/dist/runner/conformance/harness.js +87 -18
  221. package/dist/runner/conformance/subject.d.ts +1 -1
  222. package/dist/runner/dispatch.js +3 -0
  223. package/dist/runner/end-of-run.d.ts +22 -12
  224. package/dist/runner/end-of-run.js +38 -16
  225. package/dist/runner/github-app.d.ts +2 -1
  226. package/dist/runner/github-app.js +6 -4
  227. package/dist/runner/harness-loops.js +16 -2
  228. package/dist/runner/held-run.d.ts +65 -0
  229. package/dist/runner/held-run.js +158 -0
  230. package/dist/runner/journal-kinds.d.ts +35 -6
  231. package/dist/runner/journal-kinds.js +20 -1
  232. package/dist/runner/journal-reader.d.ts +5 -4
  233. package/dist/runner/journal-reader.js +12 -10
  234. package/dist/runner/learning-ask.d.ts +7 -1
  235. package/dist/runner/learning-ask.js +21 -6
  236. package/dist/runner/learning-dispatch.d.ts +22 -0
  237. package/dist/runner/learning-dispatch.js +77 -10
  238. package/dist/runner/learning-end.d.ts +37 -1
  239. package/dist/runner/learning-end.js +115 -14
  240. package/dist/runner/learning-factory.d.ts +1 -1
  241. package/dist/runner/learning-factory.js +15 -5
  242. package/dist/runner/learning-loop.d.ts +139 -7
  243. package/dist/runner/learning-loop.js +369 -32
  244. package/dist/runner/learning-seed.d.ts +9 -0
  245. package/dist/runner/learning-seed.js +14 -1
  246. package/dist/runner/live-ticker.js +1 -0
  247. package/dist/runner/loop-contract.d.ts +16 -1
  248. package/dist/runner/loop-contract.js +6 -0
  249. package/dist/runner/loop.d.ts +10 -2
  250. package/dist/runner/loop.js +22 -1
  251. package/dist/runner/main.d.ts +13 -1
  252. package/dist/runner/main.js +38 -6
  253. package/dist/runner/mcp-claim.d.ts +11 -4
  254. package/dist/runner/mcp-claim.js +140 -23
  255. package/dist/runner/mcp-github.d.ts +4 -2
  256. package/dist/runner/mcp-github.js +1 -8
  257. package/dist/runner/mcp-run.d.ts +6 -4
  258. package/dist/runner/mcp-run.js +16 -3
  259. package/dist/runner/metrics.d.ts +15 -2
  260. package/dist/runner/metrics.js +21 -2
  261. package/dist/runner/model-route.d.ts +3 -0
  262. package/dist/runner/model-route.js +5 -2
  263. package/dist/runner/pr-checkout.d.ts +60 -0
  264. package/dist/runner/pr-checkout.js +176 -0
  265. package/dist/runner/reflect-hook.d.ts +19 -0
  266. package/dist/runner/reflect-hook.js +20 -8
  267. package/dist/runner/runner.d.ts +26 -0
  268. package/dist/runner/runner.js +231 -27
  269. package/dist/runner/scratch-sweep.d.ts +13 -0
  270. package/dist/runner/scratch-sweep.js +62 -0
  271. package/dist/runner/sessions.d.ts +1 -1
  272. package/dist/runner/spec-holds.d.ts +8 -3
  273. package/dist/runner/spec-holds.js +12 -10
  274. package/dist/runner/store-port.d.ts +7 -2
  275. package/dist/runner/store-secrets.js +21 -4
  276. package/dist/runner/subagent.d.ts +44 -0
  277. package/dist/runner/subagent.js +190 -0
  278. package/dist/runner/workflow-host.d.ts +24 -3
  279. package/dist/runner/workflow-host.js +24 -4
  280. package/dist/runner/workflow-loop.d.ts +6 -3
  281. package/dist/runner/workflow-loop.js +9 -8
  282. package/dist/runner/workflow-spec.d.ts +39 -15
  283. package/dist/runner/workflow-spec.js +143 -40
  284. package/dist/runs-over-store.d.ts +16 -6
  285. package/dist/runs-over-store.js +145 -29
  286. package/dist/seal-key.js +3 -3
  287. package/dist/sealed-settings-store.d.ts +5 -2
  288. package/dist/sealed-settings-store.js +10 -4
  289. package/dist/sealing.js +1 -2
  290. package/dist/secret-cut.d.ts +1 -1
  291. package/dist/secret-cut.js +1 -1
  292. package/dist/secret-writes.d.ts +5 -4
  293. package/dist/secret-writes.js +5 -4
  294. package/dist/server-secrets-store.d.ts +4 -3
  295. package/dist/server-secrets-store.js +15 -9
  296. package/dist/server-secrets.js +3 -2
  297. package/dist/server.d.ts +75 -63
  298. package/dist/server.js +712 -316
  299. package/dist/settings-wake.d.ts +21 -0
  300. package/dist/settings-wake.js +59 -0
  301. package/dist/standard-webhooks.d.ts +4 -1
  302. package/dist/standard-webhooks.js +8 -4
  303. package/dist/store/agent-body.d.ts +9 -2
  304. package/dist/store/agent-body.js +16 -8
  305. package/dist/store/command-wake.d.ts +12 -0
  306. package/dist/store/command-wake.js +37 -0
  307. package/dist/store/deadline.js +9 -5
  308. package/dist/store/dialect.d.ts +6 -0
  309. package/dist/store/dialect.js +5 -0
  310. package/dist/store/index.d.ts +4 -4
  311. package/dist/store/index.js +2 -2
  312. package/dist/store/journal/storage.d.ts +3 -2
  313. package/dist/store/journal/storage.js +15 -6
  314. package/dist/store/postgres/connection.js +9 -4
  315. package/dist/store/postgres/dialect.js +4 -0
  316. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  317. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  318. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  319. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  320. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  321. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  322. package/dist/store/schema.d.ts +2 -1
  323. package/dist/store/schema.js +85 -13
  324. package/dist/store/seal.d.ts +13 -0
  325. package/dist/store/seal.js +19 -0
  326. package/dist/store/sqlite/connection.d.ts +5 -0
  327. package/dist/store/sqlite/connection.js +88 -47
  328. package/dist/store/sqlite/run-patch.d.ts +25 -7
  329. package/dist/store/sqlite/run-patch.js +58 -14
  330. package/dist/store/sqlite/store.js +331 -59
  331. package/dist/store/store.d.ts +330 -21
  332. package/dist/store/store.js +34 -2
  333. package/dist/store-reads/analytics.js +3 -2
  334. package/dist/store-reads/cap.d.ts +2 -4
  335. package/dist/store-reads/cap.js +16 -7
  336. package/dist/store-reads/decisions.d.ts +3 -3
  337. package/dist/store-reads/decisions.js +3 -6
  338. package/dist/store-reads/import-summary.d.ts +1 -1
  339. package/dist/store-reads/journal.d.ts +5 -4
  340. package/dist/store-reads/journal.js +118 -27
  341. package/dist/store-reads/learning.d.ts +34 -4
  342. package/dist/store-reads/learning.js +137 -23
  343. package/dist/store-reads/runs.d.ts +7 -5
  344. package/dist/store-reads/runs.js +17 -10
  345. package/dist/store-reads/stats.js +5 -1
  346. package/dist/store-reads/workflow.d.ts +1 -1
  347. package/dist/store-view.d.ts +5 -0
  348. package/dist/store-view.js +70 -29
  349. package/dist/template-eval.js +8 -5
  350. package/dist/template-github-permissions.d.ts +22 -8
  351. package/dist/template-github-permissions.js +35 -15
  352. package/dist/templates.d.ts +64 -0
  353. package/dist/templates.js +101 -16
  354. package/dist/timeline/timeline.d.ts +30 -1
  355. package/dist/timeline/timeline.js +29 -13
  356. package/dist/timeline/util.d.ts +4 -0
  357. package/dist/timeline/util.js +14 -0
  358. package/dist/tool-blurbs.js +1 -0
  359. package/dist/tool-budget.d.ts +27 -7
  360. package/dist/tool-budget.js +21 -9
  361. package/dist/tool-gate.d.ts +23 -10
  362. package/dist/tool-gate.js +60 -44
  363. package/dist/tool-plane.d.ts +46 -28
  364. package/dist/tool-plane.js +73 -31
  365. package/dist/tools.d.ts +31 -38
  366. package/dist/tools.js +117 -74
  367. package/dist/trigger-adapter.d.ts +4 -0
  368. package/dist/trigger-secrets-shown.d.ts +2 -2
  369. package/dist/trigger-secrets-shown.js +1 -1
  370. package/dist/trigger-signatures.d.ts +26 -6
  371. package/dist/trigger-signatures.js +44 -8
  372. package/dist/trigger-targets.d.ts +2 -0
  373. package/dist/trigger-targets.js +1 -0
  374. package/dist/trigger-webhook.js +5 -2
  375. package/dist/triggers.d.ts +10 -6
  376. package/dist/triggers.js +37 -7
  377. package/dist/turn-end.d.ts +0 -3
  378. package/dist/turn-end.js +0 -3
  379. package/dist/turns.js +16 -1
  380. package/dist/usage-lines.d.ts +1 -1
  381. package/dist/validate.d.ts +6 -0
  382. package/dist/validate.js +41 -4
  383. package/dist/web-fetch.d.ts +1 -1
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +147 -103
  387. package/dist/webhooks.js +564 -324
  388. package/dist/workflow/decision-recovery.d.ts +23 -0
  389. package/dist/workflow/decision-recovery.js +80 -0
  390. package/dist/workflow/decisions.d.ts +134 -0
  391. package/dist/workflow/decisions.js +46 -0
  392. package/dist/workflow/host-session.d.ts +5 -0
  393. package/dist/workflow/host-session.js +85 -0
  394. package/dist/workflow/host-tools.d.ts +3 -0
  395. package/dist/workflow/host-tools.js +3 -0
  396. package/dist/workflow/node-runner.d.ts +113 -0
  397. package/dist/workflow/node-runner.js +270 -0
  398. package/dist/workflow/node.d.ts +89 -0
  399. package/dist/workflow/node.js +101 -0
  400. package/dist/workflow/operator-error.d.ts +4 -0
  401. package/dist/workflow/operator-error.js +4 -0
  402. package/dist/workflow/pi-versions.d.ts +32 -0
  403. package/dist/workflow/pi-versions.js +65 -0
  404. package/dist/workflow/record-file.d.ts +10 -0
  405. package/dist/workflow/record-file.js +56 -0
  406. package/dist/workflow/record-tool.d.ts +77 -0
  407. package/dist/workflow/record-tool.js +126 -0
  408. package/dist/workflow/record.d.ts +151 -0
  409. package/dist/workflow/record.js +401 -0
  410. package/dist/workflow/run-error.d.ts +16 -0
  411. package/dist/workflow/run-error.js +26 -0
  412. package/dist/workflow/runner.d.ts +6 -0
  413. package/dist/workflow/runner.js +240 -0
  414. package/dist/workflow/store.d.ts +23 -0
  415. package/dist/workflow/store.js +242 -0
  416. package/dist/workflow/task.d.ts +133 -0
  417. package/dist/workflow/task.js +412 -0
  418. package/dist/workflow/thinking.d.ts +3 -0
  419. package/dist/workflow/thinking.js +7 -0
  420. package/dist/workflow/tool-context.d.ts +21 -0
  421. package/dist/workflow/tool-context.js +13 -0
  422. package/dist/workflow/types.d.ts +126 -0
  423. package/dist/workflow/types.js +1 -0
  424. package/dist/workflow-run.d.ts +2 -2
  425. package/dist/workspace/agent-computer.d.ts +137 -0
  426. package/dist/workspace/agent-computer.js +292 -0
  427. package/dist/workspace/archil-claim.d.ts +11 -0
  428. package/dist/workspace/archil-claim.js +18 -10
  429. package/dist/workspace/archil-disks.d.ts +49 -0
  430. package/dist/workspace/archil-disks.js +185 -0
  431. package/dist/workspace/archil-exec.js +2 -3
  432. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  433. package/dist/workspace/archil-mount-credential.js +13 -4
  434. package/dist/workspace/attached-computers.d.ts +41 -0
  435. package/dist/workspace/attached-computers.js +114 -0
  436. package/dist/workspace/computer-deps.d.ts +32 -17
  437. package/dist/workspace/computer-deps.js +37 -14
  438. package/dist/workspace/computer-for-claim.d.ts +58 -13
  439. package/dist/workspace/computer-for-claim.js +267 -26
  440. package/dist/workspace/computer-hold.d.ts +11 -27
  441. package/dist/workspace/computer-hold.js +36 -56
  442. package/dist/workspace/computer-janitor.d.ts +3 -2
  443. package/dist/workspace/computer-janitor.js +43 -9
  444. package/dist/workspace/computer-ledger.d.ts +5 -1
  445. package/dist/workspace/computer-ledger.js +11 -0
  446. package/dist/workspace/computer-mcp.d.ts +25 -0
  447. package/dist/workspace/computer-mcp.js +41 -0
  448. package/dist/workspace/computer-ports.d.ts +4 -13
  449. package/dist/workspace/computer-ports.js +4 -107
  450. package/dist/workspace/computer-script.d.ts +37 -0
  451. package/dist/workspace/computer-script.js +138 -0
  452. package/dist/workspace/executors.d.ts +1 -1
  453. package/dist/workspace/index.d.ts +7 -4
  454. package/dist/workspace/index.js +4 -1
  455. package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
  456. package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
  457. package/dist/workspace/resolve-computer.d.ts +45 -11
  458. package/dist/workspace/resolve-computer.js +72 -14
  459. package/dist/workspace/run-disk.d.ts +34 -0
  460. package/dist/workspace/run-disk.js +91 -0
  461. package/dist/workspace/run-tools.d.ts +35 -18
  462. package/dist/workspace/run-tools.js +24 -29
  463. package/dist/workspace/server-run-workspace.d.ts +3 -2
  464. package/dist/workspace/server-run-workspace.js +17 -4
  465. package/dist/workspace.js +1 -1
  466. package/package.json +19 -21
  467. package/templates/README.md +9 -6
  468. package/templates/code-review/agent.md +27 -11
  469. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  470. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  471. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  472. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  473. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  474. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  475. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  476. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  477. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  478. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  479. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  480. package/templates/code-review/evals/re-review/prompt.md +1 -1
  481. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  482. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  483. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  484. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  485. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  486. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  487. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  488. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  489. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  490. package/templates/code-review/findings.schema.json +131 -27
  491. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  492. package/templates/code-review/skills/review/DEEP.md +130 -0
  493. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  494. package/templates/code-review/skills/review/SKILL.md +104 -154
  495. package/templates/market-monitor/agent.md +1 -1
  496. package/dist/box/record.d.ts +0 -6
  497. package/dist/box/record.js +0 -41
  498. package/dist/box/sweep.d.ts +0 -53
  499. package/dist/box/sweep.js +0 -193
  500. package/dist/box-egress-vm.d.ts +0 -118
  501. package/dist/box-egress-vm.js +0 -354
  502. package/dist/box-egress.d.ts +0 -105
  503. package/dist/box-egress.js +0 -256
  504. package/dist/box-relay-vm.d.ts +0 -84
  505. package/dist/box-relay-vm.js +0 -437
  506. package/dist/box-relay.d.ts +0 -36
  507. package/dist/box-relay.js +0 -207
  508. package/dist/boxes.d.ts +0 -109
  509. package/dist/boxes.js +0 -249
  510. package/dist/budget.d.ts +0 -71
  511. package/dist/budget.js +0 -199
  512. package/dist/console/assets/index-B7NKTU8E.css +0 -1
  513. package/dist/console/assets/index-CXZMgJE7.js +0 -550
  514. package/dist/daytona-api.d.ts +0 -10
  515. package/dist/daytona-api.js +0 -20
  516. package/dist/egress-proxy.d.ts +0 -45
  517. package/dist/egress-proxy.js +0 -416
  518. package/dist/egress-table.d.ts +0 -24
  519. package/dist/egress-table.js +0 -165
  520. package/dist/run-db.d.ts +0 -53
  521. package/dist/run-db.js +0 -116
  522. package/templates/code-review/rules/REVIEW.md +0 -41
@@ -0,0 +1,563 @@
1
+ var m_=Object.defineProperty;var p_=(e,t,s)=>t in e?m_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var it=(e,t,s)=>p_(e,typeof t!="symbol"?t+"":t,s);function h_(e,t){for(var s=0;s<t.length;s++){const r=t[s];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>r[a]})}}}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 a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function s(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=s(a);fetch(a.href,l)}})();function _0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qm={exports:{}},ll={},Zm={exports:{}},Qe={};/**
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 _b;function g_(){if(_b)return Qe;_b=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.iterator;function h(O){return O===null||typeof O!="object"?null:(O=v&&O[v]||O["@@iterator"],typeof O=="function"?O:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,w={};function j(O,B,ee){this.props=O,this.context=B,this.refs=w,this.updater=ee||m}j.prototype.isReactComponent={},j.prototype.setState=function(O,B){if(typeof O!="object"&&typeof O!="function"&&O!=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,O,B,"setState")},j.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function N(){}N.prototype=j.prototype;function R(O,B,ee){this.props=O,this.context=B,this.refs=w,this.updater=ee||m}var $=R.prototype=new N;$.constructor=R,b($,j.prototype),$.isPureReactComponent=!0;var S=Array.isArray,E=Object.prototype.hasOwnProperty,C={current:null},T={key:!0,ref:!0,__self:!0,__source:!0};function A(O,B,ee){var le,ie={},ue=null,ae=null;if(B!=null)for(le in B.ref!==void 0&&(ae=B.ref),B.key!==void 0&&(ue=""+B.key),B)E.call(B,le)&&!T.hasOwnProperty(le)&&(ie[le]=B[le]);var ce=arguments.length-2;if(ce===1)ie.children=ee;else if(1<ce){for(var he=Array(ce),et=0;et<ce;et++)he[et]=arguments[et+2];ie.children=he}if(O&&O.defaultProps)for(le in ce=O.defaultProps,ce)ie[le]===void 0&&(ie[le]=ce[le]);return{$$typeof:e,type:O,key:ue,ref:ae,props:ie,_owner:C.current}}function F(O,B){return{$$typeof:e,type:O.type,key:B,ref:O.ref,props:O.props,_owner:O._owner}}function L(O){return typeof O=="object"&&O!==null&&O.$$typeof===e}function z(O){var B={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(ee){return B[ee]})}var W=/\/+/g;function U(O,B){return typeof O=="object"&&O!==null&&O.key!=null?z(""+O.key):B.toString(36)}function D(O,B,ee,le,ie){var ue=typeof O;(ue==="undefined"||ue==="boolean")&&(O=null);var ae=!1;if(O===null)ae=!0;else switch(ue){case"string":case"number":ae=!0;break;case"object":switch(O.$$typeof){case e:case t:ae=!0}}if(ae)return ae=O,ie=ie(ae),O=le===""?"."+U(ae,0):le,S(ie)?(ee="",O!=null&&(ee=O.replace(W,"$&/")+"/"),D(ie,B,ee,"",function(et){return et})):ie!=null&&(L(ie)&&(ie=F(ie,ee+(!ie.key||ae&&ae.key===ie.key?"":(""+ie.key).replace(W,"$&/")+"/")+O)),B.push(ie)),1;if(ae=0,le=le===""?".":le+":",S(O))for(var ce=0;ce<O.length;ce++){ue=O[ce];var he=le+U(ue,ce);ae+=D(ue,B,ee,he,ie)}else if(he=h(O),typeof he=="function")for(O=he.call(O),ce=0;!(ue=O.next()).done;)ue=ue.value,he=le+U(ue,ce++),ae+=D(ue,B,ee,he,ie);else if(ue==="object")throw B=String(O),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return ae}function K(O,B,ee){if(O==null)return O;var le=[],ie=0;return D(O,le,"","",function(ue){return B.call(ee,ue,ie++)}),le}function P(O){if(O._status===-1){var B=O._result;B=B(),B.then(function(ee){(O._status===0||O._status===-1)&&(O._status=1,O._result=ee)},function(ee){(O._status===0||O._status===-1)&&(O._status=2,O._result=ee)}),O._status===-1&&(O._status=0,O._result=B)}if(O._status===1)return O._result.default;throw O._result}var G={current:null},I={transition:null},Y={ReactCurrentDispatcher:G,ReactCurrentBatchConfig:I,ReactCurrentOwner:C};function q(){throw Error("act(...) is not supported in production builds of React.")}return Qe.Children={map:K,forEach:function(O,B,ee){K(O,function(){B.apply(this,arguments)},ee)},count:function(O){var B=0;return K(O,function(){B++}),B},toArray:function(O){return K(O,function(B){return B})||[]},only:function(O){if(!L(O))throw Error("React.Children.only expected to receive a single React element child.");return O}},Qe.Component=j,Qe.Fragment=s,Qe.Profiler=a,Qe.PureComponent=R,Qe.StrictMode=r,Qe.Suspense=f,Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,Qe.act=q,Qe.cloneElement=function(O,B,ee){if(O==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+O+".");var le=b({},O.props),ie=O.key,ue=O.ref,ae=O._owner;if(B!=null){if(B.ref!==void 0&&(ue=B.ref,ae=C.current),B.key!==void 0&&(ie=""+B.key),O.type&&O.type.defaultProps)var ce=O.type.defaultProps;for(he in B)E.call(B,he)&&!T.hasOwnProperty(he)&&(le[he]=B[he]===void 0&&ce!==void 0?ce[he]:B[he])}var he=arguments.length-2;if(he===1)le.children=ee;else if(1<he){ce=Array(he);for(var et=0;et<he;et++)ce[et]=arguments[et+2];le.children=ce}return{$$typeof:e,type:O.type,key:ie,ref:ue,props:le,_owner:ae}},Qe.createContext=function(O){return O={$$typeof:c,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},O.Provider={$$typeof:l,_context:O},O.Consumer=O},Qe.createElement=A,Qe.createFactory=function(O){var B=A.bind(null,O);return B.type=O,B},Qe.createRef=function(){return{current:null}},Qe.forwardRef=function(O){return{$$typeof:u,render:O}},Qe.isValidElement=L,Qe.lazy=function(O){return{$$typeof:g,_payload:{_status:-1,_result:O},_init:P}},Qe.memo=function(O,B){return{$$typeof:p,type:O,compare:B===void 0?null:B}},Qe.startTransition=function(O){var B=I.transition;I.transition={};try{O()}finally{I.transition=B}},Qe.unstable_act=q,Qe.useCallback=function(O,B){return G.current.useCallback(O,B)},Qe.useContext=function(O){return G.current.useContext(O)},Qe.useDebugValue=function(){},Qe.useDeferredValue=function(O){return G.current.useDeferredValue(O)},Qe.useEffect=function(O,B){return G.current.useEffect(O,B)},Qe.useId=function(){return G.current.useId()},Qe.useImperativeHandle=function(O,B,ee){return G.current.useImperativeHandle(O,B,ee)},Qe.useInsertionEffect=function(O,B){return G.current.useInsertionEffect(O,B)},Qe.useLayoutEffect=function(O,B){return G.current.useLayoutEffect(O,B)},Qe.useMemo=function(O,B){return G.current.useMemo(O,B)},Qe.useReducer=function(O,B,ee){return G.current.useReducer(O,B,ee)},Qe.useRef=function(O){return G.current.useRef(O)},Qe.useState=function(O){return G.current.useState(O)},Qe.useSyncExternalStore=function(O,B,ee){return G.current.useSyncExternalStore(O,B,ee)},Qe.useTransition=function(){return G.current.useTransition()},Qe.version="18.3.1",Qe}var $b;function Md(){return $b||($b=1,Zm.exports=g_()),Zm.exports}/**
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 Eb;function x_(){if(Eb)return ll;Eb=1;var e=Md(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(u,f,p){var g,v={},h=null,m=null;p!==void 0&&(h=""+p),f.key!==void 0&&(h=""+f.key),f.ref!==void 0&&(m=f.ref);for(g in f)r.call(f,g)&&!l.hasOwnProperty(g)&&(v[g]=f[g]);if(u&&u.defaultProps)for(g in f=u.defaultProps,f)v[g]===void 0&&(v[g]=f[g]);return{$$typeof:t,type:u,key:h,ref:m,props:v,_owner:a.current}}return ll.Fragment=s,ll.jsx=c,ll.jsxs=c,ll}var Cb;function y_(){return Cb||(Cb=1,Qm.exports=x_()),Qm.exports}var n=y_(),x=Md();const Ne=_0(x),Up=h_({__proto__:null,default:Ne},[x]);var vu={},Jm={exports:{}},Gn={},ep={exports:{}},tp={};/**
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
+ */var Tb;function b_(){return Tb||(Tb=1,(function(e){function t(I,Y){var q=I.length;I.push(Y);e:for(;0<q;){var O=q-1>>>1,B=I[O];if(0<a(B,Y))I[O]=Y,I[q]=B,q=O;else break e}}function s(I){return I.length===0?null:I[0]}function r(I){if(I.length===0)return null;var Y=I[0],q=I.pop();if(q!==Y){I[0]=q;e:for(var O=0,B=I.length,ee=B>>>1;O<ee;){var le=2*(O+1)-1,ie=I[le],ue=le+1,ae=I[ue];if(0>a(ie,q))ue<B&&0>a(ae,ie)?(I[O]=ae,I[ue]=q,O=ue):(I[O]=ie,I[le]=q,O=le);else if(ue<B&&0>a(ae,q))I[O]=ae,I[ue]=q,O=ue;else break e}}return Y}function a(I,Y){var q=I.sortIndex-Y.sortIndex;return q!==0?q:I.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var f=[],p=[],g=1,v=null,h=3,m=!1,b=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function $(I){for(var Y=s(p);Y!==null;){if(Y.callback===null)r(p);else if(Y.startTime<=I)r(p),Y.sortIndex=Y.expirationTime,t(f,Y);else break;Y=s(p)}}function S(I){if(w=!1,$(I),!b)if(s(f)!==null)b=!0,P(E);else{var Y=s(p);Y!==null&&G(S,Y.startTime-I)}}function E(I,Y){b=!1,w&&(w=!1,N(A),A=-1),m=!0;var q=h;try{for($(Y),v=s(f);v!==null&&(!(v.expirationTime>Y)||I&&!z());){var O=v.callback;if(typeof O=="function"){v.callback=null,h=v.priorityLevel;var B=O(v.expirationTime<=Y);Y=e.unstable_now(),typeof B=="function"?v.callback=B:v===s(f)&&r(f),$(Y)}else r(f);v=s(f)}if(v!==null)var ee=!0;else{var le=s(p);le!==null&&G(S,le.startTime-Y),ee=!1}return ee}finally{v=null,h=q,m=!1}}var C=!1,T=null,A=-1,F=5,L=-1;function z(){return!(e.unstable_now()-L<F)}function W(){if(T!==null){var I=e.unstable_now();L=I;var Y=!0;try{Y=T(!0,I)}finally{Y?U():(C=!1,T=null)}}else C=!1}var U;if(typeof R=="function")U=function(){R(W)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,K=D.port2;D.port1.onmessage=W,U=function(){K.postMessage(null)}}else U=function(){j(W,0)};function P(I){T=I,C||(C=!0,U())}function G(I,Y){A=j(function(){I(e.unstable_now())},Y)}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(I){I.callback=null},e.unstable_continueExecution=function(){b||m||(b=!0,P(E))},e.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return s(f)},e.unstable_next=function(I){switch(h){case 1:case 2:case 3:var Y=3;break;default:Y=h}var q=h;h=Y;try{return I()}finally{h=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,Y){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var q=h;h=I;try{return Y()}finally{h=q}},e.unstable_scheduleCallback=function(I,Y,q){var O=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?O+q:O):q=O,I){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=q+B,I={id:g++,callback:Y,priorityLevel:I,startTime:q,expirationTime:B,sortIndex:-1},q>O?(I.sortIndex=q,t(p,I),s(f)===null&&I===s(p)&&(w?(N(A),A=-1):w=!0,G(S,q-O))):(I.sortIndex=B,t(f,I),b||m||(b=!0,P(E))),I},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(I){var Y=h;return function(){var q=h;h=Y;try{return I.apply(this,arguments)}finally{h=q}}}})(tp)),tp}var Rb;function v_(){return Rb||(Rb=1,ep.exports=b_()),ep.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 Ab;function w_(){if(Ab)return Gn;Ab=1;var e=Md(),t=v_();function s(o){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+o,d=1;d<arguments.length;d++)i+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+o+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function l(o,i){c(o,i),c(o+"Capture",i)}function c(o,i){for(a[o]=i,o=0;o<i.length;o++)r.add(i[o])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,p=/^[: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]*$/,g={},v={};function h(o){return f.call(v,o)?!0:f.call(g,o)?!1:p.test(o)?v[o]=!0:(g[o]=!0,!1)}function m(o,i,d,y){if(d!==null&&d.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return y?!1:d!==null?!d.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function b(o,i,d,y){if(i===null||typeof i>"u"||m(o,i,d,y))return!0;if(y)return!1;if(d!==null)switch(d.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function w(o,i,d,y,k,_,M){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=y,this.attributeNamespace=k,this.mustUseProperty=d,this.propertyName=o,this.type=i,this.sanitizeURL=_,this.removeEmptyString=M}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){j[o]=new w(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var i=o[0];j[i]=new w(i,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){j[o]=new w(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){j[o]=new w(o,2,!1,o,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(o){j[o]=new w(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){j[o]=new w(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){j[o]=new w(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){j[o]=new w(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){j[o]=new w(o,5,!1,o.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function R(o){return o[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(o){var i=o.replace(N,R);j[i]=new w(i,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var i=o.replace(N,R);j[i]=new w(i,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var i=o.replace(N,R);j[i]=new w(i,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){j[o]=new w(o,1,!1,o.toLowerCase(),null,!1,!1)}),j.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){j[o]=new w(o,1,!1,o.toLowerCase(),null,!0,!0)});function $(o,i,d,y){var k=j.hasOwnProperty(i)?j[i]:null;(k!==null?k.type!==0:y||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(b(i,d,k,y)&&(d=null),y||k===null?h(i)&&(d===null?o.removeAttribute(i):o.setAttribute(i,""+d)):k.mustUseProperty?o[k.propertyName]=d===null?k.type===3?!1:"":d:(i=k.attributeName,y=k.attributeNamespace,d===null?o.removeAttribute(i):(k=k.type,d=k===3||k===4&&d===!0?"":""+d,y?o.setAttributeNS(y,i,d):o.setAttribute(i,d))))}var S=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),C=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),z=Symbol.for("react.context"),W=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),K=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),G=Symbol.for("react.offscreen"),I=Symbol.iterator;function Y(o){return o===null||typeof o!="object"?null:(o=I&&o[I]||o["@@iterator"],typeof o=="function"?o:null)}var q=Object.assign,O;function B(o){if(O===void 0)try{throw Error()}catch(d){var i=d.stack.trim().match(/\n( *(at )?)/);O=i&&i[1]||""}return`
34
+ `+O+o}var ee=!1;function le(o,i){if(!o||ee)return"";ee=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(re){var y=re}Reflect.construct(o,[],i)}else{try{i.call()}catch(re){y=re}o.call(i.prototype)}else{try{throw Error()}catch(re){y=re}o()}}catch(re){if(re&&y&&typeof re.stack=="string"){for(var k=re.stack.split(`
35
+ `),_=y.stack.split(`
36
+ `),M=k.length-1,H=_.length-1;1<=M&&0<=H&&k[M]!==_[H];)H--;for(;1<=M&&0<=H;M--,H--)if(k[M]!==_[H]){if(M!==1||H!==1)do if(M--,H--,0>H||k[M]!==_[H]){var X=`
37
+ `+k[M].replace(" at new "," at ");return o.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",o.displayName)),X}while(1<=M&&0<=H);break}}}finally{ee=!1,Error.prepareStackTrace=d}return(o=o?o.displayName||o.name:"")?B(o):""}function ie(o){switch(o.tag){case 5:return B(o.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return o=le(o.type,!1),o;case 11:return o=le(o.type.render,!1),o;case 1:return o=le(o.type,!0),o;default:return""}}function ue(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case T:return"Fragment";case C:return"Portal";case F:return"Profiler";case A:return"StrictMode";case U:return"Suspense";case D:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case z:return(o.displayName||"Context")+".Consumer";case L:return(o._context.displayName||"Context")+".Provider";case W:var i=o.render;return o=o.displayName,o||(o=i.displayName||i.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case K:return i=o.displayName||null,i!==null?i:ue(o.type)||"Memo";case P:i=o._payload,o=o._init;try{return ue(o(i))}catch{}}return null}function ae(o){var i=o.type;switch(o.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=i.render,o=o.displayName||o.name||"",i.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ue(i);case 8:return i===A?"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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function ce(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function he(o){var i=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function et(o){var i=he(o)?"checked":"value",d=Object.getOwnPropertyDescriptor(o.constructor.prototype,i),y=""+o[i];if(!o.hasOwnProperty(i)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var k=d.get,_=d.set;return Object.defineProperty(o,i,{configurable:!0,get:function(){return k.call(this)},set:function(M){y=""+M,_.call(this,M)}}),Object.defineProperty(o,i,{enumerable:d.enumerable}),{getValue:function(){return y},setValue:function(M){y=""+M},stopTracking:function(){o._valueTracker=null,delete o[i]}}}}function se(o){o._valueTracker||(o._valueTracker=et(o))}function ke(o){if(!o)return!1;var i=o._valueTracker;if(!i)return!0;var d=i.getValue(),y="";return o&&(y=he(o)?o.checked?"true":"false":o.value),o=y,o!==d?(i.setValue(o),!0):!1}function Se(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function Fe(o,i){var d=i.checked;return q({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??o._wrapperState.initialChecked})}function fe(o,i){var d=i.defaultValue==null?"":i.defaultValue,y=i.checked!=null?i.checked:i.defaultChecked;d=ce(i.value!=null?i.value:d),o._wrapperState={initialChecked:y,initialValue:d,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Le(o,i){i=i.checked,i!=null&&$(o,"checked",i,!1)}function He(o,i){Le(o,i);var d=ce(i.value),y=i.type;if(d!=null)y==="number"?(d===0&&o.value===""||o.value!=d)&&(o.value=""+d):o.value!==""+d&&(o.value=""+d);else if(y==="submit"||y==="reset"){o.removeAttribute("value");return}i.hasOwnProperty("value")?We(o,i.type,d):i.hasOwnProperty("defaultValue")&&We(o,i.type,ce(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(o.defaultChecked=!!i.defaultChecked)}function It(o,i,d){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var y=i.type;if(!(y!=="submit"&&y!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+o._wrapperState.initialValue,d||i===o.value||(o.value=i),o.defaultValue=i}d=o.name,d!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,d!==""&&(o.name=d)}function We(o,i,d){(i!=="number"||Se(o.ownerDocument)!==o)&&(d==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+d&&(o.defaultValue=""+d))}var we=Array.isArray;function lt(o,i,d,y){if(o=o.options,i){i={};for(var k=0;k<d.length;k++)i["$"+d[k]]=!0;for(d=0;d<o.length;d++)k=i.hasOwnProperty("$"+o[d].value),o[d].selected!==k&&(o[d].selected=k),k&&y&&(o[d].defaultSelected=!0)}else{for(d=""+ce(d),i=null,k=0;k<o.length;k++){if(o[k].value===d){o[k].selected=!0,y&&(o[k].defaultSelected=!0);return}i!==null||o[k].disabled||(i=o[k])}i!==null&&(i.selected=!0)}}function jt(o,i){if(i.dangerouslySetInnerHTML!=null)throw Error(s(91));return q({},i,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function Nt(o,i){var d=i.value;if(d==null){if(d=i.children,i=i.defaultValue,d!=null){if(i!=null)throw Error(s(92));if(we(d)){if(1<d.length)throw Error(s(93));d=d[0]}i=d}i==null&&(i=""),d=i}o._wrapperState={initialValue:ce(d)}}function on(o,i){var d=ce(i.value),y=ce(i.defaultValue);d!=null&&(d=""+d,d!==o.value&&(o.value=d),i.defaultValue==null&&o.defaultValue!==d&&(o.defaultValue=d)),y!=null&&(o.defaultValue=""+y)}function en(o){var i=o.textContent;i===o._wrapperState.initialValue&&i!==""&&i!==null&&(o.value=i)}function Ot(o){switch(o){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 Wt(o,i){return o==null||o==="http://www.w3.org/1999/xhtml"?Ot(i):o==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Et,ct=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,d,y,k){MSApp.execUnsafeLocalFunction(function(){return o(i,d,y,k)})}:o})(function(o,i){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=i;else{for(Et=Et||document.createElement("div"),Et.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=Et.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;i.firstChild;)o.appendChild(i.firstChild)}});function Ie(o,i){if(i){var d=o.firstChild;if(d&&d===o.lastChild&&d.nodeType===3){d.nodeValue=i;return}}o.textContent=i}var st={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},gt=["Webkit","ms","Moz","O"];Object.keys(st).forEach(function(o){gt.forEach(function(i){i=i+o.charAt(0).toUpperCase()+o.substring(1),st[i]=st[o]})});function Xe(o,i,d){return i==null||typeof i=="boolean"||i===""?"":d||typeof i!="number"||i===0||st.hasOwnProperty(o)&&st[o]?(""+i).trim():i+"px"}function St(o,i){o=o.style;for(var d in i)if(i.hasOwnProperty(d)){var y=d.indexOf("--")===0,k=Xe(d,i[d],y);d==="float"&&(d="cssFloat"),y?o.setProperty(d,k):o[d]=k}}var qt=q({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 Ln(o,i){if(i){if(qt[o]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(s(137,o));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(s(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(s(61))}if(i.style!=null&&typeof i.style!="object")throw Error(s(62))}}function Kn(o,i){if(o.indexOf("-")===-1)return typeof i.is=="string";switch(o){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 fs=null;function Xn(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var Yn=null,Qn=null,an=null;function Zn(o){if(o=Vi(o)){if(typeof Yn!="function")throw Error(s(280));var i=o.stateNode;i&&(i=Pc(i),Yn(o.stateNode,o.type,i))}}function dr(o){Qn?an?an.push(o):an=[o]:Qn=o}function yt(){if(Qn){var o=Qn,i=an;if(an=Qn=null,Zn(o),i)for(o=0;o<i.length;o++)Zn(i[o])}}function Q(o,i){return o(i)}function Ae(){}var qe=!1;function ut(o,i,d){if(qe)return o(i,d);qe=!0;try{return Q(o,i,d)}finally{qe=!1,(Qn!==null||an!==null)&&(Ae(),yt())}}function xt(o,i){var d=o.stateNode;if(d===null)return null;var y=Pc(d);if(y===null)return null;d=y[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(o=o.type,y=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!y;break e;default:o=!1}if(o)return null;if(d&&typeof d!="function")throw Error(s(231,i,typeof d));return d}var Vt=!1;if(u)try{var Kt={};Object.defineProperty(Kt,"passive",{get:function(){Vt=!0}}),window.addEventListener("test",Kt,Kt),window.removeEventListener("test",Kt,Kt)}catch{Vt=!1}function mt(o,i,d,y,k,_,M,H,X){var re=Array.prototype.slice.call(arguments,3);try{i.apply(d,re)}catch(me){this.onError(me)}}var In=!1,jn=null,ms=!1,zn=null,ma={onError:function(o){In=!0,jn=o}};function Jn(o,i,d,y,k,_,M,H,X){In=!1,jn=null,mt.apply(ma,arguments)}function pa(o,i,d,y,k,_,M,H,X){if(Jn.apply(this,arguments),In){if(In){var re=jn;In=!1,jn=null}else throw Error(s(198));ms||(ms=!0,zn=re)}}function ps(o){var i=o,d=o;if(o.alternate)for(;i.return;)i=i.return;else{o=i;do i=o,(i.flags&4098)!==0&&(d=i.return),o=i.return;while(o)}return i.tag===3?d:null}function Rr(o){if(o.tag===13){var i=o.memoizedState;if(i===null&&(o=o.alternate,o!==null&&(i=o.memoizedState)),i!==null)return i.dehydrated}return null}function wo(o){if(ps(o)!==o)throw Error(s(188))}function ha(o){var i=o.alternate;if(!i){if(i=ps(o),i===null)throw Error(s(188));return i!==o?null:o}for(var d=o,y=i;;){var k=d.return;if(k===null)break;var _=k.alternate;if(_===null){if(y=k.return,y!==null){d=y;continue}break}if(k.child===_.child){for(_=k.child;_;){if(_===d)return wo(k),o;if(_===y)return wo(k),i;_=_.sibling}throw Error(s(188))}if(d.return!==y.return)d=k,y=_;else{for(var M=!1,H=k.child;H;){if(H===d){M=!0,d=k,y=_;break}if(H===y){M=!0,y=k,d=_;break}H=H.sibling}if(!M){for(H=_.child;H;){if(H===d){M=!0,d=_,y=k;break}if(H===y){M=!0,y=_,d=k;break}H=H.sibling}if(!M)throw Error(s(189))}}if(d.alternate!==y)throw Error(s(190))}if(d.tag!==3)throw Error(s(188));return d.stateNode.current===d?o:i}function Pe(o){return o=ha(o),o!==null?Z(o):null}function Z(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var i=Z(o);if(i!==null)return i;o=o.sibling}return null}var ge=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,pt=t.unstable_shouldYield,zt=t.unstable_requestPaint,Ve=t.unstable_now,Xt=t.unstable_getCurrentPriorityLevel,ln=t.unstable_ImmediatePriority,Ms=t.unstable_UserBlockingPriority,Ct=t.unstable_NormalPriority,ko=t.unstable_LowPriority,Ar=t.unstable_IdlePriority,jo=null,es=null;function gc(o){if(es&&typeof es.onCommitFiberRoot=="function")try{es.onCommitFiberRoot(jo,o,void 0,(o.current.flags&128)===128)}catch{}}var Dn=Math.clz32?Math.clz32:bc,xc=Math.log,yc=Math.LN2;function bc(o){return o>>>=0,o===0?32:31-(xc(o)/yc|0)|0}var No=64,So=4194304;function Or(o){switch(o&-o){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 o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function _o(o,i){var d=o.pendingLanes;if(d===0)return 0;var y=0,k=o.suspendedLanes,_=o.pingedLanes,M=d&268435455;if(M!==0){var H=M&~k;H!==0?y=Or(H):(_&=M,_!==0&&(y=Or(_)))}else M=d&~k,M!==0?y=Or(M):_!==0&&(y=Or(_));if(y===0)return 0;if(i!==0&&i!==y&&(i&k)===0&&(k=y&-y,_=i&-i,k>=_||k===16&&(_&4194240)!==0))return i;if((y&4)!==0&&(y|=d&16),i=o.entangledLanes,i!==0)for(o=o.entanglements,i&=y;0<i;)d=31-Dn(i),k=1<<d,y|=o[d],i&=~k;return y}function xe(o,i){switch(o){case 1:case 2:case 4:return i+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 i+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 be(o,i){for(var d=o.suspendedLanes,y=o.pingedLanes,k=o.expirationTimes,_=o.pendingLanes;0<_;){var M=31-Dn(_),H=1<<M,X=k[M];X===-1?((H&d)===0||(H&y)!==0)&&(k[M]=xe(H,i)):X<=i&&(o.expiredLanes|=H),_&=~H}}function Te(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function tt(){var o=No;return No<<=1,(No&4194240)===0&&(No=64),o}function Ye(o){for(var i=[],d=0;31>d;d++)i.push(o);return i}function pn(o,i,d){o.pendingLanes|=i,i!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,i=31-Dn(i),o[i]=d}function ts(o,i){var d=o.pendingLanes&~i;o.pendingLanes=i,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=i,o.mutableReadLanes&=i,o.entangledLanes&=i,i=o.entanglements;var y=o.eventTimes;for(o=o.expirationTimes;0<d;){var k=31-Dn(d),_=1<<k;i[k]=0,y[k]=-1,o[k]=-1,d&=~_}}function hn(o,i){var d=o.entangledLanes|=i;for(o=o.entanglements;d;){var y=31-Dn(d),k=1<<y;k&i|o[y]&i&&(o[y]|=i),d&=~k}}var at=0;function fr(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var vc,ga,Ci,Ti,$o,Xs=!1,ns=[],Mr=null,Pr=null,Lr=null,Ri=new Map,Ai=new Map,Ir=[],PS="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 cx(o,i){switch(o){case"focusin":case"focusout":Mr=null;break;case"dragenter":case"dragleave":Pr=null;break;case"mouseover":case"mouseout":Lr=null;break;case"pointerover":case"pointerout":Ri.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ai.delete(i.pointerId)}}function Oi(o,i,d,y,k,_){return o===null||o.nativeEvent!==_?(o={blockedOn:i,domEventName:d,eventSystemFlags:y,nativeEvent:_,targetContainers:[k]},i!==null&&(i=Vi(i),i!==null&&ga(i)),o):(o.eventSystemFlags|=y,i=o.targetContainers,k!==null&&i.indexOf(k)===-1&&i.push(k),o)}function LS(o,i,d,y,k){switch(i){case"focusin":return Mr=Oi(Mr,o,i,d,y,k),!0;case"dragenter":return Pr=Oi(Pr,o,i,d,y,k),!0;case"mouseover":return Lr=Oi(Lr,o,i,d,y,k),!0;case"pointerover":var _=k.pointerId;return Ri.set(_,Oi(Ri.get(_)||null,o,i,d,y,k)),!0;case"gotpointercapture":return _=k.pointerId,Ai.set(_,Oi(Ai.get(_)||null,o,i,d,y,k)),!0}return!1}function ux(o){var i=Eo(o.target);if(i!==null){var d=ps(i);if(d!==null){if(i=d.tag,i===13){if(i=Rr(d),i!==null){o.blockedOn=i,$o(o.priority,function(){Ci(d)});return}}else if(i===3&&d.stateNode.current.memoizedState.isDehydrated){o.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}o.blockedOn=null}function wc(o){if(o.blockedOn!==null)return!1;for(var i=o.targetContainers;0<i.length;){var d=Nf(o.domEventName,o.eventSystemFlags,i[0],o.nativeEvent);if(d===null){d=o.nativeEvent;var y=new d.constructor(d.type,d);fs=y,d.target.dispatchEvent(y),fs=null}else return i=Vi(d),i!==null&&ga(i),o.blockedOn=d,!1;i.shift()}return!0}function dx(o,i,d){wc(o)&&d.delete(i)}function IS(){Xs=!1,Mr!==null&&wc(Mr)&&(Mr=null),Pr!==null&&wc(Pr)&&(Pr=null),Lr!==null&&wc(Lr)&&(Lr=null),Ri.forEach(dx),Ai.forEach(dx)}function Mi(o,i){o.blockedOn===i&&(o.blockedOn=null,Xs||(Xs=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,IS)))}function Pi(o){function i(k){return Mi(k,o)}if(0<ns.length){Mi(ns[0],o);for(var d=1;d<ns.length;d++){var y=ns[d];y.blockedOn===o&&(y.blockedOn=null)}}for(Mr!==null&&Mi(Mr,o),Pr!==null&&Mi(Pr,o),Lr!==null&&Mi(Lr,o),Ri.forEach(i),Ai.forEach(i),d=0;d<Ir.length;d++)y=Ir[d],y.blockedOn===o&&(y.blockedOn=null);for(;0<Ir.length&&(d=Ir[0],d.blockedOn===null);)ux(d),d.blockedOn===null&&Ir.shift()}var xa=S.ReactCurrentBatchConfig,kc=!0;function zS(o,i,d,y){var k=at,_=xa.transition;xa.transition=null;try{at=1,jf(o,i,d,y)}finally{at=k,xa.transition=_}}function DS(o,i,d,y){var k=at,_=xa.transition;xa.transition=null;try{at=4,jf(o,i,d,y)}finally{at=k,xa.transition=_}}function jf(o,i,d,y){if(kc){var k=Nf(o,i,d,y);if(k===null)Uf(o,i,y,jc,d),cx(o,y);else if(LS(k,o,i,d,y))y.stopPropagation();else if(cx(o,y),i&4&&-1<PS.indexOf(o)){for(;k!==null;){var _=Vi(k);if(_!==null&&vc(_),_=Nf(o,i,d,y),_===null&&Uf(o,i,y,jc,d),_===k)break;k=_}k!==null&&y.stopPropagation()}else Uf(o,i,y,null,d)}}var jc=null;function Nf(o,i,d,y){if(jc=null,o=Xn(y),o=Eo(o),o!==null)if(i=ps(o),i===null)o=null;else if(d=i.tag,d===13){if(o=Rr(i),o!==null)return o;o=null}else if(d===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;o=null}else i!==o&&(o=null);return jc=o,null}function fx(o){switch(o){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(Xt()){case ln:return 1;case Ms:return 4;case Ct:case ko:return 16;case Ar:return 536870912;default:return 16}default:return 16}}var zr=null,Sf=null,Nc=null;function mx(){if(Nc)return Nc;var o,i=Sf,d=i.length,y,k="value"in zr?zr.value:zr.textContent,_=k.length;for(o=0;o<d&&i[o]===k[o];o++);var M=d-o;for(y=1;y<=M&&i[d-y]===k[_-y];y++);return Nc=k.slice(o,1<y?1-y:void 0)}function Sc(o){var i=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&i===13&&(o=13)):o=i,o===10&&(o=13),32<=o||o===13?o:0}function _c(){return!0}function px(){return!1}function ss(o){function i(d,y,k,_,M){this._reactName=d,this._targetInst=k,this.type=y,this.nativeEvent=_,this.target=M,this.currentTarget=null;for(var H in o)o.hasOwnProperty(H)&&(d=o[H],this[H]=d?d(_):_[H]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?_c:px,this.isPropagationStopped=px,this}return q(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=_c)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=_c)},persist:function(){},isPersistent:_c}),i}var ya={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_f=ss(ya),Li=q({},ya,{view:0,detail:0}),FS=ss(Li),$f,Ef,Ii,$c=q({},Li,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tf,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Ii&&(Ii&&o.type==="mousemove"?($f=o.screenX-Ii.screenX,Ef=o.screenY-Ii.screenY):Ef=$f=0,Ii=o),$f)},movementY:function(o){return"movementY"in o?o.movementY:Ef}}),hx=ss($c),US=q({},$c,{dataTransfer:0}),WS=ss(US),HS=q({},Li,{relatedTarget:0}),Cf=ss(HS),BS=q({},ya,{animationName:0,elapsedTime:0,pseudoElement:0}),GS=ss(BS),qS=q({},ya,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),VS=ss(qS),KS=q({},ya,{data:0}),gx=ss(KS),XS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},YS={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"},QS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ZS(o){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(o):(o=QS[o])?!!i[o]:!1}function Tf(){return ZS}var JS=q({},Li,{key:function(o){if(o.key){var i=XS[o.key]||o.key;if(i!=="Unidentified")return i}return o.type==="keypress"?(o=Sc(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?YS[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tf,charCode:function(o){return o.type==="keypress"?Sc(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Sc(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),e2=ss(JS),t2=q({},$c,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xx=ss(t2),n2=q({},Li,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tf}),s2=ss(n2),r2=q({},ya,{propertyName:0,elapsedTime:0,pseudoElement:0}),o2=ss(r2),a2=q({},$c,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),i2=ss(a2),l2=[9,13,27,32],Rf=u&&"CompositionEvent"in window,zi=null;u&&"documentMode"in document&&(zi=document.documentMode);var c2=u&&"TextEvent"in window&&!zi,yx=u&&(!Rf||zi&&8<zi&&11>=zi),bx=" ",vx=!1;function wx(o,i){switch(o){case"keyup":return l2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kx(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var ba=!1;function u2(o,i){switch(o){case"compositionend":return kx(i);case"keypress":return i.which!==32?null:(vx=!0,bx);case"textInput":return o=i.data,o===bx&&vx?null:o;default:return null}}function d2(o,i){if(ba)return o==="compositionend"||!Rf&&wx(o,i)?(o=mx(),Nc=Sf=zr=null,ba=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return yx&&i.locale!=="ko"?null:i.data;default:return null}}var f2={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 jx(o){var i=o&&o.nodeName&&o.nodeName.toLowerCase();return i==="input"?!!f2[o.type]:i==="textarea"}function Nx(o,i,d,y){dr(y),i=Ac(i,"onChange"),0<i.length&&(d=new _f("onChange","change",null,d,y),o.push({event:d,listeners:i}))}var Di=null,Fi=null;function m2(o){Wx(o,0)}function Ec(o){var i=Na(o);if(ke(i))return o}function p2(o,i){if(o==="change")return i}var Sx=!1;if(u){var Af;if(u){var Of="oninput"in document;if(!Of){var _x=document.createElement("div");_x.setAttribute("oninput","return;"),Of=typeof _x.oninput=="function"}Af=Of}else Af=!1;Sx=Af&&(!document.documentMode||9<document.documentMode)}function $x(){Di&&(Di.detachEvent("onpropertychange",Ex),Fi=Di=null)}function Ex(o){if(o.propertyName==="value"&&Ec(Fi)){var i=[];Nx(i,Fi,o,Xn(o)),ut(m2,i)}}function h2(o,i,d){o==="focusin"?($x(),Di=i,Fi=d,Di.attachEvent("onpropertychange",Ex)):o==="focusout"&&$x()}function g2(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return Ec(Fi)}function x2(o,i){if(o==="click")return Ec(i)}function y2(o,i){if(o==="input"||o==="change")return Ec(i)}function b2(o,i){return o===i&&(o!==0||1/o===1/i)||o!==o&&i!==i}var Ps=typeof Object.is=="function"?Object.is:b2;function Ui(o,i){if(Ps(o,i))return!0;if(typeof o!="object"||o===null||typeof i!="object"||i===null)return!1;var d=Object.keys(o),y=Object.keys(i);if(d.length!==y.length)return!1;for(y=0;y<d.length;y++){var k=d[y];if(!f.call(i,k)||!Ps(o[k],i[k]))return!1}return!0}function Cx(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Tx(o,i){var d=Cx(o);o=0;for(var y;d;){if(d.nodeType===3){if(y=o+d.textContent.length,o<=i&&y>=i)return{node:d,offset:i-o};o=y}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Cx(d)}}function Rx(o,i){return o&&i?o===i?!0:o&&o.nodeType===3?!1:i&&i.nodeType===3?Rx(o,i.parentNode):"contains"in o?o.contains(i):o.compareDocumentPosition?!!(o.compareDocumentPosition(i)&16):!1:!1}function Ax(){for(var o=window,i=Se();i instanceof o.HTMLIFrameElement;){try{var d=typeof i.contentWindow.location.href=="string"}catch{d=!1}if(d)o=i.contentWindow;else break;i=Se(o.document)}return i}function Mf(o){var i=o&&o.nodeName&&o.nodeName.toLowerCase();return i&&(i==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||i==="textarea"||o.contentEditable==="true")}function v2(o){var i=Ax(),d=o.focusedElem,y=o.selectionRange;if(i!==d&&d&&d.ownerDocument&&Rx(d.ownerDocument.documentElement,d)){if(y!==null&&Mf(d)){if(i=y.start,o=y.end,o===void 0&&(o=i),"selectionStart"in d)d.selectionStart=i,d.selectionEnd=Math.min(o,d.value.length);else if(o=(i=d.ownerDocument||document)&&i.defaultView||window,o.getSelection){o=o.getSelection();var k=d.textContent.length,_=Math.min(y.start,k);y=y.end===void 0?_:Math.min(y.end,k),!o.extend&&_>y&&(k=y,y=_,_=k),k=Tx(d,_);var M=Tx(d,y);k&&M&&(o.rangeCount!==1||o.anchorNode!==k.node||o.anchorOffset!==k.offset||o.focusNode!==M.node||o.focusOffset!==M.offset)&&(i=i.createRange(),i.setStart(k.node,k.offset),o.removeAllRanges(),_>y?(o.addRange(i),o.extend(M.node,M.offset)):(i.setEnd(M.node,M.offset),o.addRange(i)))}}for(i=[],o=d;o=o.parentNode;)o.nodeType===1&&i.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<i.length;d++)o=i[d],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var w2=u&&"documentMode"in document&&11>=document.documentMode,va=null,Pf=null,Wi=null,Lf=!1;function Ox(o,i,d){var y=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Lf||va==null||va!==Se(y)||(y=va,"selectionStart"in y&&Mf(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Wi&&Ui(Wi,y)||(Wi=y,y=Ac(Pf,"onSelect"),0<y.length&&(i=new _f("onSelect","select",null,i,d),o.push({event:i,listeners:y}),i.target=va)))}function Cc(o,i){var d={};return d[o.toLowerCase()]=i.toLowerCase(),d["Webkit"+o]="webkit"+i,d["Moz"+o]="moz"+i,d}var wa={animationend:Cc("Animation","AnimationEnd"),animationiteration:Cc("Animation","AnimationIteration"),animationstart:Cc("Animation","AnimationStart"),transitionend:Cc("Transition","TransitionEnd")},If={},Mx={};u&&(Mx=document.createElement("div").style,"AnimationEvent"in window||(delete wa.animationend.animation,delete wa.animationiteration.animation,delete wa.animationstart.animation),"TransitionEvent"in window||delete wa.transitionend.transition);function Tc(o){if(If[o])return If[o];if(!wa[o])return o;var i=wa[o],d;for(d in i)if(i.hasOwnProperty(d)&&d in Mx)return If[o]=i[d];return o}var Px=Tc("animationend"),Lx=Tc("animationiteration"),Ix=Tc("animationstart"),zx=Tc("transitionend"),Dx=new Map,Fx="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 Dr(o,i){Dx.set(o,i),l(i,[o])}for(var zf=0;zf<Fx.length;zf++){var Df=Fx[zf],k2=Df.toLowerCase(),j2=Df[0].toUpperCase()+Df.slice(1);Dr(k2,"on"+j2)}Dr(Px,"onAnimationEnd"),Dr(Lx,"onAnimationIteration"),Dr(Ix,"onAnimationStart"),Dr("dblclick","onDoubleClick"),Dr("focusin","onFocus"),Dr("focusout","onBlur"),Dr(zx,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Hi="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(" "),N2=new Set("cancel close invalid load scroll toggle".split(" ").concat(Hi));function Ux(o,i,d){var y=o.type||"unknown-event";o.currentTarget=d,pa(y,i,void 0,o),o.currentTarget=null}function Wx(o,i){i=(i&4)!==0;for(var d=0;d<o.length;d++){var y=o[d],k=y.event;y=y.listeners;e:{var _=void 0;if(i)for(var M=y.length-1;0<=M;M--){var H=y[M],X=H.instance,re=H.currentTarget;if(H=H.listener,X!==_&&k.isPropagationStopped())break e;Ux(k,H,re),_=X}else for(M=0;M<y.length;M++){if(H=y[M],X=H.instance,re=H.currentTarget,H=H.listener,X!==_&&k.isPropagationStopped())break e;Ux(k,H,re),_=X}}}if(ms)throw o=zn,ms=!1,zn=null,o}function vt(o,i){var d=i[Vf];d===void 0&&(d=i[Vf]=new Set);var y=o+"__bubble";d.has(y)||(Hx(i,o,2,!1),d.add(y))}function Ff(o,i,d){var y=0;i&&(y|=4),Hx(d,o,y,i)}var Rc="_reactListening"+Math.random().toString(36).slice(2);function Bi(o){if(!o[Rc]){o[Rc]=!0,r.forEach(function(d){d!=="selectionchange"&&(N2.has(d)||Ff(d,!1,o),Ff(d,!0,o))});var i=o.nodeType===9?o:o.ownerDocument;i===null||i[Rc]||(i[Rc]=!0,Ff("selectionchange",!1,i))}}function Hx(o,i,d,y){switch(fx(i)){case 1:var k=zS;break;case 4:k=DS;break;default:k=jf}d=k.bind(null,i,d,o),k=void 0,!Vt||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(k=!0),y?k!==void 0?o.addEventListener(i,d,{capture:!0,passive:k}):o.addEventListener(i,d,!0):k!==void 0?o.addEventListener(i,d,{passive:k}):o.addEventListener(i,d,!1)}function Uf(o,i,d,y,k){var _=y;if((i&1)===0&&(i&2)===0&&y!==null)e:for(;;){if(y===null)return;var M=y.tag;if(M===3||M===4){var H=y.stateNode.containerInfo;if(H===k||H.nodeType===8&&H.parentNode===k)break;if(M===4)for(M=y.return;M!==null;){var X=M.tag;if((X===3||X===4)&&(X=M.stateNode.containerInfo,X===k||X.nodeType===8&&X.parentNode===k))return;M=M.return}for(;H!==null;){if(M=Eo(H),M===null)return;if(X=M.tag,X===5||X===6){y=_=M;continue e}H=H.parentNode}}y=y.return}ut(function(){var re=_,me=Xn(d),pe=[];e:{var de=Dx.get(o);if(de!==void 0){var je=_f,Re=o;switch(o){case"keypress":if(Sc(d)===0)break e;case"keydown":case"keyup":je=e2;break;case"focusin":Re="focus",je=Cf;break;case"focusout":Re="blur",je=Cf;break;case"beforeblur":case"afterblur":je=Cf;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=hx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=WS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=s2;break;case Px:case Lx:case Ix:je=GS;break;case zx:je=o2;break;case"scroll":je=FS;break;case"wheel":je=i2;break;case"copy":case"cut":case"paste":je=VS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=xx}var Oe=(i&4)!==0,Dt=!Oe&&o==="scroll",te=Oe?de!==null?de+"Capture":null:de;Oe=[];for(var J=re,ne;J!==null;){ne=J;var ye=ne.stateNode;if(ne.tag===5&&ye!==null&&(ne=ye,te!==null&&(ye=xt(J,te),ye!=null&&Oe.push(Gi(J,ye,ne)))),Dt)break;J=J.return}0<Oe.length&&(de=new je(de,Re,null,d,me),pe.push({event:de,listeners:Oe}))}}if((i&7)===0){e:{if(de=o==="mouseover"||o==="pointerover",je=o==="mouseout"||o==="pointerout",de&&d!==fs&&(Re=d.relatedTarget||d.fromElement)&&(Eo(Re)||Re[mr]))break e;if((je||de)&&(de=me.window===me?me:(de=me.ownerDocument)?de.defaultView||de.parentWindow:window,je?(Re=d.relatedTarget||d.toElement,je=re,Re=Re?Eo(Re):null,Re!==null&&(Dt=ps(Re),Re!==Dt||Re.tag!==5&&Re.tag!==6)&&(Re=null)):(je=null,Re=re),je!==Re)){if(Oe=hx,ye="onMouseLeave",te="onMouseEnter",J="mouse",(o==="pointerout"||o==="pointerover")&&(Oe=xx,ye="onPointerLeave",te="onPointerEnter",J="pointer"),Dt=je==null?de:Na(je),ne=Re==null?de:Na(Re),de=new Oe(ye,J+"leave",je,d,me),de.target=Dt,de.relatedTarget=ne,ye=null,Eo(me)===re&&(Oe=new Oe(te,J+"enter",Re,d,me),Oe.target=ne,Oe.relatedTarget=Dt,ye=Oe),Dt=ye,je&&Re)t:{for(Oe=je,te=Re,J=0,ne=Oe;ne;ne=ka(ne))J++;for(ne=0,ye=te;ye;ye=ka(ye))ne++;for(;0<J-ne;)Oe=ka(Oe),J--;for(;0<ne-J;)te=ka(te),ne--;for(;J--;){if(Oe===te||te!==null&&Oe===te.alternate)break t;Oe=ka(Oe),te=ka(te)}Oe=null}else Oe=null;je!==null&&Bx(pe,de,je,Oe,!1),Re!==null&&Dt!==null&&Bx(pe,Dt,Re,Oe,!0)}}e:{if(de=re?Na(re):window,je=de.nodeName&&de.nodeName.toLowerCase(),je==="select"||je==="input"&&de.type==="file")var Me=p2;else if(jx(de))if(Sx)Me=y2;else{Me=g2;var ze=h2}else(je=de.nodeName)&&je.toLowerCase()==="input"&&(de.type==="checkbox"||de.type==="radio")&&(Me=x2);if(Me&&(Me=Me(o,re))){Nx(pe,Me,d,me);break e}ze&&ze(o,de,re),o==="focusout"&&(ze=de._wrapperState)&&ze.controlled&&de.type==="number"&&We(de,"number",de.value)}switch(ze=re?Na(re):window,o){case"focusin":(jx(ze)||ze.contentEditable==="true")&&(va=ze,Pf=re,Wi=null);break;case"focusout":Wi=Pf=va=null;break;case"mousedown":Lf=!0;break;case"contextmenu":case"mouseup":case"dragend":Lf=!1,Ox(pe,d,me);break;case"selectionchange":if(w2)break;case"keydown":case"keyup":Ox(pe,d,me)}var De;if(Rf)e:{switch(o){case"compositionstart":var Be="onCompositionStart";break e;case"compositionend":Be="onCompositionEnd";break e;case"compositionupdate":Be="onCompositionUpdate";break e}Be=void 0}else ba?wx(o,d)&&(Be="onCompositionEnd"):o==="keydown"&&d.keyCode===229&&(Be="onCompositionStart");Be&&(yx&&d.locale!=="ko"&&(ba||Be!=="onCompositionStart"?Be==="onCompositionEnd"&&ba&&(De=mx()):(zr=me,Sf="value"in zr?zr.value:zr.textContent,ba=!0)),ze=Ac(re,Be),0<ze.length&&(Be=new gx(Be,o,null,d,me),pe.push({event:Be,listeners:ze}),De?Be.data=De:(De=kx(d),De!==null&&(Be.data=De)))),(De=c2?u2(o,d):d2(o,d))&&(re=Ac(re,"onBeforeInput"),0<re.length&&(me=new gx("onBeforeInput","beforeinput",null,d,me),pe.push({event:me,listeners:re}),me.data=De))}Wx(pe,i)})}function Gi(o,i,d){return{instance:o,listener:i,currentTarget:d}}function Ac(o,i){for(var d=i+"Capture",y=[];o!==null;){var k=o,_=k.stateNode;k.tag===5&&_!==null&&(k=_,_=xt(o,d),_!=null&&y.unshift(Gi(o,_,k)),_=xt(o,i),_!=null&&y.push(Gi(o,_,k))),o=o.return}return y}function ka(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function Bx(o,i,d,y,k){for(var _=i._reactName,M=[];d!==null&&d!==y;){var H=d,X=H.alternate,re=H.stateNode;if(X!==null&&X===y)break;H.tag===5&&re!==null&&(H=re,k?(X=xt(d,_),X!=null&&M.unshift(Gi(d,X,H))):k||(X=xt(d,_),X!=null&&M.push(Gi(d,X,H)))),d=d.return}M.length!==0&&o.push({event:i,listeners:M})}var S2=/\r\n?/g,_2=/\u0000|\uFFFD/g;function Gx(o){return(typeof o=="string"?o:""+o).replace(S2,`
38
+ `).replace(_2,"")}function Oc(o,i,d){if(i=Gx(i),Gx(o)!==i&&d)throw Error(s(425))}function Mc(){}var Wf=null,Hf=null;function Bf(o,i){return o==="textarea"||o==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Gf=typeof setTimeout=="function"?setTimeout:void 0,$2=typeof clearTimeout=="function"?clearTimeout:void 0,qx=typeof Promise=="function"?Promise:void 0,E2=typeof queueMicrotask=="function"?queueMicrotask:typeof qx<"u"?function(o){return qx.resolve(null).then(o).catch(C2)}:Gf;function C2(o){setTimeout(function(){throw o})}function qf(o,i){var d=i,y=0;do{var k=d.nextSibling;if(o.removeChild(d),k&&k.nodeType===8)if(d=k.data,d==="/$"){if(y===0){o.removeChild(k),Pi(i);return}y--}else d!=="$"&&d!=="$?"&&d!=="$!"||y++;d=k}while(d);Pi(i)}function Fr(o){for(;o!=null;o=o.nextSibling){var i=o.nodeType;if(i===1||i===3)break;if(i===8){if(i=o.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return o}function Vx(o){o=o.previousSibling;for(var i=0;o;){if(o.nodeType===8){var d=o.data;if(d==="$"||d==="$!"||d==="$?"){if(i===0)return o;i--}else d==="/$"&&i++}o=o.previousSibling}return null}var ja=Math.random().toString(36).slice(2),Ys="__reactFiber$"+ja,qi="__reactProps$"+ja,mr="__reactContainer$"+ja,Vf="__reactEvents$"+ja,T2="__reactListeners$"+ja,R2="__reactHandles$"+ja;function Eo(o){var i=o[Ys];if(i)return i;for(var d=o.parentNode;d;){if(i=d[mr]||d[Ys]){if(d=i.alternate,i.child!==null||d!==null&&d.child!==null)for(o=Vx(o);o!==null;){if(d=o[Ys])return d;o=Vx(o)}return i}o=d,d=o.parentNode}return null}function Vi(o){return o=o[Ys]||o[mr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function Na(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(s(33))}function Pc(o){return o[qi]||null}var Kf=[],Sa=-1;function Ur(o){return{current:o}}function wt(o){0>Sa||(o.current=Kf[Sa],Kf[Sa]=null,Sa--)}function bt(o,i){Sa++,Kf[Sa]=o.current,o.current=i}var Wr={},gn=Ur(Wr),Fn=Ur(!1),Co=Wr;function _a(o,i){var d=o.type.contextTypes;if(!d)return Wr;var y=o.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===i)return y.__reactInternalMemoizedMaskedChildContext;var k={},_;for(_ in d)k[_]=i[_];return y&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=i,o.__reactInternalMemoizedMaskedChildContext=k),k}function Un(o){return o=o.childContextTypes,o!=null}function Lc(){wt(Fn),wt(gn)}function Kx(o,i,d){if(gn.current!==Wr)throw Error(s(168));bt(gn,i),bt(Fn,d)}function Xx(o,i,d){var y=o.stateNode;if(i=i.childContextTypes,typeof y.getChildContext!="function")return d;y=y.getChildContext();for(var k in y)if(!(k in i))throw Error(s(108,ae(o)||"Unknown",k));return q({},d,y)}function Ic(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||Wr,Co=gn.current,bt(gn,o),bt(Fn,Fn.current),!0}function Yx(o,i,d){var y=o.stateNode;if(!y)throw Error(s(169));d?(o=Xx(o,i,Co),y.__reactInternalMemoizedMergedChildContext=o,wt(Fn),wt(gn),bt(gn,o)):wt(Fn),bt(Fn,d)}var pr=null,zc=!1,Xf=!1;function Qx(o){pr===null?pr=[o]:pr.push(o)}function A2(o){zc=!0,Qx(o)}function Hr(){if(!Xf&&pr!==null){Xf=!0;var o=0,i=at;try{var d=pr;for(at=1;o<d.length;o++){var y=d[o];do y=y(!0);while(y!==null)}pr=null,zc=!1}catch(k){throw pr!==null&&(pr=pr.slice(o+1)),ge(ln,Hr),k}finally{at=i,Xf=!1}}return null}var $a=[],Ea=0,Dc=null,Fc=0,hs=[],gs=0,To=null,hr=1,gr="";function Ro(o,i){$a[Ea++]=Fc,$a[Ea++]=Dc,Dc=o,Fc=i}function Zx(o,i,d){hs[gs++]=hr,hs[gs++]=gr,hs[gs++]=To,To=o;var y=hr;o=gr;var k=32-Dn(y)-1;y&=~(1<<k),d+=1;var _=32-Dn(i)+k;if(30<_){var M=k-k%5;_=(y&(1<<M)-1).toString(32),y>>=M,k-=M,hr=1<<32-Dn(i)+k|d<<k|y,gr=_+o}else hr=1<<_|d<<k|y,gr=o}function Yf(o){o.return!==null&&(Ro(o,1),Zx(o,1,0))}function Qf(o){for(;o===Dc;)Dc=$a[--Ea],$a[Ea]=null,Fc=$a[--Ea],$a[Ea]=null;for(;o===To;)To=hs[--gs],hs[gs]=null,gr=hs[--gs],hs[gs]=null,hr=hs[--gs],hs[gs]=null}var rs=null,os=null,_t=!1,Ls=null;function Jx(o,i){var d=vs(5,null,null,0);d.elementType="DELETED",d.stateNode=i,d.return=o,i=o.deletions,i===null?(o.deletions=[d],o.flags|=16):i.push(d)}function ey(o,i){switch(o.tag){case 5:var d=o.type;return i=i.nodeType!==1||d.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(o.stateNode=i,rs=o,os=Fr(i.firstChild),!0):!1;case 6:return i=o.pendingProps===""||i.nodeType!==3?null:i,i!==null?(o.stateNode=i,rs=o,os=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(d=To!==null?{id:hr,overflow:gr}:null,o.memoizedState={dehydrated:i,treeContext:d,retryLane:1073741824},d=vs(18,null,null,0),d.stateNode=i,d.return=o,o.child=d,rs=o,os=null,!0):!1;default:return!1}}function Zf(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Jf(o){if(_t){var i=os;if(i){var d=i;if(!ey(o,i)){if(Zf(o))throw Error(s(418));i=Fr(d.nextSibling);var y=rs;i&&ey(o,i)?Jx(y,d):(o.flags=o.flags&-4097|2,_t=!1,rs=o)}}else{if(Zf(o))throw Error(s(418));o.flags=o.flags&-4097|2,_t=!1,rs=o}}}function ty(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;rs=o}function Uc(o){if(o!==rs)return!1;if(!_t)return ty(o),_t=!0,!1;var i;if((i=o.tag!==3)&&!(i=o.tag!==5)&&(i=o.type,i=i!=="head"&&i!=="body"&&!Bf(o.type,o.memoizedProps)),i&&(i=os)){if(Zf(o))throw ny(),Error(s(418));for(;i;)Jx(o,i),i=Fr(i.nextSibling)}if(ty(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(317));e:{for(o=o.nextSibling,i=0;o;){if(o.nodeType===8){var d=o.data;if(d==="/$"){if(i===0){os=Fr(o.nextSibling);break e}i--}else d!=="$"&&d!=="$!"&&d!=="$?"||i++}o=o.nextSibling}os=null}}else os=rs?Fr(o.stateNode.nextSibling):null;return!0}function ny(){for(var o=os;o;)o=Fr(o.nextSibling)}function Ca(){os=rs=null,_t=!1}function em(o){Ls===null?Ls=[o]:Ls.push(o)}var O2=S.ReactCurrentBatchConfig;function Ki(o,i,d){if(o=d.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(s(309));var y=d.stateNode}if(!y)throw Error(s(147,o));var k=y,_=""+o;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===_?i.ref:(i=function(M){var H=k.refs;M===null?delete H[_]:H[_]=M},i._stringRef=_,i)}if(typeof o!="string")throw Error(s(284));if(!d._owner)throw Error(s(290,o))}return o}function Wc(o,i){throw o=Object.prototype.toString.call(i),Error(s(31,o==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":o))}function sy(o){var i=o._init;return i(o._payload)}function ry(o){function i(te,J){if(o){var ne=te.deletions;ne===null?(te.deletions=[J],te.flags|=16):ne.push(J)}}function d(te,J){if(!o)return null;for(;J!==null;)i(te,J),J=J.sibling;return null}function y(te,J){for(te=new Map;J!==null;)J.key!==null?te.set(J.key,J):te.set(J.index,J),J=J.sibling;return te}function k(te,J){return te=Qr(te,J),te.index=0,te.sibling=null,te}function _(te,J,ne){return te.index=ne,o?(ne=te.alternate,ne!==null?(ne=ne.index,ne<J?(te.flags|=2,J):ne):(te.flags|=2,J)):(te.flags|=1048576,J)}function M(te){return o&&te.alternate===null&&(te.flags|=2),te}function H(te,J,ne,ye){return J===null||J.tag!==6?(J=Gm(ne,te.mode,ye),J.return=te,J):(J=k(J,ne),J.return=te,J)}function X(te,J,ne,ye){var Me=ne.type;return Me===T?me(te,J,ne.props.children,ye,ne.key):J!==null&&(J.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===P&&sy(Me)===J.type)?(ye=k(J,ne.props),ye.ref=Ki(te,J,ne),ye.return=te,ye):(ye=fu(ne.type,ne.key,ne.props,null,te.mode,ye),ye.ref=Ki(te,J,ne),ye.return=te,ye)}function re(te,J,ne,ye){return J===null||J.tag!==4||J.stateNode.containerInfo!==ne.containerInfo||J.stateNode.implementation!==ne.implementation?(J=qm(ne,te.mode,ye),J.return=te,J):(J=k(J,ne.children||[]),J.return=te,J)}function me(te,J,ne,ye,Me){return J===null||J.tag!==7?(J=Do(ne,te.mode,ye,Me),J.return=te,J):(J=k(J,ne),J.return=te,J)}function pe(te,J,ne){if(typeof J=="string"&&J!==""||typeof J=="number")return J=Gm(""+J,te.mode,ne),J.return=te,J;if(typeof J=="object"&&J!==null){switch(J.$$typeof){case E:return ne=fu(J.type,J.key,J.props,null,te.mode,ne),ne.ref=Ki(te,null,J),ne.return=te,ne;case C:return J=qm(J,te.mode,ne),J.return=te,J;case P:var ye=J._init;return pe(te,ye(J._payload),ne)}if(we(J)||Y(J))return J=Do(J,te.mode,ne,null),J.return=te,J;Wc(te,J)}return null}function de(te,J,ne,ye){var Me=J!==null?J.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number")return Me!==null?null:H(te,J,""+ne,ye);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case E:return ne.key===Me?X(te,J,ne,ye):null;case C:return ne.key===Me?re(te,J,ne,ye):null;case P:return Me=ne._init,de(te,J,Me(ne._payload),ye)}if(we(ne)||Y(ne))return Me!==null?null:me(te,J,ne,ye,null);Wc(te,ne)}return null}function je(te,J,ne,ye,Me){if(typeof ye=="string"&&ye!==""||typeof ye=="number")return te=te.get(ne)||null,H(J,te,""+ye,Me);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case E:return te=te.get(ye.key===null?ne:ye.key)||null,X(J,te,ye,Me);case C:return te=te.get(ye.key===null?ne:ye.key)||null,re(J,te,ye,Me);case P:var ze=ye._init;return je(te,J,ne,ze(ye._payload),Me)}if(we(ye)||Y(ye))return te=te.get(ne)||null,me(J,te,ye,Me,null);Wc(J,ye)}return null}function Re(te,J,ne,ye){for(var Me=null,ze=null,De=J,Be=J=0,sn=null;De!==null&&Be<ne.length;Be++){De.index>Be?(sn=De,De=null):sn=De.sibling;var ot=de(te,De,ne[Be],ye);if(ot===null){De===null&&(De=sn);break}o&&De&&ot.alternate===null&&i(te,De),J=_(ot,J,Be),ze===null?Me=ot:ze.sibling=ot,ze=ot,De=sn}if(Be===ne.length)return d(te,De),_t&&Ro(te,Be),Me;if(De===null){for(;Be<ne.length;Be++)De=pe(te,ne[Be],ye),De!==null&&(J=_(De,J,Be),ze===null?Me=De:ze.sibling=De,ze=De);return _t&&Ro(te,Be),Me}for(De=y(te,De);Be<ne.length;Be++)sn=je(De,te,Be,ne[Be],ye),sn!==null&&(o&&sn.alternate!==null&&De.delete(sn.key===null?Be:sn.key),J=_(sn,J,Be),ze===null?Me=sn:ze.sibling=sn,ze=sn);return o&&De.forEach(function(Zr){return i(te,Zr)}),_t&&Ro(te,Be),Me}function Oe(te,J,ne,ye){var Me=Y(ne);if(typeof Me!="function")throw Error(s(150));if(ne=Me.call(ne),ne==null)throw Error(s(151));for(var ze=Me=null,De=J,Be=J=0,sn=null,ot=ne.next();De!==null&&!ot.done;Be++,ot=ne.next()){De.index>Be?(sn=De,De=null):sn=De.sibling;var Zr=de(te,De,ot.value,ye);if(Zr===null){De===null&&(De=sn);break}o&&De&&Zr.alternate===null&&i(te,De),J=_(Zr,J,Be),ze===null?Me=Zr:ze.sibling=Zr,ze=Zr,De=sn}if(ot.done)return d(te,De),_t&&Ro(te,Be),Me;if(De===null){for(;!ot.done;Be++,ot=ne.next())ot=pe(te,ot.value,ye),ot!==null&&(J=_(ot,J,Be),ze===null?Me=ot:ze.sibling=ot,ze=ot);return _t&&Ro(te,Be),Me}for(De=y(te,De);!ot.done;Be++,ot=ne.next())ot=je(De,te,Be,ot.value,ye),ot!==null&&(o&&ot.alternate!==null&&De.delete(ot.key===null?Be:ot.key),J=_(ot,J,Be),ze===null?Me=ot:ze.sibling=ot,ze=ot);return o&&De.forEach(function(f_){return i(te,f_)}),_t&&Ro(te,Be),Me}function Dt(te,J,ne,ye){if(typeof ne=="object"&&ne!==null&&ne.type===T&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case E:e:{for(var Me=ne.key,ze=J;ze!==null;){if(ze.key===Me){if(Me=ne.type,Me===T){if(ze.tag===7){d(te,ze.sibling),J=k(ze,ne.props.children),J.return=te,te=J;break e}}else if(ze.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===P&&sy(Me)===ze.type){d(te,ze.sibling),J=k(ze,ne.props),J.ref=Ki(te,ze,ne),J.return=te,te=J;break e}d(te,ze);break}else i(te,ze);ze=ze.sibling}ne.type===T?(J=Do(ne.props.children,te.mode,ye,ne.key),J.return=te,te=J):(ye=fu(ne.type,ne.key,ne.props,null,te.mode,ye),ye.ref=Ki(te,J,ne),ye.return=te,te=ye)}return M(te);case C:e:{for(ze=ne.key;J!==null;){if(J.key===ze)if(J.tag===4&&J.stateNode.containerInfo===ne.containerInfo&&J.stateNode.implementation===ne.implementation){d(te,J.sibling),J=k(J,ne.children||[]),J.return=te,te=J;break e}else{d(te,J);break}else i(te,J);J=J.sibling}J=qm(ne,te.mode,ye),J.return=te,te=J}return M(te);case P:return ze=ne._init,Dt(te,J,ze(ne._payload),ye)}if(we(ne))return Re(te,J,ne,ye);if(Y(ne))return Oe(te,J,ne,ye);Wc(te,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"?(ne=""+ne,J!==null&&J.tag===6?(d(te,J.sibling),J=k(J,ne),J.return=te,te=J):(d(te,J),J=Gm(ne,te.mode,ye),J.return=te,te=J),M(te)):d(te,J)}return Dt}var Ta=ry(!0),oy=ry(!1),Hc=Ur(null),Bc=null,Ra=null,tm=null;function nm(){tm=Ra=Bc=null}function sm(o){var i=Hc.current;wt(Hc),o._currentValue=i}function rm(o,i,d){for(;o!==null;){var y=o.alternate;if((o.childLanes&i)!==i?(o.childLanes|=i,y!==null&&(y.childLanes|=i)):y!==null&&(y.childLanes&i)!==i&&(y.childLanes|=i),o===d)break;o=o.return}}function Aa(o,i){Bc=o,tm=Ra=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&i)!==0&&(Wn=!0),o.firstContext=null)}function xs(o){var i=o._currentValue;if(tm!==o)if(o={context:o,memoizedValue:i,next:null},Ra===null){if(Bc===null)throw Error(s(308));Ra=o,Bc.dependencies={lanes:0,firstContext:o}}else Ra=Ra.next=o;return i}var Ao=null;function om(o){Ao===null?Ao=[o]:Ao.push(o)}function ay(o,i,d,y){var k=i.interleaved;return k===null?(d.next=d,om(i)):(d.next=k.next,k.next=d),i.interleaved=d,xr(o,y)}function xr(o,i){o.lanes|=i;var d=o.alternate;for(d!==null&&(d.lanes|=i),d=o,o=o.return;o!==null;)o.childLanes|=i,d=o.alternate,d!==null&&(d.childLanes|=i),d=o,o=o.return;return d.tag===3?d.stateNode:null}var Br=!1;function am(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function iy(o,i){o=o.updateQueue,i.updateQueue===o&&(i.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function yr(o,i){return{eventTime:o,lane:i,tag:0,payload:null,callback:null,next:null}}function Gr(o,i,d){var y=o.updateQueue;if(y===null)return null;if(y=y.shared,(rt&2)!==0){var k=y.pending;return k===null?i.next=i:(i.next=k.next,k.next=i),y.pending=i,xr(o,d)}return k=y.interleaved,k===null?(i.next=i,om(y)):(i.next=k.next,k.next=i),y.interleaved=i,xr(o,d)}function Gc(o,i,d){if(i=i.updateQueue,i!==null&&(i=i.shared,(d&4194240)!==0)){var y=i.lanes;y&=o.pendingLanes,d|=y,i.lanes=d,hn(o,d)}}function ly(o,i){var d=o.updateQueue,y=o.alternate;if(y!==null&&(y=y.updateQueue,d===y)){var k=null,_=null;if(d=d.firstBaseUpdate,d!==null){do{var M={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};_===null?k=_=M:_=_.next=M,d=d.next}while(d!==null);_===null?k=_=i:_=_.next=i}else k=_=i;d={baseState:y.baseState,firstBaseUpdate:k,lastBaseUpdate:_,shared:y.shared,effects:y.effects},o.updateQueue=d;return}o=d.lastBaseUpdate,o===null?d.firstBaseUpdate=i:o.next=i,d.lastBaseUpdate=i}function qc(o,i,d,y){var k=o.updateQueue;Br=!1;var _=k.firstBaseUpdate,M=k.lastBaseUpdate,H=k.shared.pending;if(H!==null){k.shared.pending=null;var X=H,re=X.next;X.next=null,M===null?_=re:M.next=re,M=X;var me=o.alternate;me!==null&&(me=me.updateQueue,H=me.lastBaseUpdate,H!==M&&(H===null?me.firstBaseUpdate=re:H.next=re,me.lastBaseUpdate=X))}if(_!==null){var pe=k.baseState;M=0,me=re=X=null,H=_;do{var de=H.lane,je=H.eventTime;if((y&de)===de){me!==null&&(me=me.next={eventTime:je,lane:0,tag:H.tag,payload:H.payload,callback:H.callback,next:null});e:{var Re=o,Oe=H;switch(de=i,je=d,Oe.tag){case 1:if(Re=Oe.payload,typeof Re=="function"){pe=Re.call(je,pe,de);break e}pe=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=Oe.payload,de=typeof Re=="function"?Re.call(je,pe,de):Re,de==null)break e;pe=q({},pe,de);break e;case 2:Br=!0}}H.callback!==null&&H.lane!==0&&(o.flags|=64,de=k.effects,de===null?k.effects=[H]:de.push(H))}else je={eventTime:je,lane:de,tag:H.tag,payload:H.payload,callback:H.callback,next:null},me===null?(re=me=je,X=pe):me=me.next=je,M|=de;if(H=H.next,H===null){if(H=k.shared.pending,H===null)break;de=H,H=de.next,de.next=null,k.lastBaseUpdate=de,k.shared.pending=null}}while(!0);if(me===null&&(X=pe),k.baseState=X,k.firstBaseUpdate=re,k.lastBaseUpdate=me,i=k.shared.interleaved,i!==null){k=i;do M|=k.lane,k=k.next;while(k!==i)}else _===null&&(k.shared.lanes=0);Po|=M,o.lanes=M,o.memoizedState=pe}}function cy(o,i,d){if(o=i.effects,i.effects=null,o!==null)for(i=0;i<o.length;i++){var y=o[i],k=y.callback;if(k!==null){if(y.callback=null,y=d,typeof k!="function")throw Error(s(191,k));k.call(y)}}}var Xi={},Qs=Ur(Xi),Yi=Ur(Xi),Qi=Ur(Xi);function Oo(o){if(o===Xi)throw Error(s(174));return o}function im(o,i){switch(bt(Qi,i),bt(Yi,o),bt(Qs,Xi),o=i.nodeType,o){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Wt(null,"");break;default:o=o===8?i.parentNode:i,i=o.namespaceURI||null,o=o.tagName,i=Wt(i,o)}wt(Qs),bt(Qs,i)}function Oa(){wt(Qs),wt(Yi),wt(Qi)}function uy(o){Oo(Qi.current);var i=Oo(Qs.current),d=Wt(i,o.type);i!==d&&(bt(Yi,o),bt(Qs,d))}function lm(o){Yi.current===o&&(wt(Qs),wt(Yi))}var Tt=Ur(0);function Vc(o){for(var i=o;i!==null;){if(i.tag===13){var d=i.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break;for(;i.sibling===null;){if(i.return===null||i.return===o)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var cm=[];function um(){for(var o=0;o<cm.length;o++)cm[o]._workInProgressVersionPrimary=null;cm.length=0}var Kc=S.ReactCurrentDispatcher,dm=S.ReactCurrentBatchConfig,Mo=0,Rt=null,Yt=null,tn=null,Xc=!1,Zi=!1,Ji=0,M2=0;function xn(){throw Error(s(321))}function fm(o,i){if(i===null)return!1;for(var d=0;d<i.length&&d<o.length;d++)if(!Ps(o[d],i[d]))return!1;return!0}function mm(o,i,d,y,k,_){if(Mo=_,Rt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Kc.current=o===null||o.memoizedState===null?z2:D2,o=d(y,k),Zi){_=0;do{if(Zi=!1,Ji=0,25<=_)throw Error(s(301));_+=1,tn=Yt=null,i.updateQueue=null,Kc.current=F2,o=d(y,k)}while(Zi)}if(Kc.current=Zc,i=Yt!==null&&Yt.next!==null,Mo=0,tn=Yt=Rt=null,Xc=!1,i)throw Error(s(300));return o}function pm(){var o=Ji!==0;return Ji=0,o}function Zs(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?Rt.memoizedState=tn=o:tn=tn.next=o,tn}function ys(){if(Yt===null){var o=Rt.alternate;o=o!==null?o.memoizedState:null}else o=Yt.next;var i=tn===null?Rt.memoizedState:tn.next;if(i!==null)tn=i,Yt=o;else{if(o===null)throw Error(s(310));Yt=o,o={memoizedState:Yt.memoizedState,baseState:Yt.baseState,baseQueue:Yt.baseQueue,queue:Yt.queue,next:null},tn===null?Rt.memoizedState=tn=o:tn=tn.next=o}return tn}function el(o,i){return typeof i=="function"?i(o):i}function hm(o){var i=ys(),d=i.queue;if(d===null)throw Error(s(311));d.lastRenderedReducer=o;var y=Yt,k=y.baseQueue,_=d.pending;if(_!==null){if(k!==null){var M=k.next;k.next=_.next,_.next=M}y.baseQueue=k=_,d.pending=null}if(k!==null){_=k.next,y=y.baseState;var H=M=null,X=null,re=_;do{var me=re.lane;if((Mo&me)===me)X!==null&&(X=X.next={lane:0,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),y=re.hasEagerState?re.eagerState:o(y,re.action);else{var pe={lane:me,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null};X===null?(H=X=pe,M=y):X=X.next=pe,Rt.lanes|=me,Po|=me}re=re.next}while(re!==null&&re!==_);X===null?M=y:X.next=H,Ps(y,i.memoizedState)||(Wn=!0),i.memoizedState=y,i.baseState=M,i.baseQueue=X,d.lastRenderedState=y}if(o=d.interleaved,o!==null){k=o;do _=k.lane,Rt.lanes|=_,Po|=_,k=k.next;while(k!==o)}else k===null&&(d.lanes=0);return[i.memoizedState,d.dispatch]}function gm(o){var i=ys(),d=i.queue;if(d===null)throw Error(s(311));d.lastRenderedReducer=o;var y=d.dispatch,k=d.pending,_=i.memoizedState;if(k!==null){d.pending=null;var M=k=k.next;do _=o(_,M.action),M=M.next;while(M!==k);Ps(_,i.memoizedState)||(Wn=!0),i.memoizedState=_,i.baseQueue===null&&(i.baseState=_),d.lastRenderedState=_}return[_,y]}function dy(){}function fy(o,i){var d=Rt,y=ys(),k=i(),_=!Ps(y.memoizedState,k);if(_&&(y.memoizedState=k,Wn=!0),y=y.queue,xm(hy.bind(null,d,y,o),[o]),y.getSnapshot!==i||_||tn!==null&&tn.memoizedState.tag&1){if(d.flags|=2048,tl(9,py.bind(null,d,y,k,i),void 0,null),nn===null)throw Error(s(349));(Mo&30)!==0||my(d,i,k)}return k}function my(o,i,d){o.flags|=16384,o={getSnapshot:i,value:d},i=Rt.updateQueue,i===null?(i={lastEffect:null,stores:null},Rt.updateQueue=i,i.stores=[o]):(d=i.stores,d===null?i.stores=[o]:d.push(o))}function py(o,i,d,y){i.value=d,i.getSnapshot=y,gy(i)&&xy(o)}function hy(o,i,d){return d(function(){gy(i)&&xy(o)})}function gy(o){var i=o.getSnapshot;o=o.value;try{var d=i();return!Ps(o,d)}catch{return!0}}function xy(o){var i=xr(o,1);i!==null&&Fs(i,o,1,-1)}function yy(o){var i=Zs();return typeof o=="function"&&(o=o()),i.memoizedState=i.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:el,lastRenderedState:o},i.queue=o,o=o.dispatch=I2.bind(null,Rt,o),[i.memoizedState,o]}function tl(o,i,d,y){return o={tag:o,create:i,destroy:d,deps:y,next:null},i=Rt.updateQueue,i===null?(i={lastEffect:null,stores:null},Rt.updateQueue=i,i.lastEffect=o.next=o):(d=i.lastEffect,d===null?i.lastEffect=o.next=o:(y=d.next,d.next=o,o.next=y,i.lastEffect=o)),o}function by(){return ys().memoizedState}function Yc(o,i,d,y){var k=Zs();Rt.flags|=o,k.memoizedState=tl(1|i,d,void 0,y===void 0?null:y)}function Qc(o,i,d,y){var k=ys();y=y===void 0?null:y;var _=void 0;if(Yt!==null){var M=Yt.memoizedState;if(_=M.destroy,y!==null&&fm(y,M.deps)){k.memoizedState=tl(i,d,_,y);return}}Rt.flags|=o,k.memoizedState=tl(1|i,d,_,y)}function vy(o,i){return Yc(8390656,8,o,i)}function xm(o,i){return Qc(2048,8,o,i)}function wy(o,i){return Qc(4,2,o,i)}function ky(o,i){return Qc(4,4,o,i)}function jy(o,i){if(typeof i=="function")return o=o(),i(o),function(){i(null)};if(i!=null)return o=o(),i.current=o,function(){i.current=null}}function Ny(o,i,d){return d=d!=null?d.concat([o]):null,Qc(4,4,jy.bind(null,i,o),d)}function ym(){}function Sy(o,i){var d=ys();i=i===void 0?null:i;var y=d.memoizedState;return y!==null&&i!==null&&fm(i,y[1])?y[0]:(d.memoizedState=[o,i],o)}function _y(o,i){var d=ys();i=i===void 0?null:i;var y=d.memoizedState;return y!==null&&i!==null&&fm(i,y[1])?y[0]:(o=o(),d.memoizedState=[o,i],o)}function $y(o,i,d){return(Mo&21)===0?(o.baseState&&(o.baseState=!1,Wn=!0),o.memoizedState=d):(Ps(d,i)||(d=tt(),Rt.lanes|=d,Po|=d,o.baseState=!0),i)}function P2(o,i){var d=at;at=d!==0&&4>d?d:4,o(!0);var y=dm.transition;dm.transition={};try{o(!1),i()}finally{at=d,dm.transition=y}}function Ey(){return ys().memoizedState}function L2(o,i,d){var y=Xr(o);if(d={lane:y,action:d,hasEagerState:!1,eagerState:null,next:null},Cy(o))Ty(i,d);else if(d=ay(o,i,d,y),d!==null){var k=Sn();Fs(d,o,y,k),Ry(d,i,y)}}function I2(o,i,d){var y=Xr(o),k={lane:y,action:d,hasEagerState:!1,eagerState:null,next:null};if(Cy(o))Ty(i,k);else{var _=o.alternate;if(o.lanes===0&&(_===null||_.lanes===0)&&(_=i.lastRenderedReducer,_!==null))try{var M=i.lastRenderedState,H=_(M,d);if(k.hasEagerState=!0,k.eagerState=H,Ps(H,M)){var X=i.interleaved;X===null?(k.next=k,om(i)):(k.next=X.next,X.next=k),i.interleaved=k;return}}catch{}finally{}d=ay(o,i,k,y),d!==null&&(k=Sn(),Fs(d,o,y,k),Ry(d,i,y))}}function Cy(o){var i=o.alternate;return o===Rt||i!==null&&i===Rt}function Ty(o,i){Zi=Xc=!0;var d=o.pending;d===null?i.next=i:(i.next=d.next,d.next=i),o.pending=i}function Ry(o,i,d){if((d&4194240)!==0){var y=i.lanes;y&=o.pendingLanes,d|=y,i.lanes=d,hn(o,d)}}var Zc={readContext:xs,useCallback:xn,useContext:xn,useEffect:xn,useImperativeHandle:xn,useInsertionEffect:xn,useLayoutEffect:xn,useMemo:xn,useReducer:xn,useRef:xn,useState:xn,useDebugValue:xn,useDeferredValue:xn,useTransition:xn,useMutableSource:xn,useSyncExternalStore:xn,useId:xn,unstable_isNewReconciler:!1},z2={readContext:xs,useCallback:function(o,i){return Zs().memoizedState=[o,i===void 0?null:i],o},useContext:xs,useEffect:vy,useImperativeHandle:function(o,i,d){return d=d!=null?d.concat([o]):null,Yc(4194308,4,jy.bind(null,i,o),d)},useLayoutEffect:function(o,i){return Yc(4194308,4,o,i)},useInsertionEffect:function(o,i){return Yc(4,2,o,i)},useMemo:function(o,i){var d=Zs();return i=i===void 0?null:i,o=o(),d.memoizedState=[o,i],o},useReducer:function(o,i,d){var y=Zs();return i=d!==void 0?d(i):i,y.memoizedState=y.baseState=i,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:i},y.queue=o,o=o.dispatch=L2.bind(null,Rt,o),[y.memoizedState,o]},useRef:function(o){var i=Zs();return o={current:o},i.memoizedState=o},useState:yy,useDebugValue:ym,useDeferredValue:function(o){return Zs().memoizedState=o},useTransition:function(){var o=yy(!1),i=o[0];return o=P2.bind(null,o[1]),Zs().memoizedState=o,[i,o]},useMutableSource:function(){},useSyncExternalStore:function(o,i,d){var y=Rt,k=Zs();if(_t){if(d===void 0)throw Error(s(407));d=d()}else{if(d=i(),nn===null)throw Error(s(349));(Mo&30)!==0||my(y,i,d)}k.memoizedState=d;var _={value:d,getSnapshot:i};return k.queue=_,vy(hy.bind(null,y,_,o),[o]),y.flags|=2048,tl(9,py.bind(null,y,_,d,i),void 0,null),d},useId:function(){var o=Zs(),i=nn.identifierPrefix;if(_t){var d=gr,y=hr;d=(y&~(1<<32-Dn(y)-1)).toString(32)+d,i=":"+i+"R"+d,d=Ji++,0<d&&(i+="H"+d.toString(32)),i+=":"}else d=M2++,i=":"+i+"r"+d.toString(32)+":";return o.memoizedState=i},unstable_isNewReconciler:!1},D2={readContext:xs,useCallback:Sy,useContext:xs,useEffect:xm,useImperativeHandle:Ny,useInsertionEffect:wy,useLayoutEffect:ky,useMemo:_y,useReducer:hm,useRef:by,useState:function(){return hm(el)},useDebugValue:ym,useDeferredValue:function(o){var i=ys();return $y(i,Yt.memoizedState,o)},useTransition:function(){var o=hm(el)[0],i=ys().memoizedState;return[o,i]},useMutableSource:dy,useSyncExternalStore:fy,useId:Ey,unstable_isNewReconciler:!1},F2={readContext:xs,useCallback:Sy,useContext:xs,useEffect:xm,useImperativeHandle:Ny,useInsertionEffect:wy,useLayoutEffect:ky,useMemo:_y,useReducer:gm,useRef:by,useState:function(){return gm(el)},useDebugValue:ym,useDeferredValue:function(o){var i=ys();return Yt===null?i.memoizedState=o:$y(i,Yt.memoizedState,o)},useTransition:function(){var o=gm(el)[0],i=ys().memoizedState;return[o,i]},useMutableSource:dy,useSyncExternalStore:fy,useId:Ey,unstable_isNewReconciler:!1};function Is(o,i){if(o&&o.defaultProps){i=q({},i),o=o.defaultProps;for(var d in o)i[d]===void 0&&(i[d]=o[d]);return i}return i}function bm(o,i,d,y){i=o.memoizedState,d=d(y,i),d=d==null?i:q({},i,d),o.memoizedState=d,o.lanes===0&&(o.updateQueue.baseState=d)}var Jc={isMounted:function(o){return(o=o._reactInternals)?ps(o)===o:!1},enqueueSetState:function(o,i,d){o=o._reactInternals;var y=Sn(),k=Xr(o),_=yr(y,k);_.payload=i,d!=null&&(_.callback=d),i=Gr(o,_,k),i!==null&&(Fs(i,o,k,y),Gc(i,o,k))},enqueueReplaceState:function(o,i,d){o=o._reactInternals;var y=Sn(),k=Xr(o),_=yr(y,k);_.tag=1,_.payload=i,d!=null&&(_.callback=d),i=Gr(o,_,k),i!==null&&(Fs(i,o,k,y),Gc(i,o,k))},enqueueForceUpdate:function(o,i){o=o._reactInternals;var d=Sn(),y=Xr(o),k=yr(d,y);k.tag=2,i!=null&&(k.callback=i),i=Gr(o,k,y),i!==null&&(Fs(i,o,y,d),Gc(i,o,y))}};function Ay(o,i,d,y,k,_,M){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(y,_,M):i.prototype&&i.prototype.isPureReactComponent?!Ui(d,y)||!Ui(k,_):!0}function Oy(o,i,d){var y=!1,k=Wr,_=i.contextType;return typeof _=="object"&&_!==null?_=xs(_):(k=Un(i)?Co:gn.current,y=i.contextTypes,_=(y=y!=null)?_a(o,k):Wr),i=new i(d,_),o.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=Jc,o.stateNode=i,i._reactInternals=o,y&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=k,o.__reactInternalMemoizedMaskedChildContext=_),i}function My(o,i,d,y){o=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(d,y),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(d,y),i.state!==o&&Jc.enqueueReplaceState(i,i.state,null)}function vm(o,i,d,y){var k=o.stateNode;k.props=d,k.state=o.memoizedState,k.refs={},am(o);var _=i.contextType;typeof _=="object"&&_!==null?k.context=xs(_):(_=Un(i)?Co:gn.current,k.context=_a(o,_)),k.state=o.memoizedState,_=i.getDerivedStateFromProps,typeof _=="function"&&(bm(o,i,_,d),k.state=o.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof k.getSnapshotBeforeUpdate=="function"||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(i=k.state,typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount(),i!==k.state&&Jc.enqueueReplaceState(k,k.state,null),qc(o,d,k,y),k.state=o.memoizedState),typeof k.componentDidMount=="function"&&(o.flags|=4194308)}function Ma(o,i){try{var d="",y=i;do d+=ie(y),y=y.return;while(y);var k=d}catch(_){k=`
39
+ Error generating stack: `+_.message+`
40
+ `+_.stack}return{value:o,source:i,stack:k,digest:null}}function wm(o,i,d){return{value:o,source:null,stack:d??null,digest:i??null}}function km(o,i){try{console.error(i.value)}catch(d){setTimeout(function(){throw d})}}var U2=typeof WeakMap=="function"?WeakMap:Map;function Py(o,i,d){d=yr(-1,d),d.tag=3,d.payload={element:null};var y=i.value;return d.callback=function(){au||(au=!0,Im=y),km(o,i)},d}function Ly(o,i,d){d=yr(-1,d),d.tag=3;var y=o.type.getDerivedStateFromError;if(typeof y=="function"){var k=i.value;d.payload=function(){return y(k)},d.callback=function(){km(o,i)}}var _=o.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(d.callback=function(){km(o,i),typeof y!="function"&&(Vr===null?Vr=new Set([this]):Vr.add(this));var M=i.stack;this.componentDidCatch(i.value,{componentStack:M!==null?M:""})}),d}function Iy(o,i,d){var y=o.pingCache;if(y===null){y=o.pingCache=new U2;var k=new Set;y.set(i,k)}else k=y.get(i),k===void 0&&(k=new Set,y.set(i,k));k.has(d)||(k.add(d),o=t_.bind(null,o,i,d),i.then(o,o))}function zy(o){do{var i;if((i=o.tag===13)&&(i=o.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return o;o=o.return}while(o!==null);return null}function Dy(o,i,d,y,k){return(o.mode&1)===0?(o===i?o.flags|=65536:(o.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(i=yr(-1,1),i.tag=2,Gr(d,i,1))),d.lanes|=1),o):(o.flags|=65536,o.lanes=k,o)}var W2=S.ReactCurrentOwner,Wn=!1;function Nn(o,i,d,y){i.child=o===null?oy(i,null,d,y):Ta(i,o.child,d,y)}function Fy(o,i,d,y,k){d=d.render;var _=i.ref;return Aa(i,k),y=mm(o,i,d,y,_,k),d=pm(),o!==null&&!Wn?(i.updateQueue=o.updateQueue,i.flags&=-2053,o.lanes&=~k,br(o,i,k)):(_t&&d&&Yf(i),i.flags|=1,Nn(o,i,y,k),i.child)}function Uy(o,i,d,y,k){if(o===null){var _=d.type;return typeof _=="function"&&!Bm(_)&&_.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(i.tag=15,i.type=_,Wy(o,i,_,y,k)):(o=fu(d.type,null,y,i,i.mode,k),o.ref=i.ref,o.return=i,i.child=o)}if(_=o.child,(o.lanes&k)===0){var M=_.memoizedProps;if(d=d.compare,d=d!==null?d:Ui,d(M,y)&&o.ref===i.ref)return br(o,i,k)}return i.flags|=1,o=Qr(_,y),o.ref=i.ref,o.return=i,i.child=o}function Wy(o,i,d,y,k){if(o!==null){var _=o.memoizedProps;if(Ui(_,y)&&o.ref===i.ref)if(Wn=!1,i.pendingProps=y=_,(o.lanes&k)!==0)(o.flags&131072)!==0&&(Wn=!0);else return i.lanes=o.lanes,br(o,i,k)}return jm(o,i,d,y,k)}function Hy(o,i,d){var y=i.pendingProps,k=y.children,_=o!==null?o.memoizedState:null;if(y.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},bt(La,as),as|=d;else{if((d&1073741824)===0)return o=_!==null?_.baseLanes|d:d,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:o,cachePool:null,transitions:null},i.updateQueue=null,bt(La,as),as|=o,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=_!==null?_.baseLanes:d,bt(La,as),as|=y}else _!==null?(y=_.baseLanes|d,i.memoizedState=null):y=d,bt(La,as),as|=y;return Nn(o,i,k,d),i.child}function By(o,i){var d=i.ref;(o===null&&d!==null||o!==null&&o.ref!==d)&&(i.flags|=512,i.flags|=2097152)}function jm(o,i,d,y,k){var _=Un(d)?Co:gn.current;return _=_a(i,_),Aa(i,k),d=mm(o,i,d,y,_,k),y=pm(),o!==null&&!Wn?(i.updateQueue=o.updateQueue,i.flags&=-2053,o.lanes&=~k,br(o,i,k)):(_t&&y&&Yf(i),i.flags|=1,Nn(o,i,d,k),i.child)}function Gy(o,i,d,y,k){if(Un(d)){var _=!0;Ic(i)}else _=!1;if(Aa(i,k),i.stateNode===null)tu(o,i),Oy(i,d,y),vm(i,d,y,k),y=!0;else if(o===null){var M=i.stateNode,H=i.memoizedProps;M.props=H;var X=M.context,re=d.contextType;typeof re=="object"&&re!==null?re=xs(re):(re=Un(d)?Co:gn.current,re=_a(i,re));var me=d.getDerivedStateFromProps,pe=typeof me=="function"||typeof M.getSnapshotBeforeUpdate=="function";pe||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(H!==y||X!==re)&&My(i,M,y,re),Br=!1;var de=i.memoizedState;M.state=de,qc(i,y,M,k),X=i.memoizedState,H!==y||de!==X||Fn.current||Br?(typeof me=="function"&&(bm(i,d,me,y),X=i.memoizedState),(H=Br||Ay(i,d,H,y,de,X,re))?(pe||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(i.flags|=4194308)):(typeof M.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=y,i.memoizedState=X),M.props=y,M.state=X,M.context=re,y=H):(typeof M.componentDidMount=="function"&&(i.flags|=4194308),y=!1)}else{M=i.stateNode,iy(o,i),H=i.memoizedProps,re=i.type===i.elementType?H:Is(i.type,H),M.props=re,pe=i.pendingProps,de=M.context,X=d.contextType,typeof X=="object"&&X!==null?X=xs(X):(X=Un(d)?Co:gn.current,X=_a(i,X));var je=d.getDerivedStateFromProps;(me=typeof je=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(H!==pe||de!==X)&&My(i,M,y,X),Br=!1,de=i.memoizedState,M.state=de,qc(i,y,M,k);var Re=i.memoizedState;H!==pe||de!==Re||Fn.current||Br?(typeof je=="function"&&(bm(i,d,je,y),Re=i.memoizedState),(re=Br||Ay(i,d,re,y,de,Re,X)||!1)?(me||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(y,Re,X),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(y,Re,X)),typeof M.componentDidUpdate=="function"&&(i.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof M.componentDidUpdate!="function"||H===o.memoizedProps&&de===o.memoizedState||(i.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||H===o.memoizedProps&&de===o.memoizedState||(i.flags|=1024),i.memoizedProps=y,i.memoizedState=Re),M.props=y,M.state=Re,M.context=X,y=re):(typeof M.componentDidUpdate!="function"||H===o.memoizedProps&&de===o.memoizedState||(i.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||H===o.memoizedProps&&de===o.memoizedState||(i.flags|=1024),y=!1)}return Nm(o,i,d,y,_,k)}function Nm(o,i,d,y,k,_){By(o,i);var M=(i.flags&128)!==0;if(!y&&!M)return k&&Yx(i,d,!1),br(o,i,_);y=i.stateNode,W2.current=i;var H=M&&typeof d.getDerivedStateFromError!="function"?null:y.render();return i.flags|=1,o!==null&&M?(i.child=Ta(i,o.child,null,_),i.child=Ta(i,null,H,_)):Nn(o,i,H,_),i.memoizedState=y.state,k&&Yx(i,d,!0),i.child}function qy(o){var i=o.stateNode;i.pendingContext?Kx(o,i.pendingContext,i.pendingContext!==i.context):i.context&&Kx(o,i.context,!1),im(o,i.containerInfo)}function Vy(o,i,d,y,k){return Ca(),em(k),i.flags|=256,Nn(o,i,d,y),i.child}var Sm={dehydrated:null,treeContext:null,retryLane:0};function _m(o){return{baseLanes:o,cachePool:null,transitions:null}}function Ky(o,i,d){var y=i.pendingProps,k=Tt.current,_=!1,M=(i.flags&128)!==0,H;if((H=M)||(H=o!==null&&o.memoizedState===null?!1:(k&2)!==0),H?(_=!0,i.flags&=-129):(o===null||o.memoizedState!==null)&&(k|=1),bt(Tt,k&1),o===null)return Jf(i),o=i.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((i.mode&1)===0?i.lanes=1:o.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(M=y.children,o=y.fallback,_?(y=i.mode,_=i.child,M={mode:"hidden",children:M},(y&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=M):_=mu(M,y,0,null),o=Do(o,y,d,null),_.return=i,o.return=i,_.sibling=o,i.child=_,i.child.memoizedState=_m(d),i.memoizedState=Sm,o):$m(i,M));if(k=o.memoizedState,k!==null&&(H=k.dehydrated,H!==null))return H2(o,i,M,y,H,k,d);if(_){_=y.fallback,M=i.mode,k=o.child,H=k.sibling;var X={mode:"hidden",children:y.children};return(M&1)===0&&i.child!==k?(y=i.child,y.childLanes=0,y.pendingProps=X,i.deletions=null):(y=Qr(k,X),y.subtreeFlags=k.subtreeFlags&14680064),H!==null?_=Qr(H,_):(_=Do(_,M,d,null),_.flags|=2),_.return=i,y.return=i,y.sibling=_,i.child=y,y=_,_=i.child,M=o.child.memoizedState,M=M===null?_m(d):{baseLanes:M.baseLanes|d,cachePool:null,transitions:M.transitions},_.memoizedState=M,_.childLanes=o.childLanes&~d,i.memoizedState=Sm,y}return _=o.child,o=_.sibling,y=Qr(_,{mode:"visible",children:y.children}),(i.mode&1)===0&&(y.lanes=d),y.return=i,y.sibling=null,o!==null&&(d=i.deletions,d===null?(i.deletions=[o],i.flags|=16):d.push(o)),i.child=y,i.memoizedState=null,y}function $m(o,i){return i=mu({mode:"visible",children:i},o.mode,0,null),i.return=o,o.child=i}function eu(o,i,d,y){return y!==null&&em(y),Ta(i,o.child,null,d),o=$m(i,i.pendingProps.children),o.flags|=2,i.memoizedState=null,o}function H2(o,i,d,y,k,_,M){if(d)return i.flags&256?(i.flags&=-257,y=wm(Error(s(422))),eu(o,i,M,y)):i.memoizedState!==null?(i.child=o.child,i.flags|=128,null):(_=y.fallback,k=i.mode,y=mu({mode:"visible",children:y.children},k,0,null),_=Do(_,k,M,null),_.flags|=2,y.return=i,_.return=i,y.sibling=_,i.child=y,(i.mode&1)!==0&&Ta(i,o.child,null,M),i.child.memoizedState=_m(M),i.memoizedState=Sm,_);if((i.mode&1)===0)return eu(o,i,M,null);if(k.data==="$!"){if(y=k.nextSibling&&k.nextSibling.dataset,y)var H=y.dgst;return y=H,_=Error(s(419)),y=wm(_,y,void 0),eu(o,i,M,y)}if(H=(M&o.childLanes)!==0,Wn||H){if(y=nn,y!==null){switch(M&-M){case 4:k=2;break;case 16:k=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:k=32;break;case 536870912:k=268435456;break;default:k=0}k=(k&(y.suspendedLanes|M))!==0?0:k,k!==0&&k!==_.retryLane&&(_.retryLane=k,xr(o,k),Fs(y,o,k,-1))}return Hm(),y=wm(Error(s(421))),eu(o,i,M,y)}return k.data==="$?"?(i.flags|=128,i.child=o.child,i=n_.bind(null,o),k._reactRetry=i,null):(o=_.treeContext,os=Fr(k.nextSibling),rs=i,_t=!0,Ls=null,o!==null&&(hs[gs++]=hr,hs[gs++]=gr,hs[gs++]=To,hr=o.id,gr=o.overflow,To=i),i=$m(i,y.children),i.flags|=4096,i)}function Xy(o,i,d){o.lanes|=i;var y=o.alternate;y!==null&&(y.lanes|=i),rm(o.return,i,d)}function Em(o,i,d,y,k){var _=o.memoizedState;_===null?o.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:y,tail:d,tailMode:k}:(_.isBackwards=i,_.rendering=null,_.renderingStartTime=0,_.last=y,_.tail=d,_.tailMode=k)}function Yy(o,i,d){var y=i.pendingProps,k=y.revealOrder,_=y.tail;if(Nn(o,i,y.children,d),y=Tt.current,(y&2)!==0)y=y&1|2,i.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=i.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&Xy(o,d,i);else if(o.tag===19)Xy(o,d,i);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break e;for(;o.sibling===null;){if(o.return===null||o.return===i)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}y&=1}if(bt(Tt,y),(i.mode&1)===0)i.memoizedState=null;else switch(k){case"forwards":for(d=i.child,k=null;d!==null;)o=d.alternate,o!==null&&Vc(o)===null&&(k=d),d=d.sibling;d=k,d===null?(k=i.child,i.child=null):(k=d.sibling,d.sibling=null),Em(i,!1,k,d,_);break;case"backwards":for(d=null,k=i.child,i.child=null;k!==null;){if(o=k.alternate,o!==null&&Vc(o)===null){i.child=k;break}o=k.sibling,k.sibling=d,d=k,k=o}Em(i,!0,d,null,_);break;case"together":Em(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function tu(o,i){(i.mode&1)===0&&o!==null&&(o.alternate=null,i.alternate=null,i.flags|=2)}function br(o,i,d){if(o!==null&&(i.dependencies=o.dependencies),Po|=i.lanes,(d&i.childLanes)===0)return null;if(o!==null&&i.child!==o.child)throw Error(s(153));if(i.child!==null){for(o=i.child,d=Qr(o,o.pendingProps),i.child=d,d.return=i;o.sibling!==null;)o=o.sibling,d=d.sibling=Qr(o,o.pendingProps),d.return=i;d.sibling=null}return i.child}function B2(o,i,d){switch(i.tag){case 3:qy(i),Ca();break;case 5:uy(i);break;case 1:Un(i.type)&&Ic(i);break;case 4:im(i,i.stateNode.containerInfo);break;case 10:var y=i.type._context,k=i.memoizedProps.value;bt(Hc,y._currentValue),y._currentValue=k;break;case 13:if(y=i.memoizedState,y!==null)return y.dehydrated!==null?(bt(Tt,Tt.current&1),i.flags|=128,null):(d&i.child.childLanes)!==0?Ky(o,i,d):(bt(Tt,Tt.current&1),o=br(o,i,d),o!==null?o.sibling:null);bt(Tt,Tt.current&1);break;case 19:if(y=(d&i.childLanes)!==0,(o.flags&128)!==0){if(y)return Yy(o,i,d);i.flags|=128}if(k=i.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),bt(Tt,Tt.current),y)break;return null;case 22:case 23:return i.lanes=0,Hy(o,i,d)}return br(o,i,d)}var Qy,Cm,Zy,Jy;Qy=function(o,i){for(var d=i.child;d!==null;){if(d.tag===5||d.tag===6)o.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===i)break;for(;d.sibling===null;){if(d.return===null||d.return===i)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},Cm=function(){},Zy=function(o,i,d,y){var k=o.memoizedProps;if(k!==y){o=i.stateNode,Oo(Qs.current);var _=null;switch(d){case"input":k=Fe(o,k),y=Fe(o,y),_=[];break;case"select":k=q({},k,{value:void 0}),y=q({},y,{value:void 0}),_=[];break;case"textarea":k=jt(o,k),y=jt(o,y),_=[];break;default:typeof k.onClick!="function"&&typeof y.onClick=="function"&&(o.onclick=Mc)}Ln(d,y);var M;d=null;for(re in k)if(!y.hasOwnProperty(re)&&k.hasOwnProperty(re)&&k[re]!=null)if(re==="style"){var H=k[re];for(M in H)H.hasOwnProperty(M)&&(d||(d={}),d[M]="")}else re!=="dangerouslySetInnerHTML"&&re!=="children"&&re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&re!=="autoFocus"&&(a.hasOwnProperty(re)?_||(_=[]):(_=_||[]).push(re,null));for(re in y){var X=y[re];if(H=k!=null?k[re]:void 0,y.hasOwnProperty(re)&&X!==H&&(X!=null||H!=null))if(re==="style")if(H){for(M in H)!H.hasOwnProperty(M)||X&&X.hasOwnProperty(M)||(d||(d={}),d[M]="");for(M in X)X.hasOwnProperty(M)&&H[M]!==X[M]&&(d||(d={}),d[M]=X[M])}else d||(_||(_=[]),_.push(re,d)),d=X;else re==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,H=H?H.__html:void 0,X!=null&&H!==X&&(_=_||[]).push(re,X)):re==="children"?typeof X!="string"&&typeof X!="number"||(_=_||[]).push(re,""+X):re!=="suppressContentEditableWarning"&&re!=="suppressHydrationWarning"&&(a.hasOwnProperty(re)?(X!=null&&re==="onScroll"&&vt("scroll",o),_||H===X||(_=[])):(_=_||[]).push(re,X))}d&&(_=_||[]).push("style",d);var re=_;(i.updateQueue=re)&&(i.flags|=4)}},Jy=function(o,i,d,y){d!==y&&(i.flags|=4)};function nl(o,i){if(!_t)switch(o.tailMode){case"hidden":i=o.tail;for(var d=null;i!==null;)i.alternate!==null&&(d=i),i=i.sibling;d===null?o.tail=null:d.sibling=null;break;case"collapsed":d=o.tail;for(var y=null;d!==null;)d.alternate!==null&&(y=d),d=d.sibling;y===null?i||o.tail===null?o.tail=null:o.tail.sibling=null:y.sibling=null}}function yn(o){var i=o.alternate!==null&&o.alternate.child===o.child,d=0,y=0;if(i)for(var k=o.child;k!==null;)d|=k.lanes|k.childLanes,y|=k.subtreeFlags&14680064,y|=k.flags&14680064,k.return=o,k=k.sibling;else for(k=o.child;k!==null;)d|=k.lanes|k.childLanes,y|=k.subtreeFlags,y|=k.flags,k.return=o,k=k.sibling;return o.subtreeFlags|=y,o.childLanes=d,i}function G2(o,i,d){var y=i.pendingProps;switch(Qf(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yn(i),null;case 1:return Un(i.type)&&Lc(),yn(i),null;case 3:return y=i.stateNode,Oa(),wt(Fn),wt(gn),um(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(o===null||o.child===null)&&(Uc(i)?i.flags|=4:o===null||o.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Ls!==null&&(Fm(Ls),Ls=null))),Cm(o,i),yn(i),null;case 5:lm(i);var k=Oo(Qi.current);if(d=i.type,o!==null&&i.stateNode!=null)Zy(o,i,d,y,k),o.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!y){if(i.stateNode===null)throw Error(s(166));return yn(i),null}if(o=Oo(Qs.current),Uc(i)){y=i.stateNode,d=i.type;var _=i.memoizedProps;switch(y[Ys]=i,y[qi]=_,o=(i.mode&1)!==0,d){case"dialog":vt("cancel",y),vt("close",y);break;case"iframe":case"object":case"embed":vt("load",y);break;case"video":case"audio":for(k=0;k<Hi.length;k++)vt(Hi[k],y);break;case"source":vt("error",y);break;case"img":case"image":case"link":vt("error",y),vt("load",y);break;case"details":vt("toggle",y);break;case"input":fe(y,_),vt("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!_.multiple},vt("invalid",y);break;case"textarea":Nt(y,_),vt("invalid",y)}Ln(d,_),k=null;for(var M in _)if(_.hasOwnProperty(M)){var H=_[M];M==="children"?typeof H=="string"?y.textContent!==H&&(_.suppressHydrationWarning!==!0&&Oc(y.textContent,H,o),k=["children",H]):typeof H=="number"&&y.textContent!==""+H&&(_.suppressHydrationWarning!==!0&&Oc(y.textContent,H,o),k=["children",""+H]):a.hasOwnProperty(M)&&H!=null&&M==="onScroll"&&vt("scroll",y)}switch(d){case"input":se(y),It(y,_,!0);break;case"textarea":se(y),en(y);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(y.onclick=Mc)}y=k,i.updateQueue=y,y!==null&&(i.flags|=4)}else{M=k.nodeType===9?k:k.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=Ot(d)),o==="http://www.w3.org/1999/xhtml"?d==="script"?(o=M.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof y.is=="string"?o=M.createElement(d,{is:y.is}):(o=M.createElement(d),d==="select"&&(M=o,y.multiple?M.multiple=!0:y.size&&(M.size=y.size))):o=M.createElementNS(o,d),o[Ys]=i,o[qi]=y,Qy(o,i,!1,!1),i.stateNode=o;e:{switch(M=Kn(d,y),d){case"dialog":vt("cancel",o),vt("close",o),k=y;break;case"iframe":case"object":case"embed":vt("load",o),k=y;break;case"video":case"audio":for(k=0;k<Hi.length;k++)vt(Hi[k],o);k=y;break;case"source":vt("error",o),k=y;break;case"img":case"image":case"link":vt("error",o),vt("load",o),k=y;break;case"details":vt("toggle",o),k=y;break;case"input":fe(o,y),k=Fe(o,y),vt("invalid",o);break;case"option":k=y;break;case"select":o._wrapperState={wasMultiple:!!y.multiple},k=q({},y,{value:void 0}),vt("invalid",o);break;case"textarea":Nt(o,y),k=jt(o,y),vt("invalid",o);break;default:k=y}Ln(d,k),H=k;for(_ in H)if(H.hasOwnProperty(_)){var X=H[_];_==="style"?St(o,X):_==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&ct(o,X)):_==="children"?typeof X=="string"?(d!=="textarea"||X!=="")&&Ie(o,X):typeof X=="number"&&Ie(o,""+X):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(a.hasOwnProperty(_)?X!=null&&_==="onScroll"&&vt("scroll",o):X!=null&&$(o,_,X,M))}switch(d){case"input":se(o),It(o,y,!1);break;case"textarea":se(o),en(o);break;case"option":y.value!=null&&o.setAttribute("value",""+ce(y.value));break;case"select":o.multiple=!!y.multiple,_=y.value,_!=null?lt(o,!!y.multiple,_,!1):y.defaultValue!=null&&lt(o,!!y.multiple,y.defaultValue,!0);break;default:typeof k.onClick=="function"&&(o.onclick=Mc)}switch(d){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}}y&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return yn(i),null;case 6:if(o&&i.stateNode!=null)Jy(o,i,o.memoizedProps,y);else{if(typeof y!="string"&&i.stateNode===null)throw Error(s(166));if(d=Oo(Qi.current),Oo(Qs.current),Uc(i)){if(y=i.stateNode,d=i.memoizedProps,y[Ys]=i,(_=y.nodeValue!==d)&&(o=rs,o!==null))switch(o.tag){case 3:Oc(y.nodeValue,d,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&Oc(y.nodeValue,d,(o.mode&1)!==0)}_&&(i.flags|=4)}else y=(d.nodeType===9?d:d.ownerDocument).createTextNode(y),y[Ys]=i,i.stateNode=y}return yn(i),null;case 13:if(wt(Tt),y=i.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(_t&&os!==null&&(i.mode&1)!==0&&(i.flags&128)===0)ny(),Ca(),i.flags|=98560,_=!1;else if(_=Uc(i),y!==null&&y.dehydrated!==null){if(o===null){if(!_)throw Error(s(318));if(_=i.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(s(317));_[Ys]=i}else Ca(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;yn(i),_=!1}else Ls!==null&&(Fm(Ls),Ls=null),_=!0;if(!_)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=d,i):(y=y!==null,y!==(o!==null&&o.memoizedState!==null)&&y&&(i.child.flags|=8192,(i.mode&1)!==0&&(o===null||(Tt.current&1)!==0?Qt===0&&(Qt=3):Hm())),i.updateQueue!==null&&(i.flags|=4),yn(i),null);case 4:return Oa(),Cm(o,i),o===null&&Bi(i.stateNode.containerInfo),yn(i),null;case 10:return sm(i.type._context),yn(i),null;case 17:return Un(i.type)&&Lc(),yn(i),null;case 19:if(wt(Tt),_=i.memoizedState,_===null)return yn(i),null;if(y=(i.flags&128)!==0,M=_.rendering,M===null)if(y)nl(_,!1);else{if(Qt!==0||o!==null&&(o.flags&128)!==0)for(o=i.child;o!==null;){if(M=Vc(o),M!==null){for(i.flags|=128,nl(_,!1),y=M.updateQueue,y!==null&&(i.updateQueue=y,i.flags|=4),i.subtreeFlags=0,y=d,d=i.child;d!==null;)_=d,o=y,_.flags&=14680066,M=_.alternate,M===null?(_.childLanes=0,_.lanes=o,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=M.childLanes,_.lanes=M.lanes,_.child=M.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=M.memoizedProps,_.memoizedState=M.memoizedState,_.updateQueue=M.updateQueue,_.type=M.type,o=M.dependencies,_.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),d=d.sibling;return bt(Tt,Tt.current&1|2),i.child}o=o.sibling}_.tail!==null&&Ve()>Ia&&(i.flags|=128,y=!0,nl(_,!1),i.lanes=4194304)}else{if(!y)if(o=Vc(M),o!==null){if(i.flags|=128,y=!0,d=o.updateQueue,d!==null&&(i.updateQueue=d,i.flags|=4),nl(_,!0),_.tail===null&&_.tailMode==="hidden"&&!M.alternate&&!_t)return yn(i),null}else 2*Ve()-_.renderingStartTime>Ia&&d!==1073741824&&(i.flags|=128,y=!0,nl(_,!1),i.lanes=4194304);_.isBackwards?(M.sibling=i.child,i.child=M):(d=_.last,d!==null?d.sibling=M:i.child=M,_.last=M)}return _.tail!==null?(i=_.tail,_.rendering=i,_.tail=i.sibling,_.renderingStartTime=Ve(),i.sibling=null,d=Tt.current,bt(Tt,y?d&1|2:d&1),i):(yn(i),null);case 22:case 23:return Wm(),y=i.memoizedState!==null,o!==null&&o.memoizedState!==null!==y&&(i.flags|=8192),y&&(i.mode&1)!==0?(as&1073741824)!==0&&(yn(i),i.subtreeFlags&6&&(i.flags|=8192)):yn(i),null;case 24:return null;case 25:return null}throw Error(s(156,i.tag))}function q2(o,i){switch(Qf(i),i.tag){case 1:return Un(i.type)&&Lc(),o=i.flags,o&65536?(i.flags=o&-65537|128,i):null;case 3:return Oa(),wt(Fn),wt(gn),um(),o=i.flags,(o&65536)!==0&&(o&128)===0?(i.flags=o&-65537|128,i):null;case 5:return lm(i),null;case 13:if(wt(Tt),o=i.memoizedState,o!==null&&o.dehydrated!==null){if(i.alternate===null)throw Error(s(340));Ca()}return o=i.flags,o&65536?(i.flags=o&-65537|128,i):null;case 19:return wt(Tt),null;case 4:return Oa(),null;case 10:return sm(i.type._context),null;case 22:case 23:return Wm(),null;case 24:return null;default:return null}}var nu=!1,bn=!1,V2=typeof WeakSet=="function"?WeakSet:Set,$e=null;function Pa(o,i){var d=o.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(y){Mt(o,i,y)}else d.current=null}function Tm(o,i,d){try{d()}catch(y){Mt(o,i,y)}}var eb=!1;function K2(o,i){if(Wf=kc,o=Ax(),Mf(o)){if("selectionStart"in o)var d={start:o.selectionStart,end:o.selectionEnd};else e:{d=(d=o.ownerDocument)&&d.defaultView||window;var y=d.getSelection&&d.getSelection();if(y&&y.rangeCount!==0){d=y.anchorNode;var k=y.anchorOffset,_=y.focusNode;y=y.focusOffset;try{d.nodeType,_.nodeType}catch{d=null;break e}var M=0,H=-1,X=-1,re=0,me=0,pe=o,de=null;t:for(;;){for(var je;pe!==d||k!==0&&pe.nodeType!==3||(H=M+k),pe!==_||y!==0&&pe.nodeType!==3||(X=M+y),pe.nodeType===3&&(M+=pe.nodeValue.length),(je=pe.firstChild)!==null;)de=pe,pe=je;for(;;){if(pe===o)break t;if(de===d&&++re===k&&(H=M),de===_&&++me===y&&(X=M),(je=pe.nextSibling)!==null)break;pe=de,de=pe.parentNode}pe=je}d=H===-1||X===-1?null:{start:H,end:X}}else d=null}d=d||{start:0,end:0}}else d=null;for(Hf={focusedElem:o,selectionRange:d},kc=!1,$e=i;$e!==null;)if(i=$e,o=i.child,(i.subtreeFlags&1028)!==0&&o!==null)o.return=i,$e=o;else for(;$e!==null;){i=$e;try{var Re=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Re!==null){var Oe=Re.memoizedProps,Dt=Re.memoizedState,te=i.stateNode,J=te.getSnapshotBeforeUpdate(i.elementType===i.type?Oe:Is(i.type,Oe),Dt);te.__reactInternalSnapshotBeforeUpdate=J}break;case 3:var ne=i.stateNode.containerInfo;ne.nodeType===1?ne.textContent="":ne.nodeType===9&&ne.documentElement&&ne.removeChild(ne.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(ye){Mt(i,i.return,ye)}if(o=i.sibling,o!==null){o.return=i.return,$e=o;break}$e=i.return}return Re=eb,eb=!1,Re}function sl(o,i,d){var y=i.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var k=y=y.next;do{if((k.tag&o)===o){var _=k.destroy;k.destroy=void 0,_!==void 0&&Tm(i,d,_)}k=k.next}while(k!==y)}}function su(o,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var d=i=i.next;do{if((d.tag&o)===o){var y=d.create;d.destroy=y()}d=d.next}while(d!==i)}}function Rm(o){var i=o.ref;if(i!==null){var d=o.stateNode;switch(o.tag){case 5:o=d;break;default:o=d}typeof i=="function"?i(o):i.current=o}}function tb(o){var i=o.alternate;i!==null&&(o.alternate=null,tb(i)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(i=o.stateNode,i!==null&&(delete i[Ys],delete i[qi],delete i[Vf],delete i[T2],delete i[R2])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function nb(o){return o.tag===5||o.tag===3||o.tag===4}function sb(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||nb(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Am(o,i,d){var y=o.tag;if(y===5||y===6)o=o.stateNode,i?d.nodeType===8?d.parentNode.insertBefore(o,i):d.insertBefore(o,i):(d.nodeType===8?(i=d.parentNode,i.insertBefore(o,d)):(i=d,i.appendChild(o)),d=d._reactRootContainer,d!=null||i.onclick!==null||(i.onclick=Mc));else if(y!==4&&(o=o.child,o!==null))for(Am(o,i,d),o=o.sibling;o!==null;)Am(o,i,d),o=o.sibling}function Om(o,i,d){var y=o.tag;if(y===5||y===6)o=o.stateNode,i?d.insertBefore(o,i):d.appendChild(o);else if(y!==4&&(o=o.child,o!==null))for(Om(o,i,d),o=o.sibling;o!==null;)Om(o,i,d),o=o.sibling}var cn=null,zs=!1;function qr(o,i,d){for(d=d.child;d!==null;)rb(o,i,d),d=d.sibling}function rb(o,i,d){if(es&&typeof es.onCommitFiberUnmount=="function")try{es.onCommitFiberUnmount(jo,d)}catch{}switch(d.tag){case 5:bn||Pa(d,i);case 6:var y=cn,k=zs;cn=null,qr(o,i,d),cn=y,zs=k,cn!==null&&(zs?(o=cn,d=d.stateNode,o.nodeType===8?o.parentNode.removeChild(d):o.removeChild(d)):cn.removeChild(d.stateNode));break;case 18:cn!==null&&(zs?(o=cn,d=d.stateNode,o.nodeType===8?qf(o.parentNode,d):o.nodeType===1&&qf(o,d),Pi(o)):qf(cn,d.stateNode));break;case 4:y=cn,k=zs,cn=d.stateNode.containerInfo,zs=!0,qr(o,i,d),cn=y,zs=k;break;case 0:case 11:case 14:case 15:if(!bn&&(y=d.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){k=y=y.next;do{var _=k,M=_.destroy;_=_.tag,M!==void 0&&((_&2)!==0||(_&4)!==0)&&Tm(d,i,M),k=k.next}while(k!==y)}qr(o,i,d);break;case 1:if(!bn&&(Pa(d,i),y=d.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=d.memoizedProps,y.state=d.memoizedState,y.componentWillUnmount()}catch(H){Mt(d,i,H)}qr(o,i,d);break;case 21:qr(o,i,d);break;case 22:d.mode&1?(bn=(y=bn)||d.memoizedState!==null,qr(o,i,d),bn=y):qr(o,i,d);break;default:qr(o,i,d)}}function ob(o){var i=o.updateQueue;if(i!==null){o.updateQueue=null;var d=o.stateNode;d===null&&(d=o.stateNode=new V2),i.forEach(function(y){var k=s_.bind(null,o,y);d.has(y)||(d.add(y),y.then(k,k))})}}function Ds(o,i){var d=i.deletions;if(d!==null)for(var y=0;y<d.length;y++){var k=d[y];try{var _=o,M=i,H=M;e:for(;H!==null;){switch(H.tag){case 5:cn=H.stateNode,zs=!1;break e;case 3:cn=H.stateNode.containerInfo,zs=!0;break e;case 4:cn=H.stateNode.containerInfo,zs=!0;break e}H=H.return}if(cn===null)throw Error(s(160));rb(_,M,k),cn=null,zs=!1;var X=k.alternate;X!==null&&(X.return=null),k.return=null}catch(re){Mt(k,i,re)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)ab(i,o),i=i.sibling}function ab(o,i){var d=o.alternate,y=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(Ds(i,o),Js(o),y&4){try{sl(3,o,o.return),su(3,o)}catch(Oe){Mt(o,o.return,Oe)}try{sl(5,o,o.return)}catch(Oe){Mt(o,o.return,Oe)}}break;case 1:Ds(i,o),Js(o),y&512&&d!==null&&Pa(d,d.return);break;case 5:if(Ds(i,o),Js(o),y&512&&d!==null&&Pa(d,d.return),o.flags&32){var k=o.stateNode;try{Ie(k,"")}catch(Oe){Mt(o,o.return,Oe)}}if(y&4&&(k=o.stateNode,k!=null)){var _=o.memoizedProps,M=d!==null?d.memoizedProps:_,H=o.type,X=o.updateQueue;if(o.updateQueue=null,X!==null)try{H==="input"&&_.type==="radio"&&_.name!=null&&Le(k,_),Kn(H,M);var re=Kn(H,_);for(M=0;M<X.length;M+=2){var me=X[M],pe=X[M+1];me==="style"?St(k,pe):me==="dangerouslySetInnerHTML"?ct(k,pe):me==="children"?Ie(k,pe):$(k,me,pe,re)}switch(H){case"input":He(k,_);break;case"textarea":on(k,_);break;case"select":var de=k._wrapperState.wasMultiple;k._wrapperState.wasMultiple=!!_.multiple;var je=_.value;je!=null?lt(k,!!_.multiple,je,!1):de!==!!_.multiple&&(_.defaultValue!=null?lt(k,!!_.multiple,_.defaultValue,!0):lt(k,!!_.multiple,_.multiple?[]:"",!1))}k[qi]=_}catch(Oe){Mt(o,o.return,Oe)}}break;case 6:if(Ds(i,o),Js(o),y&4){if(o.stateNode===null)throw Error(s(162));k=o.stateNode,_=o.memoizedProps;try{k.nodeValue=_}catch(Oe){Mt(o,o.return,Oe)}}break;case 3:if(Ds(i,o),Js(o),y&4&&d!==null&&d.memoizedState.isDehydrated)try{Pi(i.containerInfo)}catch(Oe){Mt(o,o.return,Oe)}break;case 4:Ds(i,o),Js(o);break;case 13:Ds(i,o),Js(o),k=o.child,k.flags&8192&&(_=k.memoizedState!==null,k.stateNode.isHidden=_,!_||k.alternate!==null&&k.alternate.memoizedState!==null||(Lm=Ve())),y&4&&ob(o);break;case 22:if(me=d!==null&&d.memoizedState!==null,o.mode&1?(bn=(re=bn)||me,Ds(i,o),bn=re):Ds(i,o),Js(o),y&8192){if(re=o.memoizedState!==null,(o.stateNode.isHidden=re)&&!me&&(o.mode&1)!==0)for($e=o,me=o.child;me!==null;){for(pe=$e=me;$e!==null;){switch(de=$e,je=de.child,de.tag){case 0:case 11:case 14:case 15:sl(4,de,de.return);break;case 1:Pa(de,de.return);var Re=de.stateNode;if(typeof Re.componentWillUnmount=="function"){y=de,d=de.return;try{i=y,Re.props=i.memoizedProps,Re.state=i.memoizedState,Re.componentWillUnmount()}catch(Oe){Mt(y,d,Oe)}}break;case 5:Pa(de,de.return);break;case 22:if(de.memoizedState!==null){cb(pe);continue}}je!==null?(je.return=de,$e=je):cb(pe)}me=me.sibling}e:for(me=null,pe=o;;){if(pe.tag===5){if(me===null){me=pe;try{k=pe.stateNode,re?(_=k.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(H=pe.stateNode,X=pe.memoizedProps.style,M=X!=null&&X.hasOwnProperty("display")?X.display:null,H.style.display=Xe("display",M))}catch(Oe){Mt(o,o.return,Oe)}}}else if(pe.tag===6){if(me===null)try{pe.stateNode.nodeValue=re?"":pe.memoizedProps}catch(Oe){Mt(o,o.return,Oe)}}else if((pe.tag!==22&&pe.tag!==23||pe.memoizedState===null||pe===o)&&pe.child!==null){pe.child.return=pe,pe=pe.child;continue}if(pe===o)break e;for(;pe.sibling===null;){if(pe.return===null||pe.return===o)break e;me===pe&&(me=null),pe=pe.return}me===pe&&(me=null),pe.sibling.return=pe.return,pe=pe.sibling}}break;case 19:Ds(i,o),Js(o),y&4&&ob(o);break;case 21:break;default:Ds(i,o),Js(o)}}function Js(o){var i=o.flags;if(i&2){try{e:{for(var d=o.return;d!==null;){if(nb(d)){var y=d;break e}d=d.return}throw Error(s(160))}switch(y.tag){case 5:var k=y.stateNode;y.flags&32&&(Ie(k,""),y.flags&=-33);var _=sb(o);Om(o,_,k);break;case 3:case 4:var M=y.stateNode.containerInfo,H=sb(o);Am(o,H,M);break;default:throw Error(s(161))}}catch(X){Mt(o,o.return,X)}o.flags&=-3}i&4096&&(o.flags&=-4097)}function X2(o,i,d){$e=o,ib(o)}function ib(o,i,d){for(var y=(o.mode&1)!==0;$e!==null;){var k=$e,_=k.child;if(k.tag===22&&y){var M=k.memoizedState!==null||nu;if(!M){var H=k.alternate,X=H!==null&&H.memoizedState!==null||bn;H=nu;var re=bn;if(nu=M,(bn=X)&&!re)for($e=k;$e!==null;)M=$e,X=M.child,M.tag===22&&M.memoizedState!==null?ub(k):X!==null?(X.return=M,$e=X):ub(k);for(;_!==null;)$e=_,ib(_),_=_.sibling;$e=k,nu=H,bn=re}lb(o)}else(k.subtreeFlags&8772)!==0&&_!==null?(_.return=k,$e=_):lb(o)}}function lb(o){for(;$e!==null;){var i=$e;if((i.flags&8772)!==0){var d=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:bn||su(5,i);break;case 1:var y=i.stateNode;if(i.flags&4&&!bn)if(d===null)y.componentDidMount();else{var k=i.elementType===i.type?d.memoizedProps:Is(i.type,d.memoizedProps);y.componentDidUpdate(k,d.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var _=i.updateQueue;_!==null&&cy(i,_,y);break;case 3:var M=i.updateQueue;if(M!==null){if(d=null,i.child!==null)switch(i.child.tag){case 5:d=i.child.stateNode;break;case 1:d=i.child.stateNode}cy(i,M,d)}break;case 5:var H=i.stateNode;if(d===null&&i.flags&4){d=H;var X=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&d.focus();break;case"img":X.src&&(d.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var re=i.alternate;if(re!==null){var me=re.memoizedState;if(me!==null){var pe=me.dehydrated;pe!==null&&Pi(pe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}bn||i.flags&512&&Rm(i)}catch(de){Mt(i,i.return,de)}}if(i===o){$e=null;break}if(d=i.sibling,d!==null){d.return=i.return,$e=d;break}$e=i.return}}function cb(o){for(;$e!==null;){var i=$e;if(i===o){$e=null;break}var d=i.sibling;if(d!==null){d.return=i.return,$e=d;break}$e=i.return}}function ub(o){for(;$e!==null;){var i=$e;try{switch(i.tag){case 0:case 11:case 15:var d=i.return;try{su(4,i)}catch(X){Mt(i,d,X)}break;case 1:var y=i.stateNode;if(typeof y.componentDidMount=="function"){var k=i.return;try{y.componentDidMount()}catch(X){Mt(i,k,X)}}var _=i.return;try{Rm(i)}catch(X){Mt(i,_,X)}break;case 5:var M=i.return;try{Rm(i)}catch(X){Mt(i,M,X)}}}catch(X){Mt(i,i.return,X)}if(i===o){$e=null;break}var H=i.sibling;if(H!==null){H.return=i.return,$e=H;break}$e=i.return}}var Y2=Math.ceil,ru=S.ReactCurrentDispatcher,Mm=S.ReactCurrentOwner,bs=S.ReactCurrentBatchConfig,rt=0,nn=null,Ht=null,un=0,as=0,La=Ur(0),Qt=0,rl=null,Po=0,ou=0,Pm=0,ol=null,Hn=null,Lm=0,Ia=1/0,vr=null,au=!1,Im=null,Vr=null,iu=!1,Kr=null,lu=0,al=0,zm=null,cu=-1,uu=0;function Sn(){return(rt&6)!==0?Ve():cu!==-1?cu:cu=Ve()}function Xr(o){return(o.mode&1)===0?1:(rt&2)!==0&&un!==0?un&-un:O2.transition!==null?(uu===0&&(uu=tt()),uu):(o=at,o!==0||(o=window.event,o=o===void 0?16:fx(o.type)),o)}function Fs(o,i,d,y){if(50<al)throw al=0,zm=null,Error(s(185));pn(o,d,y),((rt&2)===0||o!==nn)&&(o===nn&&((rt&2)===0&&(ou|=d),Qt===4&&Yr(o,un)),Bn(o,y),d===1&&rt===0&&(i.mode&1)===0&&(Ia=Ve()+500,zc&&Hr()))}function Bn(o,i){var d=o.callbackNode;be(o,i);var y=_o(o,o===nn?un:0);if(y===0)d!==null&&_e(d),o.callbackNode=null,o.callbackPriority=0;else if(i=y&-y,o.callbackPriority!==i){if(d!=null&&_e(d),i===1)o.tag===0?A2(fb.bind(null,o)):Qx(fb.bind(null,o)),E2(function(){(rt&6)===0&&Hr()}),d=null;else{switch(fr(y)){case 1:d=ln;break;case 4:d=Ms;break;case 16:d=Ct;break;case 536870912:d=Ar;break;default:d=Ct}d=vb(d,db.bind(null,o))}o.callbackPriority=i,o.callbackNode=d}}function db(o,i){if(cu=-1,uu=0,(rt&6)!==0)throw Error(s(327));var d=o.callbackNode;if(za()&&o.callbackNode!==d)return null;var y=_o(o,o===nn?un:0);if(y===0)return null;if((y&30)!==0||(y&o.expiredLanes)!==0||i)i=du(o,y);else{i=y;var k=rt;rt|=2;var _=pb();(nn!==o||un!==i)&&(vr=null,Ia=Ve()+500,Io(o,i));do try{J2();break}catch(H){mb(o,H)}while(!0);nm(),ru.current=_,rt=k,Ht!==null?i=0:(nn=null,un=0,i=Qt)}if(i!==0){if(i===2&&(k=Te(o),k!==0&&(y=k,i=Dm(o,k))),i===1)throw d=rl,Io(o,0),Yr(o,y),Bn(o,Ve()),d;if(i===6)Yr(o,y);else{if(k=o.current.alternate,(y&30)===0&&!Q2(k)&&(i=du(o,y),i===2&&(_=Te(o),_!==0&&(y=_,i=Dm(o,_))),i===1))throw d=rl,Io(o,0),Yr(o,y),Bn(o,Ve()),d;switch(o.finishedWork=k,o.finishedLanes=y,i){case 0:case 1:throw Error(s(345));case 2:zo(o,Hn,vr);break;case 3:if(Yr(o,y),(y&130023424)===y&&(i=Lm+500-Ve(),10<i)){if(_o(o,0)!==0)break;if(k=o.suspendedLanes,(k&y)!==y){Sn(),o.pingedLanes|=o.suspendedLanes&k;break}o.timeoutHandle=Gf(zo.bind(null,o,Hn,vr),i);break}zo(o,Hn,vr);break;case 4:if(Yr(o,y),(y&4194240)===y)break;for(i=o.eventTimes,k=-1;0<y;){var M=31-Dn(y);_=1<<M,M=i[M],M>k&&(k=M),y&=~_}if(y=k,y=Ve()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*Y2(y/1960))-y,10<y){o.timeoutHandle=Gf(zo.bind(null,o,Hn,vr),y);break}zo(o,Hn,vr);break;case 5:zo(o,Hn,vr);break;default:throw Error(s(329))}}}return Bn(o,Ve()),o.callbackNode===d?db.bind(null,o):null}function Dm(o,i){var d=ol;return o.current.memoizedState.isDehydrated&&(Io(o,i).flags|=256),o=du(o,i),o!==2&&(i=Hn,Hn=d,i!==null&&Fm(i)),o}function Fm(o){Hn===null?Hn=o:Hn.push.apply(Hn,o)}function Q2(o){for(var i=o;;){if(i.flags&16384){var d=i.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var y=0;y<d.length;y++){var k=d[y],_=k.getSnapshot;k=k.value;try{if(!Ps(_(),k))return!1}catch{return!1}}}if(d=i.child,i.subtreeFlags&16384&&d!==null)d.return=i,i=d;else{if(i===o)break;for(;i.sibling===null;){if(i.return===null||i.return===o)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Yr(o,i){for(i&=~Pm,i&=~ou,o.suspendedLanes|=i,o.pingedLanes&=~i,o=o.expirationTimes;0<i;){var d=31-Dn(i),y=1<<d;o[d]=-1,i&=~y}}function fb(o){if((rt&6)!==0)throw Error(s(327));za();var i=_o(o,0);if((i&1)===0)return Bn(o,Ve()),null;var d=du(o,i);if(o.tag!==0&&d===2){var y=Te(o);y!==0&&(i=y,d=Dm(o,y))}if(d===1)throw d=rl,Io(o,0),Yr(o,i),Bn(o,Ve()),d;if(d===6)throw Error(s(345));return o.finishedWork=o.current.alternate,o.finishedLanes=i,zo(o,Hn,vr),Bn(o,Ve()),null}function Um(o,i){var d=rt;rt|=1;try{return o(i)}finally{rt=d,rt===0&&(Ia=Ve()+500,zc&&Hr())}}function Lo(o){Kr!==null&&Kr.tag===0&&(rt&6)===0&&za();var i=rt;rt|=1;var d=bs.transition,y=at;try{if(bs.transition=null,at=1,o)return o()}finally{at=y,bs.transition=d,rt=i,(rt&6)===0&&Hr()}}function Wm(){as=La.current,wt(La)}function Io(o,i){o.finishedWork=null,o.finishedLanes=0;var d=o.timeoutHandle;if(d!==-1&&(o.timeoutHandle=-1,$2(d)),Ht!==null)for(d=Ht.return;d!==null;){var y=d;switch(Qf(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&Lc();break;case 3:Oa(),wt(Fn),wt(gn),um();break;case 5:lm(y);break;case 4:Oa();break;case 13:wt(Tt);break;case 19:wt(Tt);break;case 10:sm(y.type._context);break;case 22:case 23:Wm()}d=d.return}if(nn=o,Ht=o=Qr(o.current,null),un=as=i,Qt=0,rl=null,Pm=ou=Po=0,Hn=ol=null,Ao!==null){for(i=0;i<Ao.length;i++)if(d=Ao[i],y=d.interleaved,y!==null){d.interleaved=null;var k=y.next,_=d.pending;if(_!==null){var M=_.next;_.next=k,y.next=M}d.pending=y}Ao=null}return o}function mb(o,i){do{var d=Ht;try{if(nm(),Kc.current=Zc,Xc){for(var y=Rt.memoizedState;y!==null;){var k=y.queue;k!==null&&(k.pending=null),y=y.next}Xc=!1}if(Mo=0,tn=Yt=Rt=null,Zi=!1,Ji=0,Mm.current=null,d===null||d.return===null){Qt=1,rl=i,Ht=null;break}e:{var _=o,M=d.return,H=d,X=i;if(i=un,H.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var re=X,me=H,pe=me.tag;if((me.mode&1)===0&&(pe===0||pe===11||pe===15)){var de=me.alternate;de?(me.updateQueue=de.updateQueue,me.memoizedState=de.memoizedState,me.lanes=de.lanes):(me.updateQueue=null,me.memoizedState=null)}var je=zy(M);if(je!==null){je.flags&=-257,Dy(je,M,H,_,i),je.mode&1&&Iy(_,re,i),i=je,X=re;var Re=i.updateQueue;if(Re===null){var Oe=new Set;Oe.add(X),i.updateQueue=Oe}else Re.add(X);break e}else{if((i&1)===0){Iy(_,re,i),Hm();break e}X=Error(s(426))}}else if(_t&&H.mode&1){var Dt=zy(M);if(Dt!==null){(Dt.flags&65536)===0&&(Dt.flags|=256),Dy(Dt,M,H,_,i),em(Ma(X,H));break e}}_=X=Ma(X,H),Qt!==4&&(Qt=2),ol===null?ol=[_]:ol.push(_),_=M;do{switch(_.tag){case 3:_.flags|=65536,i&=-i,_.lanes|=i;var te=Py(_,X,i);ly(_,te);break e;case 1:H=X;var J=_.type,ne=_.stateNode;if((_.flags&128)===0&&(typeof J.getDerivedStateFromError=="function"||ne!==null&&typeof ne.componentDidCatch=="function"&&(Vr===null||!Vr.has(ne)))){_.flags|=65536,i&=-i,_.lanes|=i;var ye=Ly(_,H,i);ly(_,ye);break e}}_=_.return}while(_!==null)}gb(d)}catch(Me){i=Me,Ht===d&&d!==null&&(Ht=d=d.return);continue}break}while(!0)}function pb(){var o=ru.current;return ru.current=Zc,o===null?Zc:o}function Hm(){(Qt===0||Qt===3||Qt===2)&&(Qt=4),nn===null||(Po&268435455)===0&&(ou&268435455)===0||Yr(nn,un)}function du(o,i){var d=rt;rt|=2;var y=pb();(nn!==o||un!==i)&&(vr=null,Io(o,i));do try{Z2();break}catch(k){mb(o,k)}while(!0);if(nm(),rt=d,ru.current=y,Ht!==null)throw Error(s(261));return nn=null,un=0,Qt}function Z2(){for(;Ht!==null;)hb(Ht)}function J2(){for(;Ht!==null&&!pt();)hb(Ht)}function hb(o){var i=bb(o.alternate,o,as);o.memoizedProps=o.pendingProps,i===null?gb(o):Ht=i,Mm.current=null}function gb(o){var i=o;do{var d=i.alternate;if(o=i.return,(i.flags&32768)===0){if(d=G2(d,i,as),d!==null){Ht=d;return}}else{if(d=q2(d,i),d!==null){d.flags&=32767,Ht=d;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{Qt=6,Ht=null;return}}if(i=i.sibling,i!==null){Ht=i;return}Ht=i=o}while(i!==null);Qt===0&&(Qt=5)}function zo(o,i,d){var y=at,k=bs.transition;try{bs.transition=null,at=1,e_(o,i,d,y)}finally{bs.transition=k,at=y}return null}function e_(o,i,d,y){do za();while(Kr!==null);if((rt&6)!==0)throw Error(s(327));d=o.finishedWork;var k=o.finishedLanes;if(d===null)return null;if(o.finishedWork=null,o.finishedLanes=0,d===o.current)throw Error(s(177));o.callbackNode=null,o.callbackPriority=0;var _=d.lanes|d.childLanes;if(ts(o,_),o===nn&&(Ht=nn=null,un=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||iu||(iu=!0,vb(Ct,function(){return za(),null})),_=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||_){_=bs.transition,bs.transition=null;var M=at;at=1;var H=rt;rt|=4,Mm.current=null,K2(o,d),ab(d,o),v2(Hf),kc=!!Wf,Hf=Wf=null,o.current=d,X2(d),zt(),rt=H,at=M,bs.transition=_}else o.current=d;if(iu&&(iu=!1,Kr=o,lu=k),_=o.pendingLanes,_===0&&(Vr=null),gc(d.stateNode),Bn(o,Ve()),i!==null)for(y=o.onRecoverableError,d=0;d<i.length;d++)k=i[d],y(k.value,{componentStack:k.stack,digest:k.digest});if(au)throw au=!1,o=Im,Im=null,o;return(lu&1)!==0&&o.tag!==0&&za(),_=o.pendingLanes,(_&1)!==0?o===zm?al++:(al=0,zm=o):al=0,Hr(),null}function za(){if(Kr!==null){var o=fr(lu),i=bs.transition,d=at;try{if(bs.transition=null,at=16>o?16:o,Kr===null)var y=!1;else{if(o=Kr,Kr=null,lu=0,(rt&6)!==0)throw Error(s(331));var k=rt;for(rt|=4,$e=o.current;$e!==null;){var _=$e,M=_.child;if(($e.flags&16)!==0){var H=_.deletions;if(H!==null){for(var X=0;X<H.length;X++){var re=H[X];for($e=re;$e!==null;){var me=$e;switch(me.tag){case 0:case 11:case 15:sl(8,me,_)}var pe=me.child;if(pe!==null)pe.return=me,$e=pe;else for(;$e!==null;){me=$e;var de=me.sibling,je=me.return;if(tb(me),me===re){$e=null;break}if(de!==null){de.return=je,$e=de;break}$e=je}}}var Re=_.alternate;if(Re!==null){var Oe=Re.child;if(Oe!==null){Re.child=null;do{var Dt=Oe.sibling;Oe.sibling=null,Oe=Dt}while(Oe!==null)}}$e=_}}if((_.subtreeFlags&2064)!==0&&M!==null)M.return=_,$e=M;else e:for(;$e!==null;){if(_=$e,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:sl(9,_,_.return)}var te=_.sibling;if(te!==null){te.return=_.return,$e=te;break e}$e=_.return}}var J=o.current;for($e=J;$e!==null;){M=$e;var ne=M.child;if((M.subtreeFlags&2064)!==0&&ne!==null)ne.return=M,$e=ne;else e:for(M=J;$e!==null;){if(H=$e,(H.flags&2048)!==0)try{switch(H.tag){case 0:case 11:case 15:su(9,H)}}catch(Me){Mt(H,H.return,Me)}if(H===M){$e=null;break e}var ye=H.sibling;if(ye!==null){ye.return=H.return,$e=ye;break e}$e=H.return}}if(rt=k,Hr(),es&&typeof es.onPostCommitFiberRoot=="function")try{es.onPostCommitFiberRoot(jo,o)}catch{}y=!0}return y}finally{at=d,bs.transition=i}}return!1}function xb(o,i,d){i=Ma(d,i),i=Py(o,i,1),o=Gr(o,i,1),i=Sn(),o!==null&&(pn(o,1,i),Bn(o,i))}function Mt(o,i,d){if(o.tag===3)xb(o,o,d);else for(;i!==null;){if(i.tag===3){xb(i,o,d);break}else if(i.tag===1){var y=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Vr===null||!Vr.has(y))){o=Ma(d,o),o=Ly(i,o,1),i=Gr(i,o,1),o=Sn(),i!==null&&(pn(i,1,o),Bn(i,o));break}}i=i.return}}function t_(o,i,d){var y=o.pingCache;y!==null&&y.delete(i),i=Sn(),o.pingedLanes|=o.suspendedLanes&d,nn===o&&(un&d)===d&&(Qt===4||Qt===3&&(un&130023424)===un&&500>Ve()-Lm?Io(o,0):Pm|=d),Bn(o,i)}function yb(o,i){i===0&&((o.mode&1)===0?i=1:(i=So,So<<=1,(So&130023424)===0&&(So=4194304)));var d=Sn();o=xr(o,i),o!==null&&(pn(o,i,d),Bn(o,d))}function n_(o){var i=o.memoizedState,d=0;i!==null&&(d=i.retryLane),yb(o,d)}function s_(o,i){var d=0;switch(o.tag){case 13:var y=o.stateNode,k=o.memoizedState;k!==null&&(d=k.retryLane);break;case 19:y=o.stateNode;break;default:throw Error(s(314))}y!==null&&y.delete(i),yb(o,d)}var bb;bb=function(o,i,d){if(o!==null)if(o.memoizedProps!==i.pendingProps||Fn.current)Wn=!0;else{if((o.lanes&d)===0&&(i.flags&128)===0)return Wn=!1,B2(o,i,d);Wn=(o.flags&131072)!==0}else Wn=!1,_t&&(i.flags&1048576)!==0&&Zx(i,Fc,i.index);switch(i.lanes=0,i.tag){case 2:var y=i.type;tu(o,i),o=i.pendingProps;var k=_a(i,gn.current);Aa(i,d),k=mm(null,i,y,o,k,d);var _=pm();return i.flags|=1,typeof k=="object"&&k!==null&&typeof k.render=="function"&&k.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,Un(y)?(_=!0,Ic(i)):_=!1,i.memoizedState=k.state!==null&&k.state!==void 0?k.state:null,am(i),k.updater=Jc,i.stateNode=k,k._reactInternals=i,vm(i,y,o,d),i=Nm(null,i,y,!0,_,d)):(i.tag=0,_t&&_&&Yf(i),Nn(null,i,k,d),i=i.child),i;case 16:y=i.elementType;e:{switch(tu(o,i),o=i.pendingProps,k=y._init,y=k(y._payload),i.type=y,k=i.tag=o_(y),o=Is(y,o),k){case 0:i=jm(null,i,y,o,d);break e;case 1:i=Gy(null,i,y,o,d);break e;case 11:i=Fy(null,i,y,o,d);break e;case 14:i=Uy(null,i,y,Is(y.type,o),d);break e}throw Error(s(306,y,""))}return i;case 0:return y=i.type,k=i.pendingProps,k=i.elementType===y?k:Is(y,k),jm(o,i,y,k,d);case 1:return y=i.type,k=i.pendingProps,k=i.elementType===y?k:Is(y,k),Gy(o,i,y,k,d);case 3:e:{if(qy(i),o===null)throw Error(s(387));y=i.pendingProps,_=i.memoizedState,k=_.element,iy(o,i),qc(i,y,null,d);var M=i.memoizedState;if(y=M.element,_.isDehydrated)if(_={element:y,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},i.updateQueue.baseState=_,i.memoizedState=_,i.flags&256){k=Ma(Error(s(423)),i),i=Vy(o,i,y,d,k);break e}else if(y!==k){k=Ma(Error(s(424)),i),i=Vy(o,i,y,d,k);break e}else for(os=Fr(i.stateNode.containerInfo.firstChild),rs=i,_t=!0,Ls=null,d=oy(i,null,y,d),i.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(Ca(),y===k){i=br(o,i,d);break e}Nn(o,i,y,d)}i=i.child}return i;case 5:return uy(i),o===null&&Jf(i),y=i.type,k=i.pendingProps,_=o!==null?o.memoizedProps:null,M=k.children,Bf(y,k)?M=null:_!==null&&Bf(y,_)&&(i.flags|=32),By(o,i),Nn(o,i,M,d),i.child;case 6:return o===null&&Jf(i),null;case 13:return Ky(o,i,d);case 4:return im(i,i.stateNode.containerInfo),y=i.pendingProps,o===null?i.child=Ta(i,null,y,d):Nn(o,i,y,d),i.child;case 11:return y=i.type,k=i.pendingProps,k=i.elementType===y?k:Is(y,k),Fy(o,i,y,k,d);case 7:return Nn(o,i,i.pendingProps,d),i.child;case 8:return Nn(o,i,i.pendingProps.children,d),i.child;case 12:return Nn(o,i,i.pendingProps.children,d),i.child;case 10:e:{if(y=i.type._context,k=i.pendingProps,_=i.memoizedProps,M=k.value,bt(Hc,y._currentValue),y._currentValue=M,_!==null)if(Ps(_.value,M)){if(_.children===k.children&&!Fn.current){i=br(o,i,d);break e}}else for(_=i.child,_!==null&&(_.return=i);_!==null;){var H=_.dependencies;if(H!==null){M=_.child;for(var X=H.firstContext;X!==null;){if(X.context===y){if(_.tag===1){X=yr(-1,d&-d),X.tag=2;var re=_.updateQueue;if(re!==null){re=re.shared;var me=re.pending;me===null?X.next=X:(X.next=me.next,me.next=X),re.pending=X}}_.lanes|=d,X=_.alternate,X!==null&&(X.lanes|=d),rm(_.return,d,i),H.lanes|=d;break}X=X.next}}else if(_.tag===10)M=_.type===i.type?null:_.child;else if(_.tag===18){if(M=_.return,M===null)throw Error(s(341));M.lanes|=d,H=M.alternate,H!==null&&(H.lanes|=d),rm(M,d,i),M=_.sibling}else M=_.child;if(M!==null)M.return=_;else for(M=_;M!==null;){if(M===i){M=null;break}if(_=M.sibling,_!==null){_.return=M.return,M=_;break}M=M.return}_=M}Nn(o,i,k.children,d),i=i.child}return i;case 9:return k=i.type,y=i.pendingProps.children,Aa(i,d),k=xs(k),y=y(k),i.flags|=1,Nn(o,i,y,d),i.child;case 14:return y=i.type,k=Is(y,i.pendingProps),k=Is(y.type,k),Uy(o,i,y,k,d);case 15:return Wy(o,i,i.type,i.pendingProps,d);case 17:return y=i.type,k=i.pendingProps,k=i.elementType===y?k:Is(y,k),tu(o,i),i.tag=1,Un(y)?(o=!0,Ic(i)):o=!1,Aa(i,d),Oy(i,y,k),vm(i,y,k,d),Nm(null,i,y,!0,o,d);case 19:return Yy(o,i,d);case 22:return Hy(o,i,d)}throw Error(s(156,i.tag))};function vb(o,i){return ge(o,i)}function r_(o,i,d,y){this.tag=o,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vs(o,i,d,y){return new r_(o,i,d,y)}function Bm(o){return o=o.prototype,!(!o||!o.isReactComponent)}function o_(o){if(typeof o=="function")return Bm(o)?1:0;if(o!=null){if(o=o.$$typeof,o===W)return 11;if(o===K)return 14}return 2}function Qr(o,i){var d=o.alternate;return d===null?(d=vs(o.tag,i,o.key,o.mode),d.elementType=o.elementType,d.type=o.type,d.stateNode=o.stateNode,d.alternate=o,o.alternate=d):(d.pendingProps=i,d.type=o.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=o.flags&14680064,d.childLanes=o.childLanes,d.lanes=o.lanes,d.child=o.child,d.memoizedProps=o.memoizedProps,d.memoizedState=o.memoizedState,d.updateQueue=o.updateQueue,i=o.dependencies,d.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},d.sibling=o.sibling,d.index=o.index,d.ref=o.ref,d}function fu(o,i,d,y,k,_){var M=2;if(y=o,typeof o=="function")Bm(o)&&(M=1);else if(typeof o=="string")M=5;else e:switch(o){case T:return Do(d.children,k,_,i);case A:M=8,k|=8;break;case F:return o=vs(12,d,i,k|2),o.elementType=F,o.lanes=_,o;case U:return o=vs(13,d,i,k),o.elementType=U,o.lanes=_,o;case D:return o=vs(19,d,i,k),o.elementType=D,o.lanes=_,o;case G:return mu(d,k,_,i);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case L:M=10;break e;case z:M=9;break e;case W:M=11;break e;case K:M=14;break e;case P:M=16,y=null;break e}throw Error(s(130,o==null?o:typeof o,""))}return i=vs(M,d,i,k),i.elementType=o,i.type=y,i.lanes=_,i}function Do(o,i,d,y){return o=vs(7,o,y,i),o.lanes=d,o}function mu(o,i,d,y){return o=vs(22,o,y,i),o.elementType=G,o.lanes=d,o.stateNode={isHidden:!1},o}function Gm(o,i,d){return o=vs(6,o,null,i),o.lanes=d,o}function qm(o,i,d){return i=vs(4,o.children!==null?o.children:[],o.key,i),i.lanes=d,i.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},i}function a_(o,i,d,y,k){this.tag=i,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ye(0),this.expirationTimes=Ye(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ye(0),this.identifierPrefix=y,this.onRecoverableError=k,this.mutableSourceEagerHydrationData=null}function Vm(o,i,d,y,k,_,M,H,X){return o=new a_(o,i,d,H,X),i===1?(i=1,_===!0&&(i|=8)):i=0,_=vs(3,null,null,i),o.current=_,_.stateNode=o,_.memoizedState={element:y,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},am(_),o}function i_(o,i,d){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:C,key:y==null?null:""+y,children:o,containerInfo:i,implementation:d}}function wb(o){if(!o)return Wr;o=o._reactInternals;e:{if(ps(o)!==o||o.tag!==1)throw Error(s(170));var i=o;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(Un(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(s(171))}if(o.tag===1){var d=o.type;if(Un(d))return Xx(o,d,i)}return i}function kb(o,i,d,y,k,_,M,H,X){return o=Vm(d,y,!0,o,k,_,M,H,X),o.context=wb(null),d=o.current,y=Sn(),k=Xr(d),_=yr(y,k),_.callback=i??null,Gr(d,_,k),o.current.lanes=k,pn(o,k,y),Bn(o,y),o}function pu(o,i,d,y){var k=i.current,_=Sn(),M=Xr(k);return d=wb(d),i.context===null?i.context=d:i.pendingContext=d,i=yr(_,M),i.payload={element:o},y=y===void 0?null:y,y!==null&&(i.callback=y),o=Gr(k,i,M),o!==null&&(Fs(o,k,M,_),Gc(o,k,M)),M}function hu(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function jb(o,i){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var d=o.retryLane;o.retryLane=d!==0&&d<i?d:i}}function Km(o,i){jb(o,i),(o=o.alternate)&&jb(o,i)}function l_(){return null}var Nb=typeof reportError=="function"?reportError:function(o){console.error(o)};function Xm(o){this._internalRoot=o}gu.prototype.render=Xm.prototype.render=function(o){var i=this._internalRoot;if(i===null)throw Error(s(409));pu(o,i,null,null)},gu.prototype.unmount=Xm.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var i=o.containerInfo;Lo(function(){pu(null,o,null,null)}),i[mr]=null}};function gu(o){this._internalRoot=o}gu.prototype.unstable_scheduleHydration=function(o){if(o){var i=Ti();o={blockedOn:null,target:o,priority:i};for(var d=0;d<Ir.length&&i!==0&&i<Ir[d].priority;d++);Ir.splice(d,0,o),d===0&&ux(o)}};function Ym(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function xu(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function Sb(){}function c_(o,i,d,y,k){if(k){if(typeof y=="function"){var _=y;y=function(){var re=hu(M);_.call(re)}}var M=kb(i,y,o,0,null,!1,!1,"",Sb);return o._reactRootContainer=M,o[mr]=M.current,Bi(o.nodeType===8?o.parentNode:o),Lo(),M}for(;k=o.lastChild;)o.removeChild(k);if(typeof y=="function"){var H=y;y=function(){var re=hu(X);H.call(re)}}var X=Vm(o,0,!1,null,null,!1,!1,"",Sb);return o._reactRootContainer=X,o[mr]=X.current,Bi(o.nodeType===8?o.parentNode:o),Lo(function(){pu(i,X,d,y)}),X}function yu(o,i,d,y,k){var _=d._reactRootContainer;if(_){var M=_;if(typeof k=="function"){var H=k;k=function(){var X=hu(M);H.call(X)}}pu(i,M,o,k)}else M=c_(d,i,o,k,y);return hu(M)}vc=function(o){switch(o.tag){case 3:var i=o.stateNode;if(i.current.memoizedState.isDehydrated){var d=Or(i.pendingLanes);d!==0&&(hn(i,d|1),Bn(i,Ve()),(rt&6)===0&&(Ia=Ve()+500,Hr()))}break;case 13:Lo(function(){var y=xr(o,1);if(y!==null){var k=Sn();Fs(y,o,1,k)}}),Km(o,1)}},ga=function(o){if(o.tag===13){var i=xr(o,134217728);if(i!==null){var d=Sn();Fs(i,o,134217728,d)}Km(o,134217728)}},Ci=function(o){if(o.tag===13){var i=Xr(o),d=xr(o,i);if(d!==null){var y=Sn();Fs(d,o,i,y)}Km(o,i)}},Ti=function(){return at},$o=function(o,i){var d=at;try{return at=o,i()}finally{at=d}},Yn=function(o,i,d){switch(i){case"input":if(He(o,d),i=d.name,d.type==="radio"&&i!=null){for(d=o;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<d.length;i++){var y=d[i];if(y!==o&&y.form===o.form){var k=Pc(y);if(!k)throw Error(s(90));ke(y),He(y,k)}}}break;case"textarea":on(o,d);break;case"select":i=d.value,i!=null&&lt(o,!!d.multiple,i,!1)}},Q=Um,Ae=Lo;var u_={usingClientEntryPoint:!1,Events:[Vi,Na,Pc,dr,yt,Um]},il={findFiberByHostInstance:Eo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},d_={bundleType:il.bundleType,version:il.version,rendererPackageName:il.rendererPackageName,rendererConfig:il.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=Pe(o),o===null?null:o.stateNode},findFiberByHostInstance:il.findFiberByHostInstance||l_,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 bu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!bu.isDisabled&&bu.supportsFiber)try{jo=bu.inject(d_),es=bu}catch{}}return Gn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=u_,Gn.createPortal=function(o,i){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ym(i))throw Error(s(200));return i_(o,i,null,d)},Gn.createRoot=function(o,i){if(!Ym(o))throw Error(s(299));var d=!1,y="",k=Nb;return i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(y=i.identifierPrefix),i.onRecoverableError!==void 0&&(k=i.onRecoverableError)),i=Vm(o,1,!1,null,null,d,!1,y,k),o[mr]=i.current,Bi(o.nodeType===8?o.parentNode:o),new Xm(i)},Gn.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var i=o._reactInternals;if(i===void 0)throw typeof o.render=="function"?Error(s(188)):(o=Object.keys(o).join(","),Error(s(268,o)));return o=Pe(i),o=o===null?null:o.stateNode,o},Gn.flushSync=function(o){return Lo(o)},Gn.hydrate=function(o,i,d){if(!xu(i))throw Error(s(200));return yu(null,o,i,!0,d)},Gn.hydrateRoot=function(o,i,d){if(!Ym(o))throw Error(s(405));var y=d!=null&&d.hydratedSources||null,k=!1,_="",M=Nb;if(d!=null&&(d.unstable_strictMode===!0&&(k=!0),d.identifierPrefix!==void 0&&(_=d.identifierPrefix),d.onRecoverableError!==void 0&&(M=d.onRecoverableError)),i=kb(i,null,o,1,d??null,k,!1,_,M),o[mr]=i.current,Bi(o),y)for(o=0;o<y.length;o++)d=y[o],k=d._getVersion,k=k(d._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[d,k]:i.mutableSourceEagerHydrationData.push(d,k);return new gu(i)},Gn.render=function(o,i,d){if(!xu(i))throw Error(s(200));return yu(null,o,i,!1,d)},Gn.unmountComponentAtNode=function(o){if(!xu(o))throw Error(s(40));return o._reactRootContainer?(Lo(function(){yu(null,null,o,!1,function(){o._reactRootContainer=null,o[mr]=null})}),!0):!1},Gn.unstable_batchedUpdates=Um,Gn.unstable_renderSubtreeIntoContainer=function(o,i,d,y){if(!xu(d))throw Error(s(200));if(o==null||o._reactInternals===void 0)throw Error(s(38));return yu(o,i,d,!1,y)},Gn.version="18.3.1-next-f1338f8080-20240426",Gn}var Ob;function $0(){if(Ob)return Jm.exports;Ob=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Jm.exports=w_(),Jm.exports}var Mb;function k_(){if(Mb)return vu;Mb=1;var e=$0();return vu.createRoot=e.createRoot,vu.hydrateRoot=e.hydrateRoot,vu}var j_=k_();const $t=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),N_=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Wp=128,S_=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},Hp=(e,t=0)=>t>Wp?'"…"':Array.isArray(e)?`[${e.map(s=>Hp(s,t+1)).join(",")}]`:$t(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${Hp(e[s],t+1)}`).join(",")}}`:S_(e),__=e=>{let t=2166136261;for(let s=0;s<e.length;s+=1)t=Math.imul(t^e.charCodeAt(s),16777619);return(t>>>0).toString(16).padStart(8,"0")},cl=(e,t)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==t)),$_=e=>{switch(e.node){case"chain":return cl(e,"steps");case"parallel":return cl(e,"branches");case"map":case"loop":return cl(e,"body");case"route":return $t(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([t,s])=>[t,$t(s)?cl(s,"body"):s]))}:e;case"workflow":return $t(e.workflow)?{...e,workflow:cl(e.workflow,"root")}:e;default:return e}};function oi(e){const t=[],s=[],r=(a,l,c,u)=>{if(!$t(a)||typeof a.node!="string"||c>Wp)return;t.push({path:l,kind:a.node,label:typeof a.label=="string"?a.label:a.node,...a.node==="call"&&typeof a.via=="string"?{via:a.via}:{},changeCheck:__(Hp($_(a))),...C_(a,u)});const f=(p,g,v,h=l,m=u)=>{!$t(p)||typeof p.node!="string"||c+1>Wp||(s.push({from:h,to:g,kind:v}),r(p,g,c+1,m))};switch(a.node){case"chain":Array.isArray(a.steps)&&a.steps.forEach((p,g)=>f(p,`${l}/steps/${g}`,"next",g===0?l:`${l}/steps/${g-1}`));break;case"parallel":Array.isArray(a.branches)&&a.branches.forEach((p,g)=>f(p,`${l}/branches/${g}`,"branch"));break;case"map":f(a.body,`${l}/body`,"item");break;case"loop":f(a.body,`${l}/body`,"next");break;case"route":if($t(a.branches))for(const[p,g]of Object.entries(a.branches))$t(g)&&f(g.body,`${l}/branches/${N_(p)}/body`,"route");break;case"workflow":$t(a.workflow)&&f(a.workflow.root,`${l}/workflow/root`,"child",l,$t(a.workflow.schemas)?a.workflow.schemas:{});break}};return r($t(e)?e.root:void 0,"/root",0,$t(e)&&$t(e.schemas)?e.schemas:{}),{nodes:t,edges:s}}const E_=(e,t)=>{const s=typeof e=="string"&&Object.hasOwn(t,e)?t[e]:void 0,r=l=>{var c;for(let u=0;$t(l)&&typeof l.$ref=="string"&&u<8;u+=1){const f=(c=/^#\/definitions\/(.+)$/.exec(l.$ref))==null?void 0:c[1],p=$t(s)&&$t(s.definitions)?s.definitions:{};l=f===void 0?void 0:Object.hasOwn(p,f)?p[f]:Object.hasOwn(t,f)?t[f]:void 0}return l},a=r(s);return!$t(a)||!$t(a.properties)?[]:Object.entries(a.properties).map(([l,c])=>{const u=r(c),f=$t(u)&&typeof u.description=="string"?u.description:"",p=$t(u)?(Array.isArray(u.type)?u.type:[u.type]).filter(g=>g!=="null"):[];return $t(u)&&Array.isArray(u.enum)?{id:l,type:"choice",instructions:f,options:u.enum.map(String)}:p.length===1&&p[0]==="boolean"?{id:l,type:"noul",instructions:f}:p.length===1&&p[0]==="integer"?{id:l,type:"score",instructions:f}:{id:l,type:"unknown",instructions:f}})},C_=(e,t)=>{let s=e,r;const a=l=>typeof l=="string"?l:"";switch(e.node){case"judge":case"sift":r=E_(e.out,t);break;case"pick":r=[{id:"pick",type:"choice",instructions:a(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};r=[{id:"branch",type:"choice",instructions:a(e.instructions),options:$t(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const l=e.node==="loop"?e.until:e.when;if(!$t(l)||l.predicate!=="ask")return{};s=l,r=[{id:"holds",type:"noul",instructions:a(l.instructions)}];break}default:return{}}return{...typeof s.provider=="string"?{provider:s.provider}:{},...typeof s.model=="string"?{model:s.model}:{},questions:r,...$t(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function E0(e,t){const s=$=>JSON.stringify([$.kind,$.label]),r=$=>{const S=new Map;for(const E of $.nodes)S.set(s(E),(S.get(s(E))??0)+1);return S},[a,l]=[r(e),r(t)],c=$=>a.get(s($))===1&&l.get(s($))===1,u=new Map,f=new Map,p=($,S)=>{u.set(S,$),f.set($,S)},g=new Map(e.nodes.filter(c).map($=>[s($),$.path]));for(const $ of t.nodes){const S=c($)?g.get(s($)):void 0;S!==void 0&&p(S,$.path)}const v=new Map(e.nodes.map($=>[$.path,$])),h=[];for(const $ of t.nodes){const S=v.get($.path);u.has($.path)||S===void 0||f.has(S.path)||(p(S.path,$.path),(S.kind!==$.kind||S.label!==$.label)&&h.push({prev:S.path,next:$.path,was:{kind:S.kind,label:S.label},now:{kind:$.kind,label:$.label}}))}const m=[];for(const $ of t.nodes){const S=u.get($.path),E=S===void 0?void 0:v.get(S);E===void 0||E.kind!==$.kind||E.label!==$.label||E.changeCheck!==void 0&&$.changeCheck!==void 0&&E.changeCheck!==$.changeCheck&&m.push({prev:E.path,next:$.path,kind:$.kind,label:$.label})}const b=({path:$,kind:S,label:E})=>({path:$,kind:S,label:E}),w=($,S,E)=>JSON.stringify([$,S,E]),j=new Set(e.edges.map($=>w($.from,$.to,$.kind))),N=new Set(t.edges.map($=>w($.from,$.to,$.kind))),R=($,S,E)=>{const[C,T]=[S.get($.from),S.get($.to)];return C!==void 0&&T!==void 0&&E.has(w(C,T,$.kind))};return{added:t.nodes.filter($=>!u.has($.path)).map(b),removed:e.nodes.filter($=>!f.has($.path)).map(b),changed:h,moved:t.nodes.flatMap($=>{const S=u.get($.path);return S!==void 0&&S!==$.path?[{prev:S,next:$.path}]:[]}),rewritten:m,edges:{added:t.edges.filter($=>!R($,u,j)).map(({from:$,to:S,kind:E})=>({from:$,to:S,kind:E})),removed:e.edges.filter($=>!R($,f,N)).map(({from:$,to:S,kind:E})=>({from:$,to:S,kind:E}))}}}/**
41
+ * @license lucide-react v0.468.0 - ISC
42
+ *
43
+ * This source code is licensed under the ISC license.
44
+ * See the LICENSE file in the root directory of this source tree.
45
+ */const T_=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),C0=(...e)=>e.filter((t,s,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===s).join(" ").trim();/**
46
+ * @license lucide-react v0.468.0 - ISC
47
+ *
48
+ * This source code is licensed under the ISC license.
49
+ * See the LICENSE file in the root directory of this source tree.
50
+ */var R_={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
51
+ * @license lucide-react v0.468.0 - ISC
52
+ *
53
+ * This source code is licensed under the ISC license.
54
+ * See the LICENSE file in the root directory of this source tree.
55
+ */const A_=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:a="",children:l,iconNode:c,...u},f)=>x.createElement("svg",{ref:f,...R_,width:t,height:t,stroke:e,strokeWidth:r?Number(s)*24/Number(t):s,className:C0("lucide",a),...u},[...c.map(([p,g])=>x.createElement(p,g)),...Array.isArray(l)?l:[l]]));/**
56
+ * @license lucide-react v0.468.0 - ISC
57
+ *
58
+ * This source code is licensed under the ISC license.
59
+ * See the LICENSE file in the root directory of this source tree.
60
+ */const ve=(e,t)=>{const s=x.forwardRef(({className:r,...a},l)=>x.createElement(A_,{ref:l,iconNode:t,className:C0(`lucide-${T_(e)}`,r),...a}));return s.displayName=`${e}`,s};/**
61
+ * @license lucide-react v0.468.0 - ISC
62
+ *
63
+ * This source code is licensed under the ISC license.
64
+ * See the LICENSE file in the root directory of this source tree.
65
+ */const T0=ve("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
66
+ * @license lucide-react v0.468.0 - ISC
67
+ *
68
+ * This source code is licensed under the ISC license.
69
+ * See the LICENSE file in the root directory of this source tree.
70
+ */const Kl=ve("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
71
+ * @license lucide-react v0.468.0 - ISC
72
+ *
73
+ * This source code is licensed under the ISC license.
74
+ * See the LICENSE file in the root directory of this source tree.
75
+ */const qs=ve("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
76
+ * @license lucide-react v0.468.0 - ISC
77
+ *
78
+ * This source code is licensed under the ISC license.
79
+ * See the LICENSE file in the root directory of this source tree.
80
+ */const Dh=ve("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
81
+ * @license lucide-react v0.468.0 - ISC
82
+ *
83
+ * This source code is licensed under the ISC license.
84
+ * See the LICENSE file in the root directory of this source tree.
85
+ */const O_=ve("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
86
+ * @license lucide-react v0.468.0 - ISC
87
+ *
88
+ * This source code is licensed under the ISC license.
89
+ * See the LICENSE file in the root directory of this source tree.
90
+ */const R0=ve("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
91
+ * @license lucide-react v0.468.0 - ISC
92
+ *
93
+ * This source code is licensed under the ISC license.
94
+ * See the LICENSE file in the root directory of this source tree.
95
+ */const Zu=ve("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
96
+ * @license lucide-react v0.468.0 - ISC
97
+ *
98
+ * This source code is licensed under the ISC license.
99
+ * See the LICENSE file in the root directory of this source tree.
100
+ */const Fh=ve("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
101
+ * @license lucide-react v0.468.0 - ISC
102
+ *
103
+ * This source code is licensed under the ISC license.
104
+ * See the LICENSE file in the root directory of this source tree.
105
+ */const M_=ve("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
106
+ * @license lucide-react v0.468.0 - ISC
107
+ *
108
+ * This source code is licensed under the ISC license.
109
+ * See the LICENSE file in the root directory of this source tree.
110
+ */const Pd=ve("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
111
+ * @license lucide-react v0.468.0 - ISC
112
+ *
113
+ * This source code is licensed under the ISC license.
114
+ * See the LICENSE file in the root directory of this source tree.
115
+ */const Ld=ve("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
116
+ * @license lucide-react v0.468.0 - ISC
117
+ *
118
+ * This source code is licensed under the ISC license.
119
+ * See the LICENSE file in the root directory of this source tree.
120
+ */const aa=ve("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
121
+ * @license lucide-react v0.468.0 - ISC
122
+ *
123
+ * This source code is licensed under the ISC license.
124
+ * See the LICENSE file in the root directory of this source tree.
125
+ */const P_=ve("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
126
+ * @license lucide-react v0.468.0 - ISC
127
+ *
128
+ * This source code is licensed under the ISC license.
129
+ * See the LICENSE file in the root directory of this source tree.
130
+ */const Rs=ve("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
131
+ * @license lucide-react v0.468.0 - ISC
132
+ *
133
+ * This source code is licensed under the ISC license.
134
+ * See the LICENSE file in the root directory of this source tree.
135
+ */const ai=ve("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
136
+ * @license lucide-react v0.468.0 - ISC
137
+ *
138
+ * This source code is licensed under the ISC license.
139
+ * See the LICENSE file in the root directory of this source tree.
140
+ */const L_=ve("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
141
+ * @license lucide-react v0.468.0 - ISC
142
+ *
143
+ * This source code is licensed under the ISC license.
144
+ * See the LICENSE file in the root directory of this source tree.
145
+ */const A0=ve("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
146
+ * @license lucide-react v0.468.0 - ISC
147
+ *
148
+ * This source code is licensed under the ISC license.
149
+ * See the LICENSE file in the root directory of this source tree.
150
+ */const Uh=ve("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
151
+ * @license lucide-react v0.468.0 - ISC
152
+ *
153
+ * This source code is licensed under the ISC license.
154
+ * See the LICENSE file in the root directory of this source tree.
155
+ */const O0=ve("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
156
+ * @license lucide-react v0.468.0 - ISC
157
+ *
158
+ * This source code is licensed under the ISC license.
159
+ * See the LICENSE file in the root directory of this source tree.
160
+ */const I_=ve("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
161
+ * @license lucide-react v0.468.0 - ISC
162
+ *
163
+ * This source code is licensed under the ISC license.
164
+ * See the LICENSE file in the root directory of this source tree.
165
+ */const Id=ve("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
166
+ * @license lucide-react v0.468.0 - ISC
167
+ *
168
+ * This source code is licensed under the ISC license.
169
+ * See the LICENSE file in the root directory of this source tree.
170
+ */const z_=ve("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
171
+ * @license lucide-react v0.468.0 - ISC
172
+ *
173
+ * This source code is licensed under the ISC license.
174
+ * See the LICENSE file in the root directory of this source tree.
175
+ */const D_=ve("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
176
+ * @license lucide-react v0.468.0 - ISC
177
+ *
178
+ * This source code is licensed under the ISC license.
179
+ * See the LICENSE file in the root directory of this source tree.
180
+ */const F_=ve("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
181
+ * @license lucide-react v0.468.0 - ISC
182
+ *
183
+ * This source code is licensed under the ISC license.
184
+ * See the LICENSE file in the root directory of this source tree.
185
+ */const M0=ve("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
186
+ * @license lucide-react v0.468.0 - ISC
187
+ *
188
+ * This source code is licensed under the ISC license.
189
+ * See the LICENSE file in the root directory of this source tree.
190
+ */const gi=ve("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
191
+ * @license lucide-react v0.468.0 - ISC
192
+ *
193
+ * This source code is licensed under the ISC license.
194
+ * See the LICENSE file in the root directory of this source tree.
195
+ */const P0=ve("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
196
+ * @license lucide-react v0.468.0 - ISC
197
+ *
198
+ * This source code is licensed under the ISC license.
199
+ * See the LICENSE file in the root directory of this source tree.
200
+ */const U_=ve("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
201
+ * @license lucide-react v0.468.0 - ISC
202
+ *
203
+ * This source code is licensed under the ISC license.
204
+ * See the LICENSE file in the root directory of this source tree.
205
+ */const Wh=ve("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/**
206
+ * @license lucide-react v0.468.0 - ISC
207
+ *
208
+ * This source code is licensed under the ISC license.
209
+ * See the LICENSE file in the root directory of this source tree.
210
+ */const Pb=ve("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/**
211
+ * @license lucide-react v0.468.0 - ISC
212
+ *
213
+ * This source code is licensed under the ISC license.
214
+ * See the LICENSE file in the root directory of this source tree.
215
+ */const L0=ve("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
216
+ * @license lucide-react v0.468.0 - ISC
217
+ *
218
+ * This source code is licensed under the ISC license.
219
+ * See the LICENSE file in the root directory of this source tree.
220
+ */const W_=ve("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
221
+ * @license lucide-react v0.468.0 - ISC
222
+ *
223
+ * This source code is licensed under the ISC license.
224
+ * See the LICENSE file in the root directory of this source tree.
225
+ */const Hh=ve("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
226
+ * @license lucide-react v0.468.0 - ISC
227
+ *
228
+ * This source code is licensed under the ISC license.
229
+ * See the LICENSE file in the root directory of this source tree.
230
+ */const Bh=ve("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/**
231
+ * @license lucide-react v0.468.0 - ISC
232
+ *
233
+ * This source code is licensed under the ISC license.
234
+ * See the LICENSE file in the root directory of this source tree.
235
+ */const Bp=ve("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
236
+ * @license lucide-react v0.468.0 - ISC
237
+ *
238
+ * This source code is licensed under the ISC license.
239
+ * See the LICENSE file in the root directory of this source tree.
240
+ */const Qo=ve("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
241
+ * @license lucide-react v0.468.0 - ISC
242
+ *
243
+ * This source code is licensed under the ISC license.
244
+ * See the LICENSE file in the root directory of this source tree.
245
+ */const H_=ve("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
246
+ * @license lucide-react v0.468.0 - ISC
247
+ *
248
+ * This source code is licensed under the ISC license.
249
+ * See the LICENSE file in the root directory of this source tree.
250
+ */const B_=ve("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
251
+ * @license lucide-react v0.468.0 - ISC
252
+ *
253
+ * This source code is licensed under the ISC license.
254
+ * See the LICENSE file in the root directory of this source tree.
255
+ */const I0=ve("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
256
+ * @license lucide-react v0.468.0 - ISC
257
+ *
258
+ * This source code is licensed under the ISC license.
259
+ * See the LICENSE file in the root directory of this source tree.
260
+ */const G_=ve("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
261
+ * @license lucide-react v0.468.0 - ISC
262
+ *
263
+ * This source code is licensed under the ISC license.
264
+ * See the LICENSE file in the root directory of this source tree.
265
+ */const q_=ve("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
266
+ * @license lucide-react v0.468.0 - ISC
267
+ *
268
+ * This source code is licensed under the ISC license.
269
+ * See the LICENSE file in the root directory of this source tree.
270
+ */const Lb=ve("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/**
271
+ * @license lucide-react v0.468.0 - ISC
272
+ *
273
+ * This source code is licensed under the ISC license.
274
+ * See the LICENSE file in the root directory of this source tree.
275
+ */const V_=ve("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
276
+ * @license lucide-react v0.468.0 - ISC
277
+ *
278
+ * This source code is licensed under the ISC license.
279
+ * See the LICENSE file in the root directory of this source tree.
280
+ */const K_=ve("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
281
+ * @license lucide-react v0.468.0 - ISC
282
+ *
283
+ * This source code is licensed under the ISC license.
284
+ * See the LICENSE file in the root directory of this source tree.
285
+ */const X_=ve("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
286
+ * @license lucide-react v0.468.0 - ISC
287
+ *
288
+ * This source code is licensed under the ISC license.
289
+ * See the LICENSE file in the root directory of this source tree.
290
+ */const Gh=ve("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
291
+ * @license lucide-react v0.468.0 - ISC
292
+ *
293
+ * This source code is licensed under the ISC license.
294
+ * See the LICENSE file in the root directory of this source tree.
295
+ */const Y_=ve("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/**
296
+ * @license lucide-react v0.468.0 - ISC
297
+ *
298
+ * This source code is licensed under the ISC license.
299
+ * See the LICENSE file in the root directory of this source tree.
300
+ */const Q_=ve("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
301
+ * @license lucide-react v0.468.0 - ISC
302
+ *
303
+ * This source code is licensed under the ISC license.
304
+ * See the LICENSE file in the root directory of this source tree.
305
+ */const xi=ve("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
306
+ * @license lucide-react v0.468.0 - ISC
307
+ *
308
+ * This source code is licensed under the ISC license.
309
+ * See the LICENSE file in the root directory of this source tree.
310
+ */const Z_=ve("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
311
+ * @license lucide-react v0.468.0 - ISC
312
+ *
313
+ * This source code is licensed under the ISC license.
314
+ * See the LICENSE file in the root directory of this source tree.
315
+ */const J_=ve("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
316
+ * @license lucide-react v0.468.0 - ISC
317
+ *
318
+ * This source code is licensed under the ISC license.
319
+ * See the LICENSE file in the root directory of this source tree.
320
+ */const ii=ve("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
321
+ * @license lucide-react v0.468.0 - ISC
322
+ *
323
+ * This source code is licensed under the ISC license.
324
+ * See the LICENSE file in the root directory of this source tree.
325
+ */const Xl=ve("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
326
+ * @license lucide-react v0.468.0 - ISC
327
+ *
328
+ * This source code is licensed under the ISC license.
329
+ * See the LICENSE file in the root directory of this source tree.
330
+ */const yi=ve("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
331
+ * @license lucide-react v0.468.0 - ISC
332
+ *
333
+ * This source code is licensed under the ISC license.
334
+ * See the LICENSE file in the root directory of this source tree.
335
+ */const e$=ve("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
336
+ * @license lucide-react v0.468.0 - ISC
337
+ *
338
+ * This source code is licensed under the ISC license.
339
+ * See the LICENSE file in the root directory of this source tree.
340
+ */const Ol=ve("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
341
+ * @license lucide-react v0.468.0 - ISC
342
+ *
343
+ * This source code is licensed under the ISC license.
344
+ * See the LICENSE file in the root directory of this source tree.
345
+ */const t$=ve("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
346
+ * @license lucide-react v0.468.0 - ISC
347
+ *
348
+ * This source code is licensed under the ISC license.
349
+ * See the LICENSE file in the root directory of this source tree.
350
+ */const z0=ve("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
351
+ * @license lucide-react v0.468.0 - ISC
352
+ *
353
+ * This source code is licensed under the ISC license.
354
+ * See the LICENSE file in the root directory of this source tree.
355
+ */const n$=ve("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
356
+ * @license lucide-react v0.468.0 - ISC
357
+ *
358
+ * This source code is licensed under the ISC license.
359
+ * See the LICENSE file in the root directory of this source tree.
360
+ */const s$=ve("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
361
+ * @license lucide-react v0.468.0 - ISC
362
+ *
363
+ * This source code is licensed under the ISC license.
364
+ * See the LICENSE file in the root directory of this source tree.
365
+ */const D0=ve("Settings",[["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",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
366
+ * @license lucide-react v0.468.0 - ISC
367
+ *
368
+ * This source code is licensed under the ISC license.
369
+ * See the LICENSE file in the root directory of this source tree.
370
+ */const F0=ve("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
371
+ * @license lucide-react v0.468.0 - ISC
372
+ *
373
+ * This source code is licensed under the ISC license.
374
+ * See the LICENSE file in the root directory of this source tree.
375
+ */const U0=ve("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
376
+ * @license lucide-react v0.468.0 - ISC
377
+ *
378
+ * This source code is licensed under the ISC license.
379
+ * See the LICENSE file in the root directory of this source tree.
380
+ */const qh=ve("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
381
+ * @license lucide-react v0.468.0 - ISC
382
+ *
383
+ * This source code is licensed under the ISC license.
384
+ * See the LICENSE file in the root directory of this source tree.
385
+ */const r$=ve("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
386
+ * @license lucide-react v0.468.0 - ISC
387
+ *
388
+ * This source code is licensed under the ISC license.
389
+ * See the LICENSE file in the root directory of this source tree.
390
+ */const o$=ve("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
391
+ * @license lucide-react v0.468.0 - ISC
392
+ *
393
+ * This source code is licensed under the ISC license.
394
+ * See the LICENSE file in the root directory of this source tree.
395
+ */const a$=ve("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
396
+ * @license lucide-react v0.468.0 - ISC
397
+ *
398
+ * This source code is licensed under the ISC license.
399
+ * See the LICENSE file in the root directory of this source tree.
400
+ */const W0=ve("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
401
+ * @license lucide-react v0.468.0 - ISC
402
+ *
403
+ * This source code is licensed under the ISC license.
404
+ * See the LICENSE file in the root directory of this source tree.
405
+ */const i$=ve("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
406
+ * @license lucide-react v0.468.0 - ISC
407
+ *
408
+ * This source code is licensed under the ISC license.
409
+ * See the LICENSE file in the root directory of this source tree.
410
+ */const ar=ve("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
411
+ * @license lucide-react v0.468.0 - ISC
412
+ *
413
+ * This source code is licensed under the ISC license.
414
+ * See the LICENSE file in the root directory of this source tree.
415
+ */const Vh=ve("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
416
+ * @license lucide-react v0.468.0 - ISC
417
+ *
418
+ * This source code is licensed under the ISC license.
419
+ * See the LICENSE file in the root directory of this source tree.
420
+ */const Ml=ve("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/**
421
+ * @license lucide-react v0.468.0 - ISC
422
+ *
423
+ * This source code is licensed under the ISC license.
424
+ * See the LICENSE file in the root directory of this source tree.
425
+ */const H0=ve("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
426
+ * @license lucide-react v0.468.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */const ia=ve("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/**
431
+ * @license lucide-react v0.468.0 - ISC
432
+ *
433
+ * This source code is licensed under the ISC license.
434
+ * See the LICENSE file in the root directory of this source tree.
435
+ */const Ju=ve("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
436
+ * @license lucide-react v0.468.0 - ISC
437
+ *
438
+ * This source code is licensed under the ISC license.
439
+ * See the LICENSE file in the root directory of this source tree.
440
+ */const Yl=ve("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
441
+ * @license lucide-react v0.468.0 - ISC
442
+ *
443
+ * This source code is licensed under the ISC license.
444
+ * See the LICENSE file in the root directory of this source tree.
445
+ */const l$=ve("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function B0(e){var t,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(s=B0(e[t]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function G0(){for(var e,t,s=0,r="",a=arguments.length;s<a;s++)(e=arguments[s])&&(t=B0(e))&&(r&&(r+=" "),r+=t);return r}const Kh="-",c$=e=>{const t=d$(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const u=c.split(Kh);return u[0]===""&&u.length!==1&&u.shift(),q0(u,t)||u$(c)},getConflictingClassGroupIds:(c,u)=>{const f=s[c]||[];return u&&r[c]?[...f,...r[c]]:f}}},q0=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const s=e[0],r=t.nextPart.get(s),a=r?q0(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const l=e.join(Kh);return(c=t.validators.find(({validator:u})=>u(l)))==null?void 0:c.classGroupId},Ib=/^\[(.+)\]$/,u$=e=>{if(Ib.test(e)){const t=Ib.exec(e)[1],s=t==null?void 0:t.substring(0,t.indexOf(":"));if(s)return"arbitrary.."+s}},d$=e=>{const{theme:t,prefix:s}=e,r={nextPart:new Map,validators:[]};return m$(Object.entries(e.classGroups),s).forEach(([l,c])=>{Gp(c,r,l,t)}),r},Gp=(e,t,s,r)=>{e.forEach(a=>{if(typeof a=="string"){const l=a===""?t:zb(t,a);l.classGroupId=s;return}if(typeof a=="function"){if(f$(a)){Gp(a(r),t,s,r);return}t.validators.push({validator:a,classGroupId:s});return}Object.entries(a).forEach(([l,c])=>{Gp(c,zb(t,l),s,r)})})},zb=(e,t)=>{let s=e;return t.split(Kh).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},f$=e=>e.isThemeGetter,m$=(e,t)=>t?e.map(([s,r])=>{const a=r.map(l=>typeof l=="string"?t+l:typeof l=="object"?Object.fromEntries(Object.entries(l).map(([c,u])=>[t+c,u])):l);return[s,a]}):e,p$=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=new Map,r=new Map;const a=(l,c)=>{s.set(l,c),t++,t>e&&(t=0,r=s,s=new Map)};return{get(l){let c=s.get(l);if(c!==void 0)return c;if((c=r.get(l))!==void 0)return a(l,c),c},set(l,c){s.has(l)?s.set(l,c):a(l,c)}}},V0="!",h$=e=>{const{separator:t,experimentalParseClassName:s}=e,r=t.length===1,a=t[0],l=t.length,c=u=>{const f=[];let p=0,g=0,v;for(let j=0;j<u.length;j++){let N=u[j];if(p===0){if(N===a&&(r||u.slice(j,j+l)===t)){f.push(u.slice(g,j)),g=j+l;continue}if(N==="/"){v=j;continue}}N==="["?p++:N==="]"&&p--}const h=f.length===0?u:u.substring(g),m=h.startsWith(V0),b=m?h.substring(1):h,w=v&&v>g?v-g:void 0;return{modifiers:f,hasImportantModifier:m,baseClassName:b,maybePostfixModifierPosition:w}};return s?u=>s({className:u,parseClassName:c}):c},g$=e=>{if(e.length<=1)return e;const t=[];let s=[];return e.forEach(r=>{r[0]==="["?(t.push(...s.sort(),r),s=[]):s.push(r)}),t.push(...s.sort()),t},x$=e=>({cache:p$(e.cacheSize),parseClassName:h$(e),...c$(e)}),y$=/\s+/,b$=(e,t)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:a}=t,l=[],c=e.trim().split(y$);let u="";for(let f=c.length-1;f>=0;f-=1){const p=c[f],{modifiers:g,hasImportantModifier:v,baseClassName:h,maybePostfixModifierPosition:m}=s(p);let b=!!m,w=r(b?h.substring(0,m):h);if(!w){if(!b){u=p+(u.length>0?" "+u:u);continue}if(w=r(h),!w){u=p+(u.length>0?" "+u:u);continue}b=!1}const j=g$(g).join(":"),N=v?j+V0:j,R=N+w;if(l.includes(R))continue;l.push(R);const $=a(w,b);for(let S=0;S<$.length;++S){const E=$[S];l.push(N+E)}u=p+(u.length>0?" "+u:u)}return u};function v$(){let e=0,t,s,r="";for(;e<arguments.length;)(t=arguments[e++])&&(s=K0(t))&&(r&&(r+=" "),r+=s);return r}const K0=e=>{if(typeof e=="string")return e;let t,s="";for(let r=0;r<e.length;r++)e[r]&&(t=K0(e[r]))&&(s&&(s+=" "),s+=t);return s};function Db(e,...t){let s,r,a,l=c;function c(f){const p=t.reduce((g,v)=>v(g),e());return s=x$(p),r=s.cache.get,a=s.cache.set,l=u,u(f)}function u(f){const p=r(f);if(p)return p;const g=b$(f,s);return a(f,g),g}return function(){return l(v$.apply(null,arguments))}}const kt=e=>{const t=s=>s[e]||[];return t.isThemeGetter=!0,t},X0=/^\[(?:([a-z-]+):)?(.+)\]$/i,w$=/^\d+\/\d+$/,k$=new Set(["px","full","screen"]),j$=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,N$=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,S$=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,_$=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$$=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,wr=e=>Ka(e)||k$.has(e)||w$.test(e),Jr=e=>bi(e,"length",P$),Ka=e=>!!e&&!Number.isNaN(Number(e)),np=e=>bi(e,"number",Ka),ul=e=>!!e&&Number.isInteger(Number(e)),E$=e=>e.endsWith("%")&&Ka(e.slice(0,-1)),Ke=e=>X0.test(e),eo=e=>j$.test(e),C$=new Set(["length","size","percentage"]),T$=e=>bi(e,C$,Y0),R$=e=>bi(e,"position",Y0),A$=new Set(["image","url"]),O$=e=>bi(e,A$,I$),M$=e=>bi(e,"",L$),dl=()=>!0,bi=(e,t,s)=>{const r=X0.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):s(r[2]):!1},P$=e=>N$.test(e)&&!S$.test(e),Y0=()=>!1,L$=e=>_$.test(e),I$=e=>$$.test(e),Fb=()=>{const e=kt("colors"),t=kt("spacing"),s=kt("blur"),r=kt("brightness"),a=kt("borderColor"),l=kt("borderRadius"),c=kt("borderSpacing"),u=kt("borderWidth"),f=kt("contrast"),p=kt("grayscale"),g=kt("hueRotate"),v=kt("invert"),h=kt("gap"),m=kt("gradientColorStops"),b=kt("gradientColorStopPositions"),w=kt("inset"),j=kt("margin"),N=kt("opacity"),R=kt("padding"),$=kt("saturate"),S=kt("scale"),E=kt("sepia"),C=kt("skew"),T=kt("space"),A=kt("translate"),F=()=>["auto","contain","none"],L=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto",Ke,t],W=()=>[Ke,t],U=()=>["",wr,Jr],D=()=>["auto",Ka,Ke],K=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],P=()=>["solid","dashed","dotted","double","none"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],I=()=>["start","end","center","between","around","evenly","stretch"],Y=()=>["","0",Ke],q=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>[Ka,Ke];return{cacheSize:500,separator:":",theme:{colors:[dl],spacing:[wr,Jr],blur:["none","",eo,Ke],brightness:O(),borderColor:[e],borderRadius:["none","","full",eo,Ke],borderSpacing:W(),borderWidth:U(),contrast:O(),grayscale:Y(),hueRotate:O(),invert:Y(),gap:W(),gradientColorStops:[e],gradientColorStopPositions:[E$,Jr],inset:z(),margin:z(),opacity:O(),padding:W(),saturate:O(),scale:O(),sepia:Y(),skew:O(),space:W(),translate:W()},classGroups:{aspect:[{aspect:["auto","square","video",Ke]}],container:["container"],columns:[{columns:[eo]}],"break-after":[{"break-after":q()}],"break-before":[{"break-before":q()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...K(),Ke]}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],overscroll:[{overscroll:F()}],"overscroll-x":[{"overscroll-x":F()}],"overscroll-y":[{"overscroll-y":F()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ul,Ke]}],basis:[{basis:z()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ke]}],grow:[{grow:Y()}],shrink:[{shrink:Y()}],order:[{order:["first","last","none",ul,Ke]}],"grid-cols":[{"grid-cols":[dl]}],"col-start-end":[{col:["auto",{span:["full",ul,Ke]},Ke]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[dl]}],"row-start-end":[{row:["auto",{span:[ul,Ke]},Ke]}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ke]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ke]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...I()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...I(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...I(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[R]}],px:[{px:[R]}],py:[{py:[R]}],ps:[{ps:[R]}],pe:[{pe:[R]}],pt:[{pt:[R]}],pr:[{pr:[R]}],pb:[{pb:[R]}],pl:[{pl:[R]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ke,t]}],"min-w":[{"min-w":[Ke,t,"min","max","fit"]}],"max-w":[{"max-w":[Ke,t,"none","full","min","max","fit","prose",{screen:[eo]},eo]}],h:[{h:[Ke,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ke,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ke,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ke,t,"auto","min","max","fit"]}],"font-size":[{text:["base",eo,Jr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",np]}],"font-family":[{font:[dl]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Ke]}],"line-clamp":[{"line-clamp":["none",Ka,np]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",wr,Ke]}],"list-image":[{"list-image":["none",Ke]}],"list-style-type":[{list:["none","disc","decimal",Ke]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...P(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",wr,Jr]}],"underline-offset":[{"underline-offset":["auto",wr,Ke]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:W()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...K(),R$]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",T$]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},O$]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[l]}],"rounded-s":[{"rounded-s":[l]}],"rounded-e":[{"rounded-e":[l]}],"rounded-t":[{"rounded-t":[l]}],"rounded-r":[{"rounded-r":[l]}],"rounded-b":[{"rounded-b":[l]}],"rounded-l":[{"rounded-l":[l]}],"rounded-ss":[{"rounded-ss":[l]}],"rounded-se":[{"rounded-se":[l]}],"rounded-ee":[{"rounded-ee":[l]}],"rounded-es":[{"rounded-es":[l]}],"rounded-tl":[{"rounded-tl":[l]}],"rounded-tr":[{"rounded-tr":[l]}],"rounded-br":[{"rounded-br":[l]}],"rounded-bl":[{"rounded-bl":[l]}],"border-w":[{border:[u]}],"border-w-x":[{"border-x":[u]}],"border-w-y":[{"border-y":[u]}],"border-w-s":[{"border-s":[u]}],"border-w-e":[{"border-e":[u]}],"border-w-t":[{"border-t":[u]}],"border-w-r":[{"border-r":[u]}],"border-w-b":[{"border-b":[u]}],"border-w-l":[{"border-l":[u]}],"border-opacity":[{"border-opacity":[N]}],"border-style":[{border:[...P(),"hidden"]}],"divide-x":[{"divide-x":[u]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[u]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[N]}],"divide-style":[{divide:P()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...P()]}],"outline-offset":[{"outline-offset":[wr,Ke]}],"outline-w":[{outline:[wr,Jr]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[wr,Jr]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",eo,M$]}],"shadow-color":[{shadow:[dl]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...G(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":G()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",eo,Ke]}],grayscale:[{grayscale:[p]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[v]}],saturate:[{saturate:[$]}],sepia:[{sepia:[E]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[p]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[g]}],"backdrop-invert":[{"backdrop-invert":[v]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[$]}],"backdrop-sepia":[{"backdrop-sepia":[E]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ke]}],duration:[{duration:O()}],ease:[{ease:["linear","in","out","in-out",Ke]}],delay:[{delay:O()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ke]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[ul,Ke]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ke]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ke]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":W()}],"scroll-mx":[{"scroll-mx":W()}],"scroll-my":[{"scroll-my":W()}],"scroll-ms":[{"scroll-ms":W()}],"scroll-me":[{"scroll-me":W()}],"scroll-mt":[{"scroll-mt":W()}],"scroll-mr":[{"scroll-mr":W()}],"scroll-mb":[{"scroll-mb":W()}],"scroll-ml":[{"scroll-ml":W()}],"scroll-p":[{"scroll-p":W()}],"scroll-px":[{"scroll-px":W()}],"scroll-py":[{"scroll-py":W()}],"scroll-ps":[{"scroll-ps":W()}],"scroll-pe":[{"scroll-pe":W()}],"scroll-pt":[{"scroll-pt":W()}],"scroll-pr":[{"scroll-pr":W()}],"scroll-pb":[{"scroll-pb":W()}],"scroll-pl":[{"scroll-pl":W()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ke]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[wr,Jr,np]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},z$=(e,{cacheSize:t,prefix:s,separator:r,experimentalParseClassName:a,extend:l={},override:c={}})=>{wl(e,"cacheSize",t),wl(e,"prefix",s),wl(e,"separator",r),wl(e,"experimentalParseClassName",a);for(const u in c)D$(e[u],c[u]);for(const u in l)F$(e[u],l[u]);return e},wl=(e,t,s)=>{s!==void 0&&(e[t]=s)},D$=(e,t)=>{if(t)for(const s in t)wl(e,s,t[s])},F$=(e,t)=>{if(t)for(const s in t){const r=t[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},U$=(e,...t)=>typeof e=="function"?Db(Fb,e,...t):Db(()=>z$(Fb(),e),...t),W$=U$({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{spacing:["sidebar","control-sm","control-md","control-lg"]},classGroups:{"max-w":[{"max-w":["page","page-wide"]}],"font-size":[{text:["micro","label","small","body","lead","prose","figure","display"]}],z:[{z:["raised","sticky","overlay","dialog","popover","toast"]}],shadow:[{shadow:["float"]}],duration:[{duration:["fast","base","slow"]}],ease:[{ease:["standard"]}],"outline-w":[{outline:["focus"]}],"outline-offset":[{"outline-offset":["focus"]}]}}}),oe=(...e)=>W$(G0(e));function H$({value:e,onChange:t,options:s,label:r,name:a,size:l="md",className:c}){return n.jsx("div",{role:"radiogroup","aria-label":r,className:oe("inline-flex",c),children:s.map(u=>n.jsxs("label",{title:u.title,className:oe("caps -ml-px inline-flex items-center justify-center gap-1.5 border first:ml-0 has-[:focus-visible]:relative has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring [&_svg]:size-3.5",l==="sm"?"h-control-sm px-2.5 text-label":"h-control-md px-3 text-small",u.disabled?"cursor-not-allowed opacity-45":"cursor-pointer",e===u.value?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[n.jsx("input",{type:"radio",name:a,value:u.value,checked:e===u.value,disabled:u.disabled,onChange:()=>t(u.value),className:"sr-only"}),u.label]},u.value))})}const Es=e=>B$(e)?e.document:G$(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),zd=e=>{let t=Es(e);return(t==null?void 0:t.defaultView)??(typeof window<"u"?window:void 0)};function Q0(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function B$(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function G$(e){return Q0(e)&&e.nodeType===9}function q$(e){return Q0(e)&&e.nodeType===11&&"host"in e}let V$=!1;function Xh(){return V$}function Ko(e,t){var r;if(!Xh())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let s=t;for(;s!=null;){if(s===e)return!0;typeof s.assignedElements!="function"&&((r=s.assignedSlot)!=null&&r.parentNode)?s=s.assignedSlot.parentNode:q$(s)?s=s.host:s=s.parentNode}return!1}const ho=(e=document)=>{var s;if(!Xh())return e.activeElement;let t=e.activeElement;for(;t&&"shadowRoot"in t&&((s=t.shadowRoot)!=null&&s.activeElement);)t=t.shadowRoot.activeElement;return t};function En(e){if(Xh()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function K$(e){e.focus({preventScroll:!0})}const X$=typeof document<"u"?Ne.useLayoutEffect:()=>{};function Z0(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Y$(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function J0(e){let t=x.useRef({isFocused:!1,observer:null});return X$(()=>{const s=t.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),x.useCallback(s=>{let r=En(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){t.current.isFocused=!0;let a=r,l=c=>{if(t.current.isFocused=!1,a.disabled){let u=Z0(c);e==null||e(u)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};a.addEventListener("focusout",l,{once:!0}),t.current.observer=new MutationObserver(()=>{var c;if(t.current.isFocused&&a.disabled){(c=t.current.observer)==null||c.disconnect();let u=a===ho()?null:ho();a.dispatchEvent(new FocusEvent("blur",{relatedTarget:u})),a.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:u}))}}),t.current.observer.observe(a,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function Yh(e){var s;if(typeof window>"u"||window.navigator==null)return!1;let t=(s=window.navigator.userAgentData)==null?void 0:s.brands;return Array.isArray(t)&&t.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function Qh(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function la(e){let t=null;return()=>(t==null&&(t=e()),t)}const Zh=la(function(){return Qh(/^Mac/i)}),Q$=la(function(){return Qh(/^iPhone/i)}),ek=la(function(){return Qh(/^iPad/i)||Zh()&&navigator.maxTouchPoints>1}),Z$=la(function(){return Q$()||ek()}),J$=la(function(){return Yh(/AppleWebKit/i)&&(Z$()||!eE())}),eE=la(function(){return Yh(/Chrome|CriOS|CrMo/i)}),tE=la(function(){return Yh(/Android/i)});function nE(e){return e.pointerType===""&&e.isTrusted?!0:tE()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Pl(e,t,s=!0){let{metaKey:r,ctrlKey:a,altKey:l,shiftKey:c}=t,u=J$()&&Zh()&&!ek()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:a,altKey:l,shiftKey:c}):new MouseEvent("click",{metaKey:r,ctrlKey:a,altKey:l,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});Pl.isOpening=s,K$(e),e.dispatchEvent(u),Pl.isOpening=!1}Pl.isOpening=!1;let vi=null;const qp=new Set;let $l=new Map,Zo=!1,Uu=!1;const sE={Tab:!0,Escape:!0};function Dd(e,t){for(let s of qp)s(e,t)}function rE(e){return!(e.metaKey||!Zh()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function ed(e){Zo=!0,!Pl.isOpening&&rE(e)&&(vi="keyboard",Dd("keyboard",e))}function Xa(e){vi="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(Zo=!0,Dd("pointer",e))}function tk(e){!Pl.isOpening&&nE(e)&&(Zo=!0,vi="virtual")}function nk(e){let t=En(e),s=zd(t),r=Es(t);if(t===s){Uu=!0;return}t===r||!e.isTrusted||(!Zo&&!Uu&&(vi="virtual",Dd("virtual",e)),Zo=!1,Uu=!1)}function sk(){Zo=!1,Uu=!0}function rk(e){let t=ho(Es(En(e)));queueMicrotask(()=>{ho(Es(En(e)))!==t&&aE("keyboard")})}function Vp(e){if(typeof window>"u"||typeof document>"u")return;const t=zd(e),s=Es(e);if($l.get(t))return;let r=t.HTMLElement.prototype.focus;Reflect.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){Zo=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",ed,!0),s.addEventListener("keyup",ed,!0),s.addEventListener("click",tk,!0),s.addEventListener("invalid",rk,!0),t.addEventListener("focus",nk,!0),t.addEventListener("blur",sk,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",Xa,!0),s.addEventListener("pointermove",Xa,!0),s.addEventListener("pointerup",Xa,!0)),t.addEventListener("beforeunload",()=>{ok(e)},{once:!0}),$l.set(t,{focus:r})}const ok=(e,t)=>{const s=zd(e),r=Es(e);t&&r.removeEventListener("DOMContentLoaded",t),$l.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:$l.get(s).focus}),r.removeEventListener("keydown",ed,!0),r.removeEventListener("keyup",ed,!0),r.removeEventListener("click",tk,!0),r.removeEventListener("invalid",rk,!0),s.removeEventListener("focus",nk,!0),s.removeEventListener("blur",sk,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",Xa,!0),r.removeEventListener("pointermove",Xa,!0),r.removeEventListener("pointerup",Xa,!0)),$l.delete(s))};function oE(e){const t=Es(e);let s;return t.readyState!=="loading"?Vp(e):(s=()=>{Vp(e)},t.addEventListener("DOMContentLoaded",s)),()=>ok(e,s)}typeof document<"u"&&oE();function Kp(){return vi!=="pointer"}function aE(e){vi=e,Dd(e,null)}const iE=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function lE(e,t,s){let r=s?En(s):void 0,a=Es(r),l=zd(r);const c=typeof l<"u"?l.HTMLInputElement:HTMLInputElement,u=typeof l<"u"?l.HTMLTextAreaElement:HTMLTextAreaElement,f=typeof l<"u"?l.HTMLElement:HTMLElement,p=typeof l<"u"?l.KeyboardEvent:KeyboardEvent;let g=ho(a);return e=e||g instanceof c&&!iE.has(g.type)||g instanceof u||g instanceof f&&g.isContentEditable,!(e&&t==="keyboard"&&s instanceof p&&!sE[s.key])}function cE(e,t,s){Vp(),x.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(a,l)=>{lE(!!(s!=null&&s.isTextInput),a,l)&&e(Kp())};return qp.add(r),()=>{qp.delete(r)}},t)}function uE(e){let{isDisabled:t,onFocus:s,onBlur:r,onFocusChange:a}=e;const l=x.useCallback(f=>{if(En(f)===f.currentTarget)return r&&r(f),a&&a(!1),!0},[r,a]),c=J0(l),u=x.useCallback(f=>{let p=En(f);const g=Es(p),v=g?ho(g):ho();p===f.currentTarget&&p===v&&(s&&s(f),a&&a(!0),c(f))},[a,s,c]);return{focusProps:{onFocus:!t&&(s||a||r)?u:void 0,onBlur:!t&&(r||a)?l:void 0}}}function ak(){let e=x.useRef(new Map),t=x.useCallback((a,l,c,u)=>{let f=u!=null&&u.once?(...p)=>{e.current.delete(c),c(...p)}:c;e.current.set(c,{type:l,eventTarget:a,fn:f,options:u}),a.addEventListener(l,f,u)},[]),s=x.useCallback((a,l,c,u)=>{var p;let f=((p=e.current.get(c))==null?void 0:p.fn)||c;a.removeEventListener(l,f,u),e.current.delete(c)},[]),r=x.useCallback(()=>{e.current.forEach((a,l)=>{s(a.eventTarget,a.type,l,a.options)})},[s]);return x.useEffect(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:r}}function dE(e){let{isDisabled:t,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:a}=e,l=x.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:u}=ak(),f=x.useCallback(v=>{Ko(v.currentTarget,En(v))&&l.current.isFocusWithin&&!Ko(v.currentTarget,v.relatedTarget)&&(l.current.isFocusWithin=!1,u(),s&&s(v),a&&a(!1))},[s,a,l,u]),p=J0(f),g=x.useCallback(v=>{if(!Ko(v.currentTarget,En(v)))return;let h=En(v);const m=Es(h),b=ho(m);if(!l.current.isFocusWithin&&b===h){r&&r(v),a&&a(!0),l.current.isFocusWithin=!0,p(v);let w=v.currentTarget;c(m,"focus",j=>{let N=En(j);if(l.current.isFocusWithin&&!Ko(w,N)){let R=new m.defaultView.FocusEvent("blur",{relatedTarget:N});Y$(R,w);let $=Z0(R);f($)}},{capture:!0})}},[r,a,p,c,f]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:g,onBlur:f}}}function fE(e={}){let{autoFocus:t=!1,isTextInput:s,within:r}=e,a=x.useRef({isFocused:!1,isFocusVisible:t||Kp()}),[l,c]=x.useState(!1),[u,f]=x.useState(()=>a.current.isFocused&&a.current.isFocusVisible),p=x.useCallback(()=>f(a.current.isFocused&&a.current.isFocusVisible),[]),g=x.useCallback(m=>{a.current.isFocused=m,a.current.isFocusVisible=Kp(),c(m),p()},[p]);cE(m=>{a.current.isFocusVisible=m,p()},[s,l],{enabled:l,isTextInput:s});let{focusProps:v}=uE({isDisabled:r,onFocusChange:g}),{focusWithinProps:h}=dE({isDisabled:!r,onFocusWithinChange:g});return{isFocused:l,isFocusVisible:u,focusProps:r?h:v}}var ir=$0();let Xp=!1,wu=0;function mE(){Xp=!0,setTimeout(()=>{Xp=!1},500)}function Ub(e){e.pointerType==="touch"&&mE()}function pE(){let e=Es(null);if(!(typeof e>"u"))return wu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",Ub),wu++,()=>{wu--,!(wu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",Ub)}}function hE(e){let{onHoverStart:t,onHoverChange:s,onHoverEnd:r,isDisabled:a}=e,[l,c]=x.useState(!1),u=x.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;x.useEffect(pE,[]);let{addGlobalListener:f,removeAllGlobalListeners:p}=ak(),{hoverProps:g,triggerHoverEnd:v}=x.useMemo(()=>{let h=(w,j)=>{if(u.pointerType=j,a||j==="touch"||u.isHovered||!Ko(w.currentTarget,En(w)))return;u.isHovered=!0;let N=w.currentTarget;u.target=N,f(Es(En(w)),"pointerover",R=>{u.isHovered&&u.target&&!Ko(u.target,En(R))&&m(R,R.pointerType)},{capture:!0}),t&&t({type:"hoverstart",target:N,pointerType:j}),s&&s(!0),c(!0)},m=(w,j)=>{let N=u.target;u.pointerType="",u.target=null,!(j==="touch"||!u.isHovered||!N)&&(u.isHovered=!1,p(),r&&r({type:"hoverend",target:N,pointerType:j}),s&&s(!1),c(!1))},b={};return typeof PointerEvent<"u"&&(b.onPointerEnter=w=>{Xp&&w.pointerType==="mouse"||h(w,w.pointerType)},b.onPointerLeave=w=>{!a&&Ko(w.currentTarget,En(w))&&m(w,w.pointerType)}),{hoverProps:b,triggerHoverEnd:m}},[t,s,r,a,u,f,p]);return x.useEffect(()=>{a&&v({currentTarget:u.target},u.pointerType)},[a]),{hoverProps:g,isHovered:l}}var gE=Object.defineProperty,xE=(e,t,s)=>t in e?gE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,sp=(e,t,s)=>(xE(e,typeof t!="symbol"?t+"":t,s),s);let yE=class{constructor(){sp(this,"current",this.detect()),sp(this,"handoffState","pending"),sp(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},sr=new yE;function wi(e){var t;return sr.isServer?null:e==null?document:(t=e==null?void 0:e.ownerDocument)!=null?t:document}function td(e){var t,s;return sr.isServer?null:e==null?document:(s=(t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))!=null?s:document}function ik(e){var t,s;return(s=(t=td(e))==null?void 0:t.activeElement)!=null?s:null}function lk(e){return ik(e)===e}function Fd(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function ds(){let e=[],t={addEventListener(s,r,a,l){return s.addEventListener(r,a,l),t.add(()=>s.removeEventListener(r,a,l))},requestAnimationFrame(...s){let r=requestAnimationFrame(...s);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...s){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...s))},setTimeout(...s){let r=setTimeout(...s);return t.add(()=>clearTimeout(r))},microTask(...s){let r={current:!0};return Fd(()=>{r.current&&s[0]()}),t.add(()=>{r.current=!1})},style(s,r,a){let l=s.style.getPropertyValue(r);return Object.assign(s.style,{[r]:a}),this.add(()=>{Object.assign(s.style,{[r]:l})})},group(s){let r=ds();return s(r),this.add(()=>r.dispose())},add(s){return e.includes(s)||e.push(s),()=>{let r=e.indexOf(s);if(r>=0)for(let a of e.splice(r,1))a()}},dispose(){for(let s of e.splice(0))s()}};return t}function yo(){let[e]=x.useState(ds);return x.useEffect(()=>()=>e.dispose(),[e]),e}let At=(e,t)=>{sr.isServer?x.useEffect(e,t):x.useLayoutEffect(e,t)};function bo(e){let t=x.useRef(e);return At(()=>{t.current=e},[e]),t}let Ge=function(e){let t=bo(e);return Ne.useCallback((...s)=>t.current(...s),[t])};function bE(e){let t=e.width/2,s=e.height/2;return{top:e.clientY-s,right:e.clientX+t,bottom:e.clientY+s,left:e.clientX-t}}function vE(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function wE({disabled:e=!1}={}){let t=x.useRef(null),[s,r]=x.useState(!1),a=yo(),l=Ge(()=>{t.current=null,r(!1),a.dispose()}),c=Ge(u=>{if(a.dispose(),t.current===null){t.current=u.currentTarget,r(!0);{let f=wi(u.currentTarget);a.addEventListener(f,"pointerup",l,!1),a.addEventListener(f,"pointermove",p=>{if(t.current){let g=bE(p);r(vE(g,t.current.getBoundingClientRect()))}},!1),a.addEventListener(f,"pointercancel",l,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:c,onPointerUp:l,onClick:l}}}function Cs(e){return x.useMemo(()=>e,Object.values(e))}let kE=x.createContext(void 0);function Jh(){return x.useContext(kE)}function Yp(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function Rn(e,t,...s){if(e in t){let a=t[e];return typeof a=="function"?a(...s):a}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(a=>`"${a}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Rn),r}var li=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(li||{}),io=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(io||{});function rn(){let e=NE();return x.useCallback(t=>jE({mergeRefs:e,...t}),[e])}function jE({ourProps:e,theirProps:t,slot:s,defaultTag:r,features:a,visible:l=!0,name:c,mergeRefs:u}){u=u??SE;let f=ck(t,e);if(l)return ku(f,s,r,c,u);let p=a??0;if(p&2){let{static:g=!1,...v}=f;if(g)return ku(v,s,r,c,u)}if(p&1){let{unmount:g=!0,...v}=f;return Rn(g?0:1,{0(){return null},1(){return ku({...v,hidden:!0,style:{display:"none"}},s,r,c,u)}})}return ku(f,s,r,c,u)}function ku(e,t={},s,r,a){let{as:l=s,children:c,refName:u="ref",...f}=rp(e,["unmount","static"]),p=e.ref!==void 0?{[u]:e.ref}:{},g=typeof c=="function"?c(t):c;g=dk(g),"className"in f&&f.className&&typeof f.className=="function"&&(f.className=f.className(t)),f["aria-labelledby"]&&f["aria-labelledby"]===f.id&&(f["aria-labelledby"]=void 0);let v={};if(t){let h=!1,m=[];for(let[b,w]of Object.entries(t))typeof w=="boolean"&&(h=!0),w===!0&&m.push(b.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(h){v["data-headlessui-state"]=m.join(" ");for(let b of m)v[`data-${b}`]=""}}if(El(l)&&(Object.keys(ro(f)).length>0||Object.keys(ro(v)).length>0))if(!x.isValidElement(g)||Array.isArray(g)&&g.length>1||$E(g)){if(Object.keys(ro(f)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(ro(f)).concat(Object.keys(ro(v))).map(h=>` - ${h}`).join(`
446
+ `),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(h=>` - ${h}`).join(`
447
+ `)].join(`
448
+ `))}else{let h=g.props,m=h==null?void 0:h.className,b=typeof m=="function"?(...N)=>Yp(m(...N),f.className):Yp(m,f.className),w=b?{className:b}:{},j=ck(g.props,ro(rp(f,["ref"])));for(let N in v)N in j&&delete v[N];return x.cloneElement(g,Object.assign({},j,v,p,{ref:a(_E(g),p.ref)},w))}return x.createElement(l,Object.assign({},rp(f,["ref"]),!El(l)&&p,!El(l)&&v),g)}function NE(){let e=x.useRef([]),t=x.useCallback(s=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(s):r.current=s)},[]);return(...s)=>{if(!s.every(r=>r==null))return e.current=s,t}}function SE(...e){return e.every(t=>t==null)?void 0:t=>{for(let s of e)s!=null&&(typeof s=="function"?s(t):s.current=t)}}function ck(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},s={};for(let r of e)for(let a in r)a.startsWith("on")&&typeof r[a]=="function"?(s[a]!=null||(s[a]=[]),s[a].push(r[a])):t[a]=r[a];if(t.disabled||t["aria-disabled"])for(let r in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(s[r]=[a=>{var l;return(l=a==null?void 0:a.preventDefault)==null?void 0:l.call(a)}]);for(let r in s)Object.assign(t,{[r](a,...l){let c=s[r];for(let u of c){if((a instanceof Event||(a==null?void 0:a.nativeEvent)instanceof Event)&&a.defaultPrevented)return;u(a,...l)}}});return t}function uk(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},s={};for(let r of e)for(let a in r)a.startsWith("on")&&typeof r[a]=="function"?(s[a]!=null||(s[a]=[]),s[a].push(r[a])):t[a]=r[a];for(let r in s)Object.assign(t,{[r](...a){let l=s[r];for(let c of l)c==null||c(...a)}});return t}function Gt(e){var t;return Object.assign(x.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function ro(e){let t=Object.assign({},e);for(let s in t)t[s]===void 0&&delete t[s];return t}function rp(e,t=[]){let s=Object.assign({},e);for(let r of t)r in s&&delete s[r];return s}function _E(e){return Ne.version.split(".")[0]>="19"?e.props.ref:e.ref}function dk(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let t=e._payload;if(t!=null&&t.status==="fulfilled")return dk(t.value)}return e}function El(e){return e===x.Fragment||e===Symbol.for("react.fragment")}function $E(e){return El(e.type)}function EE(e,t,s){let[r,a]=x.useState(s),l=e!==void 0,c=x.useRef(l),u=x.useRef(!1),f=x.useRef(!1);return l&&!c.current&&!u.current?(u.current=!0,c.current=l,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!l&&c.current&&!f.current&&(f.current=!0,c.current=l,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[l?e:r,Ge(p=>(l||ir.flushSync(()=>a(p)),t==null?void 0:t(p)))]}function CE(e){let[t]=x.useState(e);return t}function fk(e={},t=null,s=[]){for(let[r,a]of Object.entries(e))pk(s,mk(t,r),a);return s}function mk(e,t){return e?e+"["+t+"]":t}function pk(e,t,s){if(Array.isArray(s))for(let[r,a]of s.entries())pk(e,mk(t,r.toString()),a);else s instanceof Date?e.push([t,s.toISOString()]):typeof s=="boolean"?e.push([t,s?"1":"0"]):typeof s=="string"?e.push([t,s]):typeof s=="number"?e.push([t,`${s}`]):s==null?e.push([t,""]):RE(s)&&!x.isValidElement(s)&&fk(s,t,e)}function TE(e){var t,s;let r=(t=e==null?void 0:e.form)!=null?t:e.closest("form");if(r){for(let a of r.elements)if(a!==e&&(a.tagName==="INPUT"&&a.type==="submit"||a.tagName==="BUTTON"&&a.type==="submit"||a.nodeName==="INPUT"&&a.type==="image")){a.click();return}(s=r.requestSubmit)==null||s.call(r)}}function RE(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}let AE="span";var ci=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(ci||{});function OE(e,t){var s;let{features:r=1,...a}=e,l={ref:t,"aria-hidden":(r&2)===2?!0:(s=a["aria-hidden"])!=null?s:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return rn()({ourProps:l,theirProps:a,slot:{},defaultTag:AE,name:"Hidden"})}let Ll=Gt(OE),ME=x.createContext(null);function PE({children:e}){let t=x.useContext(ME);if(!t)return Ne.createElement(Ne.Fragment,null,e);let{target:s}=t;return s?ir.createPortal(Ne.createElement(Ne.Fragment,null,e),s):null}function LE({data:e,form:t,disabled:s,onReset:r,overrides:a}){let[l,c]=x.useState(null),u=yo();return x.useEffect(()=>{if(r&&l)return u.addEventListener(l,"reset",r)},[l,t,r]),Ne.createElement(PE,null,Ne.createElement(IE,{setForm:c,formId:t}),fk(e).map(([f,p])=>Ne.createElement(Ll,{features:ci.Hidden,...ro({key:f,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:t,disabled:s,name:f,value:p,...a})})))}function IE({setForm:e,formId:t}){return x.useEffect(()=>{if(t){let s=document.getElementById(t);s&&e(s)}},[e,t]),t?null:Ne.createElement(Ll,{features:ci.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let zE=x.createContext(void 0);function hk(){return x.useContext(zE)}function gk(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function $r(e){return gk(e)&&"tagName"in e}function cs(e){return $r(e)&&"accessKey"in e}function Sr(e){return $r(e)&&"tabIndex"in e}function DE(e){return $r(e)&&"style"in e}function FE(e){return cs(e)&&e.nodeName==="IFRAME"}function xk(e){return cs(e)&&e.nodeName==="INPUT"}function Wb(e){return cs(e)&&e.nodeName==="LABEL"}function UE(e){return cs(e)&&e.nodeName==="FIELDSET"}function yk(e){return cs(e)&&e.nodeName==="LEGEND"}function WE(e){return $r(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function Hb(e){let t=e.parentElement,s=null;for(;t&&!UE(t);)yk(t)&&(s=t),t=t.parentElement;let r=(t==null?void 0:t.getAttribute("disabled"))==="";return r&&HE(s)?!1:r}function HE(e){if(!e)return!1;let t=e.previousElementSibling;for(;t!==null;){if(yk(t))return!1;t=t.previousElementSibling}return!0}let bk=Symbol();function BE(e,t=!0){return Object.assign(e,{[bk]:t})}function wn(...e){let t=x.useRef(e);x.useEffect(()=>{t.current=e},[e]);let s=Ge(r=>{for(let a of t.current)a!=null&&(typeof a=="function"?a(r):a.current=r)});return e.every(r=>r==null||(r==null?void 0:r[bk]))?void 0:s}let Ud=x.createContext(null);Ud.displayName="DescriptionContext";function vk(){let e=x.useContext(Ud);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,vk),t}return e}function GE(){var e,t;return(t=(e=x.useContext(Ud))==null?void 0:e.value)!=null?t:void 0}function qE(){let[e,t]=x.useState([]);return[e.length>0?e.join(" "):void 0,x.useMemo(()=>function(s){let r=Ge(l=>(t(c=>[...c,l]),()=>t(c=>{let u=c.slice(),f=u.indexOf(l);return f!==-1&&u.splice(f,1),u}))),a=x.useMemo(()=>({register:r,slot:s.slot,name:s.name,props:s.props,value:s.value}),[r,s.slot,s.name,s.props,s.value]);return Ne.createElement(Ud.Provider,{value:a},s.children)},[t])]}let VE="p";function KE(e,t){let s=x.useId(),r=Jh(),{id:a=`headlessui-description-${s}`,...l}=e,c=vk(),u=wn(t);At(()=>c.register(a),[a,c.register]);let f=Cs({...c.slot,disabled:r||!1}),p={ref:u,...c.props,id:a};return rn()({ourProps:p,theirProps:l,slot:f,defaultTag:VE,name:c.name||"Description"})}let XE=Gt(KE),wk=Object.assign(XE,{});var Zt=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(Zt||{});let Wd=x.createContext(null);Wd.displayName="LabelContext";function kk(){let e=x.useContext(Wd);if(e===null){let t=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,kk),t}return e}function jk(e){var t,s,r;let a=(s=(t=x.useContext(Wd))==null?void 0:t.value)!=null?s:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[a,...e].filter(Boolean).join(" "):a}function YE({inherit:e=!1}={}){let t=jk(),[s,r]=x.useState([]),a=e?[t,...s].filter(Boolean):s;return[a.length>0?a.join(" "):void 0,x.useMemo(()=>function(l){let c=Ge(f=>(r(p=>[...p,f]),()=>r(p=>{let g=p.slice(),v=g.indexOf(f);return v!==-1&&g.splice(v,1),g}))),u=x.useMemo(()=>({register:c,slot:l.slot,name:l.name,props:l.props,value:l.value}),[c,l.slot,l.name,l.props,l.value]);return Ne.createElement(Wd.Provider,{value:u},l.children)},[r])]}let QE="label";function ZE(e,t){var s;let r=x.useId(),a=kk(),l=hk(),c=Jh(),{id:u=`headlessui-label-${r}`,htmlFor:f=l??((s=a.props)==null?void 0:s.htmlFor),passive:p=!1,...g}=e,v=wn(t);At(()=>a.register(u),[u,a.register]);let h=Ge(w=>{let j=w.currentTarget;if(!(w.target!==w.currentTarget&&WE(w.target))&&(Wb(j)&&w.preventDefault(),a.props&&"onClick"in a.props&&typeof a.props.onClick=="function"&&a.props.onClick(w),Wb(j))){let N=document.getElementById(j.htmlFor);if(N){let R=N.getAttribute("disabled");if(R==="true"||R==="")return;let $=N.getAttribute("aria-disabled");if($==="true"||$==="")return;(xk(N)&&(N.type==="file"||N.type==="radio"||N.type==="checkbox")||N.role==="radio"||N.role==="checkbox"||N.role==="switch")&&N.click(),N.focus({preventScroll:!0})}}}),m=Cs({...a.slot,disabled:c||!1}),b={ref:v,...a.props,id:u,htmlFor:f,onClick:h};return p&&("onClick"in b&&(delete b.htmlFor,delete b.onClick),"onClick"in g&&delete g.onClick),rn()({ourProps:b,theirProps:g,slot:m,defaultTag:f?QE:"div",name:a.name||"Label"})}let JE=Gt(ZE),eC=Object.assign(JE,{}),tC=x.createContext(()=>{});function nC({value:e,children:t}){return Ne.createElement(tC.Provider,{value:e},t)}function sC(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function rC(e=sC){return x.useCallback((t,s)=>{if(typeof e=="string"){let r=e;return(t==null?void 0:t[r])===(s==null?void 0:s[r])}return e(t,s)},[e])}function Bb(e){if(e===null)return{width:0,height:0};let{width:t,height:s}=e.getBoundingClientRect();return{width:t,height:s}}function oC(e,t,s=!1){let[r,a]=x.useState(()=>Bb(t));return At(()=>{if(!t||!e)return;let l=ds();return l.requestAnimationFrame(function c(){l.requestAnimationFrame(c),a(u=>{let f=Bb(t);return f.width===u.width&&f.height===u.height?u:f})}),()=>{l.dispose()}},[t,e]),s?{width:`${r.width}px`,height:`${r.height}px`}:r}var Nk=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(Nk||{});function aC(e){let t=x.useRef(null),s=Ge(a=>{t.current=a.pointerType,!Hb(a.currentTarget)&&a.pointerType==="mouse"&&a.button===Nk.Left&&(a.preventDefault(),e(a))}),r=Ge(a=>{t.current!=="mouse"&&(Hb(a.currentTarget)||e(a))});return{onPointerDown:s,onClick:r}}let Sk=class extends Map{constructor(t){super(),this.factory=t}get(t){let s=super.get(t);return s===void 0&&(s=this.factory(t),this.set(t,s)),s}};var iC=Object.defineProperty,lC=(e,t,s)=>t in e?iC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,cC=(e,t,s)=>(lC(e,t+"",s),s),_k=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)},ws=(e,t,s)=>(_k(e,t,"read from private field"),s?s.call(e):t.get(e)),op=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},Gb=(e,t,s,r)=>(_k(e,t,"write to private field"),t.set(e,s),s),er,kl,jl;let $k=class{constructor(t){op(this,er,{}),op(this,kl,new Sk(()=>new Set)),op(this,jl,new Set),cC(this,"disposables",ds()),Gb(this,er,t),sr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return ws(this,er)}subscribe(t,s){if(sr.isServer)return()=>{};let r={selector:t,callback:s,current:t(ws(this,er))};return ws(this,jl).add(r),this.disposables.add(()=>{ws(this,jl).delete(r)})}on(t,s){return sr.isServer?()=>{}:(ws(this,kl).get(t).add(s),this.disposables.add(()=>{ws(this,kl).get(t).delete(s)}))}send(t){let s=this.reduce(ws(this,er),t);if(s!==ws(this,er)){Gb(this,er,s);for(let r of ws(this,jl)){let a=r.selector(ws(this,er));Ek(r.current,a)||(r.current=a,r.callback(a))}for(let r of ws(this,kl).get(t.type))r(ws(this,er),t)}}};er=new WeakMap,kl=new WeakMap,jl=new WeakMap;function Ek(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null?!1:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:ap(e[Symbol.iterator](),t[Symbol.iterator]()):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?e.size!==t.size?!1:ap(e.entries(),t.entries()):qb(e)&&qb(t)?ap(Object.entries(e)[Symbol.iterator](),Object.entries(t)[Symbol.iterator]()):!1}function ap(e,t){do{let s=e.next(),r=t.next();if(s.done&&r.done)return!0;if(s.done||r.done||!Object.is(s.value,r.value))return!1}while(!0)}function qb(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function ip(e){let[t,s]=e(),r=ds();return(...a)=>{t(...a),r.dispose(),r.microTask(s)}}var uC=Object.defineProperty,dC=(e,t,s)=>t in e?uC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Vb=(e,t,s)=>(dC(e,typeof t!="symbol"?t+"":t,s),s),Ck=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(Ck||{});let fC={0(e,t){let s=t.id,r=e.stack,a=e.stack.indexOf(s);if(a!==-1){let l=e.stack.slice();return l.splice(a,1),l.push(s),r=l,{...e,stack:r}}return{...e,stack:[...e.stack,s]}},1(e,t){let s=t.id,r=e.stack.indexOf(s);if(r===-1)return e;let a=e.stack.slice();return a.splice(r,1),{...e,stack:a}}},mC=class Tk extends $k{constructor(){super(...arguments),Vb(this,"actions",{push:t=>this.send({type:0,id:t}),pop:t=>this.send({type:1,id:t})}),Vb(this,"selectors",{isTop:(t,s)=>t.stack[t.stack.length-1]===s,inStack:(t,s)=>t.stack.includes(s)})}static new(){return new Tk({stack:[]})}reduce(t,s){return Rn(s.type,fC,t,s)}};const Hd=new Sk(()=>mC.new());var lp={exports:{}},cp={};/**
449
+ * @license React
450
+ * use-sync-external-store-with-selector.production.js
451
+ *
452
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
453
+ *
454
+ * This source code is licensed under the MIT license found in the
455
+ * LICENSE file in the root directory of this source tree.
456
+ */var Kb;function pC(){if(Kb)return cp;Kb=1;var e=Md();function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var s=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,a=e.useRef,l=e.useEffect,c=e.useMemo,u=e.useDebugValue;return cp.useSyncExternalStoreWithSelector=function(f,p,g,v,h){var m=a(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=c(function(){function j(E){if(!N){if(N=!0,R=E,E=v(E),h!==void 0&&b.hasValue){var C=b.value;if(h(C,E))return $=C}return $=E}if(C=$,s(R,E))return C;var T=v(E);return h!==void 0&&h(C,T)?(R=E,C):(R=E,$=T)}var N=!1,R,$,S=g===void 0?null:g;return[function(){return j(p())},S===null?void 0:function(){return j(S())}]},[p,g,v,h]);var w=r(f,m[0],m[1]);return l(function(){b.hasValue=!0,b.value=w},[w]),u(w),w},cp}var Xb;function hC(){return Xb||(Xb=1,lp.exports=pC()),lp.exports}var gC=hC();function $n(e,t,s=Ek){return gC.useSyncExternalStoreWithSelector(Ge(r=>e.subscribe(xC,r)),Ge(()=>e.state),Ge(()=>e.state),Ge(t),s)}function xC(e){return e}function Ql(e,t){let s=x.useId(),r=Hd.get(t),[a,l]=$n(r,x.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return At(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?l?a:!0:!1}let Qp=new Map,Cl=new Map;function Yb(e){var t;let s=(t=Cl.get(e))!=null?t:0;return Cl.set(e,s+1),s!==0?()=>Qb(e):(Qp.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Qb(e))}function Qb(e){var t;let s=(t=Cl.get(e))!=null?t:1;if(s===1?Cl.delete(e):Cl.set(e,s-1),s!==1)return;let r=Qp.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Qp.delete(e))}function Rk(e,{allowed:t,disallowed:s}={}){let r=Ql(e,"inert-others");At(()=>{var a,l;if(!r)return;let c=ds();for(let f of(a=s==null?void 0:s())!=null?a:[])f&&c.add(Yb(f));let u=(l=t==null?void 0:t())!=null?l:[];for(let f of u){if(!f)continue;let p=wi(f);if(!p)continue;let g=f.parentElement;for(;g&&g!==p.body;){for(let v of g.children)u.some(h=>v.contains(h))||c.add(Yb(v));g=g.parentElement}}return c.dispose},[r,t,s])}function Ak(e,t,s){let r=bo(a=>{let l=a.getBoundingClientRect();l.x===0&&l.y===0&&l.width===0&&l.height===0&&s()});x.useEffect(()=>{if(!e)return;let a=t===null?null:cs(t)?t:t.current;if(!a)return;let l=ds();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>r.current(a));c.observe(a),l.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>r.current(a));c.observe(a),l.add(()=>c.disconnect())}return()=>l.dispose()},[t,r,e])}let nd=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),yC=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var Hs=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(Hs||{}),Zp=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(Zp||{}),bC=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(bC||{});function Ok(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(nd)).sort((t,s)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function vC(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(yC)).sort((t,s)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var eg=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(eg||{});function Mk(e,t=0){var s;return e===((s=wi(e))==null?void 0:s.body)?!1:Rn(t,{0(){return e.matches(nd)},1(){let r=e;for(;r!==null;){if(r.matches(nd))return!0;r=r.parentElement}return!1}})}var wC=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(wC||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function Er(e){e==null||e.focus({preventScroll:!0})}let kC=["textarea","input"].join(",");function jC(e){var t,s;return(s=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,kC))!=null?s:!1}function Pk(e,t=s=>s){return e.slice().sort((s,r)=>{let a=t(s),l=t(r);if(a===null||l===null)return 0;let c=a.compareDocumentPosition(l);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function NC(e,t,s=e===null?document.body:td(e)){return Ya(Ok(s),t,{relativeTo:e})}function Ya(e,t,{sorted:s=!0,relativeTo:r=null,skipElements:a=[]}={}){let l=Array.isArray(e)?e.length>0?td(e[0]):document:td(e),c=Array.isArray(e)?s?Pk(e):e:t&64?vC(e):Ok(e);a.length>0&&c.length>1&&(c=c.filter(m=>!a.some(b=>b!=null&&"current"in b?(b==null?void 0:b.current)===m:b===m))),r=r??(l==null?void 0:l.activeElement);let u=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,c.indexOf(r))-1;if(t&4)return Math.max(0,c.indexOf(r))+1;if(t&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),p=t&32?{preventScroll:!0}:{},g=0,v=c.length,h;do{if(g>=v||g+v<=0)return 0;let m=f+g;if(t&16)m=(m+v)%v;else{if(m<0)return 3;if(m>=v)return 1}h=c[m],h==null||h.focus(p),g+=u}while(h!==ik(h));return t&6&&jC(h)&&h.select(),2}function Lk(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function SC(){return/Android/gi.test(window.navigator.userAgent)}function Zb(){return Lk()||SC()}function Ba(e,t,s,r){let a=bo(s);x.useEffect(()=>{if(!e)return;function l(c){a.current(c)}return document.addEventListener(t,l,r),()=>document.removeEventListener(t,l,r)},[e,t,r])}function Ik(e,t,s,r){let a=bo(s);x.useEffect(()=>{if(!e)return;function l(c){a.current(c)}return window.addEventListener(t,l,r),()=>window.removeEventListener(t,l,r)},[e,t,r])}const Jb=30;function zk(e,t,s){let r=bo(s),a=x.useCallback(function(u,f){if(u.defaultPrevented)return;let p=f(u);if(p===null||!p.getRootNode().contains(p)||!p.isConnected)return;let g=(function v(h){return typeof h=="function"?v(h()):Array.isArray(h)||h instanceof Set?h:[h]})(t);for(let v of g)if(v!==null&&(v.contains(p)||u.composed&&u.composedPath().includes(v)))return;return!Mk(p,eg.Loose)&&p.tabIndex!==-1&&u.preventDefault(),r.current(u,p)},[r,t]),l=x.useRef(null);Ba(e,"pointerdown",u=>{var f,p;Zb()||(l.current=((p=(f=u.composedPath)==null?void 0:f.call(u))==null?void 0:p[0])||u.target)},!0),Ba(e,"pointerup",u=>{if(Zb()||!l.current)return;let f=l.current;return l.current=null,a(u,()=>f)},!0);let c=x.useRef({x:0,y:0});Ba(e,"touchstart",u=>{c.current.x=u.touches[0].clientX,c.current.y=u.touches[0].clientY},!0),Ba(e,"touchend",u=>{let f={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(f.x-c.current.x)>=Jb||Math.abs(f.y-c.current.y)>=Jb))return a(u,()=>Sr(u.target)?u.target:null)},!0),Ik(e,"blur",u=>a(u,()=>FE(window.document.activeElement)?window.document.activeElement:null),!0)}function Il(...e){return x.useMemo(()=>wi(...e),[...e])}var _C=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(_C||{});const ju={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},$C=200,ev=5;function EC(e,{trigger:t,action:s,close:r,select:a}){let l=x.useRef(null),c=x.useRef(null),u=x.useRef(null);Ba(e&&t!==null,"pointerdown",f=>{gk(f==null?void 0:f.target)&&t!=null&&t.contains(f.target)&&(c.current=f.x,u.current=f.y,l.current=f.timeStamp)}),Ba(e&&t!==null,"pointerup",f=>{var p,g;let v=l.current;if(v===null||(l.current=null,!Sr(f.target))||Math.abs(f.x-((p=c.current)!=null?p:f.x))<ev&&Math.abs(f.y-((g=u.current)!=null?g:f.y))<ev)return;let h=s(f);switch(h.kind){case 0:return;case 1:{f.timeStamp-v>$C&&(a(h.target),r());break}case 2:{r();break}}},{capture:!0})}function Dk(e,t,s,r){let a=bo(s);x.useEffect(()=>{e=e??window;function l(c){a.current(c)}return e.addEventListener(t,l,r),()=>e.removeEventListener(t,l,r)},[e,t,r])}function CC(e,t){return x.useMemo(()=>{var s;if(e.type)return e.type;let r=(s=e.as)!=null?s:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(t==null?void 0:t.tagName)==="BUTTON"&&!t.hasAttribute("type"))return"button"},[e.type,e.as,t])}function TC(e){return x.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function RC(e,t){let s=e(),r=new Set;return{getSnapshot(){return s},subscribe(a){return r.add(a),()=>r.delete(a)},dispatch(a,...l){let c=t[a].call(s,...l);c&&(s=c,r.forEach(u=>u()))}}}function AC(){let e;return{before({doc:t}){var s;let r=t.documentElement,a=(s=t.defaultView)!=null?s:window;e=Math.max(0,a.innerWidth-r.clientWidth)},after({doc:t,d:s}){let r=t.documentElement,a=Math.max(0,r.clientWidth-r.offsetWidth),l=Math.max(0,e-a);s.style(r,"paddingRight",`${l}px`)}}}function OC(){return Lk()?{before({doc:e,d:t,meta:s}){function r(a){for(let l of s().containers)for(let c of l())if(c.contains(a))return!0;return!1}t.microTask(()=>{var a;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let u=ds();u.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>u.dispose()))}let l=(a=window.scrollY)!=null?a:window.pageYOffset,c=null;t.addEventListener(e,"click",u=>{if(Sr(u.target))try{let f=u.target.closest("a");if(!f)return;let{hash:p}=new URL(f.href),g=e.querySelector(p);Sr(g)&&!r(g)&&(c=g)}catch{}},!0),t.group(u=>{t.addEventListener(e,"touchstart",f=>{if(u.dispose(),Sr(f.target)&&DE(f.target))if(r(f.target)){let p=f.target;for(;p.parentElement&&r(p.parentElement);)p=p.parentElement;u.style(p,"overscrollBehavior","contain")}else u.style(f.target,"touchAction","none")})}),t.addEventListener(e,"touchmove",u=>{if(Sr(u.target)){if(xk(u.target))return;if(r(u.target)){let f=u.target;for(;f.parentElement&&f.dataset.headlessuiPortal!==""&&!(f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth);)f=f.parentElement;f.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),t.add(()=>{var u;let f=(u=window.scrollY)!=null?u:window.pageYOffset;l!==f&&window.scrollTo(0,l),c&&c.isConnected&&(c.scrollIntoView({block:"nearest"}),c=null)})})}}:{}}function MC(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function tv(e){let t={};for(let s of e)Object.assign(t,s(t));return t}let Xo=RC(()=>new Map,{PUSH(e,t){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:ds(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(t),r.computedMeta=tv(r.meta),this.set(e,r),this},POP(e,t){let s=this.get(e);return s&&(s.count--,s.meta.delete(t),s.computedMeta=tv(s.meta)),this},SCROLL_PREVENT(e){let t={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[OC(),AC(),MC()];s.forEach(({before:r})=>r==null?void 0:r(t)),s.forEach(({after:r})=>r==null?void 0:r(t))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});Xo.subscribe(()=>{let e=Xo.getSnapshot(),t=new Map;for(let[s]of e)t.set(s,s.documentElement.style.overflow);for(let s of e.values()){let r=t.get(s.doc)==="hidden",a=s.count!==0;(a&&!r||!a&&r)&&Xo.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&Xo.dispatch("TEARDOWN",s)}});function PC(e,t,s=()=>({containers:[]})){let r=TC(Xo),a=t?r.get(t):void 0,l=a?a.count>0:!1;return At(()=>{if(!(!t||!e))return Xo.dispatch("PUSH",t,s),()=>Xo.dispatch("POP",t,s)},[e,t]),l}function Fk(e,t,s=()=>[document.body]){let r=Ql(e,"scroll-lock");PC(r,t,a=>{var l;return{containers:[...(l=a.containers)!=null?l:[],s]}})}function nv(e){return[e.screenX,e.screenY]}function LC(){let e=x.useRef([-1,-1]);return{wasMoved(t){let s=nv(t);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(t){e.current=nv(t)}}}function IC(e=0){let[t,s]=x.useState(e),r=x.useCallback(f=>s(f),[]),a=x.useCallback(f=>s(p=>p|f),[]),l=x.useCallback(f=>(t&f)===f,[t]),c=x.useCallback(f=>s(p=>p&~f),[]),u=x.useCallback(f=>s(p=>p^f),[]);return{flags:t,setFlag:r,addFlag:a,hasFlag:l,removeFlag:c,toggleFlag:u}}var zC={},sv,rv;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((sv=process==null?void 0:zC)==null?void 0:sv.NODE_ENV)==="test"&&typeof((rv=Element==null?void 0:Element.prototype)==null?void 0:rv.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
457
+ `)),[]});var DC=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(DC||{});function Uk(e){let t={};for(let s in e)e[s]===!0&&(t[`data-${s}`]="");return t}function Wk(e,t,s,r){let[a,l]=x.useState(s),{hasFlag:c,addFlag:u,removeFlag:f}=IC(e&&a?3:0),p=x.useRef(!1),g=x.useRef(!1),v=yo();return At(()=>{var h;if(e){if(s&&l(!0),!t){s&&u(3);return}return(h=r==null?void 0:r.start)==null||h.call(r,s),FC(t,{inFlight:p,prepare(){g.current?g.current=!1:g.current=p.current,p.current=!0,!g.current&&(s?(u(3),f(4)):(u(4),f(2)))},run(){g.current?s?(f(3),u(4)):(f(4),u(3)):s?f(1):u(1)},done(){var m;g.current&&HC(t)||(p.current=!1,f(7),s||l(!1),(m=r==null?void 0:r.end)==null||m.call(r,s))}})}},[e,s,t,v]),e?[a,{closed:c(1),enter:c(2),leave:c(4),transition:c(2)||c(4)}]:[s,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function FC(e,{prepare:t,run:s,done:r,inFlight:a}){let l=ds();return WC(e,{prepare:t,inFlight:a}),l.nextFrame(()=>{s(),l.requestAnimationFrame(()=>{l.add(UC(e,r))})}),l.dispose}function UC(e,t){var s,r;let a=ds();if(!e)return a.dispose;let l=!1;a.add(()=>{l=!0});let c=(r=(s=e.getAnimations)==null?void 0:s.call(e).filter(u=>u instanceof CSSTransition))!=null?r:[];return c.length===0?(t(),a.dispose):(Promise.allSettled(c.map(u=>u.finished)).then(()=>{l||t()}),a.dispose)}function WC(e,{inFlight:t,prepare:s}){if(t!=null&&t.current){s();return}let r=e.style.transition;e.style.transition="none",s(),e.offsetHeight,e.style.transition=r}function HC(e){var t,s;return((s=(t=e.getAnimations)==null?void 0:t.call(e))!=null?s:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function tg(e,t){let s=x.useRef([]),r=Ge(e);x.useEffect(()=>{let a=[...s.current];for(let[l,c]of t.entries())if(s.current[l]!==c){let u=r(t,a);return s.current=t,u}},[r,...t])}function Bd(){return typeof window<"u"}function ki(e){return Hk(e)?(e.nodeName||"").toLowerCase():"#document"}function Vn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Tr(e){var t;return(t=(Hk(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Hk(e){return Bd()?e instanceof Node||e instanceof Vn(e).Node:!1}function qn(e){return Bd()?e instanceof Element||e instanceof Vn(e).Element:!1}function vo(e){return Bd()?e instanceof HTMLElement||e instanceof Vn(e).HTMLElement:!1}function ov(e){return!Bd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vn(e).ShadowRoot}function Gd(e){const{overflow:t,overflowX:s,overflowY:r,display:a}=lr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+s)&&a!=="inline"&&a!=="contents"}function BC(e){return/^(table|td|th)$/.test(ki(e))}function qd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const GC=/transform|translate|scale|rotate|perspective|filter/,qC=/paint|layout|strict|content/,Fo=e=>!!e&&e!=="none";let up;function ng(e){const t=qn(e)?lr(e):e;return Fo(t.transform)||Fo(t.translate)||Fo(t.scale)||Fo(t.rotate)||Fo(t.perspective)||!sg()&&(Fo(t.backdropFilter)||Fo(t.filter))||GC.test(t.willChange||"")||qC.test(t.contain||"")}function VC(e){let t=Jo(e);for(;vo(t)&&!zl(t);){if(ng(t))return t;if(qd(t))return null;t=Jo(t)}return null}function sg(){return up==null&&(up=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),up}function zl(e){return/^(html|body|#document)$/.test(ki(e))}function lr(e){return Vn(e).getComputedStyle(e)}function Vd(e){return qn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Jo(e){if(ki(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ov(e)&&e.host||Tr(e);return ov(t)?t.host:t}function Bk(e){const t=Jo(e);return zl(t)?(e.ownerDocument||e).body:vo(t)&&Gd(t)?t:Bk(t)}function Dl(e,t,s){var r;t===void 0&&(t=[]),s===void 0&&(s=!0);const a=Bk(e),l=a===((r=e.ownerDocument)==null?void 0:r.body),c=Vn(a);if(l){const u=Jp(c);return t.concat(c,c.visualViewport||[],Gd(a)?a:[],u&&s?Dl(u):[])}else return t.concat(a,Dl(a,[],s))}function Jp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function KC(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:s,version:r}=t;return s+"/"+r}).join(" "):navigator.userAgent}const ea=Math.min,_s=Math.max,Fl=Math.round,Nu=Math.floor,Cr=e=>({x:e,y:e}),XC={left:"right",right:"left",bottom:"top",top:"bottom"};function YC(e,t,s){return _s(e,ea(t,s))}function ji(e,t){return typeof e=="function"?e(t):e}function ta(e){return e.split("-")[0]}function Zl(e){return e.split("-")[1]}function Gk(e){return e==="x"?"y":"x"}function qk(e){return e==="y"?"height":"width"}function _r(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Vk(e){return Gk(_r(e))}function QC(e,t,s){s===void 0&&(s=!1);const r=Zl(e),a=Vk(e),l=qk(a);let c=a==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=sd(c)),[c,sd(c)]}function ZC(e){const t=sd(e);return[eh(e),t,eh(t)]}function eh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const av=["left","right"],iv=["right","left"],JC=["top","bottom"],eT=["bottom","top"];function tT(e,t,s){switch(e){case"top":case"bottom":return s?t?iv:av:t?av:iv;case"left":case"right":return t?JC:eT;default:return[]}}function nT(e,t,s,r){const a=Zl(e);let l=tT(ta(e),s==="start",r);return a&&(l=l.map(c=>c+"-"+a),t&&(l=l.concat(l.map(eh)))),l}function sd(e){const t=ta(e);return XC[t]+e.slice(t.length)}function sT(e){var t,s,r,a;return{top:(t=e.top)!=null?t:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(a=e.left)!=null?a:0}}function rT(e){return typeof e!="number"?sT(e):{top:e,right:e,bottom:e,left:e}}function rd(e){const{x:t,y:s,width:r,height:a}=e;return{width:r,height:a,top:s,left:t,right:t+r,bottom:s+a,x:t,y:s}}function lv(e,t,s){let{reference:r,floating:a}=e;const l=_r(t),c=Vk(t),u=qk(c),f=ta(t),p=l==="y",g=r.x+r.width/2-a.width/2,v=r.y+r.height/2-a.height/2,h=r[u]/2-a[u]/2;let m;switch(f){case"top":m={x:g,y:r.y-a.height};break;case"bottom":m={x:g,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:v};break;case"left":m={x:r.x-a.width,y:v};break;default:m={x:r.x,y:r.y}}const b=Zl(t);return b&&(m[c]+=h*(b==="end"?1:-1)*(s&&p?-1:1)),m}async function Kk(e,t){var s;t===void 0&&(t={});const{x:r,y:a,platform:l,rects:c,elements:u,strategy:f}=e,{boundary:p="clippingAncestors",rootBoundary:g="viewport",elementContext:v="floating",altBoundary:h=!1,padding:m=0}=ji(t,e),b=rT(m),j=u[h?v==="floating"?"reference":"floating":v],N=rd(await l.getClippingRect({element:(s=await(l.isElement==null?void 0:l.isElement(j)))==null||s?j:j.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:p,rootBoundary:g,strategy:f})),R=v==="floating"?{x:r,y:a,width:c.floating.width,height:c.floating.height}:c.reference,$=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),S=await(l.isElement==null?void 0:l.isElement($))&&await(l.getScale==null?void 0:l.getScale($))||{x:1,y:1},E=rd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:R,offsetParent:$,strategy:f}):R);return{top:(N.top-E.top+b.top)/S.y,bottom:(E.bottom-N.bottom+b.bottom)/S.y,left:(N.left-E.left+b.left)/S.x,right:(E.right-N.right+b.right)/S.x}}const oT=50,aT=async(e,t,s)=>{const{placement:r="bottom",strategy:a="absolute",middleware:l=[],platform:c}=s,u=c.detectOverflow?c:{...c,detectOverflow:Kk},f=await(c.isRTL==null?void 0:c.isRTL(t));let p=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:g,y:v}=lv(p,r,f),h=r,m=0;const b={};for(let w=0;w<l.length;w++){const j=l[w];if(!j)continue;const{name:N,fn:R}=j,{x:$,y:S,data:E,reset:C}=await R({x:g,y:v,initialPlacement:r,placement:h,strategy:a,middlewareData:b,rects:p,platform:u,elements:{reference:e,floating:t}});g=$??g,v=S??v,b[N]={...b[N],...E},C&&m<oT&&(m++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(p=C.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):C.rects),{x:g,y:v}=lv(p,h,f)),w=-1)}return{x:g,y:v,placement:h,strategy:a,middlewareData:b}},iT=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,r;const{placement:a,middlewareData:l,rects:c,initialPlacement:u,platform:f,elements:p}=t,{mainAxis:g=!0,crossAxis:v=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:w=!0,...j}=ji(e,t);if((s=l.arrow)!=null&&s.alignmentOffset)return{};const N=ta(a),R=_r(u),$=ta(u)===u,S=await(f.isRTL==null?void 0:f.isRTL(p.floating)),E=h||($||!w?[sd(u)]:ZC(u)),C=b!=="none";!h&&C&&E.push(...nT(u,w,b,S));const T=[u,...E],A=await f.detectOverflow(t,j),F=[];let L=((r=l.flip)==null?void 0:r.overflows)||[];if(g&&F.push(A[N]),v){const D=QC(a,c,S);F.push(A[D[0]],A[D[1]])}if(L=[...L,{placement:a,overflows:F}],!F.every(D=>D<=0)){var z,W;const D=(((z=l.flip)==null?void 0:z.index)||0)+1,K=T[D];if(K&&(!(v==="alignment"?R!==_r(K):!1)||L.every(I=>_r(I.placement)===R?I.overflows[0]>0:!0)))return{data:{index:D,overflows:L},reset:{placement:K}};let P=(W=L.filter(G=>G.overflows[0]<=0).sort((G,I)=>G.overflows[1]-I.overflows[1])[0])==null?void 0:W.placement;if(!P)switch(m){case"bestFit":{var U;const G=(U=L.filter(I=>{if(C){const Y=_r(I.placement);return Y===R||Y==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(Y=>Y>0).reduce((Y,q)=>Y+q,0)]).sort((I,Y)=>I[1]-Y[1])[0])==null?void 0:U[0];G&&(P=G);break}case"initialPlacement":P=u;break}if(a!==P)return{reset:{placement:P}}}return{}}}},lT=new Set(["left","top"]);async function cT(e,t){const{placement:s,platform:r,elements:a}=e,l=await(r.isRTL==null?void 0:r.isRTL(a.floating)),c=ta(s),u=Zl(s),f=_r(s)==="y",p=lT.has(c)?-1:1,g=l&&f?-1:1,v=ji(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:b}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return u&&typeof b=="number"&&(m=u==="end"?b*-1:b),f?{x:m*g,y:h*p}:{x:h*p,y:m*g}}const uT=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,r;const{x:a,y:l,placement:c,middlewareData:u}=t,f=await cT(t,e);return c===((s=u.offset)==null?void 0:s.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:a+f.x,y:l+f.y,data:{...f,placement:c}}}}},dT=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:r,placement:a,platform:l}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:f={fn:R=>{let{x:$,y:S}=R;return{x:$,y:S}}},...p}=ji(e,t),g={x:s,y:r},v=await l.detectOverflow(t,p),h=_r(a),m=Gk(h);let b=g[m],w=g[h];const j=(R,$)=>YC($+v[R==="y"?"top":"left"],$,$-v[R==="y"?"bottom":"right"]);c&&(b=j(m,b)),u&&(w=j(h,w));const N=f.fn({...t,[m]:b,[h]:w});return{...N,data:{x:N.x-s,y:N.y-r,enabled:{[m]:c,[h]:u}}}}}},fT=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:s,rects:r,platform:a,elements:l}=t,{apply:c=()=>{},...u}=ji(e,t),f=await a.detectOverflow(t,u),p=ta(s),g=Zl(s),v=_r(s)==="y",{width:h,height:m}=r.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=g===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(w=p,b=g==="end"?"top":"bottom");const j=m-f.top-f.bottom,N=h-f.left-f.right,R=ea(m-f[b],j),$=ea(h-f[w],N),S=t.middlewareData.shift,E=!S;let C=R,T=$;S!=null&&S.enabled.x&&(T=N),S!=null&&S.enabled.y&&(C=j),E&&!g&&(v?T=h-2*_s(f.left,f.right):C=m-2*_s(f.top,f.bottom)),await c({...t,availableWidth:T,availableHeight:C});const A=await a.getDimensions(l.floating);return h!==A.width||m!==A.height?{reset:{rects:!0}}:{}}}};function Xk(e){const t=lr(e);let s=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=vo(e),l=a?e.offsetWidth:s,c=a?e.offsetHeight:r,u=Fl(s)!==l||Fl(r)!==c;return u&&(s=l,r=c),{width:s,height:r,$:u}}function rg(e){return qn(e)?e:e.contextElement}function Qa(e){const t=rg(e);if(!vo(t))return Cr(1);const s=t.getBoundingClientRect(),{width:r,height:a,$:l}=Xk(t);let c=(l?Fl(s.width):s.width)/r,u=(l?Fl(s.height):s.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const mT=Cr(0);function Yk(e){const t=Vn(e);return!sg()||!t.visualViewport?mT:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function pT(e,t,s){return t===void 0&&(t=!1),!!s&&t&&s===Vn(e)}function na(e,t,s,r){t===void 0&&(t=!1),s===void 0&&(s=!1);const a=e.getBoundingClientRect(),l=rg(e);let c=Cr(1);t&&(r?qn(r)&&(c=Qa(r)):c=Qa(e));const u=pT(l,s,r)?Yk(l):Cr(0);let f=(a.left+u.x)/c.x,p=(a.top+u.y)/c.y,g=a.width/c.x,v=a.height/c.y;if(l&&r){const h=Vn(l),m=qn(r)?Vn(r):r;let b=h,w=Jp(b);for(;w&&m!==b;){const j=Qa(w),N=w.getBoundingClientRect(),R=lr(w),$=N.left+(w.clientLeft+parseFloat(R.paddingLeft))*j.x,S=N.top+(w.clientTop+parseFloat(R.paddingTop))*j.y;f*=j.x,p*=j.y,g*=j.x,v*=j.y,f+=$,p+=S,b=Vn(w),w=Jp(b)}}return rd({width:g,height:v,x:f,y:p})}function Kd(e,t){const s=Vd(e).scrollLeft;return t?t.left+s:na(Tr(e)).left+s}function Qk(e,t){const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-Kd(e,s),a=s.top+t.scrollTop;return{x:r,y:a}}function hT(e){let{elements:t,rect:s,offsetParent:r,strategy:a}=e;const l=a==="fixed",c=Tr(r),u=t?qd(t.floating):!1;if(r===c||u&&l)return s;let f={scrollLeft:0,scrollTop:0},p=Cr(1);const g=Cr(0),v=vo(r);if((v||!l)&&((ki(r)!=="body"||Gd(c))&&(f=Vd(r)),v)){const m=na(r);p=Qa(r),g.x=m.x+r.clientLeft,g.y=m.y+r.clientTop}const h=c&&!v&&!l?Qk(c,f):Cr(0);return{width:s.width*p.x,height:s.height*p.y,x:s.x*p.x-f.scrollLeft*p.x+g.x+h.x,y:s.y*p.y-f.scrollTop*p.y+g.y+h.y}}function gT(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function xT(e){const t=Vd(e),s=e.ownerDocument.body,r=_s(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),a=_s(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let l=-t.scrollLeft+Kd(e);const c=-t.scrollTop;return lr(s).direction==="rtl"&&(l+=_s(e.clientWidth,s.clientWidth)-r),{width:r,height:a,x:l,y:c}}const yT=25;function bT(e,t,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",a=Vn(e),l=Tr(e),c=a.visualViewport;let u=l.clientWidth,f=l.clientHeight,p=0,g=0;if(c){const h=!sg()||t==="fixed";r?h||(p=-c.offsetLeft,g=-c.offsetTop):(u=c.width,f=c.height,h&&(p=c.offsetLeft,g=c.offsetTop))}if(Kd(l)<=0){const h=l.ownerDocument,m=h.body,b=getComputedStyle(m),w=h.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,j=Math.abs(l.clientWidth-m.clientWidth-w),N=getComputedStyle(l).scrollbarGutter==="stable both-edges"?j/2:j;N<=yT&&(u-=N)}return{width:u,height:f,x:p,y:g}}function vT(e,t){const s=na(e,!0,t==="fixed"),r=s.top+e.clientTop,a=s.left+e.clientLeft,l=Qa(e),c=e.clientWidth*l.x,u=e.clientHeight*l.y,f=a*l.x,p=r*l.y;return{width:c,height:u,x:f,y:p}}function cv(e,t,s){let r;if(t==="viewport"||t==="layoutViewport")r=bT(e,s,t);else if(t==="document")r=xT(Tr(e));else if(qn(t))r=vT(t,s);else{const a=Yk(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return rd(r)}function wT(e,t){const s=t.get(e);if(s)return s;let r=Dl(e,[],!1).filter(u=>qn(u)&&ki(u)!=="body"),a=null;const l=lr(e).position==="fixed";let c=l?Jo(e):e;for(;qn(c)&&!zl(c);){const u=lr(c),f=ng(c),p=a?a.position:l?"fixed":"";!f&&(p==="fixed"||p==="absolute"&&u.position==="static")?r=r.filter(v=>v!==c):a=u,c=Jo(c)}return t.set(e,r),r}function kT(e){let{element:t,boundary:s,rootBoundary:r,strategy:a}=e;const c=[...s==="clippingAncestors"?qd(t)?[]:wT(t,this._c):[].concat(s),r],u=cv(t,c[0],a);let f=u.top,p=u.right,g=u.bottom,v=u.left;for(let h=1;h<c.length;h++){const m=cv(t,c[h],a);f=_s(m.top,f),p=ea(m.right,p),g=ea(m.bottom,g),v=_s(m.left,v)}return{width:p-v,height:g-f,x:v,y:f}}function jT(e){const{width:t,height:s}=Xk(e);return{width:t,height:s}}function NT(e,t,s){const r=vo(t),a=Tr(t),l=s==="fixed",c=na(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const f=Cr(0);if((r||!l)&&((ki(t)!=="body"||Gd(a))&&(u=Vd(t)),r)){const h=na(t,!0,l,t);f.x=h.x+t.clientLeft,f.y=h.y+t.clientTop}!r&&a&&(f.x=Kd(a));const p=a&&!r&&!l?Qk(a,u):Cr(0),g=c.left+u.scrollLeft-f.x-p.x,v=c.top+u.scrollTop-f.y-p.y;return{x:g,y:v,width:c.width,height:c.height}}function dp(e){return lr(e).position==="static"}function uv(e,t){if(!vo(e)||lr(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return Tr(e)===s&&(s=s.ownerDocument.body),s}function Zk(e,t){const s=Vn(e);if(qd(e))return s;if(!vo(e)){let a=Jo(e);for(;a&&!zl(a);){if(qn(a)&&!dp(a))return a;a=Jo(a)}return s}let r=uv(e,t);for(;r&&BC(r)&&dp(r);)r=uv(r,t);return r&&zl(r)&&dp(r)&&!ng(r)?s:r||VC(e)||s}const ST=async function(e){const t=this.getOffsetParent||Zk,s=this.getDimensions,r=await s(e.floating);return{reference:NT(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _T(e){return lr(e).direction==="rtl"}const $T={convertOffsetParentRelativeRectToViewportRelativeRect:hT,getDocumentElement:Tr,getClippingRect:kT,getOffsetParent:Zk,getElementRects:ST,getClientRects:gT,getDimensions:jT,getScale:Qa,isElement:qn,isRTL:_T};function Jk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ET(e,t,s){let r=null,a;const l=Tr(e);function c(){var g;clearTimeout(a),(g=r)==null||g.disconnect(),r=null}function u(g,v){g===void 0&&(g=!1),v===void 0&&(v=1),c();const h=e.getBoundingClientRect(),{left:m,top:b,width:w,height:j}=h;if(g||t(),!w||!j)return;const N=Nu(b),R=Nu(l.clientWidth-(m+w)),$=Nu(l.clientHeight-(b+j)),S=Nu(m),C={rootMargin:-N+"px "+-R+"px "+-$+"px "+-S+"px",threshold:_s(0,ea(1,v))||1};let T=!0;function A(F){const L=F[0].intersectionRatio;if(!Jk(h,e.getBoundingClientRect()))return u();if(L!==v){if(!T)return u();L?u(!1,L):a=setTimeout(()=>{u(!1,1e-7)},1e3)}T=!1}try{r=new IntersectionObserver(A,{...C,root:l.ownerDocument})}catch{r=new IntersectionObserver(A,C)}r.observe(e)}const f=Vn(e),p=()=>u(s);return f.addEventListener("resize",p),u(!0),()=>{f.removeEventListener("resize",p),c()}}function CT(e,t,s,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:f=!1}=r,p=rg(e),g=a||l?[...p?Dl(p):[],...t?Dl(t):[]]:[];g.forEach(N=>{a&&N.addEventListener("scroll",s),l&&N.addEventListener("resize",s)});const v=p&&u?ET(p,s,l):null;let h=-1,m=null;c&&(m=new ResizeObserver(N=>{let[R]=N;R&&R.target===p&&m&&t&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var $;($=m)==null||$.observe(t)})),s()}),p&&!f&&m.observe(p),t&&m.observe(t));let b,w=f?na(e):null;f&&j();function j(){const N=na(e);w&&!Jk(w,N)&&s(),w=N,b=requestAnimationFrame(j)}return s(),()=>{var N;g.forEach(R=>{a&&R.removeEventListener("scroll",s),l&&R.removeEventListener("resize",s)}),v==null||v(),(N=m)==null||N.disconnect(),m=null,f&&cancelAnimationFrame(b)}}const fp=Kk,TT=uT,RT=dT,AT=iT,OT=fT,MT=(e,t,s)=>{const r=new Map,a=s??{},l={...$T,...a.platform,_c:r};return aT(e,t,{...a,platform:l})};var PT=typeof document<"u",LT=function(){},Wu=PT?x.useLayoutEffect:LT;function od(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 s,r,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(r=s;r--!==0;)if(!od(e[r],t[r]))return!1;return!0}if(a=Object.keys(e),s=a.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(t,a[r]))return!1;for(r=s;r--!==0;){const l=a[r];if(!(l==="_owner"&&e.$$typeof)&&!od(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function ej(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dv(e,t){const s=ej(e);return Math.round(t*s)/s}function mp(e){const t=x.useRef(e);return Wu(()=>{t.current=e}),t}function IT(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:r=[],platform:a,elements:{reference:l,floating:c}={},transform:u=!0,whileElementsMounted:f,open:p}=e,[g,v]=x.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=x.useState(r);od(h,r)||m(r);const[b,w]=x.useState(null),[j,N]=x.useState(null),R=x.useCallback(I=>{I!==C.current&&(C.current=I,w(I))},[]),$=x.useCallback(I=>{I!==T.current&&(T.current=I,N(I))},[]),S=l||b,E=c||j,C=x.useRef(null),T=x.useRef(null),A=x.useRef(g),F=f!=null,L=mp(f),z=mp(a),W=mp(p),U=x.useCallback(()=>{if(!C.current||!T.current)return;const I={placement:t,strategy:s,middleware:h};z.current&&(I.platform=z.current),MT(C.current,T.current,I).then(Y=>{const q={...Y,isPositioned:W.current!==!1};D.current&&!od(A.current,q)&&(A.current=q,ir.flushSync(()=>{v(q)}))})},[h,t,s,z,W]);Wu(()=>{p===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,v(I=>({...I,isPositioned:!1})))},[p]);const D=x.useRef(!1);Wu(()=>(D.current=!0,()=>{D.current=!1}),[]),Wu(()=>{if(S&&(C.current=S),E&&(T.current=E),S&&E){if(L.current)return L.current(S,E,U);U()}},[S,E,U,L,F]);const K=x.useMemo(()=>({reference:C,floating:T,setReference:R,setFloating:$}),[R,$]),P=x.useMemo(()=>({reference:S,floating:E}),[S,E]),G=x.useMemo(()=>{const I={position:s,left:0,top:0};if(!P.floating)return I;const Y=dv(P.floating,g.x),q=dv(P.floating,g.y);return u?{...I,transform:"translate("+Y+"px, "+q+"px)",...ej(P.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:Y,top:q}},[s,u,P.floating,g.x,g.y]);return x.useMemo(()=>({...g,update:U,refs:K,elements:P,floatingStyles:G}),[g,U,K,P,G])}const tj=(e,t)=>{const s=TT(e);return{name:s.name,fn:s.fn,options:[e,t]}},zT=(e,t)=>{const s=RT(e);return{name:s.name,fn:s.fn,options:[e,t]}},DT=(e,t)=>{const s=AT(e);return{name:s.name,fn:s.fn,options:[e,t]}},FT=(e,t)=>{const s=OT(e);return{name:s.name,fn:s.fn,options:[e,t]}},nj={...Up},UT=nj.useInsertionEffect,WT=UT||(e=>e());function sj(e){const t=x.useRef(()=>{});return WT(()=>{t.current=e}),x.useCallback(function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}var th=typeof document<"u"?x.useLayoutEffect:x.useEffect;let fv=!1,HT=0;const mv=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+HT++;function BT(){const[e,t]=x.useState(()=>fv?mv():void 0);return th(()=>{e==null&&t(mv())},[]),x.useEffect(()=>{fv=!0},[]),e}const GT=nj.useId,qT=GT||BT;function VT(){const e=new Map;return{emit(t,s){var r;(r=e.get(t))==null||r.forEach(a=>a(s))},on(t,s){e.set(t,[...e.get(t)||[],s])},off(t,s){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(a=>a!==s))||[])}}}const KT=x.createContext(null),XT=x.createContext(null),YT=()=>{var e;return((e=x.useContext(KT))==null?void 0:e.id)||null},QT=()=>x.useContext(XT),ZT="data-floating-ui-focusable";function JT(e){const{open:t=!1,onOpenChange:s,elements:r}=e,a=qT(),l=x.useRef({}),[c]=x.useState(()=>VT()),u=YT()!=null,[f,p]=x.useState(r.reference),g=sj((m,b,w)=>{l.current.openEvent=m?b:void 0,c.emit("openchange",{open:m,event:b,reason:w,nested:u}),s==null||s(m,b,w)}),v=x.useMemo(()=>({setPositionReference:p}),[]),h=x.useMemo(()=>({reference:f||r.reference||null,floating:r.floating||null,domReference:r.reference}),[f,r.reference,r.floating]);return x.useMemo(()=>({dataRef:l,open:t,onOpenChange:g,elements:h,events:c,floatingId:a,refs:v}),[t,g,h,c,a,v])}function eR(e){e===void 0&&(e={});const{nodeId:t}=e,s=JT({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,a=r.elements,[l,c]=x.useState(null),[u,f]=x.useState(null),g=(a==null?void 0:a.domReference)||l,v=x.useRef(null),h=QT();th(()=>{g&&(v.current=g)},[g]);const m=IT({...e,elements:{...a,...u&&{reference:u}}}),b=x.useCallback($=>{const S=qn($)?{getBoundingClientRect:()=>$.getBoundingClientRect(),contextElement:$}:$;f(S),m.refs.setReference(S)},[m.refs]),w=x.useCallback($=>{(qn($)||$===null)&&(v.current=$,c($)),(qn(m.refs.reference.current)||m.refs.reference.current===null||$!==null&&!qn($))&&m.refs.setReference($)},[m.refs]),j=x.useMemo(()=>({...m.refs,setReference:w,setPositionReference:b,domReference:v}),[m.refs,w,b]),N=x.useMemo(()=>({...m.elements,domReference:g}),[m.elements,g]),R=x.useMemo(()=>({...m,...r,refs:j,elements:N,nodeId:t}),[m,j,N,t,r]);return th(()=>{r.dataRef.current.floatingContext=R;const $=h==null?void 0:h.nodesRef.current.find(S=>S.id===t);$&&($.context=R)}),x.useMemo(()=>({...m,context:R,refs:j,elements:N}),[m,j,N,R])}const pv="active",hv="selected";function pp(e,t,s){const r=new Map,a=s==="item";let l=e;if(a&&e){const{[pv]:c,[hv]:u,...f}=e;l=f}return{...s==="floating"&&{tabIndex:-1,[ZT]:""},...l,...t.map(c=>{const u=c?c[s]:null;return typeof u=="function"?e?u(e):null:u}).concat(e).reduce((c,u)=>(u&&Object.entries(u).forEach(f=>{let[p,g]=f;if(!(a&&[pv,hv].includes(p)))if(p.indexOf("on")===0){if(r.has(p)||r.set(p,[]),typeof g=="function"){var v;(v=r.get(p))==null||v.push(g),c[p]=function(){for(var h,m=arguments.length,b=new Array(m),w=0;w<m;w++)b[w]=arguments[w];return(h=r.get(p))==null?void 0:h.map(j=>j(...b)).find(j=>j!==void 0)}}}else c[p]=g}),c),{})}}function tR(e){e===void 0&&(e=[]);const t=e.map(u=>u==null?void 0:u.reference),s=e.map(u=>u==null?void 0:u.floating),r=e.map(u=>u==null?void 0:u.item),a=x.useCallback(u=>pp(u,e,"reference"),t),l=x.useCallback(u=>pp(u,e,"floating"),s),c=x.useCallback(u=>pp(u,e,"item"),r);return x.useMemo(()=>({getReferenceProps:a,getFloatingProps:l,getItemProps:c}),[a,l,c])}function gv(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const nR=e=>({name:"inner",options:e,async fn(t){const{listRef:s,overflowRef:r,onFallbackChange:a,offset:l=0,index:c=0,minItemsVisible:u=4,referenceOverflowThreshold:f=0,scrollRef:p,...g}=ji(e,t),{rects:v,elements:{floating:h}}=t,m=s.current[c],b=(p==null?void 0:p.current)||h,w=h.clientTop||b.clientTop,j=h.clientTop!==0,N=b.clientTop!==0,R=h===b;if(!m)return{};const $={...t,...await tj(-m.offsetTop-h.clientTop-v.reference.height/2-m.offsetHeight/2-l).fn(t)},S=await fp(gv($,b.scrollHeight+w+h.clientTop),g),E=await fp($,{...g,elementContext:"reference"}),C=_s(0,S.top),T=$.y+C,L=(b.scrollHeight>b.clientHeight?z=>z:Fl)(_s(0,b.scrollHeight+(j&&R||N?w*2:0)-C-_s(0,S.bottom)));if(b.style.maxHeight=L+"px",b.scrollTop=C,a){const z=b.offsetHeight<m.offsetHeight*ea(u,s.current.length)-1||E.top>=-f||E.bottom>=-f;ir.flushSync(()=>a(z))}return r&&(r.current=await fp(gv({...$,y:T},b.offsetHeight+w+h.clientTop),g)),{y:T}}});function sR(e,t){const{open:s,elements:r}=e,{enabled:a=!0,overflowRef:l,scrollRef:c,onChange:u}=t,f=sj(u),p=x.useRef(!1),g=x.useRef(null),v=x.useRef(null);x.useEffect(()=>{if(!a)return;function m(w){if(w.ctrlKey||!b||l.current==null)return;const j=w.deltaY,N=l.current.top>=-.5,R=l.current.bottom>=-.5,$=b.scrollHeight-b.clientHeight,S=j<0?-1:1,E=j<0?"max":"min";b.scrollHeight<=b.clientHeight||(!N&&j>0||!R&&j<0?(w.preventDefault(),ir.flushSync(()=>{f(C=>C+Math[E](j,$*S))})):/firefox/i.test(KC())&&(b.scrollTop+=j))}const b=(c==null?void 0:c.current)||r.floating;if(s&&b)return b.addEventListener("wheel",m),requestAnimationFrame(()=>{g.current=b.scrollTop,l.current!=null&&(v.current={...l.current})}),()=>{g.current=null,v.current=null,b.removeEventListener("wheel",m)}},[a,s,r.floating,l,c,f]);const h=x.useMemo(()=>({onKeyDown(){p.current=!0},onWheel(){p.current=!1},onPointerMove(){p.current=!1},onScroll(){const m=(c==null?void 0:c.current)||r.floating;if(!(!l.current||!m||!p.current)){if(g.current!==null){const b=m.scrollTop-g.current;(l.current.bottom<-.5&&b<-1||l.current.top<-.5&&b>1)&&ir.flushSync(()=>f(w=>w+b))}requestAnimationFrame(()=>{g.current=m.scrollTop})}}}),[r.floating,f,l,c]);return x.useMemo(()=>a?{floating:h}:{},[a,h])}let Ni=x.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Ni.displayName="FloatingContext";let og=x.createContext(null);og.displayName="PlacementContext";function rR(e){return x.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function oR(){return x.useContext(Ni).setReference}function aR(){return x.useContext(Ni).getReferenceProps}function iR(){let{getFloatingProps:e,slot:t}=x.useContext(Ni);return x.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":t.anchor}),[e,t])}function lR(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=x.useContext(og),s=x.useMemo(()=>e,[JSON.stringify(e,(a,l)=>{var c;return(c=l==null?void 0:l.outerHTML)!=null?c:l})]);At(()=>{t==null||t(s??null)},[t,s]);let r=x.useContext(Ni);return x.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let xv=4;function cR({children:e,enabled:t=!0}){let[s,r]=x.useState(null),[a,l]=x.useState(0),c=x.useRef(null),[u,f]=x.useState(null);uR(u);let p=t&&s!==null&&u!==null,{to:g="bottom",gap:v=0,offset:h=0,padding:m=0,inner:b}=dR(s,u),[w,j="center"]=g.split(" ");At(()=>{p&&l(0)},[p]);let{refs:N,floatingStyles:R,context:$}=eR({open:p,placement:w==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${w}`:`${w}-${j}`,strategy:"absolute",transform:!1,middleware:[tj({mainAxis:w==="selection"?0:v,crossAxis:h}),zT({padding:m}),w!=="selection"&&DT({padding:m}),w==="selection"&&b?nR({...b,padding:m,overflowRef:c,offset:a,minItemsVisible:xv,referenceOverflowThreshold:m,onFallbackChange(z){var W,U;if(!z)return;let D=$.elements.floating;if(!D)return;let K=parseFloat(getComputedStyle(D).scrollPaddingBottom)||0,P=Math.min(xv,D.childElementCount),G=0,I=0;for(let Y of(U=(W=$.elements.floating)==null?void 0:W.childNodes)!=null?U:[])if(cs(Y)){let q=Y.offsetTop,O=q+Y.clientHeight+K,B=D.scrollTop,ee=B+D.clientHeight;if(q>=B&&O<=ee)P--;else{I=Math.max(0,Math.min(O,ee)-Math.max(q,B)),G=Y.clientHeight;break}}P>=1&&l(Y=>{let q=G*P-I+K;return Y>=q?Y:q})}}):null,FT({padding:m,apply({availableWidth:z,availableHeight:W,elements:U}){Object.assign(U.floating.style,{overflow:"auto",maxWidth:`${z}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${W}px)`})}})].filter(Boolean),whileElementsMounted:CT}),[S=w,E=j]=$.placement.split("-");w==="selection"&&(S="selection");let C=x.useMemo(()=>({anchor:[S,E].filter(Boolean).join(" ")}),[S,E]),T=sR($,{overflowRef:c,onChange:l}),{getReferenceProps:A,getFloatingProps:F}=tR([T]),L=Ge(z=>{f(z),N.setFloating(z)});return x.createElement(og.Provider,{value:r},x.createElement(Ni.Provider,{value:{setFloating:L,setReference:N.setReference,styles:R,getReferenceProps:A,getFloatingProps:F,slot:C}},e))}function uR(e){At(()=>{if(!e)return;let t=new MutationObserver(()=>{let s=window.getComputedStyle(e).maxHeight,r=parseFloat(s);if(isNaN(r))return;let a=parseInt(s);isNaN(a)||r!==a&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function dR(e,t){var s,r,a;let l=hp((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",t),c=hp((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),u=hp((a=e==null?void 0:e.padding)!=null?a:"var(--anchor-padding, 0)",t);return{...e,gap:l,offset:c,padding:u}}function hp(e,t,s=void 0){let r=yo(),a=Ge((f,p)=>{if(f==null)return[s,null];if(typeof f=="number")return[f,null];if(typeof f=="string"){if(!p)return[s,null];let g=yv(f,p);return[g,v=>{let h=rj(f);{let m=h.map(b=>window.getComputedStyle(p).getPropertyValue(b));r.requestAnimationFrame(function b(){r.nextFrame(b);let w=!1;for(let[N,R]of h.entries()){let $=window.getComputedStyle(p).getPropertyValue(R);if(m[N]!==$){m[N]=$,w=!0;break}}if(!w)return;let j=yv(f,p);g!==j&&(v(j),g=j)})}return r.dispose}]}return[s,null]}),l=x.useMemo(()=>a(e,t)[0],[e,t]),[c=l,u]=x.useState();return At(()=>{let[f,p]=a(e,t);if(u(f),!!p)return p(u)},[e,t]),c}function rj(e){let t=/var\((.*)\)/.exec(e);if(t){let s=t[1].indexOf(",");if(s===-1)return[t[1]];let r=t[1].slice(0,s).trim(),a=t[1].slice(s+1).trim();return a?[r,...rj(a)]:[r]}return[]}function yv(e,t){let s=document.createElement("div");t.appendChild(s),s.style.setProperty("margin-top","0px","important"),s.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(s).marginTop)||0;return t.removeChild(s),r}function fR({children:e,freeze:t},s){let r=oj(t,e);return x.isValidElement(r)?x.cloneElement(r,{ref:s}):Ne.createElement(Ne.Fragment,null,r)}Ne.forwardRef(fR);function oj(e,t){let[s,r]=x.useState(t);return!e&&s!==t&&r(t),e?s:t}let Xd=x.createContext(null);Xd.displayName="OpenClosedContext";var Cn=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Cn||{});function Jl(){return x.useContext(Xd)}function aj({value:e,children:t}){return Ne.createElement(Xd.Provider,{value:e},t)}function mR({children:e}){return Ne.createElement(Xd.Provider,{value:null},e)}function pR(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let oo=[];pR(()=>{function e(t){if(!Sr(t.target)||t.target===document.body||oo[0]===t.target)return;let s=t.target;s=s.closest(nd),oo.unshift(s??t.target),oo=oo.filter(r=>r!=null&&r.isConnected),oo.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function hR(e){throw new Error("Unexpected object: "+e)}var Pt=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(Pt||{});function Su(e,t){let s=t.resolveItems();if(s.length<=0)return null;let r=t.resolveActiveIndex(),a=r??-1;switch(e.focus){case 0:{for(let l=0;l<s.length;++l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 1:{a===-1&&(a=s.length);for(let l=a-1;l>=0;--l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 2:{for(let l=a+1;l<s.length;++l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 3:{for(let l=s.length-1;l>=0;--l)if(!t.resolveDisabled(s[l],l,s))return l;return r}case 4:{for(let l=0;l<s.length;++l)if(t.resolveId(s[l],l,s)===e.id)return l;return r}case 5:return null;default:hR(e)}}function ag(e){let t=Ge(e),s=x.useRef(!1);x.useEffect(()=>(s.current=!1,()=>{s.current=!0,Fd(()=>{s.current&&t()})}),[t])}function gR(){let e=typeof document>"u";return"useSyncExternalStore"in Up?(t=>t.useSyncExternalStore)(Up)(()=>()=>{},()=>!1,()=>!e):!1}function ec(){let e=gR(),[t,s]=x.useState(sr.isHandoffComplete);return t&&sr.isHandoffComplete===!1&&s(!1),x.useEffect(()=>{t!==!0&&s(!0)},[t]),x.useEffect(()=>sr.handoff(),[]),e?!1:t}let ij=x.createContext(!1);function xR(){return x.useContext(ij)}function bv(e){return Ne.createElement(ij.Provider,{value:e.force},e.children)}function yR(e){let t=xR(),s=x.useContext(cj),[r,a]=x.useState(()=>{var l;if(!t&&s!==null)return(l=s.current)!=null?l:null;if(sr.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let u=e.createElement("div");return u.setAttribute("id","headlessui-portal-root"),e.body.appendChild(u)});return x.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),x.useEffect(()=>{t||s!==null&&a(s.current)},[s,a,t]),r}let lj=x.Fragment,bR=Gt(function(e,t){let{ownerDocument:s=null,...r}=e,a=x.useRef(null),l=wn(BE(m=>{a.current=m}),t),c=Il(a.current),u=s??c,f=yR(u),p=x.useContext(nh),g=yo(),v=ec(),h=rn();return ag(()=>{var m;f&&f.childNodes.length<=0&&((m=f.parentElement)==null||m.removeChild(f))}),!f||!v?null:ir.createPortal(Ne.createElement("div",{"data-headlessui-portal":"",ref:m=>{g.dispose(),p&&m&&g.add(p.register(m))}},h({ourProps:{ref:l},theirProps:r,slot:{},defaultTag:lj,name:"Portal"})),f)});function vR(e,t){let s=wn(t),{enabled:r=!0,ownerDocument:a,...l}=e,c=rn();return r?Ne.createElement(bR,{...l,ownerDocument:a,ref:s}):c({ourProps:{ref:s},theirProps:l,slot:{},defaultTag:lj,name:"Portal"})}let wR=x.Fragment,cj=x.createContext(null);function kR(e,t){let{target:s,...r}=e,a={ref:wn(t)},l=rn();return Ne.createElement(cj.Provider,{value:s},l({ourProps:a,theirProps:r,defaultTag:wR,name:"Popover.Group"}))}let nh=x.createContext(null);function jR(){let e=x.useContext(nh),t=x.useRef([]),s=Ge(l=>(t.current.push(l),e&&e.register(l),()=>r(l))),r=Ge(l=>{let c=t.current.indexOf(l);c!==-1&&t.current.splice(c,1),e&&e.unregister(l)}),a=x.useMemo(()=>({register:s,unregister:r,portals:t}),[s,r,t]);return[t,x.useMemo(()=>function({children:l}){return Ne.createElement(nh.Provider,{value:a},l)},[a])]}let NR=Gt(vR),uj=Gt(kR),dj=Object.assign(NR,{Group:uj});const Hu={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function fj(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function SR(e,t,s){let r=ds();if(t.kind==="Tracked"){let a=function(){l!==fj(e)&&(r.dispose(),s())},{position:l}=t,c=new ResizeObserver(a);c.observe(e),r.add(()=>c.disconnect()),r.addEventListener(window,"scroll",a,{passive:!0}),r.addEventListener(window,"resize",a)}return()=>r.dispose()}function _R(e,t=typeof document<"u"?document.defaultView:null,s){let r=Ql(e,"escape");Dk(t,"keydown",a=>{r&&(a.defaultPrevented||a.key===Zt.Escape&&s(a))})}function $R(){var e;let[t]=x.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[s,r]=x.useState((e=t==null?void 0:t.matches)!=null?e:!1);return At(()=>{if(!t)return;function a(l){r(l.matches)}return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[t]),s}function ER({defaultContainers:e=[],portals:t,mainTreeNode:s}={}){let r=Ge(()=>{var a,l;let c=wi(s),u=[];for(let f of e)f!==null&&($r(f)?u.push(f):"current"in f&&$r(f.current)&&u.push(f.current));if(t!=null&&t.current)for(let f of t.current)u.push(f);for(let f of(a=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?a:[])f!==document.body&&f!==document.head&&$r(f)&&f.id!=="headlessui-portal-root"&&(s&&(f.contains(s)||f.contains((l=s==null?void 0:s.getRootNode())==null?void 0:l.host))||u.some(p=>f.contains(p))||u.push(f));return u});return{resolveContainers:r,contains:Ge(a=>r().some(l=>l.contains(a)))}}let mj=x.createContext(null);function vv({children:e,node:t}){let[s,r]=x.useState(null),a=pj(t??s);return Ne.createElement(mj.Provider,{value:a},e,a===null&&Ne.createElement(Ll,{features:ci.Hidden,ref:l=>{var c,u;if(l){for(let f of(u=(c=wi(l))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?u:[])if(f!==document.body&&f!==document.head&&$r(f)&&f!=null&&f.contains(l)){r(f);break}}}}))}function pj(e=null){var t;return(t=x.useContext(mj))!=null?t:e}function ig(){let e=x.useRef(!1);return At(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Nl=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Nl||{});function CR(){let e=x.useRef(0);return Ik(!0,"keydown",t=>{t.key==="Tab"&&(e.current=t.shiftKey?1:0)},!0),e}function hj(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let s of e.current)$r(s.current)&&t.add(s.current);return t}let TR="div";var Go=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(Go||{});function RR(e,t){let s=x.useRef(null),r=wn(s,t),{initialFocus:a,initialFocusFallback:l,containers:c,features:u=15,...f}=e;ec()||(u=0);let p=Il(s.current);PR(u,{ownerDocument:p});let g=LR(u,{ownerDocument:p,container:s,initialFocus:a,initialFocusFallback:l});IR(u,{ownerDocument:p,container:s,containers:c,previousActiveElement:g});let v=CR(),h=Ge(R=>{if(!cs(s.current))return;let $=s.current;(S=>S())(()=>{Rn(v.current,{[Nl.Forwards]:()=>{Ya($,Hs.First,{skipElements:[R.relatedTarget,l]})},[Nl.Backwards]:()=>{Ya($,Hs.Last,{skipElements:[R.relatedTarget,l]})}})})}),m=Ql(!!(u&2),"focus-trap#tab-lock"),b=yo(),w=x.useRef(!1),j={ref:r,onKeyDown(R){R.key=="Tab"&&(w.current=!0,b.requestAnimationFrame(()=>{w.current=!1}))},onBlur(R){if(!(u&4))return;let $=hj(c);cs(s.current)&&$.add(s.current);let S=R.relatedTarget;Sr(S)&&S.dataset.headlessuiFocusGuard!=="true"&&(gj($,S)||(w.current?Ya(s.current,Rn(v.current,{[Nl.Forwards]:()=>Hs.Next,[Nl.Backwards]:()=>Hs.Previous})|Hs.WrapAround,{relativeTo:R.target}):Sr(R.target)&&Er(R.target)))}},N=rn();return Ne.createElement(Ne.Fragment,null,m&&Ne.createElement(Ll,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:h,features:ci.Focusable}),N({ourProps:j,theirProps:f,defaultTag:TR,name:"FocusTrap"}),m&&Ne.createElement(Ll,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:h,features:ci.Focusable}))}let AR=Gt(RR),OR=Object.assign(AR,{features:Go});function MR(e=!0){let t=x.useRef(oo.slice());return tg(([s],[r])=>{r===!0&&s===!1&&Fd(()=>{t.current.splice(0)}),r===!1&&s===!0&&(t.current=oo.slice())},[e,oo,t]),Ge(()=>{var s;return(s=t.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function PR(e,{ownerDocument:t}){let s=!!(e&8),r=MR(s);tg(()=>{s||lk(t==null?void 0:t.body)&&Er(r())},[s]),ag(()=>{s&&Er(r())})}function LR(e,{ownerDocument:t,container:s,initialFocus:r,initialFocusFallback:a}){let l=x.useRef(null),c=Ql(!!(e&1),"focus-trap#initial-focus"),u=ig();return tg(()=>{if(e===0)return;if(!c){a!=null&&a.current&&Er(a.current);return}let f=s.current;f&&Fd(()=>{if(!u.current)return;let p=t==null?void 0:t.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===p){l.current=p;return}}else if(f.contains(p)){l.current=p;return}if(r!=null&&r.current)Er(r.current);else{if(e&16){if(Ya(f,Hs.First|Hs.AutoFocus)!==Zp.Error)return}else if(Ya(f,Hs.First)!==Zp.Error)return;if(a!=null&&a.current&&(Er(a.current),(t==null?void 0:t.activeElement)===a.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}l.current=t==null?void 0:t.activeElement})},[a,c,e]),l}function IR(e,{ownerDocument:t,container:s,containers:r,previousActiveElement:a}){let l=ig(),c=!!(e&4);Dk(t==null?void 0:t.defaultView,"focus",u=>{if(!c||!l.current)return;let f=hj(r);cs(s.current)&&f.add(s.current);let p=a.current;if(!p)return;let g=u.target;cs(g)?gj(f,g)?(a.current=g,Er(g)):(u.preventDefault(),u.stopPropagation(),Er(p)):Er(a.current)},!0)}function gj(e,t){for(let s of e)if(s.contains(t))return!0;return!1}function xj(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!El((t=e.as)!=null?t:bj)||Ne.Children.count(e.children)===1}let Yd=x.createContext(null);Yd.displayName="TransitionContext";var zR=(e=>(e.Visible="visible",e.Hidden="hidden",e))(zR||{});function DR(){let e=x.useContext(Yd);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function FR(){let e=x.useContext(Qd);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let Qd=x.createContext(null);Qd.displayName="NestingContext";function Zd(e){return"children"in e?Zd(e.children):e.current.filter(({el:t})=>t.current!==null).filter(({state:t})=>t==="visible").length>0}function yj(e,t){let s=bo(e),r=x.useRef([]),a=ig(),l=yo(),c=Ge((m,b=io.Hidden)=>{let w=r.current.findIndex(({el:j})=>j===m);w!==-1&&(Rn(b,{[io.Unmount](){r.current.splice(w,1)},[io.Hidden](){r.current[w].state="hidden"}}),l.microTask(()=>{var j;!Zd(r)&&a.current&&((j=s.current)==null||j.call(s))}))}),u=Ge(m=>{let b=r.current.find(({el:w})=>w===m);return b?b.state!=="visible"&&(b.state="visible"):r.current.push({el:m,state:"visible"}),()=>c(m,io.Unmount)}),f=x.useRef([]),p=x.useRef(Promise.resolve()),g=x.useRef({enter:[],leave:[]}),v=Ge((m,b,w)=>{f.current.splice(0),t&&(t.chains.current[b]=t.chains.current[b].filter(([j])=>j!==m)),t==null||t.chains.current[b].push([m,new Promise(j=>{f.current.push(j)})]),t==null||t.chains.current[b].push([m,new Promise(j=>{Promise.all(g.current[b].map(([N,R])=>R)).then(()=>j())})]),b==="enter"?p.current=p.current.then(()=>t==null?void 0:t.wait.current).then(()=>w(b)):w(b)}),h=Ge((m,b,w)=>{Promise.all(g.current[b].splice(0).map(([j,N])=>N)).then(()=>{var j;(j=f.current.shift())==null||j()}).then(()=>w(b))});return x.useMemo(()=>({children:r,register:u,unregister:c,onStart:v,onStop:h,wait:p,chains:g}),[u,c,r,v,h,g,p])}let bj=x.Fragment,vj=li.RenderStrategy;function UR(e,t){var s,r;let{transition:a=!0,beforeEnter:l,afterEnter:c,beforeLeave:u,afterLeave:f,enter:p,enterFrom:g,enterTo:v,entered:h,leave:m,leaveFrom:b,leaveTo:w,...j}=e,[N,R]=x.useState(null),$=x.useRef(null),S=xj(e),E=wn(...S?[$,t,R]:t===null?[]:[t]),C=(s=j.unmount)==null||s?io.Unmount:io.Hidden,{show:T,appear:A,initial:F}=DR(),[L,z]=x.useState(T?"visible":"hidden"),W=FR(),{register:U,unregister:D}=W;At(()=>U($),[U,$]),At(()=>{if(C===io.Hidden&&$.current){if(T&&L!=="visible"){z("visible");return}return Rn(L,{hidden:()=>D($),visible:()=>U($)})}},[L,$,U,D,T,C]);let K=ec();At(()=>{if(S&&K&&L==="visible"&&$.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[$,L,K,S]);let P=F&&!A,G=A&&T&&F,I=x.useRef(!1),Y=yj(()=>{I.current||(z("hidden"),D($))},W),q=Ge(ae=>{I.current=!0;let ce=ae?"enter":"leave";Y.onStart($,ce,he=>{he==="enter"?l==null||l():he==="leave"&&(u==null||u())})}),O=Ge(ae=>{let ce=ae?"enter":"leave";I.current=!1,Y.onStop($,ce,he=>{he==="enter"?c==null||c():he==="leave"&&(f==null||f())}),ce==="leave"&&!Zd(Y)&&(z("hidden"),D($))});x.useEffect(()=>{S&&a||(q(T),O(T))},[T,S,a]);let B=!(!a||!S||!K||P),[,ee]=Wk(B,N,T,{start:q,end:O}),le=ro({ref:E,className:((r=Yp(j.className,G&&p,G&&g,ee.enter&&p,ee.enter&&ee.closed&&g,ee.enter&&!ee.closed&&v,ee.leave&&m,ee.leave&&!ee.closed&&b,ee.leave&&ee.closed&&w,!ee.transition&&T&&h))==null?void 0:r.trim())||void 0,...Uk(ee)}),ie=0;L==="visible"&&(ie|=Cn.Open),L==="hidden"&&(ie|=Cn.Closed),T&&L==="hidden"&&(ie|=Cn.Opening),!T&&L==="visible"&&(ie|=Cn.Closing);let ue=rn();return Ne.createElement(Qd.Provider,{value:Y},Ne.createElement(aj,{value:ie},ue({ourProps:le,theirProps:j,defaultTag:bj,features:vj,visible:L==="visible",name:"Transition.Child"})))}function WR(e,t){let{show:s,appear:r=!1,unmount:a=!0,...l}=e,c=x.useRef(null),u=xj(e),f=wn(...u?[c,t]:t===null?[]:[t]);ec();let p=Jl();if(s===void 0&&p!==null&&(s=(p&Cn.Open)===Cn.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,v]=x.useState(s?"visible":"hidden"),h=yj(()=>{s||v("hidden")}),[m,b]=x.useState(!0),w=x.useRef([s]);At(()=>{m!==!1&&w.current[w.current.length-1]!==s&&(w.current.push(s),b(!1))},[w,s]);let j=x.useMemo(()=>({show:s,appear:r,initial:m}),[s,r,m]);At(()=>{s?v("visible"):!Zd(h)&&c.current!==null&&v("hidden")},[s,h]);let N={unmount:a},R=Ge(()=>{var E;m&&b(!1),(E=e.beforeEnter)==null||E.call(e)}),$=Ge(()=>{var E;m&&b(!1),(E=e.beforeLeave)==null||E.call(e)}),S=rn();return Ne.createElement(Qd.Provider,{value:h},Ne.createElement(Yd.Provider,{value:j},S({ourProps:{...N,as:x.Fragment,children:Ne.createElement(wj,{ref:f,...N,...l,beforeEnter:R,beforeLeave:$})},theirProps:{},defaultTag:x.Fragment,features:vj,visible:g==="visible",name:"Transition"})))}function HR(e,t){let s=x.useContext(Yd)!==null,r=Jl()!==null;return Ne.createElement(Ne.Fragment,null,!s&&r?Ne.createElement(sh,{ref:t,...e}):Ne.createElement(wj,{ref:t,...e}))}let sh=Gt(WR),wj=Gt(UR),lg=Gt(HR),BR=Object.assign(sh,{Child:lg,Root:sh});var GR=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(GR||{}),qR=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(qR||{});let VR={0(e,t){return e.titleId===t.id?e:{...e,titleId:t.id}}},cg=x.createContext(null);cg.displayName="DialogContext";function Jd(e){let t=x.useContext(cg);if(t===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Jd),s}return t}function KR(e,t){return Rn(t.type,VR,e,t)}let wv=Gt(function(e,t){let s=x.useId(),{id:r=`headlessui-dialog-${s}`,open:a,onClose:l,initialFocus:c,role:u="dialog",autoFocus:f=!0,__demoMode:p=!1,unmount:g=!1,...v}=e,h=x.useRef(!1);u=(function(){return u==="dialog"||u==="alertdialog"?u:(h.current||(h.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let m=Jl();a===void 0&&m!==null&&(a=(m&Cn.Open)===Cn.Open);let b=x.useRef(null),w=wn(b,t),j=Il(b.current),N=a?0:1,[R,$]=x.useReducer(KR,{titleId:null,descriptionId:null,panelRef:x.createRef()}),S=Ge(()=>l(!1)),E=Ge(ee=>$({type:0,id:ee})),C=ec()?N===0:!1,[T,A]=jR(),F={get current(){var ee;return(ee=R.panelRef.current)!=null?ee:b.current}},L=pj(),{resolveContainers:z}=ER({mainTreeNode:L,portals:T,defaultContainers:[F]}),W=m!==null?(m&Cn.Closing)===Cn.Closing:!1;Rk(p||W?!1:C,{allowed:Ge(()=>{var ee,le;return[(le=(ee=b.current)==null?void 0:ee.closest("[data-headlessui-portal]"))!=null?le:null]}),disallowed:Ge(()=>{var ee;return[(ee=L==null?void 0:L.closest("body > *:not(#headlessui-portal-root)"))!=null?ee:null]})});let U=Hd.get(null);At(()=>{if(C)return U.actions.push(r),()=>U.actions.pop(r)},[U,r,C]);let D=$n(U,x.useCallback(ee=>U.selectors.isTop(ee,r),[U,r]));zk(D,z,ee=>{ee.preventDefault(),S()}),_R(D,j==null?void 0:j.defaultView,ee=>{ee.preventDefault(),ee.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),S()}),Fk(p||W?!1:C,j,z),Ak(C,b,S);let[K,P]=qE(),G=x.useMemo(()=>[{dialogState:N,close:S,setTitleId:E,unmount:g},R],[N,S,E,g,R]),I=Cs({open:N===0}),Y={ref:w,id:r,role:u,tabIndex:-1,"aria-modal":p?void 0:N===0?!0:void 0,"aria-labelledby":R.titleId,"aria-describedby":K,unmount:g},q=!$R(),O=Go.None;C&&!p&&(O|=Go.RestoreFocus,O|=Go.TabLock,f&&(O|=Go.AutoFocus),q&&(O|=Go.InitialFocus));let B=rn();return Ne.createElement(mR,null,Ne.createElement(bv,{force:!0},Ne.createElement(dj,null,Ne.createElement(cg.Provider,{value:G},Ne.createElement(uj,{target:b},Ne.createElement(bv,{force:!1},Ne.createElement(P,{slot:I},Ne.createElement(A,null,Ne.createElement(OR,{initialFocus:c,initialFocusFallback:b,containers:z,features:O},Ne.createElement(nC,{value:S},B({ourProps:Y,theirProps:v,slot:I,defaultTag:XR,features:YR,visible:N===0,name:"Dialog"})))))))))))}),XR="div",YR=li.RenderStrategy|li.Static;function QR(e,t){let{transition:s=!1,open:r,...a}=e,l=Jl(),c=e.hasOwnProperty("open")||l!==null,u=e.hasOwnProperty("onClose");if(!c&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!c)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!l&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||s)&&!a.static?Ne.createElement(vv,null,Ne.createElement(BR,{show:r,transition:s,unmount:a.unmount},Ne.createElement(wv,{ref:t,...a}))):Ne.createElement(vv,null,Ne.createElement(wv,{ref:t,open:r,...a}))}let ZR="div";function JR(e,t){let s=x.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:a=!1,...l}=e,[{dialogState:c,unmount:u},f]=Jd("Dialog.Panel"),p=wn(t,f.panelRef),g=Cs({open:c===0}),v=Ge(j=>{j.stopPropagation()}),h={ref:p,id:r,onClick:v},m=a?lg:x.Fragment,b=a?{unmount:u}:{},w=rn();return Ne.createElement(m,{...b},w({ourProps:h,theirProps:l,slot:g,defaultTag:ZR,name:"Dialog.Panel"}))}let e3="div";function t3(e,t){let{transition:s=!1,...r}=e,[{dialogState:a,unmount:l}]=Jd("Dialog.Backdrop"),c=Cs({open:a===0}),u={ref:t,"aria-hidden":!0},f=s?lg:x.Fragment,p=s?{unmount:l}:{},g=rn();return Ne.createElement(f,{...p},g({ourProps:u,theirProps:r,slot:c,defaultTag:e3,name:"Dialog.Backdrop"}))}let n3="h2";function s3(e,t){let s=x.useId(),{id:r=`headlessui-dialog-title-${s}`,...a}=e,[{dialogState:l,setTitleId:c}]=Jd("Dialog.Title"),u=wn(t);x.useEffect(()=>(c(r),()=>c(null)),[r,c]);let f=Cs({open:l===0}),p={ref:u,id:r};return rn()({ourProps:p,theirProps:a,slot:f,defaultTag:n3,name:"Dialog.Title"})}let r3=Gt(QR),kj=Gt(JR),o3=Gt(t3),jj=Gt(s3),a3=Object.assign(r3,{Panel:kj,Title:jj,Description:wk}),kv=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function jv(e){var t,s;let r=(t=e.innerText)!=null?t:"",a=e.cloneNode(!0);if(!cs(a))return r;let l=!1;for(let u of a.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))u.remove(),l=!0;let c=l?(s=a.innerText)!=null?s:"":r;return kv.test(c)&&(c=c.replace(kv,"")),c}function i3(e){let t=e.getAttribute("aria-label");if(typeof t=="string")return t.trim();let s=e.getAttribute("aria-labelledby");if(s){let r=s.split(" ").map(a=>{let l=document.getElementById(a);if(l){let c=l.getAttribute("aria-label");return typeof c=="string"?c.trim():jv(l).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return jv(e).trim()}function l3(e){let t=x.useRef(""),s=x.useRef("");return Ge(()=>{let r=e.current;if(!r)return"";let a=r.innerText;if(t.current===a)return s.current;let l=i3(r).trim().toLowerCase();return t.current=a,s.current=l,l})}var c3=Object.defineProperty,u3=(e,t,s)=>t in e?c3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Nv=(e,t,s)=>(u3(e,typeof t!="symbol"?t+"":t,s),s),vn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(vn||{}),lo=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(lo||{}),Bu=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(Bu||{}),Nj=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.SelectOption=5]="SelectOption",e[e.RegisterOptions=6]="RegisterOptions",e[e.UnregisterOptions=7]="UnregisterOptions",e[e.SetButtonElement=8]="SetButtonElement",e[e.SetOptionsElement=9]="SetOptionsElement",e[e.SortOptions=10]="SortOptions",e[e.MarkButtonAsMoved=11]="MarkButtonAsMoved",e))(Nj||{});function Sv(e,t=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=Pk(t(e.options.slice()),l=>l.dataRef.current.domRef.current),a=s?r.indexOf(s):null;return a===-1&&(a=null),{options:r,activeOptionIndex:a}}let d3={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let t=e.buttonElement?Hu.Tracked(fj(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:Pt.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:t}},0(e,t){if(e.dataRef.current.disabled||e.listboxState===0)return e;let s=e.activeOptionIndex,{isSelected:r}=e.dataRef.current,a=e.options.findIndex(l=>r(l.dataRef.current.value));return a!==-1&&(s=a),{...e,frozenValue:!1,pendingFocus:t.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:Hu.Idle}},2(e,t){var s,r,a,l,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let u={...e,searchQuery:"",activationTrigger:(s=t.trigger)!=null?s:1,__demoMode:!1};if(t.focus===Pt.Nothing)return{...u,activeOptionIndex:null};if(t.focus===Pt.Specific)return{...u,activeOptionIndex:e.options.findIndex(g=>g.id===t.id)};if(t.focus===Pt.Previous){let g=e.activeOptionIndex;if(g!==null){let v=e.options[g].dataRef.current.domRef,h=Su(t,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(h!==null){let m=e.options[h].dataRef.current.domRef;if(((r=v.current)==null?void 0:r.previousElementSibling)===m.current||((a=m.current)==null?void 0:a.previousElementSibling)===null)return{...u,activeOptionIndex:h}}}}else if(t.focus===Pt.Next){let g=e.activeOptionIndex;if(g!==null){let v=e.options[g].dataRef.current.domRef,h=Su(t,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(h!==null){let m=e.options[h].dataRef.current.domRef;if(((l=v.current)==null?void 0:l.nextElementSibling)===m.current||((c=m.current)==null?void 0:c.nextElementSibling)===null)return{...u,activeOptionIndex:h}}}}let f=Sv(e),p=Su(t,{resolveItems:()=>f.options,resolveActiveIndex:()=>f.activeOptionIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});return{...u,...f,activeOptionIndex:p}},3:(e,t)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.searchQuery!==""?0:1,r=e.searchQuery+t.value.toLowerCase(),a=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+s).concat(e.options.slice(0,e.activeOptionIndex+s)):e.options).find(c=>{var u;return!c.dataRef.current.disabled&&((u=c.dataRef.current.textValue)==null?void 0:u.startsWith(r))}),l=a?e.options.indexOf(a):-1;return l===-1||l===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:l,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,t)=>{let s=e.options.concat(t.options),r=e.activeOptionIndex;if(e.pendingFocus.focus!==Pt.Nothing&&(r=Su(e.pendingFocus,{resolveItems:()=>s,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:a}=e.dataRef.current;if(a){let l=s.findIndex(c=>a==null?void 0:a(c.dataRef.current.value));l!==-1&&(r=l)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:Pt.Nothing},pendingShouldSort:!0}},7:(e,t)=>{let s=e.options,r=[],a=new Set(t.options);for(let[l,c]of s.entries())if(a.has(c.id)&&(r.push(l),a.delete(c.id),a.size===0))break;if(r.length>0){s=s.slice();for(let l of r.reverse())s.splice(l,1)}return{...e,options:s,activationTrigger:1}},8:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},9:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},10:e=>e.pendingShouldSort?{...e,...Sv(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:Hu.Moved}}};class ug extends $k{constructor(t){super(t),Nv(this,"actions",{onChange:s=>{let{onChange:r,compare:a,mode:l,value:c}=this.state.dataRef.current;return Rn(l,{0:()=>r==null?void 0:r(s),1:()=>{let u=c.slice(),f=u.findIndex(p=>a(p,s));return f===-1?u.push(s):u.splice(f,1),r==null?void 0:r(u)}})},registerOption:ip(()=>{let s=[],r=new Set;return[(a,l)=>{r.has(l)||(r.add(l),s.push({id:a,dataRef:l}))},()=>(r.clear(),this.send({type:6,options:s.splice(0)}))]}),unregisterOption:ip(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:ip(()=>{let s=null;return[(r,a)=>{s={type:2,...r,trigger:a}},()=>s&&this.send(s)]}),closeListbox:()=>{this.send({type:1})},openListbox:s=>{this.send({type:0,focus:s})},selectActiveOption:()=>{var s;if(this.state.activeOptionIndex!==null){let{dataRef:r}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(r.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(s=this.state.buttonElement)==null||s.focus({preventScroll:!0}))},selectOption:s=>{this.send({type:5,value:s})},search:s=>{this.send({type:3,value:s})},clearSearch:()=>{this.send({type:4})},setButtonElement:s=>{this.send({type:8,element:s})},setOptionsElement:s=>{this.send({type:9,element:s})}}),Nv(this,"selectors",{activeDescendantId(s){var r;let a=s.activeOptionIndex,l=s.options;return a===null||(r=l[a])==null?void 0:r.id},isActive(s,r){var a;let l=s.activeOptionIndex,c=s.options;return l!==null?((a=c[l])==null?void 0:a.id)===r:!1},hasFrozenValue(s){return s.frozenValue},shouldScrollIntoView(s,r){return s.__demoMode||s.listboxState!==0||s.activationTrigger===0?!1:this.isActive(s,r)},didButtonMove(s){return s.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let s=this.state.id,r=Hd.get(null);this.disposables.add(r.on(Ck.Push,a=>{!r.selectors.isTop(a,s)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>r.actions.push(s)),this.on(1,()=>r.actions.pop(s))}this.disposables.group(s=>{this.on(1,r=>{r.buttonElement&&(s.dispose(),s.add(SR(r.buttonElement,r.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(s,r)=>{var a;this.actions.onChange(r.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(a=this.state.buttonElement)==null||a.focus({preventScroll:!0}))})}static new({id:t,__demoMode:s=!1}){return new ug({id:t,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:Pt.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:Hu.Idle})}reduce(t,s){return Rn(s.type,d3,t,s)}}const Sj=x.createContext(null);function dg(e){let t=x.useContext(Sj);if(t===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,_j),s}return t}function _j({id:e,__demoMode:t=!1}){let s=x.useMemo(()=>ug.new({id:e,__demoMode:t}),[]);return ag(()=>s.dispose()),s}let ef=x.createContext(null);ef.displayName="ListboxDataContext";function tc(e){let t=x.useContext(ef);if(t===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,tc),s}return t}let f3=x.Fragment;function m3(e,t){let s=x.useId(),r=Jh(),{value:a,defaultValue:l,form:c,name:u,onChange:f,by:p,invalid:g=!1,disabled:v=r||!1,horizontal:h=!1,multiple:m=!1,__demoMode:b=!1,...w}=e;const j=h?"horizontal":"vertical";let N=wn(t),R=CE(l),[$=m?[]:void 0,S]=EE(a,f,R),E=_j({id:s,__demoMode:b}),C=x.useRef({static:!1,hold:!1}),T=x.useRef(new Map),A=rC(p),F=x.useCallback(B=>Rn(L.mode,{[lo.Multi]:()=>$.some(ee=>A(ee,B)),[lo.Single]:()=>A($,B)}),[$]),L=Cs({value:$,disabled:v,invalid:g,mode:m?lo.Multi:lo.Single,orientation:j,onChange:S,compare:A,isSelected:F,optionsPropsRef:C,listRef:T});At(()=>{E.state.dataRef.current=L},[L]);let z=$n(E,B=>B.listboxState),W=Hd.get(null),U=$n(W,x.useCallback(B=>W.selectors.isTop(B,s),[W,s])),[D,K]=$n(E,B=>[B.buttonElement,B.optionsElement]);zk(U,[D,K],(B,ee)=>{E.send({type:Nj.CloseListbox}),Mk(ee,eg.Loose)||(B.preventDefault(),D==null||D.focus())});let P=Cs({open:z===vn.Open,disabled:v,invalid:g,value:$}),[G,I]=YE({inherit:!0}),Y={ref:N},q=x.useCallback(()=>{if(R!==void 0)return S==null?void 0:S(R)},[S,R]),O=rn();return Ne.createElement(I,{value:G,props:{htmlFor:D==null?void 0:D.id},slot:{open:z===vn.Open,disabled:v}},Ne.createElement(cR,null,Ne.createElement(Sj.Provider,{value:E},Ne.createElement(ef.Provider,{value:L},Ne.createElement(aj,{value:Rn(z,{[vn.Open]:Cn.Open,[vn.Closed]:Cn.Closed})},u!=null&&$!=null&&Ne.createElement(LE,{disabled:v,data:{[u]:$},form:c,onReset:q}),O({ourProps:Y,theirProps:w,slot:P,defaultTag:f3,name:"Listbox"}))))))}let p3="button";function h3(e,t){let s=x.useId(),r=hk(),a=tc("Listbox.Button"),l=dg("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:u=a.disabled||!1,autoFocus:f=!1,...p}=e,g=wn(t,oR(),l.actions.setButtonElement),v=aR(),[h,m,b]=$n(l,K=>[K.listboxState,K.buttonElement,K.optionsElement]),w=h===vn.Open;EC(w,{trigger:m,action:x.useCallback(K=>{if(m!=null&&m.contains(K.target))return ju.Ignore;let P=K.target.closest('[role="option"]:not([data-disabled])');return cs(P)?ju.Select(P):b!=null&&b.contains(K.target)?ju.Ignore:ju.Close},[m,b]),close:l.actions.closeListbox,select:l.actions.selectActiveOption});let j=Ge(K=>{switch(K.key){case Zt.Enter:TE(K.currentTarget);break;case Zt.Space:case Zt.ArrowDown:K.preventDefault(),l.actions.openListbox({focus:a.value?Pt.Nothing:Pt.First});break;case Zt.ArrowUp:K.preventDefault(),l.actions.openListbox({focus:a.value?Pt.Nothing:Pt.Last});break}}),N=Ge(K=>{switch(K.key){case Zt.Space:K.preventDefault();break}}),R=aC(K=>{var P;l.state.listboxState===vn.Open?(ir.flushSync(()=>l.actions.closeListbox()),(P=l.state.buttonElement)==null||P.focus({preventScroll:!0})):(K.preventDefault(),l.actions.openListbox({focus:Pt.Nothing}))}),$=Ge(K=>K.preventDefault()),S=jk([c]),E=GE(),{isFocusVisible:C,focusProps:T}=fE({autoFocus:f}),{isHovered:A,hoverProps:F}=hE({isDisabled:u}),{pressed:L,pressProps:z}=wE({disabled:u}),W=Cs({open:h===vn.Open,active:L||h===vn.Open,disabled:u,invalid:a.invalid,value:a.value,hover:A,focus:C,autofocus:f}),U=$n(l,K=>K.listboxState===vn.Open),D=uk(v(),{ref:g,id:c,type:CC(e,m),"aria-haspopup":"listbox","aria-controls":b==null?void 0:b.id,"aria-expanded":U,"aria-labelledby":S,"aria-describedby":E,disabled:u||void 0,autoFocus:f,onKeyDown:j,onKeyUp:N,onKeyPress:$},R,T,F,z);return rn()({ourProps:D,theirProps:p,slot:W,defaultTag:p3,name:"Listbox.Button"})}let $j=x.createContext(!1),g3="div",x3=li.RenderStrategy|li.Static;function y3(e,t){let s=x.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:a,portal:l=!1,modal:c=!0,transition:u=!1,...f}=e,p=rR(a),[g,v]=x.useState(null);p&&(l=!0);let h=tc("Listbox.Options"),m=dg("Listbox.Options"),[b,w,j,N]=$n(m,ue=>[ue.listboxState,ue.buttonElement,ue.optionsElement,ue.__demoMode]),R=Il(w),$=Il(j),S=Jl(),[E,C]=Wk(u,g,S!==null?(S&Cn.Open)===Cn.Open:b===vn.Open);Ak(E,w,m.actions.closeListbox);let T=N?!1:c&&b===vn.Open;Fk(T,$);let A=N?!1:c&&b===vn.Open;Rk(A,{allowed:x.useCallback(()=>[w,j],[w,j])});let F=$n(m,m.selectors.didButtonMove)?!1:E,L=$n(m,m.selectors.hasFrozenValue)&&!e.static,z=oj(L,h.value),W=x.useCallback(ue=>h.compare(z,ue),[h.compare,z]),U=$n(m,ue=>{var ae;if(p==null||!((ae=p==null?void 0:p.to)!=null&&ae.includes("selection")))return null;let ce=ue.options.findIndex(he=>W(he.dataRef.current.value));return ce===-1&&(ce=0),ce}),D=(()=>{if(p==null)return;if(U===null)return{...p,inner:void 0};let ue=Array.from(h.listRef.current.values());return{...p,inner:{listRef:{current:ue},index:U}}})(),[K,P]=lR(D),G=iR(),I=wn(t,p?K:null,m.actions.setOptionsElement,v),Y=yo();x.useEffect(()=>{let ue=j;ue&&b===vn.Open&&(lk(ue)||ue==null||ue.focus({preventScroll:!0}))},[b,j]);let q=Ge(ue=>{var ae;switch(Y.dispose(),ue.key){case Zt.Space:if(m.state.searchQuery!=="")return ue.preventDefault(),ue.stopPropagation(),m.actions.search(ue.key);case Zt.Enter:ue.preventDefault(),ue.stopPropagation(),m.actions.selectActiveOption();break;case Rn(h.orientation,{vertical:Zt.ArrowDown,horizontal:Zt.ArrowRight}):return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:Pt.Next});case Rn(h.orientation,{vertical:Zt.ArrowUp,horizontal:Zt.ArrowLeft}):return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:Pt.Previous});case Zt.Home:case Zt.PageUp:return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:Pt.First});case Zt.End:case Zt.PageDown:return ue.preventDefault(),ue.stopPropagation(),m.actions.goToOption({focus:Pt.Last});case Zt.Escape:ue.preventDefault(),ue.stopPropagation(),ir.flushSync(()=>m.actions.closeListbox()),(ae=m.state.buttonElement)==null||ae.focus({preventScroll:!0});return;case Zt.Tab:ue.preventDefault(),ue.stopPropagation(),ir.flushSync(()=>m.actions.closeListbox()),NC(m.state.buttonElement,ue.shiftKey?Hs.Previous:Hs.Next);break;default:ue.key.length===1&&(m.actions.search(ue.key),Y.setTimeout(()=>m.actions.clearSearch(),350));break}}),O=$n(m,ue=>{var ae;return(ae=ue.buttonElement)==null?void 0:ae.id}),B=Cs({open:b===vn.Open}),ee=uk(p?G():{},{id:r,ref:I,"aria-activedescendant":$n(m,m.selectors.activeDescendantId),"aria-multiselectable":h.mode===lo.Multi?!0:void 0,"aria-labelledby":O,"aria-orientation":h.orientation,onKeyDown:q,role:"listbox",tabIndex:b===vn.Open?0:void 0,style:{...f.style,...P,"--button-width":oC(E,w,!0).width},...Uk(C)}),le=rn(),ie=x.useMemo(()=>h.mode===lo.Multi?h:{...h,isSelected:W},[h,W]);return Ne.createElement(dj,{enabled:l?e.static||E:!1,ownerDocument:R},Ne.createElement(ef.Provider,{value:ie},le({ourProps:ee,theirProps:f,slot:B,defaultTag:g3,features:x3,visible:F,name:"Listbox.Options"})))}let b3="div";function v3(e,t){let s=x.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:a=!1,value:l,...c}=e,u=x.useContext($j)===!0,f=tc("Listbox.Option"),p=dg("Listbox.Option"),g=$n(p,L=>p.selectors.isActive(L,r)),v=f.isSelected(l),h=x.useRef(null),m=l3(h),b=bo({disabled:a,value:l,domRef:h,get textValue(){return m()}}),w=wn(t,h,L=>{L?f.listRef.current.set(r,L):f.listRef.current.delete(r)}),j=$n(p,L=>p.selectors.shouldScrollIntoView(L,r));At(()=>{if(j)return ds().requestAnimationFrame(()=>{var L,z;(z=(L=h.current)==null?void 0:L.scrollIntoView)==null||z.call(L,{block:"nearest"})})},[j,h]),At(()=>{if(!u)return p.actions.registerOption(r,b),()=>p.actions.unregisterOption(r)},[b,r,u]);let N=Ge(L=>{if(a)return L.preventDefault();p.actions.selectOption(l)}),R=Ge(()=>{if(a)return p.actions.goToOption({focus:Pt.Nothing});p.actions.goToOption({focus:Pt.Specific,id:r})}),$=LC(),S=Ge(L=>$.update(L)),E=Ge(L=>{$.wasMoved(L)&&(a||g&&p.state.activationTrigger===Bu.Pointer||p.actions.goToOption({focus:Pt.Specific,id:r},Bu.Pointer))}),C=Ge(L=>{$.wasMoved(L)&&(a||g&&p.state.activationTrigger===Bu.Pointer&&p.actions.goToOption({focus:Pt.Nothing}))}),T=Cs({active:g,focus:g,selected:v,disabled:a,selectedOption:v&&u}),A=u?{}:{id:r,ref:w,role:"option",tabIndex:a===!0?void 0:-1,"aria-disabled":a===!0?!0:void 0,"aria-selected":v,disabled:void 0,onClick:N,onFocus:R,onPointerEnter:S,onMouseEnter:S,onPointerMove:E,onMouseMove:E,onPointerLeave:C,onMouseLeave:C},F=rn();return!v&&u?null:F({ourProps:A,theirProps:c,slot:T,defaultTag:b3,name:"Listbox.Option"})}let w3=x.Fragment;function k3(e,t){let{options:s,placeholder:r,...a}=e,l={ref:wn(t)},c=tc("ListboxSelectedOption"),u=Cs({}),f=c.value===void 0||c.value===null||c.mode===lo.Multi&&Array.isArray(c.value)&&c.value.length===0,p=rn();return Ne.createElement($j.Provider,{value:!0},p({ourProps:l,theirProps:{...a,children:Ne.createElement(Ne.Fragment,null,r&&f?r:s)},slot:u,defaultTag:w3,name:"ListboxSelectedOption"}))}let j3=Gt(m3),Ej=Gt(h3),N3=eC,Cj=Gt(y3),Tj=Gt(v3),S3=Gt(k3),_3=Object.assign(j3,{Button:Ej,Label:N3,Options:Cj,Option:Tj,SelectedOption:S3});const fg=x.createContext(null),$3=()=>x.useContext(fg);function mg(e){const t=x.useContext(fg);return{id:e.id??(t==null?void 0:t.id),"aria-describedby":e["aria-describedby"]??(t==null?void 0:t.describedBy),"aria-invalid":e["aria-invalid"]??((t==null?void 0:t.invalid)||void 0),"aria-required":e["aria-required"]??((t==null?void 0:t.required)&&!e.required||void 0)}}function Bs({label:e,id:t,required:s,optional:r,note:a,hint:l,error:c,warning:u,aside:f,group:p,className:g,children:v}){const h=x.useId(),m=t??`${h}-control`,[b,w,j,N,R]=[`${h}-label`,`${h}-note`,`${h}-hint`,`${h}-error`,`${h}-warning`],$=[a&&w,l&&j,c&&N,u&&R].filter(Boolean).join(" ")||void 0,S=n.jsxs(n.Fragment,{children:[e,s&&n.jsx("span",{className:"text-destructive-text","aria-hidden":!0,children:" *"}),r&&n.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:" (optional)"})]});return n.jsxs("div",{className:g,...p===!0?{role:"group","aria-labelledby":b,"aria-describedby":$}:{},children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[p?n.jsx("span",{id:b,className:"caps text-small font-semibold",children:S}):n.jsx("label",{id:b,htmlFor:m,className:"caps text-small font-semibold",children:S}),f]}),a&&n.jsx("p",{id:w,className:"-mt-1 mb-2 text-small text-muted-foreground",children:a}),n.jsx(fg.Provider,{value:p?null:{id:m,describedBy:$,invalid:!!c,required:!!s},children:v}),l&&n.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:l}),c&&n.jsx("p",{id:N,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),u&&n.jsx("p",{id:R,className:"mt-2 font-mono text-small text-warning-text",children:u})]})}const Rj="w-full border border-input bg-background px-3 font-mono text-body placeholder:text-muted-foreground hover:border-foreground/60 focus-visible:outline-offset-0 read-only:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-45 aria-[invalid=true]:border-destructive",Aj="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",Oj="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",Ue=x.forwardRef(({className:e,fieldSize:t="md",bare:s,...r},a)=>n.jsx("input",{ref:a,...r,...mg(r),className:oe(s?Aj:oe(Rj,t==="sm"?"h-control-sm":"h-control-md"),e)}));Ue.displayName="Input";const As=x.forwardRef(({className:e,bare:t,...s},r)=>n.jsx("textarea",{ref:r,...s,...mg(s),className:oe(t?Aj:oe(Rj,"py-2.5"),e)}));As.displayName="Textarea";const Mj=e=>{const t=x.forwardRef(({label:s,note:r,className:a,disabled:l,...c},u)=>n.jsxs("label",{className:oe("flex items-start gap-2.5 text-body",l?"cursor-not-allowed opacity-45":"cursor-pointer",a),children:[n.jsx("input",{ref:u,type:e,disabled:l,...c,...mg(c),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block",children:s}),r&&n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:r})]})]}));return t.displayName=e==="checkbox"?"Checkbox":"Radio",t},E3=Mj("checkbox");Mj("radio");function Lt({value:e,onChange:t,options:s,label:r,id:a,className:l,disabled:c=!1,name:u,small:f=!1,placeholder:p,autoFocus:g}){const v=s.find(m=>m.value===e),h=$3();return n.jsxs(_3,{value:e,onChange:t,disabled:c,name:u,children:[n.jsxs(Ej,{id:a??(h==null?void 0:h.id),autoFocus:g,"aria-label":r,"aria-describedby":h==null?void 0:h.describedBy,"aria-invalid":(h==null?void 0:h.invalid)||void 0,"data-value":e,className:oe("flex min-w-0 items-center justify-between gap-2 border border-input bg-background text-left font-mono hover:border-foreground/60 focus-visible:outline-offset-0 disabled:opacity-60 data-[open]:border-foreground",f?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",l),children:[n.jsx("span",{className:oe("min-w-0 truncate",!v&&"text-muted-foreground"),children:(v==null?void 0:v.label)??p??""}),n.jsx(aa,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),n.jsx(Cj,{anchor:"bottom start","data-picker-list":"",className:"z-popover max-h-72 w-[var(--button-width)] min-w-[12rem] overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",children:s.map(m=>n.jsxs(Tj,{value:m.value,disabled:m.disabled,title:m.title,"data-value":m.value,className:"group flex min-h-10 cursor-pointer items-center gap-2 px-3 py-2 data-[disabled]:cursor-not-allowed data-[focus]:bg-accent data-[disabled]:opacity-50 data-[selected]:text-foreground",children:[n.jsx(Ld,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 break-words",children:m.label})]},m.value))})]})}const Pj=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<t.id?-1:e.id>t.id?1:0),tf=e=>[...e].sort((t,s)=>Pj({name:t.definition.name||t.agent_id,id:t.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:Lj,setPrototypeOf:_v,isFrozen:C3,getPrototypeOf:T3,getOwnPropertyDescriptor:R3}=Object;let{freeze:An,seal:Ts,create:Ij}=Object,{apply:rh,construct:oh}=typeof Reflect<"u"&&Reflect;An||(An=function(t){return t});Ts||(Ts=function(t){return t});rh||(rh=function(t,s,r){return t.apply(s,r)});oh||(oh=function(t,s){return new t(...s)});const _u=us(Array.prototype.forEach),$v=us(Array.prototype.pop),fl=us(Array.prototype.push),Gu=us(String.prototype.toLowerCase),gp=us(String.prototype.toString),Ev=us(String.prototype.match),ml=us(String.prototype.replace),A3=us(String.prototype.indexOf),O3=us(String.prototype.trim),Ws=us(Object.prototype.hasOwnProperty),_n=us(RegExp.prototype.test),pl=M3(TypeError);function us(e){return function(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return rh(e,t,r)}}function M3(e){return function(){for(var t=arguments.length,s=new Array(t),r=0;r<t;r++)s[r]=arguments[r];return oh(e,s)}}function Ze(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gu;_v&&_v(e,null);let r=t.length;for(;r--;){let a=t[r];if(typeof a=="string"){const l=s(a);l!==a&&(C3(t)||(t[r]=l),a=l)}e[a]=!0}return e}function P3(e){for(let t=0;t<e.length;t++)Ws(e,t)||(e[t]=null);return e}function Bo(e){const t=Ij(null);for(const[s,r]of Lj(e))Ws(e,s)&&(Array.isArray(r)?t[s]=P3(r):r&&typeof r=="object"&&r.constructor===Object?t[s]=Bo(r):t[s]=r);return t}function hl(e,t){for(;e!==null;){const r=R3(e,t);if(r){if(r.get)return us(r.get);if(typeof r.value=="function")return us(r.value)}e=T3(e)}function s(){return null}return s}const Cv=An(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),xp=An(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),yp=An(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),L3=An(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),bp=An(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),I3=An(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Tv=An(["#text"]),Rv=An(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),vp=An(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Av=An(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),$u=An(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),z3=Ts(/\{\{[\w\W]*|[\w\W]*\}\}/gm),D3=Ts(/<%[\w\W]*|[\w\W]*%>/gm),F3=Ts(/\$\{[\w\W]*}/gm),U3=Ts(/^data-[\-\w.\u00B7-\uFFFF]+$/),W3=Ts(/^aria-[\-\w]+$/),zj=Ts(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),H3=Ts(/^(?:\w+script|data):/i),B3=Ts(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Dj=Ts(/^html$/i),G3=Ts(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ov=Object.freeze({__proto__:null,ARIA_ATTR:W3,ATTR_WHITESPACE:B3,CUSTOM_ELEMENT:G3,DATA_ATTR:U3,DOCTYPE_NAME:Dj,ERB_EXPR:D3,IS_ALLOWED_URI:zj,IS_SCRIPT_OR_DATA:H3,MUSTACHE_EXPR:z3,TMPLIT_EXPR:F3});const gl={element:1,text:3,progressingInstruction:7,comment:8,document:9},q3=function(){return typeof window>"u"?null:window},V3=function(t,s){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const a="data-tt-policy-suffix";s&&s.hasAttribute(a)&&(r=s.getAttribute(a));const l="dompurify"+(r?"#"+r:"");try{return t.createPolicy(l,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+l+" could not be created."),null}},Mv=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Fj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:q3();const t=Pe=>Fj(Pe);if(t.version="3.2.3",t.removed=[],!e||!e.document||e.document.nodeType!==gl.document)return t.isSupported=!1,t;let{document:s}=e;const r=s,a=r.currentScript,{DocumentFragment:l,HTMLTemplateElement:c,Node:u,Element:f,NodeFilter:p,NamedNodeMap:g=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:v,DOMParser:h,trustedTypes:m}=e,b=f.prototype,w=hl(b,"cloneNode"),j=hl(b,"remove"),N=hl(b,"nextSibling"),R=hl(b,"childNodes"),$=hl(b,"parentNode");if(typeof c=="function"){const Pe=s.createElement("template");Pe.content&&Pe.content.ownerDocument&&(s=Pe.content.ownerDocument)}let S,E="";const{implementation:C,createNodeIterator:T,createDocumentFragment:A,getElementsByTagName:F}=s,{importNode:L}=r;let z=Mv();t.isSupported=typeof Lj=="function"&&typeof $=="function"&&C&&C.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:W,ERB_EXPR:U,TMPLIT_EXPR:D,DATA_ATTR:K,ARIA_ATTR:P,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:I,CUSTOM_ELEMENT:Y}=Ov;let{IS_ALLOWED_URI:q}=Ov,O=null;const B=Ze({},[...Cv,...xp,...yp,...bp,...Tv]);let ee=null;const le=Ze({},[...Rv,...vp,...Av,...$u]);let ie=Object.seal(Ij(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ue=null,ae=null,ce=!0,he=!0,et=!1,se=!0,ke=!1,Se=!0,Fe=!1,fe=!1,Le=!1,He=!1,It=!1,We=!1,we=!0,lt=!1;const jt="user-content-";let Nt=!0,on=!1,en={},Ot=null;const Wt=Ze({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Et=null;const ct=Ze({},["audio","video","img","source","image","track"]);let Ie=null;const st=Ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gt="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",St="http://www.w3.org/1999/xhtml";let qt=St,Ln=!1,Kn=null;const fs=Ze({},[gt,Xe,St],gp);let Xn=Ze({},["mi","mo","mn","ms","mtext"]),Yn=Ze({},["annotation-xml"]);const Qn=Ze({},["title","style","font","a","script"]);let an=null;const Zn=["application/xhtml+xml","text/html"],dr="text/html";let yt=null,Q=null;const Ae=s.createElement("form"),qe=function(Z){return Z instanceof RegExp||Z instanceof Function},ut=function(){let Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Q&&Q===Z)){if((!Z||typeof Z!="object")&&(Z={}),Z=Bo(Z),an=Zn.indexOf(Z.PARSER_MEDIA_TYPE)===-1?dr:Z.PARSER_MEDIA_TYPE,yt=an==="application/xhtml+xml"?gp:Gu,O=Ws(Z,"ALLOWED_TAGS")?Ze({},Z.ALLOWED_TAGS,yt):B,ee=Ws(Z,"ALLOWED_ATTR")?Ze({},Z.ALLOWED_ATTR,yt):le,Kn=Ws(Z,"ALLOWED_NAMESPACES")?Ze({},Z.ALLOWED_NAMESPACES,gp):fs,Ie=Ws(Z,"ADD_URI_SAFE_ATTR")?Ze(Bo(st),Z.ADD_URI_SAFE_ATTR,yt):st,Et=Ws(Z,"ADD_DATA_URI_TAGS")?Ze(Bo(ct),Z.ADD_DATA_URI_TAGS,yt):ct,Ot=Ws(Z,"FORBID_CONTENTS")?Ze({},Z.FORBID_CONTENTS,yt):Wt,ue=Ws(Z,"FORBID_TAGS")?Ze({},Z.FORBID_TAGS,yt):{},ae=Ws(Z,"FORBID_ATTR")?Ze({},Z.FORBID_ATTR,yt):{},en=Ws(Z,"USE_PROFILES")?Z.USE_PROFILES:!1,ce=Z.ALLOW_ARIA_ATTR!==!1,he=Z.ALLOW_DATA_ATTR!==!1,et=Z.ALLOW_UNKNOWN_PROTOCOLS||!1,se=Z.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ke=Z.SAFE_FOR_TEMPLATES||!1,Se=Z.SAFE_FOR_XML!==!1,Fe=Z.WHOLE_DOCUMENT||!1,He=Z.RETURN_DOM||!1,It=Z.RETURN_DOM_FRAGMENT||!1,We=Z.RETURN_TRUSTED_TYPE||!1,Le=Z.FORCE_BODY||!1,we=Z.SANITIZE_DOM!==!1,lt=Z.SANITIZE_NAMED_PROPS||!1,Nt=Z.KEEP_CONTENT!==!1,on=Z.IN_PLACE||!1,q=Z.ALLOWED_URI_REGEXP||zj,qt=Z.NAMESPACE||St,Xn=Z.MATHML_TEXT_INTEGRATION_POINTS||Xn,Yn=Z.HTML_INTEGRATION_POINTS||Yn,ie=Z.CUSTOM_ELEMENT_HANDLING||{},Z.CUSTOM_ELEMENT_HANDLING&&qe(Z.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ie.tagNameCheck=Z.CUSTOM_ELEMENT_HANDLING.tagNameCheck),Z.CUSTOM_ELEMENT_HANDLING&&qe(Z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ie.attributeNameCheck=Z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),Z.CUSTOM_ELEMENT_HANDLING&&typeof Z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ie.allowCustomizedBuiltInElements=Z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ke&&(he=!1),It&&(He=!0),en&&(O=Ze({},Tv),ee=[],en.html===!0&&(Ze(O,Cv),Ze(ee,Rv)),en.svg===!0&&(Ze(O,xp),Ze(ee,vp),Ze(ee,$u)),en.svgFilters===!0&&(Ze(O,yp),Ze(ee,vp),Ze(ee,$u)),en.mathMl===!0&&(Ze(O,bp),Ze(ee,Av),Ze(ee,$u))),Z.ADD_TAGS&&(O===B&&(O=Bo(O)),Ze(O,Z.ADD_TAGS,yt)),Z.ADD_ATTR&&(ee===le&&(ee=Bo(ee)),Ze(ee,Z.ADD_ATTR,yt)),Z.ADD_URI_SAFE_ATTR&&Ze(Ie,Z.ADD_URI_SAFE_ATTR,yt),Z.FORBID_CONTENTS&&(Ot===Wt&&(Ot=Bo(Ot)),Ze(Ot,Z.FORBID_CONTENTS,yt)),Nt&&(O["#text"]=!0),Fe&&Ze(O,["html","head","body"]),O.table&&(Ze(O,["tbody"]),delete ue.tbody),Z.TRUSTED_TYPES_POLICY){if(typeof Z.TRUSTED_TYPES_POLICY.createHTML!="function")throw pl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Z.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw pl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=Z.TRUSTED_TYPES_POLICY,E=S.createHTML("")}else S===void 0&&(S=V3(m,a)),S!==null&&typeof E=="string"&&(E=S.createHTML(""));An&&An(Z),Q=Z}},xt=Ze({},[...xp,...yp,...L3]),Vt=Ze({},[...bp,...I3]),Kt=function(Z){let ge=$(Z);(!ge||!ge.tagName)&&(ge={namespaceURI:qt,tagName:"template"});const _e=Gu(Z.tagName),pt=Gu(ge.tagName);return Kn[Z.namespaceURI]?Z.namespaceURI===Xe?ge.namespaceURI===St?_e==="svg":ge.namespaceURI===gt?_e==="svg"&&(pt==="annotation-xml"||Xn[pt]):!!xt[_e]:Z.namespaceURI===gt?ge.namespaceURI===St?_e==="math":ge.namespaceURI===Xe?_e==="math"&&Yn[pt]:!!Vt[_e]:Z.namespaceURI===St?ge.namespaceURI===Xe&&!Yn[pt]||ge.namespaceURI===gt&&!Xn[pt]?!1:!Vt[_e]&&(Qn[_e]||!xt[_e]):!!(an==="application/xhtml+xml"&&Kn[Z.namespaceURI]):!1},mt=function(Z){fl(t.removed,{element:Z});try{$(Z).removeChild(Z)}catch{j(Z)}},In=function(Z,ge){try{fl(t.removed,{attribute:ge.getAttributeNode(Z),from:ge})}catch{fl(t.removed,{attribute:null,from:ge})}if(ge.removeAttribute(Z),Z==="is")if(He||It)try{mt(ge)}catch{}else try{ge.setAttribute(Z,"")}catch{}},jn=function(Z){let ge=null,_e=null;if(Le)Z="<remove></remove>"+Z;else{const Ve=Ev(Z,/^[\r\n\t ]+/);_e=Ve&&Ve[0]}an==="application/xhtml+xml"&&qt===St&&(Z='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Z+"</body></html>");const pt=S?S.createHTML(Z):Z;if(qt===St)try{ge=new h().parseFromString(pt,an)}catch{}if(!ge||!ge.documentElement){ge=C.createDocument(qt,"template",null);try{ge.documentElement.innerHTML=Ln?E:pt}catch{}}const zt=ge.body||ge.documentElement;return Z&&_e&&zt.insertBefore(s.createTextNode(_e),zt.childNodes[0]||null),qt===St?F.call(ge,Fe?"html":"body")[0]:Fe?ge.documentElement:zt},ms=function(Z){return T.call(Z.ownerDocument||Z,Z,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},zn=function(Z){return Z instanceof v&&(typeof Z.nodeName!="string"||typeof Z.textContent!="string"||typeof Z.removeChild!="function"||!(Z.attributes instanceof g)||typeof Z.removeAttribute!="function"||typeof Z.setAttribute!="function"||typeof Z.namespaceURI!="string"||typeof Z.insertBefore!="function"||typeof Z.hasChildNodes!="function")},ma=function(Z){return typeof u=="function"&&Z instanceof u};function Jn(Pe,Z,ge){_u(Pe,_e=>{_e.call(t,Z,ge,Q)})}const pa=function(Z){let ge=null;if(Jn(z.beforeSanitizeElements,Z,null),zn(Z))return mt(Z),!0;const _e=yt(Z.nodeName);if(Jn(z.uponSanitizeElement,Z,{tagName:_e,allowedTags:O}),Z.hasChildNodes()&&!ma(Z.firstElementChild)&&_n(/<[/\w]/g,Z.innerHTML)&&_n(/<[/\w]/g,Z.textContent)||Z.nodeType===gl.progressingInstruction||Se&&Z.nodeType===gl.comment&&_n(/<[/\w]/g,Z.data))return mt(Z),!0;if(!O[_e]||ue[_e]){if(!ue[_e]&&Rr(_e)&&(ie.tagNameCheck instanceof RegExp&&_n(ie.tagNameCheck,_e)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(_e)))return!1;if(Nt&&!Ot[_e]){const pt=$(Z)||Z.parentNode,zt=R(Z)||Z.childNodes;if(zt&&pt){const Ve=zt.length;for(let Xt=Ve-1;Xt>=0;--Xt){const ln=w(zt[Xt],!0);ln.__removalCount=(Z.__removalCount||0)+1,pt.insertBefore(ln,N(Z))}}}return mt(Z),!0}return Z instanceof f&&!Kt(Z)||(_e==="noscript"||_e==="noembed"||_e==="noframes")&&_n(/<\/no(script|embed|frames)/i,Z.innerHTML)?(mt(Z),!0):(ke&&Z.nodeType===gl.text&&(ge=Z.textContent,_u([W,U,D],pt=>{ge=ml(ge,pt," ")}),Z.textContent!==ge&&(fl(t.removed,{element:Z.cloneNode()}),Z.textContent=ge)),Jn(z.afterSanitizeElements,Z,null),!1)},ps=function(Z,ge,_e){if(we&&(ge==="id"||ge==="name")&&(_e in s||_e in Ae))return!1;if(!(he&&!ae[ge]&&_n(K,ge))){if(!(ce&&_n(P,ge))){if(!ee[ge]||ae[ge]){if(!(Rr(Z)&&(ie.tagNameCheck instanceof RegExp&&_n(ie.tagNameCheck,Z)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(Z))&&(ie.attributeNameCheck instanceof RegExp&&_n(ie.attributeNameCheck,ge)||ie.attributeNameCheck instanceof Function&&ie.attributeNameCheck(ge))||ge==="is"&&ie.allowCustomizedBuiltInElements&&(ie.tagNameCheck instanceof RegExp&&_n(ie.tagNameCheck,_e)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(_e))))return!1}else if(!Ie[ge]){if(!_n(q,ml(_e,I,""))){if(!((ge==="src"||ge==="xlink:href"||ge==="href")&&Z!=="script"&&A3(_e,"data:")===0&&Et[Z])){if(!(et&&!_n(G,ml(_e,I,"")))){if(_e)return!1}}}}}}return!0},Rr=function(Z){return Z!=="annotation-xml"&&Ev(Z,Y)},wo=function(Z){Jn(z.beforeSanitizeAttributes,Z,null);const{attributes:ge}=Z;if(!ge||zn(Z))return;const _e={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let pt=ge.length;for(;pt--;){const zt=ge[pt],{name:Ve,namespaceURI:Xt,value:ln}=zt,Ms=yt(Ve);let Ct=Ve==="value"?ln:O3(ln);if(_e.attrName=Ms,_e.attrValue=Ct,_e.keepAttr=!0,_e.forceKeepAttr=void 0,Jn(z.uponSanitizeAttribute,Z,_e),Ct=_e.attrValue,lt&&(Ms==="id"||Ms==="name")&&(In(Ve,Z),Ct=jt+Ct),Se&&_n(/((--!?|])>)|<\/(style|title)/i,Ct)){In(Ve,Z);continue}if(_e.forceKeepAttr||(In(Ve,Z),!_e.keepAttr))continue;if(!se&&_n(/\/>/i,Ct)){In(Ve,Z);continue}ke&&_u([W,U,D],Ar=>{Ct=ml(Ct,Ar," ")});const ko=yt(Z.nodeName);if(ps(ko,Ms,Ct)){if(S&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Xt)switch(m.getAttributeType(ko,Ms)){case"TrustedHTML":{Ct=S.createHTML(Ct);break}case"TrustedScriptURL":{Ct=S.createScriptURL(Ct);break}}try{Xt?Z.setAttributeNS(Xt,Ve,Ct):Z.setAttribute(Ve,Ct),zn(Z)?mt(Z):$v(t.removed)}catch{}}}Jn(z.afterSanitizeAttributes,Z,null)},ha=function Pe(Z){let ge=null;const _e=ms(Z);for(Jn(z.beforeSanitizeShadowDOM,Z,null);ge=_e.nextNode();)Jn(z.uponSanitizeShadowNode,ge,null),pa(ge),wo(ge),ge.content instanceof l&&Pe(ge.content);Jn(z.afterSanitizeShadowDOM,Z,null)};return t.sanitize=function(Pe){let Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ge=null,_e=null,pt=null,zt=null;if(Ln=!Pe,Ln&&(Pe="<!-->"),typeof Pe!="string"&&!ma(Pe))if(typeof Pe.toString=="function"){if(Pe=Pe.toString(),typeof Pe!="string")throw pl("dirty is not a string, aborting")}else throw pl("toString is not a function");if(!t.isSupported)return Pe;if(fe||ut(Z),t.removed=[],typeof Pe=="string"&&(on=!1),on){if(Pe.nodeName){const ln=yt(Pe.nodeName);if(!O[ln]||ue[ln])throw pl("root node is forbidden and cannot be sanitized in-place")}}else if(Pe instanceof u)ge=jn("<!---->"),_e=ge.ownerDocument.importNode(Pe,!0),_e.nodeType===gl.element&&_e.nodeName==="BODY"||_e.nodeName==="HTML"?ge=_e:ge.appendChild(_e);else{if(!He&&!ke&&!Fe&&Pe.indexOf("<")===-1)return S&&We?S.createHTML(Pe):Pe;if(ge=jn(Pe),!ge)return He?null:We?E:""}ge&&Le&&mt(ge.firstChild);const Ve=ms(on?Pe:ge);for(;pt=Ve.nextNode();)pa(pt),wo(pt),pt.content instanceof l&&ha(pt.content);if(on)return Pe;if(He){if(It)for(zt=A.call(ge.ownerDocument);ge.firstChild;)zt.appendChild(ge.firstChild);else zt=ge;return(ee.shadowroot||ee.shadowrootmode)&&(zt=L.call(r,zt,!0)),zt}let Xt=Fe?ge.outerHTML:ge.innerHTML;return Fe&&O["!doctype"]&&ge.ownerDocument&&ge.ownerDocument.doctype&&ge.ownerDocument.doctype.name&&_n(Dj,ge.ownerDocument.doctype.name)&&(Xt="<!DOCTYPE "+ge.ownerDocument.doctype.name+`>
458
+ `+Xt),ke&&_u([W,U,D],ln=>{Xt=ml(Xt,ln," ")}),S&&We?S.createHTML(Xt):Xt},t.setConfig=function(){let Pe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ut(Pe),fe=!0},t.clearConfig=function(){Q=null,fe=!1},t.isValidAttribute=function(Pe,Z,ge){Q||ut({});const _e=yt(Pe),pt=yt(Z);return ps(_e,pt,ge)},t.addHook=function(Pe,Z){typeof Z=="function"&&fl(z[Pe],Z)},t.removeHook=function(Pe){return $v(z[Pe])},t.removeHooks=function(Pe){z[Pe]=[]},t.removeAllHooks=function(){z=Mv()},t}var qu=Fj();function pg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ca=pg();function Uj(e){ca=e}const Tl={exec:()=>null};function ht(e,t=""){let s=typeof e=="string"?e:e.source;const r={replace:(a,l)=>{let c=typeof l=="string"?l:l.source;return c=c.replace(Tn.caret,"$1"),s=s.replace(a,c),r},getRegex:()=>new RegExp(s,t)};return r}const Tn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},K3=/^(?:[ \t]*(?:\n|$))+/,X3=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Y3=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,nc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Q3=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wj=/(?:[*+-]|\d{1,9}[.)])/,Hj=ht(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Wj).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),hg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Z3=/^[^\n]+/,gg=/(?!\s*\])(?:\\.|[^\[\]\\])+/,J3=ht(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),e4=ht(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Wj).getRegex(),nf="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",xg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,t4=ht("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",xg).replace("tag",nf).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Bj=ht(hg).replace("hr",nc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",nf).getRegex(),n4=ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Bj).getRegex(),yg={blockquote:n4,code:X3,def:J3,fences:Y3,heading:Q3,hr:nc,html:t4,lheading:Hj,list:e4,newline:K3,paragraph:Bj,table:Tl,text:Z3},Pv=ht("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",nc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",nf).getRegex(),s4={...yg,table:Pv,paragraph:ht(hg).replace("hr",nc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Pv).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",nf).getRegex()},r4={...yg,html:ht(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",xg).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Tl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ht(hg).replace("hr",nc).replace("heading",` *#{1,6} *[^
459
+ ]`).replace("lheading",Hj).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},o4=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,a4=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gj=/^( {2,}|\\)\n(?!\s*$)/,i4=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,sf=/[\p{P}\p{S}]/u,bg=/[\s\p{P}\p{S}]/u,qj=/[^\s\p{P}\p{S}]/u,l4=ht(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,bg).getRegex(),Vj=/(?!~)[\p{P}\p{S}]/u,c4=/(?!~)[\s\p{P}\p{S}]/u,u4=/(?:[^\s\p{P}\p{S}]|~)/u,d4=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Kj=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,f4=ht(Kj,"u").replace(/punct/g,sf).getRegex(),m4=ht(Kj,"u").replace(/punct/g,Vj).getRegex(),Xj="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",p4=ht(Xj,"gu").replace(/notPunctSpace/g,qj).replace(/punctSpace/g,bg).replace(/punct/g,sf).getRegex(),h4=ht(Xj,"gu").replace(/notPunctSpace/g,u4).replace(/punctSpace/g,c4).replace(/punct/g,Vj).getRegex(),g4=ht("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,qj).replace(/punctSpace/g,bg).replace(/punct/g,sf).getRegex(),x4=ht(/\\(punct)/,"gu").replace(/punct/g,sf).getRegex(),y4=ht(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),b4=ht(xg).replace("(?:-->|$)","-->").getRegex(),v4=ht("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",b4).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ad=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,w4=ht(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",ad).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Yj=ht(/^!?\[(label)\]\[(ref)\]/).replace("label",ad).replace("ref",gg).getRegex(),Qj=ht(/^!?\[(ref)\](?:\[\])?/).replace("ref",gg).getRegex(),k4=ht("reflink|nolink(?!\\()","g").replace("reflink",Yj).replace("nolink",Qj).getRegex(),vg={_backpedal:Tl,anyPunctuation:x4,autolink:y4,blockSkip:d4,br:Gj,code:a4,del:Tl,emStrongLDelim:f4,emStrongRDelimAst:p4,emStrongRDelimUnd:g4,escape:o4,link:w4,nolink:Qj,punctuation:l4,reflink:Yj,reflinkSearch:k4,tag:v4,text:i4,url:Tl},j4={...vg,link:ht(/^!?\[(label)\]\((.*?)\)/).replace("label",ad).getRegex(),reflink:ht(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ad).getRegex()},ah={...vg,emStrongRDelimAst:h4,emStrongLDelim:m4,url:ht(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},N4={...ah,br:ht(Gj).replace("{2,}","*").getRegex(),text:ht(ah.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Eu={normal:yg,gfm:s4,pedantic:r4},xl={normal:vg,gfm:ah,breaks:N4,pedantic:j4},S4={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Lv=e=>S4[e];function tr(e,t){if(t){if(Tn.escapeTest.test(e))return e.replace(Tn.escapeReplace,Lv)}else if(Tn.escapeTestNoEncode.test(e))return e.replace(Tn.escapeReplaceNoEncode,Lv);return e}function Iv(e){try{e=encodeURI(e).replace(Tn.percentDecode,"%")}catch{return null}return e}function zv(e,t){var l;const s=e.replace(Tn.findPipe,(c,u,f)=>{let p=!1,g=u;for(;--g>=0&&f[g]==="\\";)p=!p;return p?"|":" |"}),r=s.split(Tn.splitPipe);let a=0;if(r[0].trim()||r.shift(),r.length>0&&!((l=r.at(-1))!=null&&l.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;a<r.length;a++)r[a]=r[a].trim().replace(Tn.slashPipe,"|");return r}function yl(e,t,s){const r=e.length;if(r===0)return"";let a=0;for(;a<r&&e.charAt(r-a-1)===t;)a++;return e.slice(0,r-a)}function _4(e,t){if(e.indexOf(t[1])===-1)return-1;let s=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])s++;else if(e[r]===t[1]&&(s--,s<0))return r;return-1}function Dv(e,t,s,r,a){const l=t.href,c=t.title||null,u=e[1].replace(a.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const f={type:"link",raw:s,href:l,title:c,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,f}return{type:"image",raw:s,href:l,title:c,text:u}}function $4(e,t,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return t;const a=r[1];return t.split(`
460
+ `).map(l=>{const c=l.match(s.other.beginningSpace);if(c===null)return l;const[u]=c;return u.length>=a.length?l.slice(a.length):l}).join(`
461
+ `)}class id{constructor(t){it(this,"options");it(this,"rules");it(this,"lexer");this.options=t||ca}space(t){const s=this.rules.block.newline.exec(t);if(s&&s[0].length>0)return{type:"space",raw:s[0]}}code(t){const s=this.rules.block.code.exec(t);if(s){const r=s[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s[0],codeBlockStyle:"indented",text:this.options.pedantic?r:yl(r,`
462
+ `)}}}fences(t){const s=this.rules.block.fences.exec(t);if(s){const r=s[0],a=$4(r,s[3]||"",this.rules);return{type:"code",raw:r,lang:s[2]?s[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):s[2],text:a}}}heading(t){const s=this.rules.block.heading.exec(t);if(s){let r=s[2].trim();if(this.rules.other.endingHash.test(r)){const a=yl(r,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(r=a.trim())}return{type:"heading",raw:s[0],depth:s[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const s=this.rules.block.hr.exec(t);if(s)return{type:"hr",raw:yl(s[0],`
463
+ `)}}blockquote(t){const s=this.rules.block.blockquote.exec(t);if(s){let r=yl(s[0],`
464
+ `).split(`
465
+ `),a="",l="";const c=[];for(;r.length>0;){let u=!1;const f=[];let p;for(p=0;p<r.length;p++)if(this.rules.other.blockquoteStart.test(r[p]))f.push(r[p]),u=!0;else if(!u)f.push(r[p]);else break;r=r.slice(p);const g=f.join(`
466
+ `),v=g.replace(this.rules.other.blockquoteSetextReplace,`
467
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
468
+ ${g}`:g,l=l?`${l}
469
+ ${v}`:v;const h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(v,c,!0),this.lexer.state.top=h,r.length===0)break;const m=c.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){const b=m,w=b.raw+`
470
+ `+r.join(`
471
+ `),j=this.blockquote(w);c[c.length-1]=j,a=a.substring(0,a.length-b.raw.length)+j.raw,l=l.substring(0,l.length-b.text.length)+j.text;break}else if((m==null?void 0:m.type)==="list"){const b=m,w=b.raw+`
472
+ `+r.join(`
473
+ `),j=this.list(w);c[c.length-1]=j,a=a.substring(0,a.length-m.raw.length)+j.raw,l=l.substring(0,l.length-b.raw.length)+j.raw,r=w.substring(c.at(-1).raw.length).split(`
474
+ `);continue}}return{type:"blockquote",raw:a,tokens:c,text:l}}}list(t){let s=this.rules.block.list.exec(t);if(s){let r=s[1].trim();const a=r.length>1,l={type:"list",raw:"",ordered:a,start:a?+r.slice(0,-1):"",loose:!1,items:[]};r=a?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=a?r:"[*+-]");const c=this.rules.other.listItemRegex(r);let u=!1;for(;t;){let p=!1,g="",v="";if(!(s=c.exec(t))||this.rules.block.hr.test(t))break;g=s[0],t=t.substring(g.length);let h=s[2].split(`
475
+ `,1)[0].replace(this.rules.other.listReplaceTabs,R=>" ".repeat(3*R.length)),m=t.split(`
476
+ `,1)[0],b=!h.trim(),w=0;if(this.options.pedantic?(w=2,v=h.trimStart()):b?w=s[1].length+1:(w=s[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,v=h.slice(w),w+=s[1].length),b&&this.rules.other.blankLine.test(m)&&(g+=m+`
477
+ `,t=t.substring(m.length+1),p=!0),!p){const R=this.rules.other.nextBulletRegex(w),$=this.rules.other.hrRegex(w),S=this.rules.other.fencesBeginRegex(w),E=this.rules.other.headingBeginRegex(w),C=this.rules.other.htmlBeginRegex(w);for(;t;){const T=t.split(`
478
+ `,1)[0];let A;if(m=T,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),A=m):A=m.replace(this.rules.other.tabCharGlobal," "),S.test(m)||E.test(m)||C.test(m)||R.test(m)||$.test(m))break;if(A.search(this.rules.other.nonSpaceChar)>=w||!m.trim())v+=`
479
+ `+A.slice(w);else{if(b||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(h)||E.test(h)||$.test(h))break;v+=`
480
+ `+m}!b&&!m.trim()&&(b=!0),g+=T+`
481
+ `,t=t.substring(T.length+1),h=A.slice(w)}}l.loose||(u?l.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(u=!0));let j=null,N;this.options.gfm&&(j=this.rules.other.listIsTask.exec(v),j&&(N=j[0]!=="[ ] ",v=v.replace(this.rules.other.listReplaceTask,""))),l.items.push({type:"list_item",raw:g,task:!!j,checked:N,loose:!1,text:v,tokens:[]}),l.raw+=g}const f=l.items.at(-1);if(f)f.raw=f.raw.trimEnd(),f.text=f.text.trimEnd();else return;l.raw=l.raw.trimEnd();for(let p=0;p<l.items.length;p++)if(this.lexer.state.top=!1,l.items[p].tokens=this.lexer.blockTokens(l.items[p].text,[]),!l.loose){const g=l.items[p].tokens.filter(h=>h.type==="space"),v=g.length>0&&g.some(h=>this.rules.other.anyLine.test(h.raw));l.loose=v}if(l.loose)for(let p=0;p<l.items.length;p++)l.items[p].loose=!0;return l}}html(t){const s=this.rules.block.html.exec(t);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(t){const s=this.rules.block.def.exec(t);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=s[2]?s[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=s[3]?s[3].substring(1,s[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):s[3];return{type:"def",tag:r,raw:s[0],href:a,title:l}}}table(t){var u;const s=this.rules.block.table.exec(t);if(!s||!this.rules.other.tableDelimiter.test(s[2]))return;const r=zv(s[1]),a=s[2].replace(this.rules.other.tableAlignChars,"").split("|"),l=(u=s[3])!=null&&u.trim()?s[3].replace(this.rules.other.tableRowBlankLine,"").split(`
482
+ `):[],c={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===a.length){for(const f of a)this.rules.other.tableAlignRight.test(f)?c.align.push("right"):this.rules.other.tableAlignCenter.test(f)?c.align.push("center"):this.rules.other.tableAlignLeft.test(f)?c.align.push("left"):c.align.push(null);for(let f=0;f<r.length;f++)c.header.push({text:r[f],tokens:this.lexer.inline(r[f]),header:!0,align:c.align[f]});for(const f of l)c.rows.push(zv(f,c.header.length).map((p,g)=>({text:p,tokens:this.lexer.inline(p),header:!1,align:c.align[g]})));return c}}lheading(t){const s=this.rules.block.lheading.exec(t);if(s)return{type:"heading",raw:s[0],depth:s[2].charAt(0)==="="?1:2,text:s[1],tokens:this.lexer.inline(s[1])}}paragraph(t){const s=this.rules.block.paragraph.exec(t);if(s){const r=s[1].charAt(s[1].length-1)===`
483
+ `?s[1].slice(0,-1):s[1];return{type:"paragraph",raw:s[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const s=this.rules.block.text.exec(t);if(s)return{type:"text",raw:s[0],text:s[0],tokens:this.lexer.inline(s[0])}}escape(t){const s=this.rules.inline.escape.exec(t);if(s)return{type:"escape",raw:s[0],text:s[1]}}tag(t){const s=this.rules.inline.tag.exec(t);if(s)return!this.lexer.state.inLink&&this.rules.other.startATag.test(s[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(s[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(s[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(s[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:s[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:s[0]}}link(t){const s=this.rules.inline.link.exec(t);if(s){const r=s[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const c=yl(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=_4(s[2],"()");if(c>-1){const f=(s[0].indexOf("!")===0?5:4)+s[1].length+c;s[2]=s[2].substring(0,c),s[0]=s[0].substring(0,f).trim(),s[3]=""}}let a=s[2],l="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(a);c&&(a=c[1],l=c[3])}else l=s[3]?s[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?a=a.slice(1):a=a.slice(1,-1)),Dv(s,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},s[0],this.lexer,this.rules)}}reflink(t,s){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){const a=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),l=s[a.toLowerCase()];if(!l){const c=r[0].charAt(0);return{type:"text",raw:c,text:c}}return Dv(r,l,r[0],this.lexer,this.rules)}}emStrong(t,s,r=""){let a=this.rules.inline.emStrongLDelim.exec(t);if(!a||a[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(a[1]||a[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const c=[...a[0]].length-1;let u,f,p=c,g=0;const v=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(v.lastIndex=0,s=s.slice(-1*t.length+c);(a=v.exec(s))!=null;){if(u=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!u)continue;if(f=[...u].length,a[3]||a[4]){p+=f;continue}else if((a[5]||a[6])&&c%3&&!((c+f)%3)){g+=f;continue}if(p-=f,p>0)continue;f=Math.min(f,f+p+g);const h=[...a[0]][0].length,m=t.slice(0,c+a.index+h+f);if(Math.min(c,f)%2){const w=m.slice(1,-1);return{type:"em",raw:m,text:w,tokens:this.lexer.inlineTokens(w)}}const b=m.slice(2,-2);return{type:"strong",raw:m,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(t){const s=this.rules.inline.code.exec(t);if(s){let r=s[2].replace(this.rules.other.newLineCharGlobal," ");const a=this.rules.other.nonSpaceChar.test(r),l=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return a&&l&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:s[0],text:r}}}br(t){const s=this.rules.inline.br.exec(t);if(s)return{type:"br",raw:s[0]}}del(t){const s=this.rules.inline.del.exec(t);if(s)return{type:"del",raw:s[0],text:s[2],tokens:this.lexer.inlineTokens(s[2])}}autolink(t){const s=this.rules.inline.autolink.exec(t);if(s){let r,a;return s[2]==="@"?(r=s[1],a="mailto:"+r):(r=s[1],a=r),{type:"link",raw:s[0],text:r,href:a,tokens:[{type:"text",raw:r,text:r}]}}}url(t){var r;let s;if(s=this.rules.inline.url.exec(t)){let a,l;if(s[2]==="@")a=s[0],l="mailto:"+a;else{let c;do c=s[0],s[0]=((r=this.rules.inline._backpedal.exec(s[0]))==null?void 0:r[0])??"";while(c!==s[0]);a=s[0],s[1]==="www."?l="http://"+s[0]:l=s[0]}return{type:"link",raw:s[0],text:a,href:l,tokens:[{type:"text",raw:a,text:a}]}}}inlineText(t){const s=this.rules.inline.text.exec(t);if(s){const r=this.lexer.state.inRawBlock;return{type:"text",raw:s[0],text:s[0],escaped:r}}}}class js{constructor(t){it(this,"tokens");it(this,"options");it(this,"state");it(this,"tokenizer");it(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ca,this.options.tokenizer=this.options.tokenizer||new id,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const s={other:Tn,block:Eu.normal,inline:xl.normal};this.options.pedantic?(s.block=Eu.pedantic,s.inline=xl.pedantic):this.options.gfm&&(s.block=Eu.gfm,this.options.breaks?s.inline=xl.breaks:s.inline=xl.gfm),this.tokenizer.rules=s}static get rules(){return{block:Eu,inline:xl}}static lex(t,s){return new js(s).lex(t)}static lexInline(t,s){return new js(s).inlineTokens(t)}lex(t){t=t.replace(Tn.carriageReturn,`
484
+ `),this.blockTokens(t,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){const r=this.inlineQueue[s];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,s=[],r=!1){var a,l,c;for(this.options.pedantic&&(t=t.replace(Tn.tabCharGlobal," ").replace(Tn.spaceLine,""));t;){let u;if((l=(a=this.options.extensions)==null?void 0:a.block)!=null&&l.some(p=>(u=p.call({lexer:this},t,s))?(t=t.substring(u.raw.length),s.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);const p=s.at(-1);u.raw.length===1&&p!==void 0?p.raw+=`
485
+ `:s.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);const p=s.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=`
486
+ `+u.raw,p.text+=`
487
+ `+u.text,this.inlineQueue.at(-1).src=p.text):s.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);const p=s.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=`
488
+ `+u.raw,p.text+=`
489
+ `+u.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title});continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),s.push(u);continue}let f=t;if((c=this.options.extensions)!=null&&c.startBlock){let p=1/0;const g=t.slice(1);let v;this.options.extensions.startBlock.forEach(h=>{v=h.call({lexer:this},g),typeof v=="number"&&v>=0&&(p=Math.min(p,v))}),p<1/0&&p>=0&&(f=t.substring(0,p+1))}if(this.state.top&&(u=this.tokenizer.paragraph(f))){const p=s.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=`
490
+ `+u.raw,p.text+=`
491
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):s.push(u),r=f.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);const p=s.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=`
492
+ `+u.raw,p.text+=`
493
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):s.push(u);continue}if(t){const p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return this.state.top=!0,s}inline(t,s=[]){return this.inlineQueue.push({src:t,tokens:s}),s}inlineTokens(t,s=[]){var u,f,p;let r=t,a=null;if(this.tokens.links){const g=Object.keys(this.tokens.links);if(g.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,a.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let l=!1,c="";for(;t;){l||(c=""),l=!1;let g;if((f=(u=this.options.extensions)==null?void 0:u.inline)!=null&&f.some(h=>(g=h.call({lexer:this},t,s))?(t=t.substring(g.raw.length),s.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);const h=s.at(-1);g.type==="text"&&(h==null?void 0:h.type)==="text"?(h.raw+=g.raw,h.text+=g.text):s.push(g);continue}if(g=this.tokenizer.emStrong(t,r,c)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.del(t)){t=t.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),s.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),s.push(g);continue}let v=t;if((p=this.options.extensions)!=null&&p.startInline){let h=1/0;const m=t.slice(1);let b;this.options.extensions.startInline.forEach(w=>{b=w.call({lexer:this},m),typeof b=="number"&&b>=0&&(h=Math.min(h,b))}),h<1/0&&h>=0&&(v=t.substring(0,h+1))}if(g=this.tokenizer.inlineText(v)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),l=!0;const h=s.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=g.raw,h.text+=g.text):s.push(g);continue}if(t){const h="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return s}}class ld{constructor(t){it(this,"options");it(this,"parser");this.options=t||ca}space(t){return""}code({text:t,lang:s,escaped:r}){var c;const a=(c=(s||"").match(Tn.notSpaceStart))==null?void 0:c[0],l=t.replace(Tn.endingNewline,"")+`
494
+ `;return a?'<pre><code class="language-'+tr(a)+'">'+(r?l:tr(l,!0))+`</code></pre>
495
+ `:"<pre><code>"+(r?l:tr(l,!0))+`</code></pre>
496
+ `}blockquote({tokens:t}){return`<blockquote>
497
+ ${this.parser.parse(t)}</blockquote>
498
+ `}html({text:t}){return t}heading({tokens:t,depth:s}){return`<h${s}>${this.parser.parseInline(t)}</h${s}>
499
+ `}hr(t){return`<hr>
500
+ `}list(t){const s=t.ordered,r=t.start;let a="";for(let u=0;u<t.items.length;u++){const f=t.items[u];a+=this.listitem(f)}const l=s?"ol":"ul",c=s&&r!==1?' start="'+r+'"':"";return"<"+l+c+`>
501
+ `+a+"</"+l+`>
502
+ `}listitem(t){var r;let s="";if(t.task){const a=this.checkbox({checked:!!t.checked});t.loose?((r=t.tokens[0])==null?void 0:r.type)==="paragraph"?(t.tokens[0].text=a+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=a+" "+tr(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:a+" ",text:a+" ",escaped:!0}):s+=a+" "}return s+=this.parser.parse(t.tokens,!!t.loose),`<li>${s}</li>
503
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
504
+ `}table(t){let s="",r="";for(let l=0;l<t.header.length;l++)r+=this.tablecell(t.header[l]);s+=this.tablerow({text:r});let a="";for(let l=0;l<t.rows.length;l++){const c=t.rows[l];r="";for(let u=0;u<c.length;u++)r+=this.tablecell(c[u]);a+=this.tablerow({text:r})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
505
+ <thead>
506
+ `+s+`</thead>
507
+ `+a+`</table>
508
+ `}tablerow({text:t}){return`<tr>
509
+ ${t}</tr>
510
+ `}tablecell(t){const s=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+s+`</${r}>
511
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${tr(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:s,tokens:r}){const a=this.parser.parseInline(r),l=Iv(t);if(l===null)return a;t=l;let c='<a href="'+t+'"';return s&&(c+=' title="'+tr(s)+'"'),c+=">"+a+"</a>",c}image({href:t,title:s,text:r}){const a=Iv(t);if(a===null)return tr(r);t=a;let l=`<img src="${t}" alt="${r}"`;return s&&(l+=` title="${tr(s)}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:tr(t.text)}}class wg{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class Ns{constructor(t){it(this,"options");it(this,"renderer");it(this,"textRenderer");this.options=t||ca,this.options.renderer=this.options.renderer||new ld,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new wg}static parse(t,s){return new Ns(s).parse(t)}static parseInline(t,s){return new Ns(s).parseInline(t)}parse(t,s=!0){var a,l;let r="";for(let c=0;c<t.length;c++){const u=t[c];if((l=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&l[u.type]){const p=u,g=this.options.extensions.renderers[p.type].call({parser:this},p);if(g!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type)){r+=g||"";continue}}const f=u;switch(f.type){case"space":{r+=this.renderer.space(f);continue}case"hr":{r+=this.renderer.hr(f);continue}case"heading":{r+=this.renderer.heading(f);continue}case"code":{r+=this.renderer.code(f);continue}case"table":{r+=this.renderer.table(f);continue}case"blockquote":{r+=this.renderer.blockquote(f);continue}case"list":{r+=this.renderer.list(f);continue}case"html":{r+=this.renderer.html(f);continue}case"paragraph":{r+=this.renderer.paragraph(f);continue}case"text":{let p=f,g=this.renderer.text(p);for(;c+1<t.length&&t[c+1].type==="text";)p=t[++c],g+=`
512
+ `+this.renderer.text(p);s?r+=this.renderer.paragraph({type:"paragraph",raw:g,text:g,tokens:[{type:"text",raw:g,text:g,escaped:!0}]}):r+=g;continue}default:{const p='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}parseInline(t,s=this.renderer){var a,l;let r="";for(let c=0;c<t.length;c++){const u=t[c];if((l=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&l[u.type]){const p=this.options.extensions.renderers[u.type].call({parser:this},u);if(p!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){r+=p||"";continue}}const f=u;switch(f.type){case"escape":{r+=s.text(f);break}case"html":{r+=s.html(f);break}case"link":{r+=s.link(f);break}case"image":{r+=s.image(f);break}case"strong":{r+=s.strong(f);break}case"em":{r+=s.em(f);break}case"codespan":{r+=s.codespan(f);break}case"br":{r+=s.br(f);break}case"del":{r+=s.del(f);break}case"text":{r+=s.text(f);break}default:{const p='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}}class Rl{constructor(t){it(this,"options");it(this,"block");this.options=t||ca}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?js.lex:js.lexInline}provideParser(){return this.block?Ns.parse:Ns.parseInline}}it(Rl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class E4{constructor(...t){it(this,"defaults",pg());it(this,"options",this.setOptions);it(this,"parse",this.parseMarkdown(!0));it(this,"parseInline",this.parseMarkdown(!1));it(this,"Parser",Ns);it(this,"Renderer",ld);it(this,"TextRenderer",wg);it(this,"Lexer",js);it(this,"Tokenizer",id);it(this,"Hooks",Rl);this.use(...t)}walkTokens(t,s){var a,l;let r=[];for(const c of t)switch(r=r.concat(s.call(this,c)),c.type){case"table":{const u=c;for(const f of u.header)r=r.concat(this.walkTokens(f.tokens,s));for(const f of u.rows)for(const p of f)r=r.concat(this.walkTokens(p.tokens,s));break}case"list":{const u=c;r=r.concat(this.walkTokens(u.items,s));break}default:{const u=c;(l=(a=this.defaults.extensions)==null?void 0:a.childTokens)!=null&&l[u.type]?this.defaults.extensions.childTokens[u.type].forEach(f=>{const p=u[f].flat(1/0);r=r.concat(this.walkTokens(p,s))}):u.tokens&&(r=r.concat(this.walkTokens(u.tokens,s)))}}return r}use(...t){const s=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const a={...r};if(a.async=this.defaults.async||a.async||!1,r.extensions&&(r.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const c=s.renderers[l.name];c?s.renderers[l.name]=function(...u){let f=l.renderer.apply(this,u);return f===!1&&(f=c.apply(this,u)),f}:s.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const c=s[l.level];c?c.unshift(l.tokenizer):s[l.level]=[l.tokenizer],l.start&&(l.level==="block"?s.startBlock?s.startBlock.push(l.start):s.startBlock=[l.start]:l.level==="inline"&&(s.startInline?s.startInline.push(l.start):s.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(s.childTokens[l.name]=l.childTokens)}),a.extensions=s),r.renderer){const l=this.defaults.renderer||new ld(this.defaults);for(const c in r.renderer){if(!(c in l))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const u=c,f=r.renderer[u],p=l[u];l[u]=(...g)=>{let v=f.apply(l,g);return v===!1&&(v=p.apply(l,g)),v||""}}a.renderer=l}if(r.tokenizer){const l=this.defaults.tokenizer||new id(this.defaults);for(const c in r.tokenizer){if(!(c in l))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const u=c,f=r.tokenizer[u],p=l[u];l[u]=(...g)=>{let v=f.apply(l,g);return v===!1&&(v=p.apply(l,g)),v}}a.tokenizer=l}if(r.hooks){const l=this.defaults.hooks||new Rl;for(const c in r.hooks){if(!(c in l))throw new Error(`hook '${c}' does not exist`);if(["options","block"].includes(c))continue;const u=c,f=r.hooks[u],p=l[u];Rl.passThroughHooks.has(c)?l[u]=g=>{if(this.defaults.async)return Promise.resolve(f.call(l,g)).then(h=>p.call(l,h));const v=f.call(l,g);return p.call(l,v)}:l[u]=(...g)=>{let v=f.apply(l,g);return v===!1&&(v=p.apply(l,g)),v}}a.hooks=l}if(r.walkTokens){const l=this.defaults.walkTokens,c=r.walkTokens;a.walkTokens=function(u){let f=[];return f.push(c.call(this,u)),l&&(f=f.concat(l.call(this,u))),f}}this.defaults={...this.defaults,...a}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,s){return js.lex(t,s??this.defaults)}parser(t,s){return Ns.parse(t,s??this.defaults)}parseMarkdown(t){return(r,a)=>{const l={...a},c={...this.defaults,...l},u=this.onError(!!c.silent,!!c.async);if(this.defaults.async===!0&&l.async===!1)return u(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return u(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return u(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));c.hooks&&(c.hooks.options=c,c.hooks.block=t);const f=c.hooks?c.hooks.provideLexer():t?js.lex:js.lexInline,p=c.hooks?c.hooks.provideParser():t?Ns.parse:Ns.parseInline;if(c.async)return Promise.resolve(c.hooks?c.hooks.preprocess(r):r).then(g=>f(g,c)).then(g=>c.hooks?c.hooks.processAllTokens(g):g).then(g=>c.walkTokens?Promise.all(this.walkTokens(g,c.walkTokens)).then(()=>g):g).then(g=>p(g,c)).then(g=>c.hooks?c.hooks.postprocess(g):g).catch(u);try{c.hooks&&(r=c.hooks.preprocess(r));let g=f(r,c);c.hooks&&(g=c.hooks.processAllTokens(g)),c.walkTokens&&this.walkTokens(g,c.walkTokens);let v=p(g,c);return c.hooks&&(v=c.hooks.postprocess(v)),v}catch(g){return u(g)}}}onError(t,s){return r=>{if(r.message+=`
513
+ Please report this to https://github.com/markedjs/marked.`,t){const a="<p>An error occurred:</p><pre>"+tr(r.message+"",!0)+"</pre>";return s?Promise.resolve(a):a}if(s)return Promise.reject(r);throw r}}}const sa=new E4;function dt(e,t){return sa.parse(e,t)}dt.options=dt.setOptions=function(e){return sa.setOptions(e),dt.defaults=sa.defaults,Uj(dt.defaults),dt};dt.getDefaults=pg;dt.defaults=ca;dt.use=function(...e){return sa.use(...e),dt.defaults=sa.defaults,Uj(dt.defaults),dt};dt.walkTokens=function(e,t){return sa.walkTokens(e,t)};dt.parseInline=sa.parseInline;dt.Parser=Ns;dt.parser=Ns.parse;dt.Renderer=ld;dt.TextRenderer=wg;dt.Lexer=js;dt.lexer=js.lex;dt.Tokenizer=id;dt.Hooks=Rl;dt.parse=dt;dt.options;dt.setOptions;dt.use;dt.walkTokens;dt.parseInline;Ns.parse;js.lex;let bl;const C4=e=>(bl||(qu.addHook("uponSanitizeElement",(t,s)=>{bl??(bl=s.allowedTags)}),qu.sanitize("<b></b>"),qu.removeHook("uponSanitizeElement")),(bl==null?void 0:bl[e.toLowerCase()])===!0),T4=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");dt.use({breaks:!0,renderer:{html:({text:e,block:t})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(a,l)=>C4(l)?(s++,a):T4(a));return t&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
514
+ `)}</p>
515
+ `:r}}});const ua=e=>e.slice(-8),rf=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),ft=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function ui(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const Zj=e=>e.basis==="estimate",fo=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,cd=e=>{if(e>0&&e<1e-4)return"<$0.0001";if(e>=1)return`$${e.toFixed(2)}`;const[t,s=""]=e.toFixed(4).split(".");return`$${t}.${s.replace(/0+$/,"").padEnd(2,"0")}`},Si=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,R4=(e,{ended:t=!1}={})=>`The charges priced${t?"":" so far"}. ${e.unpriced} ${e.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,A4=new Set(["completed","failed","cancelled"]),ra=e=>typeof e=="string"&&A4.has(e),O4=(e,{ended:t=!1}={})=>e.usd!==null?fo(e.usd):typeof e.so_far_usd=="number"?t?`${cd(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${cd(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function go(e,{ended:t=!1}={}){const s=Si(e),r=a=>Zj(a)?" est.":"";return s?t?`${cd(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${cd(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":`${fo(e.usd)}${r(e)}`}function Fv(e,t,{ended:s=!1,text:r}={}){const a=r??go(e,{ended:s});return typeof t!="number"?a:(r!==void 0?M4.test(r):!Si(e)&&!!e&&e.usd!==null)?`${a} of ${Uv(t)}`:`${a} · cap ${Uv(t)}`}const M4=/^<?\$[\d.,]+( est\.)?$/;function Uv(e){for(let t=2;t<8;t++)if(Number(e.toFixed(t))===e)return`$${e.toFixed(t)}`;return`$${e.toFixed(8)}`}function P4(e,t){if(e.startsWith("/")||e.startsWith("#"))return null;const s=t.from?`${t.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const r=decodeURIComponent(new URL(e,`file:///${s}`).pathname.slice(1));return t.paths.includes(r)?r:null}catch{return null}}function mo(e,t){const s=qu.sanitize(dt.parse(e,{async:!1}),{RETURN_DOM:!0});for(const r of[...s.querySelectorAll("pre")])r.classList.add("whitespace-pre-wrap","break-words","[overflow-wrap:anywhere]");for(const r of[...s.querySelectorAll("a[href]")]){const a=r.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(a)){r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(a))continue;const l=t&&P4(a,t);if(l){const c=r.ownerDocument.createElement("button");c.type="button",c.title=`Open ${l}`,c.dataset.runFile=l,c.append(...r.childNodes),r.replaceWith(c)}else r.replaceWith(...r.childNodes)}return s.innerHTML}const kg=e=>t=>{var r,a,l;const s=(l=(a=(r=t.target).closest)==null?void 0:a.call(r,"[data-run-file]"))==null?void 0:l.getAttribute("data-run-file");s&&(t.preventDefault(),e(s))},L4=e=>{const t=s=>{var r;return(r=new RegExp(`\\b${s}="([^"]*)"`).exec(e))==null?void 0:r[1]};return t("scheme")==="github"||t("source")==="github"?"A GitHub event":t("source")==="webhook"?"A webhook request":"A trigger's request"};function mn(e){const{title:t}=e;if(!e.trigger)return t;let s=t.search(/<trigger-payload\b/);if(s<0){const a=/<([a-z-]*)…$/.exec(t);if(!a||!"trigger-payload".startsWith(a[1]))return t;s=a.index}return t.slice(0,s).trim()||L4(t.slice(s))}function I4(e){return e.usd===null?{total:"Unknown"}:{total:go({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const jg=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Za=864e5,ih=e=>Math.floor(e/Za)*Za;function Ng(e,t=Date.now()){var r;const s=(r=jg.find(a=>a.id===e))==null?void 0:r.days;return s?new Date(ih(t)-(s-1)*Za).toISOString():void 0}const Jj=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function z4(e){return[`${e.completed-e.needs_review} completed`,`${e.failed} failed`,e.needs_review?`${e.needs_review} ${e.needs_review===1?"needs":"need"} review`:""].filter(Boolean).join(" · ")}function D4(e){const t=e.input+e.cache_read+e.cache_write;return t?e.cache_read/t:null}const e1=(e,t)=>I4({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Sg=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function oa(e){if(e<1e4)return e.toLocaleString("en-US");const[t,s]=e<1e6?[e/1e3,"K"]:e<1e9?[e/1e6,"M"]:[e/1e9,"B"];return`${t<100?t.toFixed(1).replace(/\.0$/,""):Math.round(t)}${s}`}const ud=e=>e===null?"—":`${Math.round(e*100)}%`;function Wv(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function F4(e,t,s=Date.now()){if(!e.length)return[];const r=ih(s),a=Math.max(r-29*Za,t?ih(Date.parse(t)):r-29*Za),l=new Map(e.map(u=>[u.day,u])),c=[];for(let u=a;u<=r;u+=Za){const f=new Date(u).toISOString().slice(0,10);c.push(l.get(f)??{day:f,runs:0,completed:0,failed:0,needs_review:0,runs_with_metrics:0,tokens:0,cost_usd:null,unknown_cost_runs:0})}return c}function U4(e,t){return{agents:e.agents,runs:{total:e.runs.total,active:e.runs.active,needsInput:e.runs.needs_input,failed:e.runs.failed,statusUnknown:e.runs.status_unknown,needsReview:e.runs.needs_review},perAgent:e.per_agent.map(s=>({agentId:s.agent_id,name:s.name,runs:s.runs})).sort((s,r)=>Pj({name:s.name,id:s.agentId},{name:r.name,id:r.agentId})),cost:{usd:e.cost.usd,basis:e.cost.basis,unknownRuns:e.cost.unknown_runs},recent:t,analytics:e.analytics}}function t1({range:e,onRange:t,agent:s,agents:r,onAgent:a}){return n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsx(H$,{label:"Range",name:"mission-range",value:e,onChange:t,options:jg.map(l=>({value:l.id,label:l.label}))}),a&&r.length>0&&n.jsx(Lt,{label:"Agent",value:s??"",onChange:l=>a(l||null),className:"h-[38px] w-56",options:[{value:"",label:"All agents"},...r.map(l=>({value:l.agentId,label:l.name}))]})]})}const Vu=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function n1({a:e,basis:t,now:s=Date.now(),refreshing:r=!1}){const a=e.totals,l=D4(a),c=Jj(a),u=e1(a),f=[{label:"Tokens",value:oa(a.tokens),notes:[`${l===null?"":`${ud(l)} of input cached · `}${oa(a.output)} output`,Sg(a),a.unmetered?`${Vu(a.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:Wv(e.time.wall_ms),notes:[`wall time of ${Vu(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${Wv(e.time.active_ms)} active, over ${Vu(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:ud(c),notes:[a.completed+a.failed?z4(a):"No run completed or failed yet"]},{label:"Cost",value:u.total,notes:[u.note]}];return n.jsxs("div",{className:oe("space-y-6 transition-opacity",r&&"opacity-60"),"aria-busy":r,children:[n.jsx("ul",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:f.map(p=>n.jsxs("li",{className:"border p-4",children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:p.label}),n.jsx("p",{className:"mt-2 font-mono text-xl font-semibold",children:p.value}),p.notes.filter(Boolean).map(g=>n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:g},g))]},p.label))}),n.jsx(G4,{days:F4(e.by_day,e.filter.from,s)}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-2",children:[n.jsx(W4,{rows:e.by_harness_effort,basis:t}),n.jsx(H4,{tools:e.tools})]}),n.jsx(B4,{groups:e.by_source})]})}function dd({title:e,children:t}){return n.jsxs("section",{className:"border",children:[n.jsx("h3",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),t]})}const s1="px-4 py-2 text-left font-normal",nr="px-4 py-2.5 align-top";function W4({rows:e,basis:t}){return n.jsx(dd,{title:"Success by harness and effort",children:e.length?n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full border-collapse text-body",children:[n.jsx("thead",{children:n.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Harness","Effort","Runs","Success","Tokens","Cost"].map(s=>n.jsx("th",{className:s1,children:s},s))})}),n.jsx("tbody",{children:e.map(s=>{const r=e1(s),a=Sg(s);return n.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[n.jsx("td",{className:nr,children:s.harness}),n.jsx("td",{className:oe(nr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),n.jsx("td",{className:nr,children:s.runs}),n.jsx("td",{className:nr,children:ud(Jj(s))}),n.jsxs("td",{className:nr,children:[n.jsx("span",{className:"whitespace-nowrap",children:oa(s.tokens)}),a&&n.jsx("span",{className:"block text-label text-muted-foreground",children:a})]}),n.jsxs("td",{className:nr,children:[n.jsx("span",{className:"whitespace-nowrap",children:r.total}),r.note&&n.jsx("span",{className:"block text-label text-muted-foreground",children:r.note})]})]},`${s.harness}:${s.effort??""}`)})})]})}):n.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs in this range."})})}function H4({tools:e}){return n.jsx(dd,{title:"Top tools",children:e.length?n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full border-collapse text-body",children:[n.jsx("thead",{children:n.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Tool","Calls","Errors","Error rate"].map(t=>n.jsx("th",{className:s1,children:t},t))})}),n.jsx("tbody",{children:e.map(t=>n.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[n.jsx("td",{className:nr,title:t.tool,children:t.label}),n.jsx("td",{className:nr,children:oa(t.calls)}),n.jsx("td",{className:oe(nr,t.errors>0&&"text-destructive-text"),children:oa(t.errors)}),n.jsx("td",{className:nr,children:ud(t.calls?t.errors/t.calls:null)})]},t.tool))})]})}):n.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No tool calls in runs with metrics."})})}function B4({groups:e}){return e.some(t=>t.source!=="live"&&t.runs>0)?n.jsx("p",{className:"font-mono text-small text-muted-foreground","aria-label":"Runs by source",children:e.map(t=>`${t.source==="live"?"Run here":`Imported from ${t.source}`}: ${Vu(t.runs,"run")}`).join(" · ")}):null}const wp=e=>Math.max(0,e.runs-e.completed-e.failed);function Hv(e){if(e<=0)return 1;const t=10**Math.floor(Math.log10(e));return[1,2,5,10].map(s=>s*t).find(s=>s>=e)}const kp=e=>e.slice(5);function G4({days:e}){if(!e.some(l=>l.runs>0))return n.jsx(dd,{title:"Per day",children:n.jsxs("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:["No runs started in this range",e.length?" in the last 30 days":"","."]})});const s=Hv(Math.max(...e.map(l=>l.runs))),r=Hv(Math.max(...e.map(l=>l.tokens))),a=[{key:"completed",label:"Completed",className:"bg-muted-foreground",of:l=>l.completed},{key:"failed",label:"Failed",className:"bg-destructive",of:l=>l.failed},{key:"other",label:"Other",className:"bg-border-strong",of:wp}];return n.jsxs(dd,{title:`Per day, ${e[0].day} to ${e.at(-1).day} (UTC)`,children:[n.jsxs("div",{className:"grid grid-cols-1 gap-6 p-4 xl:grid-cols-2",children:[n.jsxs("figure",{children:[n.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-small",children:[n.jsx("span",{className:"font-semibold",children:"Runs"}),a.map(l=>n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx("span",{className:oe("inline-block size-2.5",l.className),"aria-hidden":!0}),l.label]},l.key))]}),n.jsx(Bv,{days:e,top:s,label:"Runs per day",stack:l=>a.map(c=>({className:c.className,value:c.of(l)})),readout:l=>[`${l.runs} ${l.runs===1?"run":"runs"}`,`${l.completed} completed · ${l.failed} failed · ${wp(l)} other`]})]}),n.jsxs("figure",{children:[n.jsx("figcaption",{className:"mb-2 text-small font-semibold",children:"Tokens"}),n.jsx(Bv,{days:e,top:r,label:"Tokens per day",format:oa,stack:l=>[{className:"bg-primary",value:l.tokens}],readout:l=>[`${oa(l.tokens)} tokens`,Sg(l)??`${l.runs} ${l.runs===1?"run":"runs"}`]})]})]}),n.jsxs("details",{className:"border-t px-4 py-2",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Day","Runs","Completed","Failed","Other","Tokens"].map(l=>n.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:l},l))})}),n.jsx("tbody",{children:e.map(l=>n.jsxs("tr",{children:[n.jsx("td",{className:"py-0.5 pr-4",children:l.day}),n.jsx("td",{className:"pr-4",children:l.runs}),n.jsx("td",{className:"pr-4",children:l.completed}),n.jsx("td",{className:"pr-4",children:l.failed}),n.jsx("td",{className:"pr-4",children:wp(l)}),n.jsx("td",{className:"pr-4",children:l.tokens.toLocaleString("en-US")})]},l.day))})]})})]})]})}function Bv({days:e,top:t,label:s,stack:r,readout:a,format:l=c=>c.toLocaleString("en-US")}){return n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("div",{className:"flex w-10 shrink-0 flex-col justify-between text-right font-mono text-micro text-muted-foreground",style:{height:140},"aria-hidden":!0,children:[n.jsx("span",{children:l(t)}),n.jsx("span",{children:l(t/2)}),n.jsx("span",{children:"0"})]}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":s,children:[n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-border","aria-hidden":!0}),n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-border","aria-hidden":!0}),e.map(u=>{const f=r(u).filter(p=>p.value>0);return n.jsxs("div",{role:"listitem",tabIndex:0,"aria-label":`${u.day}: ${a(u).join(", ")}`,className:"group relative flex h-full min-w-0 flex-1 flex-col items-center justify-end outline-none hover:bg-accent/60 focus-visible:bg-accent/60",children:[n.jsx("div",{className:"flex w-full max-w-[24px] flex-col-reverse gap-[2px]",children:f.map((p,g)=>n.jsx("div",{className:oe(p.className,g===f.length-1&&""),style:{height:Math.max(1,Math.round(p.value/t*(140-2*(f.length-1))))}},g))}),n.jsxs("div",{className:"pointer-events-none absolute bottom-full left-1/2 z-raised mb-1 hidden -translate-x-1/2 whitespace-nowrap border bg-card px-2 py-1 text-left font-mono text-label shadow-float group-hover:block group-focus-visible:block",children:[n.jsx("span",{className:"block font-semibold",children:a(u)[0]}),a(u).slice(1).map(p=>n.jsx("span",{className:"block text-muted-foreground",children:p},p)),n.jsx("span",{className:"block text-muted-foreground",children:u.day})]})]},u.day)})]}),n.jsxs("div",{className:"mt-1 flex justify-between font-mono text-micro text-muted-foreground","aria-hidden":!0,children:[n.jsx("span",{children:kp(e[0].day)}),e.length>2&&n.jsx("span",{children:kp(e[Math.floor(e.length/2)].day)}),n.jsx("span",{children:kp(e.at(-1).day)})]})]})]})}function q4(e,t){if(t.unchanged&&!t.reset&&!t.drop.length&&!t.rows.length)return e;const s=new Map;if(!t.reset)for(const r of e)s.set(r.id,r);for(const r of t.drop)s.delete(r);for(const r of t.rows)s.set(r.id,r);return[...s.values()].sort((r,a)=>r.seq-a.seq)}const r1=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,o1=e=>e.refused===!0,a1=e=>e.tool_status==="failed"&&!o1(e)||e.kind==="error",V4=e=>e.paused===!0;function K4(e){const t=new Map(e.filter(p=>p.kind==="tool_result"&&p.tool_use_id).map(p=>[p.tool_use_id,p])),s=new Set(e.filter(p=>p.kind==="tool_use"&&p.tool_use_id).map(p=>p.tool_use_id)),r=new Set(e.filter(p=>p.kind==="waiting"&&p.id.endsWith(":waiting")).map(p=>p.id.slice(0,-8))),a=p=>{var g;return r.has(p.id)||(p.tool_use_id?r.has(((g=t.get(p.tool_use_id))==null?void 0:g.id)??""):!1)},l=e.findLast(p=>p.kind==="usage"),c=[],u=new Map;let f;for(const p of e){if(p.kind==="usage")continue;if(p.tool_name==="ask_person"&&(p.kind==="tool_use"||p.kind==="tool_result")&&a(p)){f=void 0;continue}if(p.kind==="tool_result"&&p.tool_use_id&&s.has(p.tool_use_id)){f=u.get(p.tool_use_id);continue}if(p.kind==="phase"&&p.path&&f&&(f.row.kind==="tool_result"||f.row.kind==="tool_use")&&!f.saved){f.saved=p.path;continue}const g=c.at(-1);if(p.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===p.summary&&g.row.text===p.text&&(g.row.agent_label??null)===(p.agent_label??null)){g.times=(g.times??1)+1,g.until=p.timestamp,f=g;continue}let v;const h=p.kind==="tool_use"&&p.tool_use_id?t.get(p.tool_use_id):void 0;if(h){const m=h.tool_status!=="failed",b=[p.tool_input_preview,h.tool_result_preview].filter(Boolean),w=h.tool_status!==null;v={row:{...h,id:p.id,seq:p.seq,timestamp:p.timestamp,summary:m?(h.summary??"").replace(/:\s*ok$/i,""):h.summary,...p.usage?{usage:p.usage}:{}},...w?{ms:Math.max(0,Date.parse(h.timestamp)-Date.parse(p.timestamp))}:{},detail:b.length===2?`${b[0]}
516
+
517
+ → ${b[1]}`:b[0]??null}}else v={row:p};c.push(v),p.kind==="tool_use"&&p.tool_use_id&&u.set(p.tool_use_id,v),f=v}return l&&c.push({row:l}),c}class Ee extends Error{constructor(s,r,a,l=!1,c){super(a);it(this,"fields");it(this,"retryAfterMs");it(this,"details");it(this,"problems");this.status=s,this.code=r,this.retryable=l,this.requestId=c,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const Jt=e=>e instanceof Ee?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),Gv=(e,t,{status:s,archived:r}={})=>{const a=new URLSearchParams({limit:String(e)});return t&&a.set("cursor",t),s&&a.set("status",s),r&&a.set("archived","true"),`?${a}`},X4=new Set(["/auth/sign-in","/setup"]);function Y4({fetch:e=globalThis.fetch.bind(globalThis),base:t="/v2",onSignedOut:s}={}){async function r(m,b,w={}){return(await a(m,b,w)).body}async function a(m,b,{body:w,headers:j={},signal:N,text:R=!1}={}){var C;const $=w!==void 0||m!=="GET"&&m!=="HEAD",S=await e(`${t}${b}`,{method:m,signal:N,credentials:"same-origin",headers:{accept:"application/json",...$?{"content-type":"application/json"}:{},...j},body:w===void 0?void 0:JSON.stringify(w)});if(!S.ok){S.status===401&&!X4.has(b)&&(s==null||s());const T=(C=await S.json().catch(()=>null))==null?void 0:C.error,A=new Ee(S.status,(T==null?void 0:T.code)??"http_error",(T==null?void 0:T.message)??`${m} ${b}: ${S.status}`,(T==null?void 0:T.retryable)??!1,T==null?void 0:T.request_id);throw T!=null&&T.fields&&(A.fields=T.fields),typeof(T==null?void 0:T.retry_after_ms)=="number"&&(A.retryAfterMs=T.retry_after_ms),T!=null&&T.details&&typeof T.details=="object"&&!Array.isArray(T.details)&&(A.details=T.details),Array.isArray(T==null?void 0:T.problems)&&(A.problems=T.problems),A}return{body:!R&&(S.headers.get("content-type")??"").includes("json")?await S.json():await S.text(),etag:S.headers.get("etag"),status:S.status}}const l=m=>`/agents/${encodeURIComponent(m)}`,c=m=>`/runs/${encodeURIComponent(m)}`,u=m=>`/settings/mcp-servers/${encodeURIComponent(m)}`,f=m=>`/triggers/${encodeURIComponent(m)}`,p=new Map,g=(m,b)=>`${l(m)}/learning/files/${encodeURIComponent(b)}`,v=m=>({note:m.body,etag:m.etag}),h={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>a("GET","/auth/session").then(m=>({status:m.status,body:m.body})),signIn:m=>r("POST","/auth/sign-in",{body:{password:m}}),setup:(m,b,w=!1)=>r("POST","/setup",{body:{password:m,...b?{code:b}:{},...w?{import:!0}:{}}}),setupImport:()=>r("GET","/setup/import").then(m=>(m==null?void 0:m.offer)===!1?null:m,m=>{if(m instanceof Ee&&(m.status===404||m.status===403))return null;throw m}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(m=50,b,w)=>r("GET",`/runs${Gv(m,b,w)}`),listAgentRuns:(m,b=50,w,j={})=>r("GET",`${l(m)}/runs${Gv(b,w,typeof j=="boolean"?{archived:j}:j)}`),listAgents:({archived:m=!1,cursor:b}={})=>{const w=new URLSearchParams;return m&&w.set("archived","true"),b&&w.set("cursor",b),r("GET",`/agents${w.size?`?${w}`:""}`)},getAgent:async m=>{const b=await a("GET",l(m)),w=p.get(m);return{agent:w&&w.revision===b.body.revision&&!b.body.warnings?{...b.body,warnings:w.warnings}:b.body,etag:b.etag}},createAgent:async m=>{var w;const b=await r("POST","/agents",{body:m});return(w=b.warnings)!=null&&w.length&&p.set(b.agent_id,{revision:b.revision,warnings:b.warnings}),b},updateDefinition:async(m,b,w)=>{const j=await a("PUT",`${l(m)}/definition`,{body:b,headers:w?{"if-match":w}:{}});return p.delete(m),{agent:j.body,etag:j.etag}},listRevisions:(m,b)=>r("GET",`${l(m)}/revisions${b?`?cursor=${encodeURIComponent(b)}`:""}`),setCurrent:async(m,b)=>{const w=await r("POST",`${l(m)}/current`,{body:{revision:b}});return p.delete(m),w},archiveAgent:m=>r("POST",`${l(m)}/archive`,{body:{}}),unarchiveAgent:m=>r("POST",`${l(m)}/unarchive`,{body:{}}),agentLearning:m=>r("GET",`${l(m)}/learning`),learningCost:(m,b)=>r("GET",`${l(m)}/learning/cost${b?`?limit=${b}`:""}`),learningBatches:m=>r("GET",`${l(m)}/learning/batches`),learningBatch:(m,b)=>r("GET",`${l(m)}/learning/batches/${encodeURIComponent(b)}`),startLearningBatch:(m,b)=>r("POST",`${l(m)}/learning/batches`,{body:b}),cancelLearningBatch:(m,b)=>r("POST",`${l(m)}/learning/batches/${encodeURIComponent(b)}/cancel`,{body:{}}),learningEvals:m=>r("GET",`${l(m)}/learning/evals`),learnedWorkflowRevisions:(m,b,w)=>r("GET",`${l(m)}/learning/workflows/${encodeURIComponent(b)}/revisions${w?`?limit=${w}`:""}`),learningNotes:(m,b)=>r("GET",`${l(m)}/learning/notes?cursor=${encodeURIComponent(b)}`),learningLog:(m,b)=>r("GET",`${l(m)}/learning/log?cursor=${encodeURIComponent(b)}`),readNote:async(m,b)=>v(await a("GET",g(m,b),{headers:h,text:!0})),writeNote:async(m,b,w,j)=>v(await a("PUT",g(m,b),{body:{text:w},headers:{...h,..."etag"in j?{"if-match":j.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(m,b,w)=>v(await a("POST",`${g(m,b)}/retire`,{body:{},headers:{...h,"if-match":w},text:!0})),approveNote:async(m,b,w)=>v(await a("POST",`${g(m,b)}/approve`,{body:{},headers:{...h,"if-match":w},text:!0})),restoreNote:async(m,b,w)=>v(await a("POST",`${g(m,b)}/restore`,{body:{},headers:{...h,"if-match":w},text:!0})),forgetSignIn:(m,b)=>r("DELETE",`${l(m)}/sign-ins/${encodeURIComponent(b)}`),promoteWorkflow:async(m,b,w)=>{var N;const j=await r("POST",`${l(m)}/learning/workflows/${encodeURIComponent(b)}/promote`,{body:{},headers:{"idempotency-key":w}});return(N=j.warnings)!=null&&N.length&&p.set(j.agent_id,{revision:j.revision,warnings:j.warnings}),j},getRun:m=>r("GET",c(m)),runLearningDiff:m=>r("GET",`${c(m)}/learning/diff`),runLearning:m=>r("GET",`${c(m)}/learning`),runComputer:m=>r("GET",`${c(m)}/computer`),takeOverComputer:m=>r("POST",`${c(m)}/computer/take-over`,{body:{}}),handBackComputer:(m,b)=>r("POST",`${c(m)}/computer/hand-back`,{body:b?{outcome:b}:{}}),archiveRun:m=>r("POST",`${c(m)}/archive`,{body:{}}),unarchiveRun:m=>r("POST",`${c(m)}/unarchive`,{body:{}}),raiseCap:(m,b)=>r("PATCH",c(m),{body:{max_cost_usd:b}}),startRun:async(m,b,w)=>{const j=await a("POST",`${l(m)}/runs`,{body:b,headers:{"idempotency-key":w}});return{run:j.body,status:j.status}},getTimeline:(m,{after:b,waitMs:w,signal:j}={})=>{const N=new URLSearchParams;return b!==void 0&&N.set("after",String(b)),w!==void 0&&N.set("wait_ms",String(w)),r("GET",`${c(m)}/timeline${N.size?`?${N}`:""}`,{signal:j})},listFiles:m=>r("GET",`${c(m)}/files`),deleteUpload:m=>r("DELETE",`/files/${encodeURIComponent(m)}`),readFile:(m,b)=>r("GET",`${c(m)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(m,b,w)=>r("POST",`${c(m)}/messages`,{body:{content:b},headers:{"idempotency-key":w}}),getRunGraph:(m,b)=>r("GET",`${c(m)}/graph`,{signal:b}),pauseRun:m=>r("POST",`${c(m)}/pause`,{body:{}}),resumeRun:m=>r("POST",`${c(m)}/resume`,{body:{}}),validateWorkflow:(m,b)=>r("POST","/workflows/validate",{body:m,signal:b}),statsOver:({from:m,agent:b})=>{const w=new URLSearchParams;return m&&w.set("from",m),b&&w.set("agent",b),r("GET",`/stats${w.size?`?${w}`:""}`)},fileUrl:(m,b)=>`${t}${c(m)}/files/${b.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(m,b)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(m)}`,{body:{values:b}}),removeToolKey:m=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(m)}`),computers:()=>r("GET","/computers"),saveComputerKeys:(m,b)=>r("PUT",`/computers/${encodeURIComponent(m)}/keys`,{body:b}),testComputer:m=>r("POST",`/computers/${encodeURIComponent(m)}/test`),computerChoices:m=>r("GET",`/computers/${encodeURIComponent(m)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:m=>r("DELETE",`/computers/${encodeURIComponent(m)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:m=>r("PUT","/workspace/archil",{body:m}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:m=>r("PUT","/settings/webhook",{body:{url:m}}),removeWebhook:()=>r("DELETE","/settings/webhook"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),listTriggers:()=>r("GET","/triggers"),getTrigger:m=>r("GET",f(m)),createTrigger:(m,b)=>r("POST","/triggers",{body:m,headers:{"idempotency-key":b}}),rotateTriggerSecret:(m,b={})=>r("POST",`${f(m)}/secret`,{body:b}),updateTrigger:(m,b)=>r("PATCH",f(m),{body:b}),deleteTrigger:m=>r("DELETE",f(m)),fireTrigger:(m,b)=>r("POST",`${f(m)}/fire`,{body:{},headers:{"idempotency-key":b}}),triggerFirings:m=>r("GET",`${f(m)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:m=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(m)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(m,b,w)=>r("POST",`/templates/${encodeURIComponent(m)}/apply`,{body:b,headers:{"idempotency-key":w}}),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(m,b,w)=>r("POST","/settings/mcp-servers/preview",{body:{url:m,auth:b,...w?{name:w}:{}}}),saveMcpServer:(m,b,w)=>r("PUT",u(m),{body:{url:b,auth:w}}),composioTools:(m,b)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:m,toolkit:b}}),saveComposioServer:(m,b,w,j)=>r("PUT",`${u(m)}/composio`,{body:{api_key:b,toolkit:w,tools:j}}),refreshMcpServer:m=>r("POST",`${u(m)}/refresh`,{body:{}}),deleteMcpServer:m=>r("DELETE",u(m)),startMcpSignIn:(m,b)=>r("POST",`${u(m)}/oauth/start`,{body:b}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:m=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:m}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:m=>r("POST","/integrations/github/connect",{body:m?{org:m}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:m=>r("PUT","/settings/tools",{body:m}),stop:m=>r("POST",`${c(m)}/stop`,{body:{}}),answerApproval:(m,b,w,j)=>r("POST",`${c(m)}/approvals/${encodeURIComponent(b)}`,{body:{decision:w,...j?{note:j}:{}}}),cancel:m=>r("POST",`${c(m)}/cancel`,{body:{}})}}async function ao(e,t,s=100){const r=[];let a=null;for(let l=0;l<s;l++){const c=await e(a);if(r.push(...t(c)),!c.next_cursor)break;a=c.next_cursor}return r}async function _g(e,t,{onRows:s,onPage:r,signal:a,waitMs:l=25e3,minDelayMs:c=250}){let u=[],f,p;for(;!(a!=null&&a.aborted);){const g=await e.getTimeline(t,f===void 0?{signal:a}:{after:f,waitMs:l,signal:a}).catch(h=>{if(a!=null&&a.aborted)return null;throw h});if(!g||a!=null&&a.aborted||(p=g,s&&(u=q4(u,g)),r==null||r(g),s==null||s(u),g.final&&!g.has_more))break;f=g.next_after;const v=Math.max(c,g.unchanged?g.poll_after_ms??0:0);v&&await new Promise(h=>setTimeout(h,v))}return p}const Ft=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ku=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function Q4(e){const t=new Map;let s=0;const r=u=>{throw Object.assign(new Error(u),{offset:s})},a=()=>{for(;s<e.length&&`
518
+ \r`.includes(e[s]);)s++},l=()=>{const u=s;for(s++;s<e.length&&e[s]!=='"';)e[s]==="\\"?s++:e.charCodeAt(s)<32&&r("a string cannot hold a raw line break or control character"),s++;s>=e.length&&(s=u,r("this string is not closed")),s++;try{return JSON.parse(e.slice(u,s))}catch{return s=u,r("this string has a bad escape")}},c=u=>{a();const f=s;let p;const g=e[s];if(g==="{"){s++;const v={};if(a(),e[s]==="}")s++;else for(;;){a(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const h=l();if(a(),e[s]!==":"&&r("expected : after the key"),s++,v[h]=c(`${u}/${Ku(h)}`),a(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}p=v}else if(g==="["){s++;const v=[];if(a(),e[s]==="]")s++;else for(;;){if(v.push(c(`${u}/${v.length}`)),a(),e[s]===","){s++,a(),e[s]==="]"&&r("a trailing comma before ]");continue}if(e[s]==="]"){s++;break}r("expected , or ] after the value")}p=v}else if(g==='"')p=l();else{const v=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));v||r(s>=e.length?"the text ends before the value":"expected a value"),s+=v[0].length,p=JSON.parse(v[0])}return t.set(u,{start:f,end:s}),p};try{const u=c("");return a(),s<e.length&&r("text after the end of the JSON"),{ok:!0,value:u,spans:t}}catch(u){return{ok:!1,error:{message:u.message,offset:u.offset??0}}}}function Z4(e,t){let s=1,r=-1;for(let a=0;a<Math.min(t,e.length);a++)e[a]===`
519
+ `&&(s++,r=a);return{line:s,col:t-r}}function i1(e,t){let s=e;for(const r of t.split("/").slice(1)){const a=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(a)];else if(Ft(s))s=Object.prototype.hasOwnProperty.call(s,a)?s[a]:void 0;else return}return s}const l1=new Set(["judge","pick","sift","route"]),qv=["jev","parallel","openrouter"];function J4(e){return!Ft(e)||!Ft(e.properties)?[]:Object.entries(e.properties).flatMap(([t,s])=>{if(!Ft(s))return[];const r=typeof s.description=="string"?s.description:t;return Array.isArray(s.enum)?[{id:t,type:"choice",text:r,options:s.enum.map(String)}]:s.type==="boolean"?[{id:t,type:"noul",text:r}]:s.type==="integer"?[{id:t,type:"score",text:r}]:[{id:t,type:"choice",text:r}]})}function $g(e,t,s){const r=i1(e,t);if(!Ft(r))return{decision:!1};const a=r.node,l=s??{},c=a==="route"&&typeof r.valuePath=="string",u=typeof a=="string"&&l1.has(a)&&!c||Array.isArray(l.questions);if(!u)return{decision:!1,...a==="call"&&typeof r.tool=="string"?{tool:r.tool}:{}};const f=typeof l.provider=="string"?l.provider:typeof r.provider=="string"?r.provider:"jev",p=typeof l.model=="string"?l.model:typeof r.model=="string"?r.model:void 0,g=Ft(e)&&Ft(e.schemas)?e.schemas:{};let v=[];Array.isArray(l.questions)?v=l.questions.map(b=>({id:b.id,type:b.type==="choice"||b.type==="score"?b.type:"noul",text:b.instructions||b.id,...b.options?{options:b.options}:{}})):a==="judge"||a==="sift"?v=typeof r.out=="string"?J4(g[r.out]):[]:a==="pick"?v=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:a==="route"&&(v=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:Ft(r.branches)?Object.keys(r.branches):[]}]);const h=Array.isArray(l.images)?l.images.map(String):Ft(r.images)?Object.keys(r.images):[],m=Ft(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:u,provider:f,model:p,questions:v,...h.length?{images:h}:{},web:f==="parallel",...m?{unsure:m}:{}}}const eA=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function tA(e){const t=[],s=(u,f)=>t.push({path:u,message:f,severity:"error"}),r=(u,f)=>t.push({path:u,message:f,severity:"warning"});if(!Ft(e))return s("","the workflow is a JSON object"),t;e.v!==2&&s("/v",'the workflow format is "v": 2'),(typeof e.name!="string"||!e.name)&&s("/name","the workflow needs a name");const a=Ft(e.schemas)?e.schemas:{};Ft(e.input)&&typeof e.input.schemaId=="string"&&!a[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),Ft(e.output)?typeof e.output.schemaId=="string"&&!a[e.output.schemaId]&&s("/output/schemaId",`no schema "${e.output.schemaId}" in schemas`):s("",'the workflow needs an output: { "schemaId": ..., "path": ... }');const l=new Map,c=(u,f)=>{if(!Ft(u)){s(f,'expected a node (an object with a "node" kind)');return}const p=u.node;if(typeof p!="string"||!eA.has(p)){s(`${f}/node`,typeof p=="string"?`"${p}" is not a node kind`:'a node names its kind in "node"');return}p!=="chain"&&(typeof u.label!="string"||!u.label?s(f,`a ${p} node needs a label`):l.has(u.label)?r(`${f}/label`,`the label "${u.label}" is also used at ${l.get(u.label)}; receipts name nodes by label`):l.set(u.label,f));const g=(h,m)=>{u[h]===void 0&&s(f,`a ${p} node needs ${h} (${m})`)},v=h=>{typeof u[h]=="string"&&!a[u[h]]&&s(`${f}/${h}`,`no schema "${u[h]}" in schemas`)};switch(p){case"chain":!Array.isArray(u.steps)||!u.steps.length?s(f,"a chain needs steps"):u.steps.forEach((h,m)=>c(h,`${f}/steps/${m}`));break;case"parallel":!Array.isArray(u.branches)||!u.branches.length?s(f,"a parallel node needs branches"):u.branches.forEach((h,m)=>c(h,`${f}/branches/${m}`));break;case"map":g("itemsPath","where the items are"),g("as","where the results go"),c(u.body,`${f}/body`);break;case"loop":g("until","when it stops"),g("maxIters","a bound"),c(u.body,`${f}/body`);break;case"workflow":Ft(u.workflow)?c(u.workflow.root,`${f}/workflow/root`):s(f,"a workflow node embeds its workflow");break;case"call":g("via","tool, executor or shell"),u.via==="tool"&&g("tool","the tool's name");break;case"code":typeof u.code!="string"&&s(f,"a code node needs code");break;case"escalate":g("when","the predicate that fires it"),g("kind","the review it asks for");break;case"judge":case"sift":g("out","the questions' schema"),v("out"),g("as","where the answers go");break;case"pick":g("itemsPath","the options' list"),g("as","where the pick goes");break;case"agent":case"decide":case"extract":v("out");break}if(p==="route"){if(!Ft(u.branches)||!Object.keys(u.branches).length)s(f,"a route needs branches");else for(const[h,m]of Object.entries(u.branches))Ft(m)?c(m.body,`${f}/branches/${Ku(h)}/body`):s(`${f}/branches/${Ku(h)}`,`branch "${h}" is an object with a body`);typeof u.valuePath!="string"&&u.instructions===void 0&&s(f,"a route asks by instructions (and state), or reads a valuePath"),Ft(u.unsure)&&Ft(u.branches)&&typeof u.unsure.branch=="string"&&!(u.unsure.branch in u.branches)&&s(`${f}/unsure/branch`,`the unsure branch "${u.unsure.branch}" is not one of the branches`)}if(l1.has(p)&&!(p==="route"&&typeof u.valuePath=="string")&&(u.provider!==void 0&&!qv.includes(u.provider)&&r(`${f}/provider`,`provider "${String(u.provider)}" is not one of ${qv.join(", ")}`),u.provider==="openrouter"&&typeof u.model!="string"&&s(f,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),Ft(u.images))){const h=JSON.stringify(u.state??{})+JSON.stringify(u.instructions??"")+(typeof u.out=="string"?JSON.stringify(a[u.out]??{}):"");for(const m of Object.keys(u.images))h.includes(m)||s(`${f}/images/${Ku(m)}`,`the image token "${m}" must appear in the state or a question, or the model never sees it`)}};return e.root===void 0?s("","the workflow needs a root node"):c(e.root,"/root"),t}function Vv(e,t){for(let s=t;;s=s.slice(0,s.lastIndexOf("/"))){const r=e.get(s);if(r)return r;if(!s)return}}function nA(e,t,s){let r=null,a=1/0;for(const l of t){const c=e.get(l);c&&c.start<=s&&s<=c.end&&c.end-c.start<a&&(r=l,a=c.end-c.start)}return r}function sA(e){const t=oi(e),r=t.nodes.map(l=>$g(e,l.path,l)).filter(l=>l.decision),a=[...new Set(r.map(l=>l.provider??"jev"))];return`${t.nodes.length} nodes · ${r.length} ${r.length===1?"decision":"decisions"}${a.length?` · ${a.join(", ")}`:""}`}const fd=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,Kv=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),sc=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function rc(e,t){return Object.fromEntries(t.nodes.map(s=>[s.path,$g(e,s.path,s)]))}const Cu=e=>e>=.995?"1.00":e.toFixed(2);function di(e){var u;if(e.status==="failed")return"failed";if(e.status==="cancelled")return"interrupted";const t=e.answers??{},s=e.action;if(((u=e.rule)==null?void 0:u.kind)==="route"&&s&&typeof s=="object"&&(s.taken||s.branch)){const f=t.branch,p=f&&f.type==="choice"?f.confidence:void 0;return s.unsure?`${s.taken} (unsure)`:`${s.taken??s.branch}${p!==void 0?` ${Cu(p)}`:""}`}const r=Object.keys(t);if(!r.length)return;const a=f=>{const p=t[f];return p.type==="choice"?`${c1(e,f,p.choice)} ${Cu(p.probabilities[p.choice]??p.confidence)}`:p.type==="noul"?`${p.noul>=.5?"yes":"no"} ${Cu(p.noul>=.5?p.noul:1-p.noul)}`:p.type==="score"?`${p.score} ${Cu(p.confidence)}`:p.type==="refusal"?"refused":"box"};if(r.length===1)return a(r[0]);const l=f=>{const p=t[f];return p.type==="noul"?Math.abs(p.noul-.5)*2:"confidence"in p&&typeof p.confidence=="number"?p.confidence:1},c=r.reduce((f,p)=>l(p)<l(f)?p:f,r[0]);return`${c} ${a(c)}`}function c1(e,t,s){var l,c;const r=(l=e.questions)==null?void 0:l[t],a=e.kind==="pick"&&(r==null?void 0:r.type)==="choice"?(c=r.criteria)==null?void 0:c[s]:null;return typeof a=="string"&&a?a:s}const u1=(e,t)=>e.nodes.filter(s=>s.path.startsWith(`${t}/body`)).map(s=>s.path);function rA(e,t,s){var v,h;const r=(h=(v=e.nodes[t])==null?void 0:v.items)==null?void 0:h.find(m=>m.index===s),a={};if(!r)return a;const l=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(m=>[m.path,m.kind])),u=u1(e.graph,t).filter(m=>!l.has(c.get(m)??""));let f=-1;u.forEach((m,b)=>{const w=e.decisions.filter(N=>N.node===m&&N.item===s),j=e.effects.filter(N=>N.node===m&&N.item===s);!w.length&&!j.length||(f=b,w.some(N=>N.status==="failed")||j.some(N=>N.status==="failed")?a[m]="failed":w.some(N=>N.status==="cancelled")?a[m]="review":j.some(N=>!N.endedAt)?a[m]=j.some(N=>N.status==="stopped")?"stopped":"working":a[m]="done")});const p=fd(r.status)??"pending";let g=!Object.values(a).includes("working");return u.forEach((m,b)=>{a[m]||(b<f||p==="done"?a[m]="done":p==="working"?(a[m]=g?"working":"pending",g=!1):p==="pending"?a[m]="pending":a[m]="not-run")}),a}function oA(e,t){var g,v,h;const s={},r=[],a={};let l=null;const c=new Map(e.graph.nodes.map(m=>[m.path,m.kind]));for(const[m,b]of Object.entries(e.nodes)){const w=fd(b.status);w&&(s[m]=w),b.branch&&r.push(`${m}/branches/${Kv(b.branch)}/body`),b.items&&(a[m]=b.items.map(j=>({index:j.index,status:fd(j.status)??"pending",label:Ul(e,m,j.index),...Eg(e,m,j)}))),b.status==="escalated"&&c.get(m)==="escalate"&&(l=m)}const u={},f=m=>/\/body(\/|$)/.test(m)&&e.graph.nodes.some(b=>b.kind==="map"&&m.startsWith(`${b.path}/body`));for(const m of e.decisions){if(!m.node||m.item!==null||f(m.node))continue;const b=di(m);b&&(u[m.node]=b)}if(t&&t.item!=null&&c.get(t.path)==="map"){Object.assign(s,rA(e,t.path,t.item));const m=((h=(v=(g=e.nodes[t.path])==null?void 0:g.items)==null?void 0:v.find(b=>b.index===t.item))==null?void 0:h.branches)??{};for(const[b,w]of Object.entries(m)){const j=`${b}/branches/`,N=`${j}${Kv(w)}/body`;for(let R=r.length-1;R>=0;R--)r[R].startsWith(j)&&r.splice(R,1);r.push(N);for(const R of e.graph.nodes)R.path.startsWith(j)&&!(R.path===N||R.path.startsWith(`${N}/`))&&(s[R.path]="not-run")}for(const b of e.decisions)if(b.node&&b.item===t.item&&b.node.startsWith(`${t.path}/body`)){const w=di(b);w&&(u[b.node]=w)}}if(e.run.paused){for(const[m,b]of Object.entries(s))b==="working"&&(s[m]="held");for(const m of Object.values(a))for(const b of m)b.status==="working"&&(b.status="held")}const p={};for(const[m,b]of Object.entries(e.nodes))b.model&&(p[m]={model:b.model,...b.tier?{tier:b.tier}:{}});return{status:s,taken:r,items:a,fired:l,verdict:u,meta:rc(e.workflow,e.graph),selected:t,...Object.keys(p).length?{ran:p}:{}}}const jp={accept:"good",accepted:"good",approve:"good",approved:"good",valid:"good",pass:"good",auto:"good",agree:"good",ok:"good",clear:"good",low:"good",review:"warn",hold:"warn",doubtful:"warn",borderline:"warn",unsure:"warn",human:"warn",escalate:"warn",edd:"warn",medium:"warn",second_look:"warn",disagree:"warn",reject:"bad",rejected:"bad",decline:"bad",declined:"bad",invalid:"bad",fail:"bad",deny:"bad",high:"bad",block:"bad"},aA=e=>{if(!e)return;const t=e.toLowerCase();return jp[t]??jp[t.split(/[_\s-]/)[0]]??jp[t.split(/[_\s-]/).at(-1)??""]};function iA(e){if(e.status!=="answered"||!e.answers)return;const t=e.action,s=e.answers.branch;if(t&&typeof t=="object"&&t.taken&&(s==null?void 0:s.type)==="choice")return{p:s.confidence,note:`${e.kind} confidence`};let r;for(const[a,l]of Object.entries(e.answers)){const c=l.type==="noul"?{p:Math.max(l.noul,1-l.noul),note:`${a}: ${l.noul>=.5?"yes":"no"}, P(yes) ${l.noul.toFixed(2)}`,sure:Math.abs(l.noul-.5)}:l.type==="choice"||l.type==="score"?{p:l.confidence,note:`${a} confidence`,sure:l.confidence-.5}:void 0;c&&(!r||c.sure<r.sure)&&(r=c)}return r&&{p:r.p,note:`least sure: ${r.note}`}}function Eg(e,t,s){const r=u1(e.graph,t),a=h=>h?r.indexOf(h):-1,l=e.decisions.filter(h=>{var m;return h.item===s.index&&!!((m=h.node)!=null&&m.startsWith(`${t}/body`))}).sort((h,m)=>a(h.node)-a(m.node));let c,u;const f=Object.entries(s.branches??{}).sort(([h],[m])=>a(h)-a(m));if(f.length)[u,c]=f[f.length-1];else{const h=l.filter(m=>{var b;return m.status==="answered"&&((b=m.action)==null?void 0:b.taken)}).at(-1);h&&(c=h.action.taken,u=h.node??void 0)}const p=u&&l.filter(h=>h.node===u).at(-1)||l.filter(h=>h.status==="answered").at(-1),g=p?iA(p):void 0,v=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":aA(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...v?{tone:v}:{}}}function Ul(e,t,s){var u,f;const r=(f=(u=e.nodes[t])==null?void 0:u.items)==null?void 0:f.find(p=>p.index===s);if(r!=null&&r.label)return r.label;const a=e.effects.find(p=>{var g;return p.item===s&&!!((g=p.node)!=null&&g.startsWith(`${t}/body`))}),l=a==null?void 0:a.input,c=(l==null?void 0:l.path)??(l==null?void 0:l.url);return typeof c=="string"?c:void 0}function d1(e=[]){const t={total:e.length,done:0,working:0,failed:0,review:0,pending:0};for(const s of e)s.status==="done"?t.done++:s.status==="working"?t.working++:s.status==="failed"?t.failed++:s.status==="needs_review"||s.status==="escalated"?t.review++:t.pending++;return t}function f1(e){const t=e.decisions.filter(s=>s.cost_usd===null).length;return{usd:e.totals.cost_usd??e.decisions.reduce((s,r)=>s+(r.cost_usd??0),0),unknown:e.totals.cost_usd===null?t:0}}const _i=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Ja=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function fi(e){const t=Math.max(0,Math.floor(e/1e3)),s=Math.floor(t/60);return s?`${s}m ${String(t%60).padStart(2,"0")}s`:`${t}s`}const lA=(e,t,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||t)-Date.parse(e.run.startedAt);return sc(e.run.status)||e.run.paused?r:r+Math.max(0,s-t)};function cA(e,t,s){return e!=="input_required"||t!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function uA(e){const t=e.content_type??"";return t.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":t.startsWith("text/")||t.includes("json")?"text":"download"}function m1(e){return e.split("/").slice(0,-1).some(t=>t.startsWith(".")||t==="__pycache__"||t==="node_modules")}const p1="The agent finished without writing an answer.",lh=[0,250,1e3],h1=e=>new Promise(t=>setTimeout(t,e));function md(){let e=0;return{begin:()=>++e,current:t=>t===e,cancel:()=>{e++}}}const g1="30d",Xv=10,dA=["queued","working","input_required","paused"];function fA({agent:e,v2:t,now:s=Date.now,stats:r}){const[a,l]=x.useState(g1),[c,u]=x.useState(r??null),[f,p]=x.useState(null),[g,v]=x.useState(!0),[h,m]=x.useState(0),b=x.useRef(0),w=x.useRef(!0);x.useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]);const j=x.useRef(null),N=x.useRef(null);x.useEffect(()=>{const $=`${a}/${h}`;if(N.current===$)return;const S=++b.current;if(j.current===$){N.current=null,p(null),v(!1);return}N.current=$,v(!0),p(null),(async()=>{for(const[E,C]of lh.entries()){if(C&&await h1(C),S!==b.current||!w.current)return;try{const T=await t.statsOver({from:Ng(a,s()),agent:e.agent_id});if(S!==b.current||!w.current)return;const A=!(T.runs.status_unknown>0);if(u(T),j.current=A||E===lh.length-1?$:null,A)break}catch(T){S===b.current&&p(Jt(T));break}}S===b.current&&(N.current=null,v(!1))})()},[t,e.agent_id,a,h]),x.useEffect(()=>{const $=new AbortController,S=E=>({status:E,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(dA.map(E=>t.listAgentRuns(e.agent_id,Xv,null,S(E)))).then(E=>{if($.signal.aborted)return;const C=E.flatMap(T=>T.status==="fulfilled"?T.value.runs:[]).filter(T=>!sc(T.status));for(const T of C.slice(0,Xv)){let A=`${T.status}/${T.state}`;_g(t,T.run_id,{signal:$.signal,onPage:F=>{const L=`${F.status}/${F.state}`;L!==A&&(A=L,m(z=>z+1))}}).catch(()=>{})}}),()=>$.abort()},[t,e.agent_id]);const R=c==null?void 0:c.analytics;return n.jsxs("div",{className:"space-y-6",children:[n.jsx(t1,{range:a,onRange:l,agent:null,agents:[]}),f?n.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",f]}):!c||!R?n.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):R.totals.runs?n.jsx(n1,{a:R,basis:c.cost.basis,now:s(),refreshing:g}):n.jsx("div",{className:"border px-4 py-12 text-center",children:n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const mA={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:Bp},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:Bp},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:A0},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:ar},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:ai}};function On({tone:e="neutral",title:t,actions:s,bar:r,icon:a,role:l,className:c,children:u,...f}){const p=mA[e],g=a===!1?null:a??p.Icon;return n.jsxs("div",{role:l??(e==="error"?"alert":"status"),...f,className:oe("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":oe("border p-4",p.box),c),children:[g&&n.jsx(g,{className:oe("size-4 shrink-0",!r&&"mt-0.5",p.text),"aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[t&&n.jsx("p",{className:oe("font-semibold",!r&&"caps text-small",!r&&p.text),children:t}),u&&n.jsx("div",{className:oe(t&&!r&&"mt-2"),children:u})]}),s&&n.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const Yv=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Qv=G0,pA=(e,t)=>s=>{var r;if((t==null?void 0:t.variants)==null)return Qv(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:a,defaultVariants:l}=t,c=Object.keys(a).map(p=>{const g=s==null?void 0:s[p],v=l==null?void 0:l[p];if(g===null)return null;const h=Yv(g)||Yv(v);return a[p][h]}),u=s&&Object.entries(s).reduce((p,g)=>{let[v,h]=g;return h===void 0||(p[v]=h),p},{}),f=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((p,g)=>{let{class:v,className:h,...m}=g;return Object.entries(m).every(b=>{let[w,j]=b;return Array.isArray(j)?j.includes({...l,...u}[w]):{...l,...u}[w]===j})?[...p,v,h]:p},[]);return Qv(e,c,f,s==null?void 0:s.class,s==null?void 0:s.className)},mi=pA("caps inline-flex items-center justify-center gap-2 whitespace-nowrap border text-small transition-colors disabled:cursor-not-allowed disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",{variants:{variant:{outline:"border-border bg-background hover:border-border-strong hover:bg-accent",primary:"border-primary text-primary-text hover:bg-primary/10",solid:"border-primary bg-primary text-primary-foreground hover:bg-primary/90",destructive:"border-destructive/60 text-destructive-text hover:bg-destructive/10",ghost:"border-transparent hover:bg-accent"},size:{xs:"h-7 gap-1.5 px-2 text-label",sm:"h-control-sm px-3",md:"h-control-md px-4",lg:"h-control-lg px-5",icon:"size-control-sm"}},defaultVariants:{variant:"outline",size:"md"}}),V=x.forwardRef(({className:e,variant:t,size:s,...r},a)=>n.jsx("button",{ref:a,className:oe(mi({variant:t,size:s}),e),...r}));V.displayName="Button";const Zv={plain:"border-border text-muted-foreground",active:"border-run-active/50 text-run-active",success:"border-success/50 bg-success/10 text-success-text",warning:"border-warning/50 bg-warning/10 text-warning-text",error:"border-destructive/50 bg-destructive/10 text-destructive-text",info:"border-info/50 bg-info/10 text-info-text",muted:"border-border-strong/60 text-muted-foreground"};function Ce({tone:e="plain",className:t,title:s,label:r,children:a}){return r?n.jsx("span",{title:s,className:oe("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",Zv[e],t),children:n.jsx("span",{className:"min-w-0 truncate",children:a})}):n.jsx("span",{title:s,className:oe("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",Zv[e],t),children:a})}const hA={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function Cg({open:e,onClose:t,title:s,description:r,footer:a,size:l="md",initialFocus:c,hideClose:u,className:f,children:p}){return n.jsxs(a3,{open:e,onClose:t,initialFocus:c,className:"relative z-dialog",children:[n.jsx(o3,{className:"fixed inset-0 bg-overlay/70"}),n.jsx("div",{className:oe("fixed inset-0 flex justify-center p-4 md:p-8",l==="full"?"items-stretch":"items-start overflow-y-auto pt-[12vh]"),children:n.jsxs(kj,{className:oe("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",hA[l],f),children:[n.jsxs("header",{className:"flex items-start gap-3 border-b px-5 py-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx(jj,{className:"text-lg font-semibold",children:s}),r&&n.jsx(wk,{className:"mt-1 text-body text-muted-foreground",children:r})]}),!u&&n.jsx(V,{size:"icon",variant:"ghost",onClick:t,"aria-label":"Close",children:n.jsx(Yl,{"aria-hidden":!0})})]}),p&&n.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:p}),a&&n.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:a})]})})]})}function gA({open:e,title:t,confirm:s,cancel:r="Cancel",tone:a="destructive",busy:l,onConfirm:c,onCancel:u,children:f}){const p=x.useRef(null);return n.jsx(Cg,{open:e,onClose:l?()=>{}:u,title:t,size:"sm",hideClose:!0,initialFocus:p,footer:n.jsxs(n.Fragment,{children:[n.jsx(V,{ref:p,size:"sm",onClick:u,disabled:l,children:r}),n.jsx(V,{size:"sm",variant:a,onClick:c,disabled:l,"aria-busy":l||void 0,children:s})]}),children:f})}function xA({icon:e,active:t,className:s,children:r,...a}){return n.jsxs("button",{type:"button","aria-current":t?"page":void 0,...a,className:oe("flex min-h-11 items-center gap-2.5 p-3 text-left text-body -outline-offset-2 hover:bg-accent",t&&"relative bg-primary/[0.06] text-primary-text before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-primary",s),children:[e&&n.jsx(e,{className:"size-4 shrink-0","aria-hidden":!0})," ",r]})}const yA=["appearance-none bg-transparent","[&::-webkit-slider-runnable-track]:h-0.5 [&::-webkit-slider-runnable-track]:bg-border-strong","[&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-3 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:bg-foreground","[&::-moz-range-track]:h-0.5 [&::-moz-range-track]:bg-border-strong","[&::-moz-range-thumb]:size-3 [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-foreground"].join(" ");function bA({value:e,onChange:t,min:s,max:r,label:a,valueText:l,className:c,disabled:u=!1}){return n.jsx("input",{type:"range",min:s,max:r,step:1,value:e,disabled:u,"aria-label":a,"aria-valuetext":l,onChange:f=>t(Number(f.target.value)),className:oe(yA,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function vA({label:e,className:t}){return n.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[n.jsx(q_,{className:oe("size-4 animate-spin text-run-active",t),"aria-hidden":!0}),e&&n.jsx("span",{className:"sr-only",children:e})]})}function wA({checked:e,onChange:t,disabled:s,label:r,labelledBy:a,busy:l,className:c}){return n.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":r,"aria-labelledby":a,"aria-busy":l||void 0,disabled:s||l,onClick:()=>t(!e),className:oe("relative inline-flex h-5 w-9 shrink-0 items-center border transition-colors disabled:cursor-not-allowed disabled:opacity-45",e?"border-primary bg-primary/20":"border-border-strong bg-background hover:border-foreground/60",l&&"motion-safe:animate-pulse",c),children:n.jsx("span",{"aria-hidden":!0,className:oe("absolute top-1/2 size-3 -translate-y-1/2 transition-[left,background-color] duration-fast",e?"left-[calc(100%-16px)] bg-primary":"left-[3px] bg-muted-foreground")})})}function x1({tabs:e,value:t,onChange:s,label:r,id:a,className:l}){var p;const c=e.some(g=>g.id===t)?t:(p=e[0])==null?void 0:p.id,u=x.useRef(null),f=g=>{var m,b;const v=e.findIndex(w=>w.id===t),h=g.key==="ArrowRight"?(v+1)%e.length:g.key==="ArrowLeft"?(v-1+e.length)%e.length:g.key==="Home"?0:g.key==="End"?e.length-1:-1;h<0||h===v||(g.preventDefault(),s(e[h].id),(b=(m=u.current)==null?void 0:m.querySelectorAll('[role="tab"]')[h])==null||b.focus())};return n.jsx("div",{ref:u,role:"tablist","aria-label":r,onKeyDown:f,className:oe("flex border-b px-5 md:px-8",l),children:e.map(g=>n.jsx("button",{type:"button",role:"tab",id:a&&`${a}-tab-${g.id}`,"aria-controls":a&&`${a}-panel-${g.id}`,"aria-selected":t===g.id,tabIndex:c===g.id?0:-1,onClick:()=>s(g.id),className:oe("caps -mb-px whitespace-nowrap border-b-2 px-3 py-3 text-small -outline-offset-2 max-sm:px-2.5 max-sm:py-2",t===g.id?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground"),children:g.label},g.id))})}function kA({tip:e,children:t,className:s,align:r="start"}){const a=x.useId();return n.jsxs("span",{className:oe("group/tip relative inline-flex",s),children:[x.cloneElement(t,{"aria-describedby":a}),n.jsx("span",{role:"tooltip",id:a,className:oe("pointer-events-none absolute top-full z-popover mt-1.5 hidden w-max max-w-[min(20rem,80vw)] border border-border-strong bg-card px-3 py-2 text-left font-sans text-small normal-case leading-snug tracking-normal text-card-foreground shadow-float group-hover/tip:block group-focus-within/tip:block",r==="end"?"right-0":"left-0"),children:e})]})}const jA=x.createContext(null),NA={neutral:[Bp,"text-muted-foreground"],success:[A0,"text-success-text"],warning:[ar,"text-warning-text"],error:[ai,"text-destructive-text"]},SA=5e3;function _A({toast:e,done:t}){const s=x.useCallback(()=>t(e.id),[t,e.id]),r=e.tone??"neutral",a=e.duration??(r==="error"?0:SA),[l,c]=x.useState(!1),[u,f]=x.useState(!1),p=l||u;x.useEffect(()=>{if(!a||p)return;const h=setTimeout(s,a);return()=>clearTimeout(h)},[a,p,s]);const[g,v]=NA[r];return n.jsxs("div",{role:r==="error"?"alert":"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>f(!0),onBlur:()=>f(!1),className:"pointer-events-auto flex w-full items-start gap-3 border border-border-strong bg-card p-3 text-body text-card-foreground shadow-float motion-safe:animate-toast-in",children:[n.jsx(g,{className:oe("mt-0.5 size-4 shrink-0",v),"aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"font-semibold",children:e.title}),e.description&&n.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),n.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:n.jsx(Yl,{className:"size-3.5","aria-hidden":!0})})]})}function $A({children:e}){const[t,s]=x.useState([]),r=x.useRef(0),a=x.useCallback(c=>s(u=>[...u,{...c,id:r.current++}].slice(-3)),[]),l=x.useCallback(c=>s(u=>u.filter(f=>f.id!==c)),[]);return n.jsxs(jA.Provider,{value:a,children:[e,n.jsx("div",{role:"region","aria-label":"Notifications","aria-live":"polite",className:"pointer-events-none fixed inset-x-4 bottom-4 z-toast flex flex-col gap-2 sm:left-auto sm:w-[22rem]",children:t.map(c=>n.jsx(_A,{toast:c,done:l},c.id))})]})}const pd=[{id:"claude",label:"Claude Code app",instruction:"Open your project in Claude Code and paste the prompt into a new or existing conversation."},{id:"claude-cli",label:"Claude Code CLI",instruction:"Open your project in a terminal, start Claude Code with claude, and paste the prompt."},{id:"codex",label:"Codex app",instruction:"Open your project in the Codex app and paste the prompt into a new or existing chat."},{id:"codex-cli",label:"Codex CLI",instruction:"Open your project in a terminal, start Codex with codex, and paste the prompt."}],y1="agentrun.coding-agent",EA="https://github.com/Parcha-ai/agentrun/tree/main/packages/serve/skills/agentrun-serve",b1=()=>{try{return globalThis.localStorage??null}catch{return null}};function CA(e=b1()){var t;try{const s=e==null?void 0:e.getItem(y1);return((t=pd.find(r=>r.id===s))==null?void 0:t.id)??"claude"}catch{return"claude"}}function TA(e,t=b1()){try{t==null||t.setItem(y1,e)}catch{}}const Jv=e=>pd.find(t=>t.id===e)??pd[0];function ew(e,t=(s=>(s=globalThis.location)==null?void 0:s.href)()){const r=new URL(e||"/",t),a=r.pathname.replace(/\/+$/,"");return{origin:r.origin,path:a,api:`${r.origin}${a}`}}const RA={create:"Create an AgentRun agent on this server.",edit:"Review and revise this AgentRun agent.",run:"Run this AgentRun agent on its pinned revision."};function AA(e,t,s){const{origin:r,path:a,api:l}=ew(t),c=a.endsWith("/v2"),u=e.kind==="create"?"":encodeURIComponent(e.agentId),f=e.kind==="create"?`POST ${a}/agents`:e.kind==="edit"?`PUT ${a}/agents/${u}/definition`:`POST ${a}/agents/${u}/runs`,p=e.kind==="run"?{...e.input!==void 0?{input:e.input}:{},...e.effort?{effort:e.effort}:{},...e.maxCostUsd!==void 0?{max_cost_usd:e.maxCostUsd}:{},revision:e.revision}:void 0,g={server:l,operation:f,...e.kind==="create"?{}:{agent_id:e.agentId,revision:e.revision},...p?{request:p}:{}},v=s?`${ew(s).api}/`:void 0,h=e.kind==="create"?[`Create it with POST ${a}/agents and one Idempotency-Key for the request and any unchanged retry.`,"Write a native definition: instructions with the tools the agent needs, or a workflow this server supports. Include every skill file the person supplies in the same request.","Do not submit missing requirements or configuration this server's capabilities do not offer."]:e.kind==="edit"?[`Read the agent first with GET ${a}/agents/${u} and keep its ETag.`,`Send the full definition with PUT ${a}/agents/${u}/definition, a higher version and If-Match set to that ETag. Keep the agent's identity and every field you were not asked to change; skill files do not change through this route.`,"A 412 precondition_failed means another revision was saved first: report it, and do not overwrite that revision."]:[`Read the pinned revision's input contract. Start the run with POST ${a}/agents/${u}/runs, the revision pinned, and one stable Idempotency-Key for this run and any unchanged retry.`,e.maxCostUsd!==void 0?"Keep max_cost_usd exactly as the request has it: the person typed that spend cap for this run.":"Do not add a spending cap unless the person asks for one.","Follow the run's actual status, its questions (input_required), its result and its files until it ends."];return[RA[e.kind],"","Install or update the public AgentRun Server skill with your own skill installation workflow:",EA,`Read its SKILL.md, then ${c?`${r}/llms.txt and `:""}${l}/openapi.json. Check ${l}/capabilities before you choose models, tools or workflow features.`,"",`Use this existing server. Authentication is separate from the skill: use the AgentRun API token the owner configured in your environment, as the skill describes. Never print a credential or ask for one in the conversation. The console's browser session does not sign you in.${c?` You can work over the server's MCP endpoint (${l}/mcp), as the skill connects it, or over the HTTP API.`:""}`,"","Task context:","```json",JSON.stringify(g,null,2),"```","","Ask about missing task inputs, required outputs and scope before you submit anything. Keep the answers and any approval already given. Explain the change or the run first when it still needs approval.",...h,`Report the server's actual answer and the ${e.kind==="run"?"run":"revision"} it names${v?`, with its link in the console (${v})`:""}. Keep an unknown cost unknown. Copying this prompt submitted nothing, so do not claim that anything ran before the server says so.`].join(`
520
+ `)}const OA={create:"Build with your coding agent",edit:"Edit with your coding agent",run:"Run with your coding agent"},MA=()=>globalThis.location?`${location.origin}${location.pathname}`:void 0;function PA({open:e,onClose:t,context:s,serverUrl:r="/v2",consoleUrl:a=MA()}){const[l,c]=x.useState(()=>CA()),[u,f]=x.useState(()=>AA(s,r,a)),[p,g]=x.useState("no"),v=x.useRef(null),h=Jv(l),m=async()=>{var b,w,j;try{if(!((b=navigator.clipboard)!=null&&b.writeText))throw new Error("No clipboard");await navigator.clipboard.writeText(u),g("yes")}catch{g("unavailable"),(w=v.current)==null||w.focus(),(j=v.current)==null||j.select()}};return n.jsx(Cg,{open:e,onClose:t,size:"lg",title:OA[s.kind],description:"Pick where you work, then review and copy the prompt. Nothing opens or runs from here.",footer:n.jsxs(n.Fragment,{children:[n.jsx(V,{size:"sm",onClick:t,children:"Close"}),n.jsxs(V,{size:"sm",variant:"solid",onClick:()=>void m(),disabled:!u.trim(),children:[n.jsx(Id,{"aria-hidden":!0})," Copy prompt"]})]}),children:n.jsxs("div",{className:"space-y-5",children:[n.jsx(Bs,{label:"Application",hint:h.instruction,children:n.jsx(Lt,{label:"Application",autoFocus:!0,value:l,className:"w-full sm:w-72",onChange:b=>{const w=Jv(b).id;TA(w),c(w),g("no")},options:pd.map(b=>({value:b.id,label:b.label}))})}),n.jsx(Bs,{label:"Prompt",note:"Review it and edit it before you copy it. It holds the task and no credential: your coding agent signs in to the server on its own.",children:n.jsx(As,{ref:v,value:u,rows:14,spellCheck:!1,className:"resize-y text-small leading-relaxed",onChange:b=>{f(b.target.value),g("no")}})}),p==="yes"&&n.jsxs(On,{tone:"success",title:"Copied",children:["Paste it into ",h.label,". Nothing was sent to the server."]}),p==="unavailable"&&n.jsx(On,{tone:"warning",role:"alert",title:"Clipboard unavailable",children:"The prompt is selected in its field. Copy it with your keyboard (Ctrl+C, or Cmd+C on a Mac)."})]})})}function Tg({context:e,label:t,serverUrl:s="/v2",size:r="sm",iconOnPhone:a,unavailable:l,className:c}){const[u,f]=x.useState(null),[p,g]=x.useState(!1),[v,h]=x.useState(0);return n.jsxs(n.Fragment,{children:[n.jsxs(V,{size:r,onClick:()=>{f(typeof e=="function"?e():e),h(m=>m+1),g(!0)},"aria-haspopup":"dialog",disabled:!!l,title:l??(a?t:void 0),className:oe(a&&"max-sm:w-8 max-sm:shrink-0 max-sm:px-0",c),children:[n.jsx(r$,{"aria-hidden":!0})," ",a?n.jsx("span",{className:"max-sm:sr-only",children:t}):t]}),u&&n.jsx(PA,{open:p,onClose:()=>g(!1),context:u,serverUrl:s},v)]})}const LA="Not read: its front matter can't be read; fix the file to use it",IA={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},v1=(e,t)=>`${IA[e]} by ${t==="person"?"you":"a run"}`,ch=e=>e.readme??e.file,Np="Can't tell which version this is: reload.",of="It changed since you opened it.",zA=e=>e==="active"?"It becomes active again for the next run.":"It goes back to waiting for your OK: no run uses it until you approve it.",DA=e=>`It makes a new agent that runs the steps of ${e} on their own, with no agent loop, under this agent's tool settings, approvals and cap. ${e} stays here, unchanged.`,FA="Making an agent from it takes your password sign-in in the console.",UA="Restoring takes your password sign-in in the console.",w1=["feedback","project","reference","user"],WA={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},k1=e=>WA[e]??e,HA={feedback:"How to work: a rule or a correction",project:"Facts about the work itself",reference:"Where to find things",user:"About the person it works for"},BA=["seeded","reflecting","proposed"],j1=e=>!!e&&BA.includes(e.state),oc=e=>Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&typeof t.file=="string"&&typeof t.name=="string"):[],N1=e=>oc(e==null?void 0:e.given),S1=e=>oc(e==null?void 0:e.read),Wl=e=>(e==null?void 0:e.state)==="merged"?oc(e.learned):[],Rg=e=>oc(e==null?void 0:e.pending),_1=e=>oc(e),tw=e=>(e==null?void 0:e.state)==="merged"?_1(e.skills):[],nw=e=>(e==null?void 0:e.state)==="merged"?_1(e.workflows):[],GA=e=>Rg(e).length>0,hd=(e,t)=>`${e} ${t}${e===1?"":"s"}`,$1=e=>e.status==="pending",gd=e=>{var t;return((t=e==null?void 0:e.learning)==null?void 0:t.pending)??0},Ag=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function qA(e){const t=e&&typeof e=="object"?e.learning:void 0;return t&&typeof t=="object"&&t.approve===!0?"yes":"password"}const E1="Approving needs your password sign-in. Until then it stays out of every run.",VA="It changes what this agent trusts or skips, so it waits for you.",KA="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",C1="[redacted]",T1=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",ei=e=>`${e} ${e===1?"note":"notes"}`,po=e=>`${e} ${e===1?"run":"runs"}`,XA={grader:"refused",checker:"refused",screen:"refused",screen_down:"refused",unparsed:"refused",empty:"nothing",no_budget:"skipped",unknown_cost:"skipped",no_write_tool:"skipped",tool_denied:"skipped"},xd=e=>XA[e??""]??"stopped",YA={empty:"Nothing new to remember from this run.",unparsed:"Not kept: its notes weren't in the expected format.",grader:"Not kept: it wouldn't help later runs enough.",checker:"Not kept: it held something that must not be stored.",screen:"Not kept: it held something that must not be stored.",screen_down:"Not kept: it couldn't be checked for safety.",no_write_tool:"Not kept: this agent can't write notes (give it the write tool).",tool_denied:"Not kept: this agent isn't allowed to write notes.",no_budget:"Skipped: no budget left in this run to look back.",unknown_cost:"Skipped: no budget left in this run to look back.",seed_failed:"Started without its notes: they couldn't be read.",cancelled:"Not kept: learning stopped (the run was cancelled).",crashed:"Not kept: learning stopped (the run ended unexpectedly).",reflect_timeout:"Not kept: learning stopped (it ran out of time).",reflect_failed:"Not kept: learning stopped (an error).",propose_failed:"Not kept: learning stopped (an error).",grade_failed:"Not kept: learning stopped (the check couldn't run)."};function Og(e){return e.detail&&e.detail.trim()?e.detail.trim():YA[e.reason??""]??"Not kept: learning stopped."}const QA=e=>e==="seeded"?"Learns after the run":"Looking back",yd=e=>fi(Math.round(e)*1e3),ti=e=>go({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),sw=(e,t)=>e>0?Math.round((t-e)/e*100):null,R1=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",A1=e=>e.after.median_learning_usd;function ZA(e){const t=[`answers in ${yd(e.after.median_duration_s)} instead of ${yd(e.before.median_duration_s)}`];R1(e)&&t.push(`${ti(e.after.median_cost_usd)} instead of ${ti(e.before.median_cost_usd)} a run`);const s=A1(e);return s!==null&&t.push(`learning itself ${ti(s)} a run`),`Since it learned (on ${po(e.after.runs)}): ${t.join(" · ")}`}const JA=e=>{const t=s=>!!s&&typeof s=="object"&&typeof s.runs=="number"&&s.runs>=2&&typeof s.median_duration_s=="number";return!!e&&typeof e=="object"&&t(e.before)&&t(e.after)},eO=/^---\n([\s\S]*?)\n?^---$\n?/m,uh=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function bd(e){const t=e.replace(/\r\n/g,`
521
+ `),s=t.startsWith(`---
522
+ `)?eO.exec(t):null;if(!s||s.index!==0)return{name:"",description:"",type:"project",body:t,rest:[]};const r={},a=[];for(const c of s[1].split(`
523
+ `)){const u=/^(name|description|type):(?:\s+(.*))?$/.exec(c);u&&!(u[1]in r)?r[u[1]]=uh((u[2]??"").trim()):c.trim()&&a.push(c)}const l=w1.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:l,body:t.slice(s[0].length),rest:a}}const rw=e=>{const t=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(t)?t.includes('"')?`'${t}'`:`"${t}"`:t},tO=e=>`---
524
+ name: ${rw(e.name)}
525
+ description: ${rw(e.description)}
526
+ type: ${e.type}
527
+ ${e.rest.map(t=>`${t}
528
+ `).join("")}---
529
+ ${e.body.replace(/^\n*/,`
530
+ `)}`;function nO(e){const t=bd(e).rest.find(r=>/^supersedes:/.test(r)),s=t?uh(t.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>uh(r.trim())).filter(Boolean):[]}const Hl=e=>bd(e).body.replace(/^\n+/,"");function ow(e,t=[]){const s=e.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"note";let r=`${s}.md`;for(let a=2;t.includes(r);a++)r=`${s}-${a}.md`;return r}const af=(e,t=[])=>{const s=t.filter(a=>a!==C1),r=new URLSearchParams(s.map(a=>["note",a]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function O1(e){return e.kind===jr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===jr?{...e,kind:jr,agent_label:null}:e}const jr="learning",sO={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},dh=e=>e?sO[e.state]??0:-1,rO=e=>{const t=e==null?void 0:e.learning;return t&&typeof t=="object"&&typeof t.state=="string"?t:void 0},aw=e=>e.charAt(0).toLowerCase()+e.slice(1);function oO(e){var s,r;if(!e||dh(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${aw(((s=e.detail)==null?void 0:s.trim())||"Checking its new notes…")}`;const t=a=>a.map(l=>l.name.replace(/\s+/g," ").trim()).join(", ");if(e.state==="merged"){const a=Wl(e),l=Rg(e),c=[...a.length?[`kept ${ei(a.length)} (${t(a)})`]:[],...l.length?[`${aw(T1(l.length))} (${t(l)})`]:[]];return c.length?`Looked back: ${c.join("; ")}`:`Looked back. ${((r=e.detail)==null?void 0:r.trim())||"It kept what it learned."}`}return xd(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${Og(e)}`}function aO(e){var l;const t=O1(e),s=t.summary??"",r=a1(t)?`${s} (failed)`:s,a=(l=r1(t))==null?void 0:l.trimEnd();return a&&a.trim()!==s.trim()?`${r}
531
+ ${a.replace(/^(?=.)/gm," ")}`:r}function M1(e,t){const s=e.filter(f=>f.agent_label===jr&&f.kind!==jr);if(!s.length)return e.map(O1);const r=e.findLast(f=>f.kind===jr),a=rO(r),l=dh(a)>dh(t??void 0)?a:t&&{...t,detail:t.detail??(a==null?void 0:a.detail)??(r==null?void 0:r.summary)??null},c=s[0],u={id:c.id,seq:c.seq,timestamp:c.timestamp,created_at:c.created_at,kind:jr,agent_label:null,tool_name:null,tool_use_id:null,tool_status:null,tool_input_preview:null,tool_result_preview:null,tool_result_size_bytes:null,summary:oO(l??void 0),text:[...s,...r?[r]:[]].map(aO).join(`
532
+ `)};return e.flatMap(f=>f===c?[u]:f.agent_label===jr||f.kind===jr?[]:[f])}const iO={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},iw=["Added","Replaced","Retired","Removed","Changed"];function lO(e){const t=[],s=[];let r=0;for(const a of e.split(`
533
+ `)){const l=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(a);l?((r||Number(l[1])>1)&&t.push({text:"…",mark:"gap"}),(r||Number(l[2])>1)&&s.push({text:"…",mark:"gap"}),r++):r&&a.startsWith(" ")?(t.push({text:a.slice(1),mark:"same"}),s.push({text:a.slice(1),mark:"same"})):r&&a.startsWith("-")?t.push({text:a.slice(1),mark:"removed"}):r&&a.startsWith("+")&&s.push({text:a.slice(1),mark:"added"})}return{before:t,after:s}}function cO(e,t){const s=e.files.filter(u=>u.path!=="MEMORY.md"),r=new Map(s.map(u=>[u.path,u.patch===void 0?null:lO(u.patch)])),a=new Map([...N1(t),...S1(t),...Wl(t)].map(u=>[u.file,u.name])),l=u=>{const f=r.get(u),p=[...(f==null?void 0:f.after)??[],...(f==null?void 0:f.before)??[]].find(g=>g.mark!=="gap"&&/^name:\s*\S/.test(g.text));return a.get(u)??(p==null?void 0:p.text.replace(/^name:\s*/,"").trim())??u.replace(/\.md$/,"")};return s.map(u=>{var m,b;const f=r.get(u.path),p=l(u.path),g=((f==null?void 0:f.after)??[]).filter(w=>w.mark==="added").map(w=>w.text.trim()),v=((m=g.find(w=>w.startsWith("superseded_by:")))==null?void 0:m.replace(/^superseded_by:\s*/,""))??((b=Wl(t).find(w=>{var j;return(j=w.supersedes)==null?void 0:j.includes(u.path)}))==null?void 0:b.file),h=u.status==="added"?`Added: ${p}`:u.status==="deleted"?`Removed: ${p}`:g.includes("status: superseded")||!f&&v?`Replaced: ${p}${v?` → ${l(v)}`:""}`:g.includes("status: retired")?`Retired: ${p}`:`Changed: ${p}`;return f?{file:u.path,said:h,before:u.status==="added"?null:f.before,after:u.status==="deleted"?null:f.after}:{file:u.path,said:h,before:null,after:null,withheld:iO[u.withheld??""]??"Not shown."}}).sort((u,f)=>iw.indexOf(u.said.split(":")[0])-iw.indexOf(f.said.split(":")[0]))}function uO(e){const t=new Map;for(const s of e)for(const r of s.files){const a=t.get(r)??{};"run"in s.by&&(a.run={id:s.by.run,at:s.at,reason:s.reason}),t.set(r,a)}return t}function lf({run:e,link:t=!1,className:s}){var v;const r=N1(e.learning),a=S1(e.learning),l=Wl(e.learning),c=j1(e.learning)&&e.learning.state!=="seeded",u=Rg(e.learning),f=GA(e.learning),p=[...tw(e.learning),...nw(e.learning)],g=((v=e.learning)==null?void 0:v.state)==="dropped"&&xd(e.learning.reason)!=="nothing"?Og(e.learning):null;return!r.length&&!a.length&&!l.length&&!c&&!f&&!p.length&&!g?null:n.jsxs("span",{className:oe("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[r.length>0&&n.jsx(Tu,{agentId:e.agent_id,refs:r,link:t,kind:"given"}),a.length>0&&n.jsx(Tu,{agentId:e.agent_id,refs:a,link:t,kind:"read"}),l.length>0&&n.jsx(Tu,{agentId:e.agent_id,refs:l,link:t,kind:"learned",replaces:l.reduce((h,m)=>{var b;return h+(((b=m.supersedes)==null?void 0:b.length)??0)},0)}),f&&n.jsx(Tu,{agentId:e.agent_id,refs:u,link:t,kind:"pending"}),g&&n.jsx(dO,{agentId:e.agent_id,said:g,link:t}),["skill","workflow"].flatMap(h=>{const m=(h==="skill"?tw:nw)(e.learning);return[!1,!0].map(b=>{const w=m.filter(j=>j.pending===!0===b);return w.length?n.jsx(fO,{agentId:e.agent_id,refs:w,link:t,kind:h,pending:b},`${h}-${b}`):null})}),c&&n.jsxs(Ce,{tone:"active",children:[n.jsxs("span",{className:"relative flex size-1.5","aria-hidden":!0,children:[n.jsx("span",{className:"absolute inline-flex size-full animate-ping bg-run-active opacity-75"}),n.jsx("span",{className:"relative inline-flex size-1.5 bg-run-active"})]}),QA(e.learning.state)]})]})}function dO({agentId:e,said:t,link:s}){const r=n.jsxs(Ce,{tone:"muted",className:oe(s&&"cursor-pointer"),children:[n.jsx(I_,{className:"size-3","aria-hidden":!0}),"Kept nothing"]});return s?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[n.jsx("a",{href:af(e),"aria-label":`Kept nothing: ${t}`,className:"inline-flex",children:r}),n.jsx("span",{className:"text-small text-muted-foreground",children:t})]}):n.jsx("span",{title:`Kept nothing: ${t}`,"aria-label":`Kept nothing: ${t}`,className:"inline-flex",children:r})}function fO({agentId:e,refs:t,link:s,kind:r,pending:a}){const l=a?`${hd(t.length,r)} ${t.length===1?"waits":"wait"} for your OK`:`Learned ${hd(t.length,r)}`,c=`${l}: ${t.map(p=>p.name).join(", ")}`,u=a?Bh:r==="skill"?Ju:ia,f=n.jsxs(Ce,{tone:a?"warning":void 0,className:oe(!a&&"border-primary/50 bg-primary/10 text-primary-text",s&&"cursor-pointer"),children:[n.jsx(u,{className:"size-3","aria-hidden":!0}),l]});return s?n.jsx("a",{href:af(e),title:c,"aria-label":c,className:"inline-flex",children:f}):n.jsx("span",{title:c,"aria-label":c,className:"inline-flex",children:f})}function Tu({agentId:e,refs:t,link:s,kind:r,replaces:a=0}){const l=r==="pending"?T1(t.length):r==="given"?`Started with: ${ei(t.length)}`:r==="read"?`Read: ${ei(t.length)}`:`Learned ${ei(t.length)}`,c=t.map(m=>m.name).join(", "),u=r==="given"||r==="read",f=u?Zu:r==="pending"?Bh:qh,p=n.jsxs(Ce,{tone:r==="pending"?"warning":void 0,className:oe(r==="learned"?"border-primary/50 bg-primary/10 text-primary-text":u?"border-border-strong/70 text-foreground/80":"",s&&"cursor-pointer transition-colors group-hover/tip:border-foreground/70"),children:[n.jsx(f,{className:"size-3","aria-hidden":!0}),l]}),g=t.filter(m=>m.file!==C1),v=`${l}${c?`: ${c}`:""}${a?` (replaces ${a===1?"1 older note":`${a} older notes`})`:""}`;if(!s||!g.length&&r!=="pending")return n.jsx("span",{title:v,"aria-label":v,className:"inline-flex",children:p});const h=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"caps block text-micro text-muted-foreground",children:r==="given"?"This run started with":r==="read"?"This run read":r==="learned"?"This run kept":"Waits for your OK before any run reads it"}),t.length>0&&n.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(m=>n.jsx("li",{className:"font-semibold",children:m.name},m.file))}),a>0&&n.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["Replaces ",a===1?"1 older note":`${a} older notes`,"."]}),n.jsx("span",{className:"mt-1.5 block text-label text-muted-foreground",children:"Open in Learning"})]});return n.jsx(kA,{tip:h,children:n.jsx("a",{href:af(e,g.map(m=>m.file)),"aria-label":v,className:"inline-flex",children:p})})}function mO({n:e,className:t}){return e<=0?null:n.jsx("span",{"aria-label":Ag(e),className:oe("inline-flex min-w-[18px] items-center justify-center border border-warning/50 bg-warning/10 px-1 font-mono text-micro text-warning-text",t),children:e})}function pO(e,t){var a;const s=e??"pi",r=(a=t.find(l=>l.id===s))==null?void 0:a.steer;return typeof r=="boolean"?r:s==="pi"}const ac={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},hO=new Set(["completed","failed","cancelled"]);function gO(e,t,s,r,a){const c=e==="queued"||e==="working"&&t==="working"?a||s==="workflow"?"steer":"follow_up":e==="input_required"&&t==="waiting"?"answer":e==="input_required"||e==="working"||e==="completed"?"follow_up":null;return!c||!r[c]?null:s==="workflow"?c==="steer"&&r.steer_workflow_runs?c:null:c}const P1=(e,t)=>e==="failed"&&(t==null?void 0:t.code)==="escalated",xO=(e,t)=>e==="completed"&&!!t;function ic(e,t,s,r,a,l,c){const u=hO.has(e),f=s==="agentic",p=P1(e,l),g=xO(e,c),v=p?"Escalated":g?"Needs review":e==="input_required"?t==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],h=p||g?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",m=gO(e,t,s,r,a);return{label:v,tone:h,live:e==="queued"||e==="working",needsYou:e==="input_required",final:u,canStop:f&&e==="working"&&t==="working",canCancel:!u,canMessage:m!==null,messageMode:m}}const yO={Queued:Lb,Working:Lb,Completed:Ld,Failed:ai,Escalated:L_,"Needs review":M0,Cancelled:R0,"Input required":Gh,Stopped:ii,Paused:O0};function lc({run:e}){const t=ic(e.status,e.state,e.kind,ac,!0,e.error,e.review),s=yO[t.label];return n.jsxs(Ce,{tone:t.tone,children:[n.jsx(s,{className:t.live?"size-3 animate-spin [animation-duration:2s]":"size-3","aria-hidden":!0}),t.label]})}const Da=(e,t={})=>({type:"object",properties:{op:{const:e,description:`Action operation. Use "op": "${e}"; never use a "kind" field.`},id:{type:"string",description:'Bracketed ID copied from the latest snapshot, as a string. Use "id"; never use "ref".'},...t},required:["op","id",...Object.keys(t).filter(s=>s!=="delay")],additionalProperties:!1}),cr=(e,t=[])=>({type:"object",additionalProperties:!1,properties:e,...t.length?{required:t}:{}}),bO={name:"snapshot",label:"Browser: snapshot",description:"Capture the active page's accessibility tree and hydrate its displayed IDs for subsequent run actions. Every call replaces the active page's ID map. On an agent's browser computer a frame another site runs in its own process is not in the tree: the snapshot names each frame it left out.",parameters:cr({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},vO=Object.freeze({cookies:"It keeps cookies across pages: use it for a page that depends on an earlier one, or one that sets cookies.",signIns:"This browser opens with this agent's saved browser profile: a site the agent was signed in to there opens signed in here, and only here (web_fetch reads every page signed out). Use it for anything behind a sign-in, or a page that depends on an earlier one."}),wO=e=>`Browse and automate websites in the persistent browser. ${vO.cookies} Navigate with JavaScript such as await page.goto("https://example.com"), or with a goto action; there is no separate navigate or start tool. Execute either a JavaScript workflow against the Stagehand Playwright facade or a batch of actions using IDs from the latest snapshot. Code is the body of an async function with page, context and browser in scope: \`return\` the value you want back. Provide exactly one of code or actions. An agent's browser computer (Browserbase, Kernel or Local Chrome) takes actions only: code is refused there. Each action must use "op" (never "kind") and "id" (never "ref"), but goto, which takes a "url". Copy the bracketed snapshot ID as a string. Examples: {"actions":[{"op":"goto","url":"https://example.com"}]}, {"actions":[{"op":"click","id":"1-42"}]}, {"actions":[{"op":"fill","id":"2-14","value":"Miami"}]}, {"actions":[{"op":"select","id":"3-9","values":"Lowest price"}]}.`,kO={name:"run",label:"Browser: run",description:wO(),parameters:cr({code:{type:"string",minLength:1},actions:{type:"array",description:'Snapshot actions with the exact fields "op" and "id" (goto: "op" and "url"). Do not use "kind" or "ref".',items:{oneOf:[{type:"object",properties:{op:{const:"goto",description:'Action operation. Use "op": "goto"; never use a "kind" field.'},url:{type:"string",description:"The http or https URL to open in the active page (or about:blank)."}},required:["op","url"],additionalProperties:!1},Da("click"),Da("hover"),Da("fill",{value:{type:"string"}}),Da("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Da("press",{key:{type:"string"}}),Da("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},jO={name:"screenshot",label:"Browser: screenshot",description:'Capture a screenshot of the active page. For size-constrained MCP clients, prefer a viewport JPEG: {"type":"jpeg","quality":40,"fullPage":false}.',parameters:cr({fullPage:{type:"boolean"},type:{type:"string",enum:["png","jpeg"]},quality:{type:"number",minimum:0,maximum:100},ask:{type:"string",description:"What you want to know from this capture. It travels with the image, so a host can answer it from the pixels when your model cannot see them."},clip:{...cr({x:{type:"number"},y:{type:"number"},width:{type:"number"},height:{type:"number"}},["x","y","width","height"]),description:"Capture only this region, in CSS pixels from the viewport's top-left corner (what the page shows now). Width and height 0 mean no clip: leave it out, or send zeros, to capture the whole viewport. A region that leaves the viewport is refused. Use one of clip, id or selector; an empty id or selector means none."},id:{type:"string",description:"Capture only this element: a bracketed ID from the latest snapshot, as a string. It is scrolled into view first. It must match one element."},selector:{type:"string",description:"Capture only the element this CSS selector matches (when there is no snapshot ID for it). It is scrolled into view first. It must match exactly one element."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"image",listedWhen:"always"},NO={name:"browser_read",label:"Browser: read",description:"Read the CURRENT page of the browser as evidence and persist it under evidence/ with the page URL: `what` = markdown (the whole page as markdown, the default for citing), text, html, url, or title. This is the citable door for anything you saw in the browser: snapshot, screenshot and run return values are not evidence. Cite the returned URL. A browser page URL in a receipt keeps its query names but shows every value replaced by a redaction marker, the word redacted in square brackets (the site chose where the browser went, and a value in it can be a credential); web_fetch keeps a query value that is in the URL you asked for.",parameters:cr({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},SO={name:"browser_release",label:"Browser: release",description:"Release the browser session now. You do not need it to finish: the session is released when your work ends and after a stretch with no browser call. Call it only to drop a session mid-task (to start the next browser call on a fresh session, or before a long stretch of work that needs no browser). Your next browser call launches a fresh session (a new tab, no cookies from the old one), so finish a flow before releasing.",parameters:cr({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},_O={name:"browser_relaunch",label:"Browser: relaunch",description:"Replace the browser session with a fresh one, after a site blocked it (403/429, a CAPTCHA wall, a bot-detection page, an empty page that should have content). The new session is Verified whenever the run's sessions are, and a relaunch never lowers that: `verified: true` asks for a Verified session where the run's sessions are not (a Verified browser carries a stronger identity and costs more). Use `geolocation` to browse as a visitor from a given place: the proxy egresses from that country (ISO alpha-2), optionally a US state and a city, so geo-aware sites (storefront region, prices, payment methods, content availability) show what a local sees. Page state is lost; navigate again with run.",parameters:cr({verified:{type:"boolean",description:"true launches the new session as a Verified browser. false, or leaving it out, keeps the run's setting: a Verified run's sessions stay Verified."},geolocation:{type:"object",additionalProperties:!1,description:"Proxy egress location for the new session. Omit to keep the run's default.",properties:{country:{type:"string",description:"ISO 3166-1 alpha-2 country code, e.g. GB, US, DE."},state:{type:"string",description:"US state abbreviation, United States only."},city:{type:"string",description:"City name, e.g. LONDON or SAO_PAULO."}},required:["country"]}}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},$O={name:"browser_request_handoff",label:"Browser: hand to a person",description:"Hand the browser to a person for a step only a human can do: a CAPTCHA you cannot pass, a sign-in that needs their device, a confirmation only they can give. Say in instruction what they should do and in completion_condition what the page shows once it is done. The call waits until the person finishes, cancels or the request expires; while they have the browser, every other browser call fails with waiting_for_human. The same request_id retries the same request. Afterwards take a snapshot and check the completion condition on the page before acting.",parameters:cr({request_id:{type:"string",pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",description:"A UUID you choose for this request; the same one retries the same request."},instruction:{type:"string",minLength:1,maxLength:2e3,description:"What the person should do, in plain words."},completion_condition:{type:"string",minLength:1,maxLength:1e3,description:"What the page shows once the step is done, for you to verify afterwards."}},["request_id","instruction","completion_condition"]),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"handoff"},EO={name:"browser_downloads",label:"Browser: downloads",description:"Copy the files this browser session downloaded into the workspace under downloads/, with downloads/manifest.json listing each file's SHA-256. Returns the files fetched now, those fetched before and those skipped with why, never their bytes; open a fetched file with read. A file the browser is still downloading is skipped as still downloading: call again to fetch it.",parameters:cr({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},CO={name:"browser_upload",label:"Browser: upload",description:"Choose one workspace file in a file input on the page, as a person picking it would; nothing is submitted. Returns the file's name, size and SHA-256; submit the form with run afterwards.",parameters:cr({path:{type:"string",minLength:1,maxLength:1e3,description:"The file's path relative to the workspace, for example reports/q3.pdf."},selector:{type:"string",minLength:1,maxLength:500,description:'CSS selector of the <input type="file">, for example input[type=file].'}},["path","selector"]),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"upload"},TO=Object.freeze([bO,kO,jO,NO,SO,_O,$O,EO,CO]),RO=Object.freeze(TO.map(e=>e.name)),pi=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,ls=e=>typeof e=="string"?e:void 0,Bl=(e,t)=>e.length>t?`${e.slice(0,t-3)}...`:e,L1=e=>e.split(`
534
+ `).map(t=>t.trim()).find(Boolean)??"";function vd(e){try{return pi(JSON.parse(e))}catch{return}}const AO=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function Gl(e){const t=AO.exec(e.trim());return Bl(t?`${t[1]}${t[2]==="/"?"":t[2]}`:e.split(/[?#]/)[0]??"",80)}const OO="…",MO=/https?:\/\/[^\s"'`<>\\]+/gi,PO=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i;function Mg(e){return e.replace(MO,t=>{var l;const s=((l=/[.,;:!?)\]}]+$/.exec(t))==null?void 0:l[0])??"",r=PO.exec(t.slice(0,t.length-s.length));if(!r)return t;const a=[...new Set((r[4]??"").split("&").map(c=>c.split("=")[0]).filter(Boolean))];return`${r[1]}${r[2]}${r[3]}${a.length?`?${a.map(c=>`${c}=${OO}`).join("&")}`:""}${s}`})}const LO=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),IO=new Map,zO=new Map,I1=new Map;function kn(e,t,s,{name:r}={}){IO.set(e,t),s&&zO.set(e,s),r&&I1.set(e,r)}const DO=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,FO=e=>{const t=DO.exec(e);return t&&t[1]!=="hands"?`${t[1]} · ${t[2]}`:void 0},UO=e=>I1.get(e)??FO(e)??e,WO=new Map;function z1(e,t){WO.set(e,t)}const HO=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...HO];const Pg=e=>ls(e.path)??ls(e.file_path),BO=/page\.goto\(\s*["'`]([^"'`]+)/;kn("read",e=>`Read ${Pg(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});kn("write",e=>`Wrote ${Pg(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});kn("edit",e=>`Edited ${Pg(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});kn("bash",e=>`Ran \`${Bl(Mg(L1(ls(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const D1=e=>{const t=e&&pi(vd(e.text)??vd(L1(e.text)));if((t==null?void 0:t.ok)!==!1)return;const s=ls(t.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:ls(t.error)??ls(t.message)??"no detail"}},GO=(e,t)=>`${D1(t)?"Tried to fetch":"Fetched"} ${Gl(ls(e.url)??"a page")}`,qO={many:e=>`Fetched ${e} pages`,subject:e=>e?Gl(e):void 0},VO=e=>{const t=D1(e);return t&&{failed:!0,text:`${t.refused?"refused":"failed"}: ${t.detail}`}};kn("web_fetch",GO,qO,{name:"Fetch web pages"});z1("web_fetch",VO);kn("web_search",e=>{const t=ls(e.query);return t?`Searched the web for "${Bl(Mg(t),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${Bl(e,40)}"`:void 0},{name:"Search the web"});z1("web_search",e=>{var s;const t=ls((s=pi(vd(e.text)))==null?void 0:s.error);return t!==void 0?{failed:!0,text:`failed: ${t}`}:void 0});kn("browser_read",(e,t)=>{var r;const s=t&&((r=/^title: (.+)$/m.exec(t.text))==null?void 0:r[1]);return s?`Read the page "${Bl(Mg(s),60)}"`:"Read the page"},{many:e=>`Read ${e} pages`,subject:(e,t)=>{var r;const s=t&&((r=/^url: (\S+)/m.exec(t))==null?void 0:r[1]);return s?Gl(s):void 0}},{name:"Read the browser's page"});kn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});kn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});kn("run",(e,t)=>{var l,c;const s=(l=BO.exec(ls(e.code)??""))==null?void 0:l[1];if(s)return`Opened ${Gl(s)}`;const r=(c=pi(t==null?void 0:t.details))==null?void 0:c.sent,a=Array.isArray(r)?r.flatMap(u=>{const f=pi(u),[p,g]=[ls(f==null?void 0:f.method),ls(f==null?void 0:f.url)];return p&&g?`${p} ${Gl(g)}`:[]}):[];return a.length?`Acted on the page (${a.length} request${a.length===1?"":"s"} sent: ${LO(a)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});kn("browser_downloads",(e,t)=>{var a;const s=t&&((a=vd(t.text))==null?void 0:a.fetched),r=Array.isArray(s)?s.flatMap(l=>{var c;return ls((c=pi(l))==null?void 0:c.name)??[]}):[];return r.length===1?`Downloaded ${r[0]}`:r.length?`Downloaded ${r.length} files`:"Downloaded files"},{many:e=>`Downloaded files ${e} times`},{name:"Download files in the browser"});kn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});kn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});kn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});kn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});kn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const lw="https://api.githubcopilot.com/mcp/";function KO(e){const t=new URLSearchParams(e??""),s=t.get("add");if(!(!s||!/^[a-z][a-z0-9-]{0,31}$/.test(s)))return{name:s,...t.get("auth")==="github_app"?{auth:"github_app"}:{}}}const XO="These are the tools the server offers, not what this credential allows: a read-only token still sees its write tools. A call the credential can't make is refused by the server when a run makes it.",YO=(e,t)=>`mcp:${e}/${t}`;function wd(e){const t=/^mcp:([^/]+)\/(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const QO=/^[A-Za-z0-9_-]{1,52}$/;function ZO(e,t){if(e==="hands")return"hands is the harnesses' own name: save this server under another to grant its tools";const s=`mcp__${e}__${t}`;if(!QO.test(s))return/^[A-Za-z0-9_-]+$/.test(t)?`name too long to grant (${s.length}/52)`:"its name has a character a tool name can't carry"}function JO(e,t,s){const r=t.input_schema,a=s==="claude-agent"&&r&&typeof r=="object"?["anyOf","allOf","oneOf"].find(l=>l in r):void 0;return ZO(e,t.name)??(a?`claude-agent drops a tool whose schema's root has ${a}`:void 0)}function e5(e,t){return e.flatMap(s=>{const r=wd(s);if(!r)return[];const a=t.find(l=>l.name===r.server);return a?a.tools.some(l=>l.name===r.tool)?[]:[{grant:s,why:`${r.server} no longer lists ${r.tool}: refresh it, or untick this.`}]:[{grant:s,why:`The MCP server ${r.server} is not saved here any more, so a run can't call it.`}]})}const cw=e=>`Create an OAuth app with its provider (on GitHub, an OAuth App in your account's developer settings)${e?`, with ${e} as its callback URL,`:","} then enter its Client ID and Secret in this server's OAuth fields and sign in.`;function hi(e){var l,c,u,f,p,g,v;if(!(e instanceof Ee))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const t=(l=e.fields)==null?void 0:l.find(h=>h.field==="url"&&h.reason==="redirect"),s=(c=e.fields)==null?void 0:c.find(h=>h.field==="client_id"&&h.reason==="registration_unavailable"),r=(u=e.details)==null?void 0:u.oauth,a=typeof(r==null?void 0:r.callback)=="string"?r.callback:"";return s?{text:s.message,detail:cw(a),signIn:!0,needsClient:!0}:e.code==="auth_required"&&((f=e.details)==null?void 0:f.auth)==="oauth"&&(r==null?void 0:r.registration)===!1?{text:"This server signs in with OAuth, and its sign-in lets no app register itself.",detail:cw(a),signIn:!0,needsClient:!0}:e.code==="auth_required"?((p=e.details)==null?void 0:p.auth)==="oauth"?{text:"This server signs in with OAuth.",detail:"Sign in to it: its tools are saved once you approve.",signIn:!0}:{text:"This server asks for a token.",detail:e.message}:e.code==="github_not_connected"?{text:"GitHub is not connected on this server.",detail:`${e.message} A GitHub App server runs on this server's GitHub App: connect GitHub, or add a repository to its installation, in Settings → GitHub, then try again.`}:e.code==="not_mcp"?{text:"This address doesn't speak MCP.",detail:e.message}:t?{text:"This address redirects; use the final address.",detail:t.message}:e.status===424?{text:`The server failed: ${e.message}`}:e.code==="wrong_origin"?{text:"Sign in from this server's own address: the sign-in comes back there.",...typeof((g=e.details)==null?void 0:g.open)=="string"?{detail:`Open ${e.details.open} and sign in from it.`}:{}}:(v=e.fields)!=null&&v.length?{text:e.fields.map(h=>h.message).join(" ")}:{text:`${e.code}: ${e.message}`}}const uw={access_denied:"the sign-in was declined on its approval page",invalid_scope:"its authorization server doesn't offer the scopes asked for: change them and sign in again",invalid_grant:"its authorization server didn't take the sign-in's code (it expired, or was used already): sign in again",invalid_client:"its authorization server didn't take this client: check the client ID and secret, or leave them empty",unauthorized_client:"its authorization server doesn't let this client sign in this way: check the client ID, or leave it empty",invalid_request:"its authorization server refused the sign-in's request",unsupported_response_type:"its authorization server doesn't support this way of signing in",unsupported_grant_type:"its authorization server doesn't support this way of signing in",invalid_target:"its authorization server won't give a token for this MCP server",server_error:"its authorization server failed: try again",temporarily_unavailable:"its authorization server is busy: try again in a moment",login_required:"its authorization server wants you to sign in on its page: sign in again",interaction_required:"its authorization server wants you to sign in on its page: sign in again",consent_required:"its authorization server wants your consent on its page: sign in again",auth_required:"the MCP server didn't take the token the sign-in gave",not_mcp:"the address doesn't speak MCP",input_invalid:"the MCP server's tools could not be kept (too many of them, or the address redirects)",upstream_failed:"the MCP server or its authorization server failed: try again",unavailable:"this server was stopping: sign in again",changed_meanwhile:"the server was changed or removed while you signed in, so nothing was saved"},t5="the sign-in didn't finish: try again",n5=e=>e&&Object.hasOwn(uw,e)?uw[e]:t5;function s5(e){const t=new URLSearchParams(e??""),s=t.get("server"),r=t.get("sign_in");if(!(!s||r!=="ok"&&r!=="failed"))return{server:s,ok:r==="ok",...r==="failed"?{error:t.get("error")??"sign_in_failed"}:{}}}function cc(e){const t=/^mcp:([a-z][a-z0-9-]{0,31})\/(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}function r5(e){const t=/^mcp__([a-z][a-z0-9-]{0,31})__(.+)$/.exec(e);return t&&t[1]!=="hands"?`${t[1]} · ${t[2]}`:null}const Lg=(e,t)=>[e,t!=null&&t.model?t.tier:void 0,t==null?void 0:t.model].filter(Boolean).join(" · "),F1=e=>e!=null&&e.model?`ran on ${e.model}${e.tier?` (the ${e.tier} tier)`:""}`:"",o5={user_message:Vh,thinking:M_,tool_use:Ju,tool_result:Ju,waiting:Gh,usage:Uh,final_answer:gi,phase:P0,error:ai,decision:n$,text_block:Y_,tool_approval_requested:F0},dw=e=>{var t;return e.kind==="tool_approval_requested"?(t=/\n\n(Not sent: [\s\S]*)$/.exec(e.text??""))==null?void 0:t[1]:void 0},fw=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),Ig=e=>e.origin==="server",U1=e=>e.origin==="trigger",W1=e=>{var l;const t=e.summary??"",s=(l=e.trigger)==null?void 0:l.name,r=s?t.indexOf(` ${s}: `):-1;if(s&&r>0&&!t.slice(0,r).includes(" "))return{who:t.slice(0,r+1+s.length),said:t.slice(r+s.length+3).trimStart()};const a=/^([^:]+):\s*/.exec(t);return a?{who:a[1],said:t.slice(a[0].length)}:{who:null,said:t}};function H1(e){const t=e.split(/(\*\*[^*\n]+?\*\*|`[^`\n]+`)/);return t.length===1?e:t.map((s,r)=>r%2===0?s:s.startsWith("`")?n.jsx("code",{className:"font-mono",children:s.slice(1,-1)},r):n.jsx("strong",{className:"font-semibold",children:H1(s.slice(2,-2))},r))}const a5=e=>{var r;const t=U1(e)?W1(e).said:(e.summary??"").replace(Ig(e)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(e.kind==="user_message"&&t.startsWith("{"))try{return Object.entries(JSON.parse(t)).map(([a,l])=>`${a}: ${typeof l=="string"?l:JSON.stringify(l)}`).join(" · ")}catch{}const s=(e.text??"").split(`
535
+ `).filter(a=>a.trim()).length>1?"…":"";return e.kind==="final_answer"?!t.trim()&&!((r=e.text)!=null&&r.trim())?p1:`${t.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${t}${s}`:t},fh=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,i5=new Set(RO),l5=new Map(Object.entries({read:"Read",write:"Write",edit:"Edit",multiedit:"Edit",apply_patch:"Edit",notebookedit:"Edit",bash:"Shell",shell:"Shell",local_shell:"Shell",exec_command:"Shell",web_fetch:"Fetch",webfetch:"Fetch",fetch:"Fetch",web_search:"Search",websearch:"Search",ls:"List files",glob:"Find files",find:"Find files",grep:"Search files",ask_person:"Question",submit:"Answer",codemode:"Script",todowrite:"To-dos",task:"Subagent",skill:"Skill"}));function c5(e){const t=e.replace(/^mcp__.+?__/,""),s=l5.get(t.toLowerCase());if(s)return s;const r=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return r?r[0].toUpperCase()+r.slice(1):e}const mw=e=>e&&(r5(e)??(i5.has(e)?UO(e):c5(e))),pw=e=>Ig(e)?"AgentRun":U1(e)?W1(e).who??"Trigger":{user_message:"You",thinking:"Thinking",tool_use:mw(e.tool_name)??"Tool",tool_result:mw(e.tool_name)??"Result",waiting:"Waiting for you",usage:"Usage",final_answer:"Answer",phase:"Phase",error:"Error",decision:"Decision",text_block:"Text",tool_approval_requested:"Your approval",learning:"Learning"}[e.kind]??e.kind,u5={budget:"Paused at cap"};function d5({step:e,last:t,ended:s,waitingChip:r,files:a,onOpen:l}){var w;const c=e.row,[u,f]=x.useState(!1),g=V4(c)?O0:o5[c.kind]??P0,v=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":a5(c),h=e.above?null:e.detail??r1(c),m=h&&h.trim()!==v.trim()?h:null,b=a1(c);return n.jsxs("li",{className:"relative flex gap-3",children:[n.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[n.jsx("span",{className:oe("mt-3 flex size-7 items-center justify-center border bg-background",(c.kind==="waiting"||fw(c))&&"border-warning/60 text-warning-text",b&&"border-destructive/60 text-destructive-text"),children:n.jsx(g,{className:"size-3.5","aria-hidden":!0})}),!t&&n.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),n.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[n.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>f(j=>!j),"aria-expanded":u,disabled:!m,children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[n.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:pw(c),children:pw(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&n.jsxs("span",{className:"font-mono text-label",children:["· ",O4(c.usage,{ended:s})]}),c.kind==="waiting"&&n.jsx(Ce,{tone:"warning",children:r??"Input required"}),fw(c)&&n.jsx(Ce,{tone:"warning",children:"Approval required"}),b&&n.jsx(Ce,{tone:"error",children:"Error"}),o1(c)&&n.jsx(Ce,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&n.jsx(Ce,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&n.jsx("span",{className:"font-mono text-label",children:fh(e.ms)}),e.times&&n.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${fh(Math.max(0,Date.parse(e.until)-Date.parse(c.timestamp)))}`:""]})]}),n.jsx("span",{className:oe("mt-0.5 block break-words text-prose leading-snug",Ig(c)&&"text-muted-foreground"),children:H1(v)}),e.saved&&n.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),dw(c)&&n.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:dw(c)})]}),n.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:rf(c.timestamp)}),m&&n.jsx(Rs,{className:oe("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",u&&"rotate-90"),"aria-hidden":!0})]}),u&&m&&c.tool_name&&n.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:c.tool_name}),u&&m&&c.kind==="final_answer"&&n.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:kg(j=>{const N=a==null?void 0:a.find(R=>R.path===j);N&&(l==null||l(N))}),dangerouslySetInnerHTML:{__html:mo(m,l&&a?{paths:a.map(j=>j.path)}:void 0)}}),u&&m&&c.kind!=="final_answer"&&n.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:m}),(w=c.learned_nodes)!=null&&w.length?n.jsx(m5,{nodes:c.learned_nodes}):null]})]})}const f5={ok:"success",failed:"error",escalated:"warning"};function m5({nodes:e}){const[t,s]=x.useState(!1),r=Object.entries(e.reduce((l,c)=>({...l,[c.status]:(l[c.status]??0)+1}),{})).filter(([l])=>l!=="ok"),a=[`${e.length} ${e.length===1?"node":"nodes"}`,...r.map(([l,c])=>`${c} ${l}`)].join(" · ");return n.jsxs("div",{className:"mt-2",children:[n.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>s(l=>!l),"aria-expanded":t,"aria-label":`${t?"Hide":"Show"} the workflow's ${e.length===1?"node":"nodes"}`,children:[n.jsx(Rs,{className:oe("size-3 transition-transform",t&&"rotate-90"),"aria-hidden":!0}),n.jsx(ia,{className:"size-3","aria-hidden":!0}),a]}),t&&n.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((l,c)=>n.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[n.jsx("span",{"data-status":l.status,className:"contents",children:n.jsx(Ce,{tone:f5[l.status]??"muted",className:"w-[5.5rem] justify-center",children:l.status})}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:l.label,children:l.label}),n.jsx("span",{"data-kind":!0,className:"font-mono text-label text-muted-foreground",title:F1(l)||void 0,children:Lg(l.kind,l)}),n.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:fh(l.duration_ms)})]},c))})]})}function B1({rows:e,live:t,fold:s=6,asking:r,waitingOn:a,files:l,onOpen:c,ended:u=!1}){var w;const f=a==="budget"?e.findLastIndex(j=>j.paused===!0):-1,p=f>=0?(w=e.slice(f+1).findLast(j=>j.kind==="waiting"))==null?void 0:w.id:void 0,[g,v]=x.useState(!1),h=K4(e).map(j=>r&&j.row.id===r?{...j,above:!0}:j),m=g?0:Math.max(0,h.length-s),b=h.slice(m);return e.length?n.jsxs("div",{children:[m>0&&n.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>v(!0),children:[n.jsx(Rs,{className:"size-3","aria-hidden":!0})," ",m," earlier ",m===1?"step":"steps"]}),n.jsx("ol",{children:b.map((j,N)=>n.jsx(d5,{step:j,last:N===b.length-1&&!t,ended:u,waitingChip:j.row.id===p&&a?u5[a]:void 0,files:l,onOpen:c},j.row.id))}),t&&n.jsx(mh,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):n.jsx(mh,{title:t?"The run is starting":"Nothing on the timeline",note:t?"Steps appear here as the agent works.":"This run recorded no steps.",spin:t})}function mh({title:e,note:t,spin:s=!0}){return n.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[s&&n.jsx(vA,{className:"size-5"}),n.jsx("p",{className:"caps text-label font-semibold",children:e}),n.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:t})]})}const hw=new Set(["completed","failed","cancelled"]),p5={firstMs:2e3,maxMs:16e3,totalMs:12e4};function G1(e,t,s,r=p5){var g;const a=!!e&&hw.has(e.status)&&j1(e.learning),l=x.useRef(t);l.current=t;const c=x.useRef(s);c.current=s;const u=(g=e==null?void 0:e.learning)==null?void 0:g.state,f=!!e&&hw.has(e.status),p=x.useRef(u);x.useEffect(()=>{var h;const v=p.current;p.current=u,v!==void 0&&v!==u&&f&&((h=c.current)==null||h.call(c))},[u,f]),x.useEffect(()=>{if(!a)return;let v,h=0,m=r.firstMs,b=!1,w=!1;const j=()=>{w||h+m>r.totalMs||(v=setTimeout(N,m))},N=()=>{if(v=void 0,document.visibilityState==="hidden"){b=!0;return}h+=m,m=Math.min(m*2,r.maxMs),l.current(),j()},R=()=>{b&&document.visibilityState!=="hidden"&&(b=!1,N())};return document.addEventListener("visibilitychange",R),j(),()=>{w=!0,v&&clearTimeout(v),document.removeEventListener("visibilitychange",R)}},[a])}function h5({v2:e,run:t,onRun:s}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,f]=x.useState(null),[p,g]=x.useState(null),[v,h]=x.useState(!1),[m,b]=x.useState(0),w=x.useRef(md()).current,j=x.useRef(`${t.status}/${t.state}`),N=x.useRef(null),R=x.useRef(j.current),$=async C=>{const T=w.begin();N.current=C;let A="";for(const F of lh){if(F&&await h1(F),!w.current(T))return;try{const L=await e.getRun(t.run_id);if(!w.current(T))return;j.current=C,N.current=null,g(null),s(L);return}catch(L){A=Jt(L)}}w.current(T)&&(N.current=null,g(A))};x.useEffect(()=>{const C=new AbortController;return _g(e,t.run_id,{signal:C.signal,onRows:a,onPage:T=>{f({status:T.status,state:T.state});const A=`${T.status}/${T.state}`,F=A!==R.current;if(R.current=A,A===j.current){w.cancel(),N.current=null,g(null);return}(F||N.current===null)&&$(A)}}).catch(T=>{C.signal.aborted||c(Jt(T))}),()=>{C.abort(),w.cancel(),N.current=null}},[e,t.run_id,m]),G1(t,()=>{const C=j.current;e.getRun(t.run_id).then(T=>{j.current===C&&N.current===null&&s(T)},()=>{})},()=>b(C=>C+1));const S=`#/runs/${encodeURIComponent(t.run_id)}`,E=u??t;return n.jsxs("section",{className:"mb-6 border","aria-label":"Latest run",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"Latest run"}),p?n.jsx(Ce,{tone:"muted",children:"Not refreshed"}):n.jsx(lc,{run:t}),n.jsx("a",{href:S,className:"min-w-0 flex-1 truncate text-lead hover:underline",title:mn(t),children:mn(t)}),n.jsx(lf,{run:t,link:!0}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ft(t.created_at)}),n.jsxs("a",{href:S,className:mi({size:"sm"}),children:["Open the run ",n.jsx(Dh,{"aria-hidden":!0})]})]}),p&&n.jsxs("p",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2 font-mono text-small text-destructive-text",role:"alert",children:["This run could not be refreshed: ",p,n.jsx(V,{type:"button",disabled:v,onClick:()=>{h(!0),$(R.current).finally(()=>h(!1))},size:"xs",className:"text-foreground",children:v?"Retrying":"Retry"})]}),n.jsx("div",{className:"px-4 py-3",children:l?n.jsxs("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:["The timeline could not be read: ",l]}):r?n.jsx(B1,{rows:M1(r,t.learning),live:ic(E.status,E.state,t.kind,ac,!0).live,ended:ra(E.status)}):n.jsx("p",{className:"py-6 text-center font-mono text-body text-muted-foreground",children:"Reading the timeline..."})})]})}function Mn({problem:e,onRetry:t,link:s,className:r="m-8"}){return n.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${r}`,role:"alert",children:[n.jsx(ar,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-prose font-semibold",children:e.title}),n.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&n.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),(t||s)&&n.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[t&&n.jsx(V,{type:"button",onClick:t,size:"sm",children:"Try again"}),s&&n.jsx("a",{href:s.href,className:"caps border px-3 py-2 text-small hover:bg-accent",children:s.label})]})]})]})}function q1({what:e,id:t,list:s}){return n.jsx(Mn,{problem:{title:`No ${e} with this id.`,why:`This server has no ${e} ${t}.`,next:`Check the address, or find the ${e} in the list.`},link:s})}function g5(e,{base:t="/v2",onProgress:s,signal:r,request:a=()=>new XMLHttpRequest}={}){return new Promise((l,c)=>{if(r!=null&&r.aborted)return c(new Ee(0,"aborted","The upload was stopped."));const u=a();u.open("POST",`${t}/files?path=${encodeURIComponent(e.name)}`),u.setRequestHeader("accept","application/json"),e.type&&u.setRequestHeader("content-type",e.type),u.upload.onprogress=f=>{f.lengthComputable&&f.total>0&&(s==null||s(Math.min(1,f.loaded/f.total)))},u.onload=()=>{let f=null;try{f=JSON.parse(u.responseText)}catch{}if(u.status===201||u.status===200){const v=f==null?void 0:f.file;return v!=null&&v.file_id?(s==null||s(1),l(v)):c(new Ee(u.status,"bad_answer","The server's answer named no file."))}const p=f==null?void 0:f.error,g=new Ee(u.status,(p==null?void 0:p.code)??"http_error",(p==null?void 0:p.message)??`The server answered ${u.status}.`,(p==null?void 0:p.retryable)??!1,p==null?void 0:p.request_id);p!=null&&p.fields&&(g.fields=p.fields),c(g)},u.onerror=()=>c(new Ee(0,"network","The upload did not reach the server.")),u.onabort=()=>c(new Ee(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>u.abort(),{once:!0}),u.send(e)})}const V1=(e,t,s)=>g5(e,{onProgress:t,signal:s});function Sp(e){if(!(e instanceof Ee))return e instanceof Error?e.message:String(e);const t=(e.fields??[]).filter(s=>s.message!==e.message).map(s=>s.message);return[e.message,...t].join(" ")}function K1({upload:e,remove:t,limits:s,frozen:r=!1}){const[a,l]=x.useState([]),[c,u]=x.useState([]),f=x.useRef(new Map),p=x.useRef(0),g=x.useRef(0);g.current=a.length;const v=x.useRef({items:a,frozen:r,remove:t});v.current={items:a,frozen:r,remove:t};const h=x.useRef(!0);x.useEffect(()=>{h.current=!0;const N=f.current;return()=>{var E;h.current=!1;for(const C of N.values())C.abort();const{items:R,frozen:$,remove:S}=v.current;if(!$)for(const C of R)C.file&&!C.removing&&((E=S==null?void 0:S(C.file.file_id))==null||E.catch(()=>{}))}},[]);const m=x.useCallback(N=>{if(v.current.frozen)return;const R=[],$=s?s.max_files_per_run-g.current:1/0,S=(s==null?void 0:s.max_upload_bytes)??null,E=[];for(const T of N)S!==null&&T.size>S?R.push({text:`${T.name} is ${ui(T.size)}: this server takes files up to ${ui(S)}.`}):E.length>=$?R.push({text:`${T.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):E.push(T);u(R);const C=E.map(T=>({key:`f${p.current++}`,name:T.name,size:T.size,progress:0}));g.current+=C.length,l(T=>[...T,...C]),C.forEach((T,A)=>{const F=new AbortController;f.current.set(T.key,F);const L=z=>{h.current&&l(W=>W.map(U=>U.key===T.key?{...U,...z}:U))};e(E[A],z=>L({progress:z}),F.signal).then(z=>{var W,U,D;if(f.current.delete(T.key),F.signal.aborted){(D=(U=(W=v.current).remove)==null?void 0:U.call(W,z.file_id))==null||D.catch(K=>{h.current&&u(P=>[...P,{text:`${T.name} was sent before it was stopped, and was not removed: ${Sp(K)}`}])});return}L({file:z,progress:1})},z=>{f.current.delete(T.key),!(F.signal.aborted||!h.current)&&(l(W=>W.filter(U=>U.key!==T.key)),u(W=>[...W,{text:`${T.name}: ${Sp(z)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),b=x.useCallback(N=>{var C;const{items:R,frozen:$,remove:S}=v.current,E=R.find(T=>T.key===N);if(!($||!E||E.removing)){if(!E.file||!S){(C=f.current.get(N))==null||C.abort(),f.current.delete(N),l(T=>T.filter(A=>A.key!==N));return}l(T=>T.map(A=>A.key===N?{...A,removing:!0}:A)),u(T=>T.filter(A=>A.about!==N)),S(E.file.file_id).then(()=>{h.current&&l(T=>T.filter(A=>A.key!==N))},T=>{h.current&&(l(A=>A.map(F=>F.key===N?{...F,removing:!1}:F)),u(A=>[...A,{about:N,text:`${E.name} was not removed: ${Sp(T)}`}]))})}},[]),w=x.useCallback(()=>{v.current={...v.current,items:[]},l([]),u([])},[]),j=a.flatMap(N=>N.file&&!N.removing?[N.file.file_id]:[]);return{items:a,refusals:c.map(N=>N.text),add:m,drop:b,clear:w,fileIds:j,frozen:r,busy:a.some(N=>!N.file||N.removing)}}function ph({attachments:e,limits:t,disabled:s,compact:r=!1}){const a=x.useRef(null),[l,c]=x.useState(!1),{items:u,refusals:f,add:p,drop:g}=e,v=s||e.frozen,h=t?[`up to ${t.max_files_per_run} files`,...t.max_upload_bytes!==null?[`${ui(t.max_upload_bytes)} each`]:[]].join(", "):"";return n.jsxs("div",{className:oe("border border-dashed px-3 py-2.5",l?"border-primary bg-primary/5":"border-border",r&&"max-sm:border-0 max-sm:p-0"),onDragOver:m=>{v||(m.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:m=>{m.preventDefault(),c(!1),v||p([...m.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(V,{type:"button",size:"sm",onClick:()=>{var m;return(m=a.current)==null?void 0:m.click()},disabled:v,title:r?`Attach files${h?` (${h})`:""}`:void 0,className:oe(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[n.jsx(J_,{"aria-hidden":!0})," ",n.jsx("span",{className:oe(r&&"max-sm:sr-only"),children:"Attach files"})]}),n.jsxs("span",{className:oe("text-small text-muted-foreground",r&&"max-sm:hidden"),children:["or drop them here",h?` (${h})`:"",". The run finds them in inputs/."]}),n.jsx("input",{ref:a,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:m=>{p([...m.target.files??[]]),m.target.value=""}})]}),u.length>0&&n.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:u.map(m=>n.jsxs("li",{className:"flex h-7 items-center gap-2 border bg-card px-2 font-mono text-small",children:[n.jsx("span",{className:"max-w-[16rem] truncate",title:m.name,children:m.name}),n.jsx("span",{className:"text-muted-foreground",children:ui(m.size)}),!m.file&&n.jsxs("span",{className:"text-muted-foreground","aria-label":`${m.name} sent ${Math.round(m.progress*100)}%`,children:[Math.round(m.progress*100),"%"]}),m.removing&&n.jsx("span",{className:"text-muted-foreground",children:"removing"}),n.jsx("button",{type:"button",onClick:()=>g(m.key),disabled:v||m.removing,"aria-label":`Remove ${m.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:n.jsx(Yl,{className:"size-3.5","aria-hidden":!0})})]},m.key))}),u.some(m=>!m.file)&&n.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),f.length>0&&n.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:f.map((m,b)=>n.jsx("li",{children:m},`${b}:${m}`))})]})}const x5=["pi","claude-agent","codex","opencode"];function y5(e){const t=new Set,s=r=>{if(Array.isArray(r)){r.forEach(s);return}if(!r||typeof r!="object")return;const a=r;a.node==="call"&&typeof a.tool=="string"&&t.add(a.tool),Object.values(a).forEach(s)};return s(e),[...t].sort()}function b5(e){const t=s=>Array.isArray(s)&&s.every(r=>typeof r=="string")?[...new Set(s)]:[];return{denied:t(e==null?void 0:e.denied),asks:t(e==null?void 0:e.asks)}}function v5(e){return(Array.isArray(e)?e:[]).flatMap(t=>{const s=t;return!s||typeof s.name!="string"||!Array.isArray(s.providers)||!s.providers.length?[]:[{name:s.name,providers:s.providers,provider:s.provider??s.providers[0],default_provider:s.default_provider??s.providers[0],resolves:s.resolves&&typeof s.resolves=="object"?s.resolves:{},available:s.available!==!1,...typeof s.reason=="string"&&s.reason?{reason:s.reason}:{}}]})}const zg="Refused on this server for every agent, whatever the agent's own setting or Never ask.",w5="Deny stops this tool only. The agent can still reach the web with other tools it has, such as browser, bash or web_search: deny those too to keep it offline.",X1=(e,t,s,r)=>{var u;const a=s==null?void 0:s.find(f=>f.name===e);if(a)return a.permission==="deny"&&a.permission_from==="server";const l=/^mcp:([^/]+)\/(.+)$/.exec(e),c=l?(u=r==null?void 0:r.find(f=>f.name===l[1]))==null?void 0:u.tools.find(f=>f.name===l[2]):void 0;return c?c.permission==="deny":t.some(f=>f.name===e&&f.permission==="deny")};function k5(e){return(e??[]).map(({name:t,permission:s,default_permission:r,permissions:a,ask_needs:l})=>({name:t,permission:s,default_permission:r,permissions:a,...l==="password"?{ask_needs:l}:{}}))}const j5={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},Y1={browser:{label:{auto:"Auto (Browserbase where its key is saved, else Kernel)",browserbase:"Browserbase",kernel:"Kernel",chrome:"Local Chrome"},help:{auto:"Browserbase where its key is set or saved, else Kernel where its key is; unavailable with neither.",browserbase:"Browserbase's hosted browser: needs the Browserbase key and project id.",kernel:"Kernel's hosted browser: needs the Kernel key.",chrome:"A Chrome on this server's own host. No server sets one up yet, so it stays unavailable."}}},kd=(e,t)=>{var s;return(t&&((s=Y1[t])==null?void 0:s.label[e]))??j5[e]??e},N5={auto:"The harness's own search, or the model provider's hosted one; else Parallel where this server holds its key; else keyless Exa.",native:"The harness's own search, or the model provider's hosted one, never a third party: unavailable where there is none.","exa-keyless":"Exa's keyless search: no key, a third party.",parallel:"Parallel: needs the Parallel key.",kernel:"This server's own fetch, guarded against private addresses."},gw=(e,t)=>{var s;return(t&&((s=Y1[t])==null?void 0:s.help[e]))??N5[e]};function Q1(e,t){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:kd(e,t),unavailable:!1}:{text:"not known",unavailable:!1}}function Z1(e,t,s,r,a){const{[t]:l,...c}=e,{[s]:u,...f}=l??{},p=r===void 0||r===a?f:{...f,[s]:r};return Object.keys(p).length?{...c,[t]:p}:c}const S5=(e,t,s,r)=>Z1(e,t,"provider",s,r),_5=(e,t,s,r)=>Z1(e,t,"permission",s,r);function xw(e,t){const s=new Map(t.map(r=>[r.name,r.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([r,a])=>{if(!a||typeof a!="object")return[];const{provider:l,...c}=a,u=l!==void 0&&!(s.has(r)&&l===s.get(r))?{...c,provider:l}:c;return Object.keys(u).length?[[r,u]]:[]}))}function J1(e,t,s){const r={},a=[];for(const[l,c]of Object.entries(e)){if(t&&l!==t&&!l.startsWith(`${t}.`)&&!l.startsWith(`${t}/`))continue;const u=t?l.slice(t.length+1):l,f=[...s].sort((p,g)=>g.length-p.length).find(p=>u===p||u.startsWith(`${p}.`)||u.startsWith(`${p}/`));f?(r[f]??(r[f]=[])).push(c):a.push(c)}return{byTool:r,rest:a}}const $5=e=>{if(!Array.isArray(e))return[e];const t=[...new Set(e.filter(s=>s!==null).map(s=>JSON.stringify(s)))].sort();return[...e.includes(null)?[null]:[],...t.map(s=>JSON.parse(s))]},E5=e=>typeof e=="string"?e:JSON.stringify(e);function C5(e){return Object.keys(e).sort().map(t=>{const s=$5(e[t]),r=s[0]===null,a=(r?s.slice(1):s).map(c=>E5(c));if(!a.length)return`${t} must be left out`;const l=a.length===1?a[0]:`one of ${a.join(", ")}`;return`${t} must be ${r?`left out or ${l}`:l}`}).join("; ")}const T5="Calls outside it are refused before they run or ask.",R5="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.";function eN({agentId:e,details:t}){const{denied:s,asks:r}=b5(t),a=[...new Set([...s,...r])];return a.length?n.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[a.map(l=>n.jsxs("a",{href:`#/agents/${encodeURIComponent(e)}/edit?tool=${encodeURIComponent(l)}`,className:"underline underline-offset-4",children:["Set ",l," for this agent"]},l)),n.jsxs("span",{children:["or for every agent: ",n.jsx("a",{href:"#/settings/tools",className:"underline underline-offset-4",children:"Settings → Tools"})]})]}):null}function rr(e){if(Number.isInteger(e))return`$${e}`;for(let t=2;t<8;t++)if(Number(e.toFixed(t))===Number(e.toFixed(8)))return`$${e.toFixed(t)}`;return`$${e.toFixed(8)}`}const tN=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${rr(e.cap_usd)} `:""}spend cap`;function A5({pending:e}){return n.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Paused at its spend cap",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[n.jsx(Uh,{className:"size-3.5","aria-hidden":!0})," ",tN(e)]}),typeof e.said=="string"&&n.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:e.said}),n.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"It waits for its cap to be raised; a message can't go on until then."})]})}const nN=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,sN=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function O5(e){var t,s;return e instanceof Ee?e.status===422?((s=(t=e.fields)==null?void 0:t[0])==null?void 0:s.message)??e.message:e.status===409?"This run has ended, so its cap can't be raised.":e.status===404?"This run is no longer on the server.":e.message:e instanceof Error?e.message:String(e)}function rN({cap:e,suggested:t,least:s=null,paused:r,onRaise:a}){const[l,c]=x.useState(t===null?"":String(t)),[u,f]=x.useState(!1),[p,g]=x.useState(null),[v,h]=x.useState(null),m=x.useRef(!1),b=Number(l),w=l.trim()!==""&&Number.isFinite(b)&&b>0,j=async N=>{if(N==null||N.preventDefault(),!(!w||m.current)){m.current=!0,f(!0),g(null),h(null);try{const R=await a(b);R.note&&h(R.note)}catch(R){g(O5(R))}finally{m.current=!1,f(!1)}}};return n.jsxs("form",{className:"border border-warning/50 p-4","aria-label":"Raise the cap",onSubmit:N=>void j(N),children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsxs("label",{className:"flex items-center gap-2 font-mono text-body",children:[n.jsx("span",{className:"text-muted-foreground",children:"$"}),n.jsx(Ue,{"aria-label":"New cap in dollars",inputMode:"decimal",value:l,onChange:N=>c(N.target.value),disabled:u,placeholder:`more than ${rr(e)}`,className:"h-9 w-32"})]}),n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:u||!w,children:u?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||t!==null)&&n.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&n.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",rr(s)]}),t!==null&&n.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",rr(t)]})]}),t!==null&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),p&&n.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:p}),v&&n.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:v})]})}function M5({waiting:e}){if(e){const t=(e.text??e.summary??"").replace(/^Waiting for you:\s*/,"");return n.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"The agent asks",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[n.jsx(Gh,{className:"size-3.5","aria-hidden":!0})," Input required"]}),n.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:t})]})}return n.jsxs("section",{className:"border border-border-strong/60 p-4","aria-label":"Stopped",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[n.jsx(ii,{className:"size-3.5","aria-hidden":!0})," Stopped"]}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The turn was stopped. The run stays open: send a message to continue it."})]})}function cf(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Ks(e=cf){let t=null;return{keyFor(s,r){const a=JSON.stringify([s,r]);return(t==null?void 0:t.request)!==a&&(t={request:a,key:e()}),t.key},done(){t=null}}}async function oN(e,t,s,r){const a=await r(t,s,e.keyFor(t,{content:s}));return e.done(),a}function P5(e=cf){const t=new Map;return s=>{let r=t.get(s);return r||(r=Ks(e),t.set(s,r)),r}}function aN(e,t){const s=new Set(e.map(r=>r.run_id));return[...e,...t.filter(r=>!s.has(r.run_id))]}function iN(e,t){var l,c,u;let s;if(e==="agentic"){if(!t.text.trim())return{ok:!1,field:"input",message:"Write the run's first message."};s={content:t.text}}else try{s=JSON.parse(t.text)}catch{return{ok:!1,field:"input",message:"The workflow's input is JSON: this is not."}}const r={input:s};if(t.revision&&(r.revision=t.revision),t.effort&&(r.effort=t.effort),e==="agentic"&&((l=t.maxCostUsd)!=null&&l.trim())){const f=Number(t.maxCostUsd);if(!Number.isFinite(f)||f<=0)return{ok:!1,field:"max_cost_usd",message:"A spend cap is a positive number of dollars."};r.max_cost_usd=f}(c=t.fileIds)!=null&&c.length&&(r.file_ids=[...t.fileIds]);const a=e==="agentic"?(u=t.repo)==null?void 0:u.trim():void 0;if(a){if(!/^[^/\s]+\/[^/\s]+$/.test(a))return{ok:!1,field:"repo",message:"A repository is owner/name, like Parcha-ai/agentrun."};r.repo=a}return{ok:!0,body:r}}function L5(e,t){return s=>{var a,l,c;const r=new Set;for(;s!=null&&s.$ref&&!r.has(s.$ref);){r.add(s.$ref);const u=(l=(a=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref))==null?void 0:a[1])==null?void 0:l.replace(/~1/g,"/").replace(/~0/g,"~"),f=u===void 0?void 0:((c=e.definitions)==null?void 0:c[u])??(Object.hasOwn(t,u)?t[u]:void 0);if(!f)break;s=f}return s}}function lN(e,t){if(e.from==="example")return`The workflow's example input. Edit it, then ${t}.`;const s=e.optional.length?` It also takes ${e.optional.join(", ")}, if you add ${e.optional.length===1?"it":"them"}.`:"";return`The workflow's input, its required fields empty. Fill them in, then ${t}.${s}`}function cN(e){var p,g,v;const t=e,s=(p=t==null?void 0:t.input)!=null&&p.schemaId?(g=t.schemas)==null?void 0:g[t.input.schemaId]:void 0;if(!s)return null;const r=L5(s,(t==null?void 0:t.schemas)??{}),a=r(s),l=Object.entries(a.properties??{}).map(([h,m])=>{const b=r(m);return{name:h,...b!=null&&b.description?{note:b.description}:{}}}),c=((v=a.examples)==null?void 0:v[0])??a.default;if(c!==void 0)return{text:JSON.stringify(c,null,2),from:"example",fields:l,optional:[]};const u=(h,m=0)=>{var j,N;const b=r(h);if(!b||m>4)return null;if((j=b.examples)!=null&&j.length)return b.examples[0];if(b.default!==void 0)return b.default;if((N=b.enum)!=null&&N.length)return b.enum[0];const w=Array.isArray(b.type)?b.type[0]:b.type;return w==="object"||b.properties?Object.fromEntries(Object.entries(b.properties??{}).filter(([R])=>(b.required??[]).includes(R)).map(([R,$])=>[R,u($,m+1)])):w==="array"?[]:w==="string"?"":w==="number"||w==="integer"?0:w==="boolean"?!1:null},f=new Set(a.required??[]);return{text:JSON.stringify(u(a),null,2),from:"shape",fields:l,optional:l.map(h=>h.name).filter(h=>!f.has(h))}}const _p=e=>`'${e.replace(/'/g,"'\\''")}'`;function I5(e,t,s,r){return[`curl -X POST ${_p(`${e}/v2/agents/${t?encodeURIComponent(t):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${_p(`Idempotency-Key: ${r}`)} \\`,` -d ${_p(JSON.stringify(s))}`].join(`
536
+ `)}const z5=e=>e>=200&&e<300;async function uN(e,t,s,r){const a=await r(t,s,e.keyFor(t,s));return z5(a.status)&&e.done(),a}function D5({agent:e,efforts:t,v2:s,go:r,blocked:a,limits:l,upload:c=V1}){var W,U;const u=e.kind==="workflow",f=x.useMemo(()=>u?cN(e.definition.workflow):null,[u,e.definition.workflow]),[p,g]=x.useState((f==null?void 0:f.text)??""),[v,h]=x.useState(""),[m,b]=x.useState(""),[w,j]=x.useState(null),N=x.useMemo(()=>Ks(),[]),[R,$]=x.useState(!1),S=K1({upload:c,remove:s.deleteUpload,limits:l,frozen:R}),E=iN(e.kind,{text:p,effort:v,maxCostUsd:m,fileIds:S.fileIds}),C=typeof e.definition.max_cost_usd=="number"?e.definition.max_cost_usd:null,T=async(D,K,P)=>{var G;try{const I=await s.startRun(D,K,P);return{status:I.status,runId:I.run.run_id}}catch(I){return I instanceof Ee?{status:I.status,problem:{message:I.message,fields:I.fields,...I.code==="agent_not_runnable"&&typeof((G=I.details)==null?void 0:G.box)=="string"?{box:I.details.box}:{},...I.code==="agent_not_runnable"&&I.details?{details:I.details}:{}}}:{status:0,problem:{message:I instanceof Error?I.message:String(I)}}}},A=x.useRef(!0);x.useEffect(()=>(A.current=!0,()=>{A.current=!1}),[]);const F=async()=>{if(!E.ok||R||a||S.busy)return;$(!0),j(null);const D=await uN(N,e.agent_id,E.body,T);A.current&&($(!1),D.runId?(S.clear(),r(`#/runs/${encodeURIComponent(D.runId)}`)):j(D.problem??{message:`The server answered ${D.status}.`}))},L=u?null:!E.ok&&E.field==="max_cost_usd"?E.message:((U=(W=w==null?void 0:w.fields)==null?void 0:W.find(D=>D.field==="max_cost_usd"))==null?void 0:U.message)??null,z=((w==null?void 0:w.fields)??[]).filter(D=>D.message!==(w==null?void 0:w.message)&&!(L&&D.field==="max_cost_usd"));return n.jsxs("section",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8","aria-label":"Start a run",children:[n.jsxs("div",{"data-phone-row":!0,className:"max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:gap-x-2 max-sm:gap-y-2",children:[n.jsxs("div",{className:"flex flex-col gap-3 max-sm:contents lg:flex-row lg:items-start",children:[n.jsx(As,{value:p,onChange:D=>g(D.target.value),rows:u?6:2,spellCheck:!u,"aria-label":u?"The run's input, as JSON":"The run's first message",placeholder:u?"The workflow's input, as JSON":"The run's first message",onKeyDown:D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&(D.preventDefault(),F())},className:oe("min-w-0 flex-1 resize-y max-sm:order-first max-sm:basis-full",u?"leading-[1.6]":"max-sm:h-10")}),n.jsxs("div",{"data-controls":!0,className:"flex items-center gap-3 max-sm:order-last max-sm:min-w-0 max-sm:max-w-full max-sm:flex-wrap max-sm:gap-2 sm:shrink-0",children:[t.length>0&&n.jsxs("div",{className:"flex items-center gap-2",title:"How hard the model thinks before it answers. default leaves it to the agent.",children:[n.jsxs("span",{className:"flex flex-col leading-tight",children:[n.jsx("label",{htmlFor:"runbar-effort",className:"caps text-label text-muted-foreground",children:"Effort"}),n.jsx("span",{className:"text-label text-muted-foreground max-sm:hidden",children:"How hard the model thinks"})]}),n.jsx(Lt,{id:"runbar-effort",label:"Effort",value:v,onChange:h,className:"w-32",options:["",...t].map(D=>({value:D,label:D||"default"}))})]}),!u&&n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"flex items-center gap-2",title:C!==null?`This run's spend cap in US dollars. Empty uses the agent's default, ${rr(C)}.`:"This run's spend cap in US dollars. Empty runs it with no cap.",children:[n.jsxs("span",{className:"flex flex-col leading-tight",children:[n.jsx("label",{htmlFor:"runbar-cap",className:"caps text-label text-muted-foreground",children:"Spend cap"}),n.jsx("span",{className:"text-label text-muted-foreground max-sm:hidden",children:"This run, US dollars"})]}),n.jsx(Ue,{id:"runbar-cap",value:m,onChange:D=>{var K;b(D.target.value),(K=w==null?void 0:w.fields)!=null&&K.some(P=>P.field==="max_cost_usd")&&j(null)},inputMode:"decimal","aria-label":"Spend cap","aria-invalid":L?!0:void 0,placeholder:C!==null?rr(C):"none",className:"w-24"})]}),L&&n.jsx("p",{className:"mt-1 max-w-[16rem] font-mono text-label text-destructive-text",role:"alert","data-issue":"max_cost_usd",children:L})]}),n.jsxs(V,{variant:"solid",onClick:()=>void F(),disabled:!E.ok||R||!!a||S.busy,title:a??(S.busy?"Waiting for the files to be sent":void 0),children:[n.jsx(yi,{"aria-hidden":!0})," ",R?"Starting":"Run"]})]})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 max-sm:mt-0",children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx(ph,{attachments:S,limits:l,disabled:!!a,compact:!0})}),n.jsx(Tg,{label:"Run with your coding agent",className:"max-sm:hidden",unavailable:S.items.length?"Remove the attached files first: they are for a run started here, and are deleted when you leave this page. Your coding agent uploads its own.":!E.ok&&E.field==="max_cost_usd"&&m.trim()?"Fix the spend cap first: the handoff carries it, and a cap that is not a positive number of dollars cannot be handed over.":void 0,context:()=>({kind:"run",agentId:e.agent_id,revision:e.revision,...E.ok?{input:E.body.input}:{},...v?{effort:v}:{},...E.ok&&E.body.max_cost_usd!==void 0?{maxCostUsd:E.body.max_cost_usd}:{}})})]})]}),f&&n.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:lN(f,"run")}),!E.ok&&E.field!=="max_cost_usd"&&p.trim()&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:E.message}),w&&n.jsxs("div",{className:"mt-3 border border-destructive/50 bg-destructive/10 px-3 py-2 font-mono text-small text-destructive-text",role:"alert",children:[n.jsxs("p",{children:["The run did not start: ",w.message]}),w.box&&n.jsxs("p",{className:"mt-1",children:["This server can't run the ",w.box," box this agent runs in: change where it runs in its settings."]}),n.jsx(eN,{agentId:e.agent_id,details:w.details}),z.length>0&&n.jsx("ul",{className:"mt-1",children:z.map(D=>n.jsxs("li",{children:[D.field,": ",D.message]},`${D.field}:${D.message}`))})]})]})}function Bt({className:e}){return n.jsx("span",{"aria-hidden":!0,className:oe("block bg-muted motion-safe:animate-pulse",e)})}function uf({label:e,className:t,children:s}){return n.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:t,children:[s,n.jsxs("span",{className:"sr-only",children:[e,"…"]})]})}function F5(){return n.jsxs(uf,{label:"Loading Mission Control",className:"mx-auto max-w-[1600px] space-y-8 px-6 py-8",children:[n.jsx(Bt,{className:"h-8 w-56"}),n.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:Array.from({length:6},(e,t)=>n.jsxs("div",{className:"border p-4",children:[n.jsx(Bt,{className:"h-3 w-16"}),n.jsx(Bt,{className:"mt-3 h-6 w-12"})]},t))}),n.jsx(Bt,{className:"h-48 w-full"}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[n.jsx(jd,{n:4}),n.jsx(jd,{n:6})]})]})}function jd({n:e}){return n.jsx("div",{className:"border",children:Array.from({length:e},(t,s)=>n.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[n.jsx(Bt,{className:"h-4 w-20"}),n.jsx(Bt,{className:"h-4 flex-1"}),n.jsx(Bt,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Os({label:e,rows:t=8}){return n.jsx(uf,{label:e,children:n.jsx(jd,{n:t})})}function U5(){return n.jsxs(uf,{label:"Loading the run",className:"space-y-6 p-5 md:p-8",children:[n.jsxs("div",{className:"space-y-3 border-b pb-6",children:[n.jsx(Bt,{className:"h-4 w-24"}),n.jsx(Bt,{className:"h-7 w-2/3"}),n.jsx(Bt,{className:"h-3 w-1/3"})]}),n.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,t)=>n.jsx(Bt,{className:"h-4 w-16"},t))}),n.jsx("div",{className:"space-y-4",children:Array.from({length:5},(e,t)=>n.jsxs("div",{className:"flex gap-3",children:[n.jsx(Bt,{className:"size-4 shrink-0"}),n.jsx(Bt,{className:oe("h-4",t%2?"w-1/2":"w-3/4")})]},t))})]})}function W5(){return n.jsxs(uf,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsx(Bt,{className:"h-7 w-64"}),n.jsx(Bt,{className:"h-3 w-80 max-w-full"})]}),n.jsx(Bt,{className:"h-12 w-full"}),n.jsx(jd,{n:5})]})}const H5={browserbase:"Browserbase",kernel:"Kernel"},Fa=e=>H5[e]??e,yw=e=>n.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),B5=5e3,bw=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function G5({agent:e,v2:t,onAgent:s,poll:r,refresh:a}){var $,S;const[l,c]=x.useState(null),[u,f]=x.useState(!1),[p,g]=x.useState(null),v=x.useRef(e);v.current=e;const h=x.useRef(r);h.current=r;const m=e.sign_ins??[],b=m.some(E=>E.state==="held");x.useEffect(()=>{if(!b||u)return;const E=setInterval(()=>h.current(),B5);return()=>clearInterval(E)},[b,u]);const w=(S=($=e.tools)==null?void 0:$.find(E=>E.name==="browser"))==null?void 0:S.resolved;if(!m.length&&w!=="browserbase"&&w!=="kernel"&&!p)return null;const j=[...new Set(m.map(E=>E.key))].map(E=>({key:E,items:m.filter(C=>C.key===E)})),N=async E=>{var C,T;f(!0),g(null);try{const F=(await t.forgetSignIn(e.agent_id,E)).removed.filter(z=>z.at_vendor==="not_deleted"),L=F.length?{tone:"warn",text:F.map(z=>`Forgotten here, but ${Fa(z.provider)} didn't confirm the delete. ${z.message??""}`.trim()).join(" ")}:null;if(g(L),c(null),!await a()){const z=v.current;s({...z,sign_ins:(z.sign_ins??[]).filter(W=>W.key!==E)}),g({tone:"warn",text:`${L?`${L.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(A){const F=A instanceof Ee&&A.code==="sign_in_held"?((C=A.details)==null?void 0:C.held_by)??((T=A.details)==null?void 0:T.handed_to):void 0;g(A instanceof Ee&&A.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...F?{run:F}:{}}:{tone:"error",text:`Not forgotten: ${Jt(A)}`}),c(null)}finally{f(!1)}},R=({key:E,items:C})=>{const T=C.length===1?`Forget the ${Fa(C[0].provider)} sign-in`:`Forget the saved sign-ins for ${bw(C.map(F=>Fa(F.provider)))}`,A=C.some(F=>F.state==="held");return n.jsx(V,{size:"sm",variant:"ghost",disabled:u||A,"aria-label":T,title:A?"A run is using it: forget it once that run ends.":void 0,onClick:()=>{g(null),c(E)},children:"Forget"})};return n.jsxs("section",{"aria-label":"Sign-ins",className:"mt-4 max-w-3xl",children:[n.jsxs("p",{className:"caps mb-1.5 flex items-center gap-2 text-label text-muted-foreground",children:[n.jsx(Qo,{className:"size-3.5","aria-hidden":!0})," Sign-ins"]}),m.length?n.jsx("ul",{className:"border",children:j.map(E=>n.jsxs("li",{className:"border-b last:border-b-0",children:[E.items.map(C=>n.jsxs("div",{"data-sign-in":!0,className:"px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsx("span",{className:"text-body font-semibold",children:Fa(C.provider)}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:C.verified_at?`last verified ${ft(C.verified_at)}`:"not verified yet"}),C.state==="held"&&C.held_by&&n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["in use by run ",yw(C.held_by)]}),E.items.length===1&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"flex-1"}),R(E)]})]}),C.state==="unreadable"&&n.jsx("p",{className:"mt-1 text-small text-warning-text",children:"This server's seal key can't open it, so runs start signed out until it's forgotten."})]},`${C.key}\0${C.provider}`)),E.items.length>1&&n.jsx("div",{className:"flex justify-end border-t px-3 py-1.5",children:R(E)}),l===E.key&&n.jsxs("div",{className:"mx-3 mb-2 flex flex-wrap items-center gap-2 border bg-card px-3 py-2",role:"alertdialog","aria-label":"Forget the sign-ins?",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[E.items.length===1?`Forget the ${Fa(E.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${bw(E.items.map(C=>Fa(C.provider)))}?`," The agent's next run with the browser starts signed out."]}),n.jsx(V,{size:"sm",variant:"solid",disabled:u,autoFocus:!0,onClick:()=>void N(E.key),children:"Yes, forget"}),n.jsx(V,{size:"sm",variant:"ghost",disabled:u,onClick:()=>c(null),children:"Keep"})]})]},E.key))}):n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No saved sign-ins. The browser keeps one once a run signs in to a site."}),p&&n.jsxs("p",{className:`mt-2 text-small ${p.tone==="error"?"text-destructive-text":"text-warning-text"}`,role:"status",children:[p.text,p.run&&n.jsxs(n.Fragment,{children:[" Run: ",yw(p.run)]})]})]})}const q5=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),V5=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function ur(e,t){var c,u;const s=`${q5(t)} could not be read.`;if(V5(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof Ee))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=((u=(c=e.fields)==null?void 0:c[0])==null?void 0:u.message)??e.message,a=[e.code,e.requestId].filter(Boolean).join(" · "),l=(f,p)=>({title:s,why:f,next:p,said:r,code:a});return e.status===401?l("This browser is signed out.","Reload the page to sign in again."):e.status===403?l("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?l("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===412?l("Someone, or a run, changed it first.","Reload to see it as it is now."):e.status===429?l("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?l("The server is busy.","Try again in a moment."):e.status>=500?l("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):l("The server turned the request down.","Try again, and if it keeps happening, the server's words below say why.")}function Pn({problem:e,onRetry:t,className:s="m-8"}){return n.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${s}`,role:"alert",children:[n.jsx(ar,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-prose font-semibold",children:e.title}),n.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&n.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),t&&n.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:n.jsx(V,{type:"button",onClick:t,size:"sm",children:"Try again"})})]})]})}const ni=[{path:"agent",label:"By the agent",fill:"fill-chart-agent",stroke:"stroke-chart-agent"},{path:"handed_back",label:"Handed back",fill:"fill-chart-handed-back",stroke:"stroke-chart-handed-back"},{path:"workflow",label:"Learned workflow",fill:"fill-chart-workflow",stroke:"stroke-chart-workflow"}],Ru=e=>ni.find(t=>t.path===e),K5=e=>e.filter(t=>t.total_usd!==null),X5=e=>Math.min(25,Math.max(3,Math.round(e/15)));function Y5(e,t){const s=[];let r=0;return e.forEach((a,l)=>{r+=a.total_usd,l>=t&&(r-=e[l-t].total_usd),s.push(r/Math.min(l+1,t))}),s}function Q5(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e));return[1,2,2.5,5,10].map(s=>s*t).find(s=>s>=e*(1-1e-9))}function Z5(e){const t=10**Math.floor(Math.log10(e)+1e-9),s=Math.round(e/t*10)/10,r={1:.25,2:.5,2.5:.5,5:1,10:2.5}[s]??e/4,a=[];for(let l=0;l*r*t<=e*(1+1e-9);l++)a.push(Math.round(l*r*t*1e12)/1e12);return a}function J5(e,t,s){if(!e.length)return{top:1,above:0};const r=e.map(c=>c.total_usd).sort((c,u)=>c-u),a=r[Math.min(r.length-1,Math.floor(r.length*.95))],l=Q5(Math.max(a,...t,s??0)*1.08);return{top:l,above:e.filter(c=>c.total_usd>l).length}}function eM(e,t,s=6){if(t<=e)return[e];const r=(t-e)/Math.max(1,s-1),a=10**Math.floor(Math.log10(r)),l=Math.max(1,[1,2,5,10].map(u=>u*a).find(u=>u>=r)),c=[];for(let u=Math.ceil(e/l)*l;u<=t;u+=l)c.push(u);return!c.includes(e)&&(c[0]??1/0)-e>l/2&&c.unshift(e),c}function tM(e,t){let s=0;for(let r=1;r<e.length;r++)Math.abs(e[r].n-t)<Math.abs(e[s].n-t)&&(s=r);return s}function to(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4).replace(/(\.\d\d\d?)0+$/,"$1").replace(/(\.\d\d)0$/,"$1")}`}function Nr(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const nM=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function sM(e,t){const s=[];for(let r=0;r<e.length;r+=t){const a=e.slice(r,r+t),l={agent:0,handed_back:0,workflow:0};for(const c of a)l[c.path]++;s.push({from:a[0].n,to:a.at(-1).n,runs:a.length,counts:l})}return s}function hh(e){const t=Math.round(e*10)/10;return`${t>=10?Math.round(e):t.toFixed(1)}x`}const $p=(e,t)=>`${t?Math.round(e/t*100):0}%`,rM=1e3,dN="Turn learning on and run the same job about 20 times: each run's cost shows here, and where a learned workflow takes the job over, the line falls.";function vw({v2:e,agentId:t,on:s,quiet:r=!1}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState(0);return x.useEffect(()=>{let g=!0;return u(null),Promise.resolve().then(()=>e.learningCost(t,rM)).then(v=>{g&&l(v)},v=>{g&&u(v??new Error("unknown"))}),()=>{g=!1}},[e,t,f]),r&&(!a||a.runs.filter(g=>g.total_usd!==null).length<2)?null:c&&!a?n.jsx(Pn,{problem:ur(c,"the cost per run"),onRetry:()=>p(g=>g+1),className:""}):a?n.jsx(oM,{data:a,on:s}):n.jsx(Bt,{className:"h-[320px] w-full"})}const nt={top:30,right:16,bottom:30,left:60},Uo=260;function oM({data:e,on:t,width:s}){var Y,q;const r=x.useMemo(()=>K5(e.runs),[e.runs]),a=X5(r.length),l=x.useMemo(()=>Y5(r,a),[r,a]),{summary:c}=e,u=x.useRef(null),[f,p]=x.useState(s??720);x.useEffect(()=>{const O=u.current;if(s||!O||typeof ResizeObserver>"u")return;const B=new ResizeObserver(([ee])=>{ee&&ee.contentRect.width>0&&p(ee.contentRect.width)});return B.observe(O),()=>B.disconnect()},[s]);const[g,v]=x.useState(null),h=ni.map(O=>({...O,runs:e.runs.filter(B=>B.path===O.path).length})),m=[e.total_runs>e.runs.length?`The latest ${e.runs.length.toLocaleString("en-US")} of ${e.total_runs.toLocaleString("en-US")} runs.`:null,e.unknown_cost_runs?`${e.unknown_cost_runs===1?"1 run's":`${e.unknown_cost_runs} runs'`} cost is not known: left out.`:null].filter(O=>!!O);if(r.length<2)return n.jsxs(jw,{title:"Cost per run",headline:null,children:[n.jsxs("div",{className:"px-4 py-8 text-center",role:"status",children:[n.jsx("p",{className:"font-mono text-body",children:r.length?"One run so far.":"No run with a known cost yet."}),n.jsx("p",{className:"mx-auto mt-1 max-w-prose text-body text-muted-foreground",children:dN})]}),e.runs.length>0&&(()=>{var ee;const O=Math.max(300,f),B=(O-nt.left-nt.right)/(e.runs.at(-1).n-e.runs[0].n+1);return n.jsx("figure",{ref:u,className:"px-4 pb-3",children:n.jsx(kw,{runs:e.runs,width:O,x:le=>nt.left+(le-e.runs[0].n+.5)*B,step:B,plot:[nt.left,O-nt.right],takeover:((ee=c.takeover)==null?void 0:ee.n)??null})})})()]});const b=Math.max(300,f),w=b-nt.left-nt.right,j=e.runs[0].n,N=e.runs.at(-1).n,R=w/(N-j+1),$=O=>nt.left+(O-j+.5)*R,{top:S,above:E}=J5(r,l,((Y=c.before)==null?void 0:Y.mean_usd)??null),C=O=>nt.top+Uo-Math.min(O,S)/S*Uo,T=Z5(S),A=eM(j,N,b<520?5:7),F=c.takeover&&c.takeover.n>=j?c.takeover:null,L=c.takeover?Math.max(c.takeover.n,j):null,z=r.map((O,B)=>`${B?"L":"M"}${$(O.n).toFixed(1)},${C(l[B]).toFixed(1)}`).join(""),W=g===null?null:r[g],U=c.times_cheaper!==null?`${hh(c.times_cheaper)} cheaper`:null,D=c.before&&c.after?`${Nr(c.before.mean_usd)} a run before learning, ${Nr(c.after.mean_usd)} after takeover${U?`: ${U}`:""}`:null,K=O=>{const B=O.currentTarget.getBoundingClientRect(),ee=(O.clientX-B.left)/B.width*b;v(tM(r,j+(ee-nt.left)/R-.5))},P=O=>{const ee={ArrowRight:le=>le+1,ArrowLeft:le=>le-1,Home:()=>0,End:()=>r.length-1,PageUp:le=>le+10,PageDown:le=>le-10}[O.key];if(!ee){O.key==="Escape"&&v(null);return}O.preventDefault(),v(le=>Math.min(r.length-1,Math.max(0,ee(le??(O.key==="ArrowLeft"?r.length:-1)))))},G=O=>[`Run ${O.n}`,`${to(O.total_usd)} all-in${O.learning_usd?` (${to(O.cost_usd??0)} the run, ${to(O.learning_usd)} learning)`:""}`,`${Ru(O.path).label}${O.workflow?`: ${O.workflow}`:""}`,O.learned_revision?`Learned revision ${O.learned_revision.slice(0,7)}`:"Nothing learned yet"],I=F?$(F.n)>nt.left+w*.62:!1;return n.jsxs(jw,{title:"Cost per run",headline:D,children:[n.jsxs("figure",{ref:u,className:"px-4 pb-2 pt-3",children:[n.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground",children:[h.filter(O=>O.runs>0).map(O=>n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:n.jsx("circle",{cx:"5",cy:"5",r:"4",className:O.fill})}),O.label," ",n.jsx("span",{className:"text-foreground",children:O.runs})]},O.path)),n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:n.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",a," runs"]}),c.before&&n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:n.jsx("path",{d:"M1,5H17",className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"4 3"})}),"Before learning"]})]}),n.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:P,onBlur:()=>v(null),"aria-label":`Cost per run, runs ${j} to ${N}. ${D??""} Arrow keys step through the runs.`,children:[n.jsxs("svg",{width:b,height:nt.top+Uo+nt.bottom,className:"block select-none font-mono",onPointerMove:K,onPointerLeave:()=>v(null),"aria-hidden":!0,children:[T.map(O=>n.jsxs("g",{children:[n.jsx("path",{d:`M${nt.left},${C(O)}H${nt.left+w}`,className:O===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),n.jsx("text",{x:nt.left-8,y:C(O),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:to(O)})]},O)),A.map(O=>n.jsx("text",{x:$(O),y:nt.top+Uo+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:O},O)),n.jsx("text",{x:nt.left,y:nt.top-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),n.jsx("text",{x:nt.left-8,y:nt.top+Uo+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),r.map((O,B)=>n.jsx("circle",{cx:$(O.n),cy:C(O.total_usd),r:B===g?0:3,className:oe(Ru(O.path).fill),fillOpacity:.65},O.run_id)),c.before&&n.jsxs("g",{children:[n.jsx("path",{d:`M${nt.left},${C(c.before.mean_usd)}H${nt.left+w}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),n.jsxs(Ep,{x:nt.left+w-4,y:C(c.before.mean_usd)-6,anchor:"end",children:["Before learning ",Nr(c.before.mean_usd)]})]}),F&&n.jsxs("g",{children:[n.jsx("path",{d:`M${$(F.n)},${nt.top-4}V${nt.top+Uo}`,className:"stroke-chart-workflow",strokeWidth:1.5}),n.jsxs(Ep,{x:$(F.n)+(I?-6:6),y:nt.top+6,anchor:I?"end":"start",children:["Workflow took over, run ",F.n]})]}),L!==null&&c.after&&n.jsxs("g",{children:[n.jsx("path",{d:`M${$(L)},${C(c.after.mean_usd)}H${nt.left+w}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),n.jsxs(Ep,{x:nt.left+w-4,y:C(c.after.mean_usd)-8,anchor:"end",strong:!0,children:[b<520?"After":"After takeover"," ",Nr(c.after.mean_usd),U?` · ${U}`:""]})]}),n.jsx("path",{d:z,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),W&&n.jsxs("g",{children:[n.jsx("path",{d:`M${$(W.n)},${nt.top}V${nt.top+Uo}`,className:"stroke-border-strong",strokeWidth:1}),n.jsx("circle",{cx:$(W.n),cy:C(W.total_usd),r:5,className:oe(Ru(W.path).fill,"stroke-card"),strokeWidth:2})]})]}),W&&n.jsxs("div",{className:oe("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",$(W.n)>b*.6&&"-translate-x-full"),style:{left:$(W.n)>b*.6?$(W.n)-10:$(W.n)+10,top:nt.top},children:[G(W).map((O,B)=>n.jsx("span",{className:oe("block",B===0?"font-semibold":"text-muted-foreground"),children:O},O)),n.jsx("span",{className:"block text-muted-foreground",children:ft(W.started_at)})]}),n.jsx("p",{className:"sr-only","aria-live":"polite",children:W?G(W).join(", "):""})]}),n.jsx(kw,{runs:e.runs,width:b,x:$,step:R,plot:[nt.left,nt.left+w],takeover:((q=c.takeover)==null?void 0:q.n)??null}),n.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each dot is a run: its own cost plus what learning spent for it (the look-back and the grade). The line is the mean of the last ",a," runs.",E?` ${E===1?"1 run costs":`${E} runs cost`} more than ${to(S)} and ${E===1?"is":"are"} drawn at the top.`:"",c.before?" The dashed line is what a run cost the agent before a learned workflow took over, learning left out.":""]}),[...m,...lM(e,t)].map(O=>n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:O},O))]}),n.jsxs("details",{className:"border-t px-4 py-2",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),n.jsx("div",{className:"max-h-96 overflow-auto",children:n.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[n.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:n.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Started","Path","Revision","Run $","Learning $","All-in $"].map(O=>n.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:O},O))})}),n.jsx("tbody",{children:e.runs.map(O=>{var B;return n.jsxs("tr",{children:[n.jsx("td",{className:"py-0.5 pr-4",children:O.n}),n.jsx("td",{className:"pr-4",children:ft(O.started_at)}),n.jsxs("td",{className:"pr-4",children:[Ru(O.path).label,O.workflow?`: ${O.workflow}`:""]}),n.jsx("td",{className:"pr-4",children:((B=O.learned_revision)==null?void 0:B.slice(0,7))??"-"}),n.jsx("td",{className:"pr-4",children:O.cost_usd===null?"unknown":to(O.cost_usd)}),n.jsx("td",{className:"pr-4",children:O.learning_usd===null?"unknown":to(O.learning_usd)}),n.jsx("td",{className:"pr-4",children:O.total_usd===null?"unknown":to(O.total_usd)})]},O.run_id)})})]})}),n.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["As CSV: ",n.jsxs("code",{className:"font-mono",children:["agentrun learning cost ",e.agent," --format csv"]})]})]})]})}const aM=64,no={top:4,bottom:6},iM=[...ni].reverse(),ww=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function kw({runs:e,width:t,x:s,step:r,plot:a,takeover:l}){const c=aM,u=nM(e.length),f=x.useMemo(()=>sM(e,u),[e,u]),[p,g]=x.useState(null);if(!f.length)return null;const[v,h]=a,m=A=>Math.min(h,Math.max(v,A)),b=A=>({from:m(s(A.from)-r/2),to:m(s(A.to)+r/2)}),w=A=>no.top+c*(1-A),j=f.at(-1),N=A=>{const{from:F,to:L}=b(A),z=L-F>4?1:0;return{x0:F+z,w:Math.max(1,L-F-2*z)}},R=A=>`${ww(A)}: ${ni.filter(F=>A.counts[F.path]).map(F=>`${F.label.toLowerCase()} ${A.counts[F.path]}`).join(", ")}`,$=f.some(A=>A.counts.workflow)?`${$p(j.counts.workflow,j.runs)} by the learned workflow`:ni.filter(A=>j.counts[A.path]).map(A=>`${$p(j.counts[A.path],j.runs)} ${A.label.toLowerCase()}`).join(", "),S=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${$}`,E=p===null?null:f[p],C=E?N(E).x0>t/2:!1,T=l!==null&&s(l)>=v&&s(l)<=h;return n.jsxs("div",{className:"relative min-w-0",style:{width:t},"data-testid":"execution-mix",children:[n.jsxs("div",{className:"font-mono text-label",style:{paddingLeft:v},children:[n.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",u>1?`, by ${u}`:""]}),n.jsx("span",{className:"block text-foreground",children:S})]}),n.jsxs("svg",{width:t,height:no.top+c+no.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>g(null),children:[[0,.5,1].map(A=>n.jsxs("text",{x:v-6,y:w(A),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[A*100,"%"]},A)),f.map((A,F)=>{const{x0:L,w:z}=N(A);let W=no.top+c;return n.jsxs("g",{onPointerEnter:()=>g(F),opacity:p===null||p===F?1:.55,children:[n.jsx("rect",{x:b(A).from,y:no.top,width:Math.max(1,b(A).to-b(A).from),height:c,className:"fill-card",fillOpacity:0}),iM.map(U=>{const D=A.counts[U.path]/A.runs*c;if(!D)return null;W-=D;const K=W>no.top+.5?Math.min(2,D):0;return n.jsx("rect",{x:L,y:W+K,width:z,height:D-K,className:U.fill,fillOpacity:.8},U.path)})]},A.from)}),T&&n.jsx("g",{"data-testid":"mix-takeover",children:n.jsx("path",{d:`M${s(l)-r/2},${no.top}V${no.top+c}`,className:"stroke-chart-workflow",strokeWidth:1.5})})]}),E&&n.jsxs("div",{className:oe("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",C&&"-translate-x-full"),style:{left:C?N(E).x0-6:N(E).x0+N(E).w+6,top:40},children:[n.jsx("span",{className:"block font-semibold",children:ww(E)}),ni.filter(A=>E.counts[A.path]).map(A=>n.jsxs("span",{className:"block text-muted-foreground",children:[A.label," ",E.counts[A.path]," (",$p(E.counts[A.path],E.runs),")"]},A.path))]}),n.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${u} runs. ${f.map(R).join(". ")}. ${S}.`})]})}function lM(e,t){const s=e.summary;return s.takeover?s.times_cheaper===null&&s.after?[`${s.after.runs===1?"1 run":`${s.after.runs} runs`} since the workflow took over: how many times cheaper it is shows after 20.`]:[]:[t?"No learned workflow has finished a run alone yet. Keep running the same job: once one does, a marker shows where, and the level after it.":dN]}function jw({title:e,headline:t,children:s}){return n.jsxs("section",{className:"min-w-0 border","aria-label":e,"data-testid":"cost-per-run",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[n.jsx("h3",{className:"caps text-small font-semibold",children:e}),t&&n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:t})]}),s]})}function Ep({x:e,y:t,anchor:s="start",strong:r=!1,children:a}){return n.jsx("text",{x:e,y:t,textAnchor:s,className:oe("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:a})}function cM(e){const t=[];let s=[],r="",a=!1;const l=e.replace(/^/,"");for(let c=0;c<l.length;c++){const u=l[c];a?u==='"'?l[c+1]==='"'?(r+='"',c++):a=!1:r+=u:u==='"'&&r===""?a=!0:u===","?(s.push(r),r=""):u===`
537
+ `||u==="\r"?(u==="\r"&&l[c+1]===`
538
+ `&&c++,s.push(r),r="",s.some(f=>f.trim()!=="")&&t.push(s),s=[]):r+=u}return a?null:(s.push(r),s.some(c=>c.trim()!=="")&&t.push(s),t)}function uM(e){var l;const t=cM(e);if(!t)return{error:"The file ends inside a quoted cell: a quote is not closed."};const s=(l=t.shift())==null?void 0:l.map(c=>c.trim());if(!s||!t.length)return{error:"The file needs a header line and at least one row."};if(s.some(c=>c===""))return{error:"A column in the header line has no name."};const r=s.find((c,u)=>s.indexOf(c)!==u);if(r!==void 0)return{error:`The column ${r} is named twice in the header line.`};const a=t.findIndex(c=>c.length!==s.length);return a>=0?{error:`Row ${a+1} has ${t[a].length} cells, and the header line has ${s.length}.`}:{columns:s,rows:t.map(c=>Object.fromEntries(s.map((u,f)=>[u,c[f]])))}}const Nw=500,dM=5,gh=e=>e.status==="running";function fM(e){return e.status==="cancelled"?`Cancelled after ${e.finished} of ${e.total} rows.`:e.status!=="stopped"?null:e.stopped==="cap"?`Stopped after ${e.finished} of ${e.total} rows: what is left of the cap does not cover another row.`:e.stopped==="cost_unknown"?`Stopped after ${e.finished} of ${e.total} rows: a row's cost is not known, and the cap is never guessed at.`:`Stopped after ${e.finished} of ${e.total} rows${e.error?`: ${e.error}`:"."}`}const mM={agent:"by hand",handed_back:"handed back",workflow:"workflow"},pM=2e3;function Sw({v2:e,agentId:t,onFinished:s,pollMs:r=pM}){const[a,l]=x.useState(void 0),[c,u]=x.useState(null),[f,p]=x.useState(!1),[g,v]=x.useState(0),h=x.useRef(!1),m=x.useRef(s);if(m.current=s,x.useEffect(()=>{let w=!0,j;const N=async R=>{var $,S;try{const E=R??(($=(await e.learningBatches(t)).batches[0])==null?void 0:$.id),C=E?await e.learningBatch(t,E):null;if(!w)return;l(C),u(null),C&&gh(C)?(h.current=!0,j=setTimeout(()=>void N(C.id),r)):C&&h.current&&(h.current=!1,(S=m.current)==null||S.call(m))}catch(E){if(!w)return;u(E??new Error("unknown")),j=setTimeout(()=>void N(R),r*2)}};return N(),()=>{w=!1,clearTimeout(j)}},[e,t,r,g]),a===void 0&&!c)return n.jsx(Bt,{className:"h-24 w-full"});if(a===void 0)return n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsxs("p",{className:"font-mono text-small text-muted-foreground",role:"status",children:["Learn from a CSV is not available right now: ",c instanceof Error?c.message:String(c),"."]}),n.jsx(V,{size:"sm",variant:"outline",onClick:()=>{u(null),v(w=>w+1)},children:"Read again"})]});const b=a&&gh(a);return n.jsxs("section",{className:"space-y-4","aria-label":"Learn from a CSV",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:"Learn from a CSV"}),!b&&!f&&n.jsx(V,{size:"sm",onClick:()=>p(!0),children:a?"Learn from another CSV":"Learn from a CSV"})]}),!!c&&n.jsxs("p",{className:"font-mono text-small text-warning-text",role:"status",children:["The batch was not read again: ",c instanceof Error?c.message:String(c),". Trying again."]}),f&&!b&&n.jsx(hM,{v2:e,agentId:t,onStarted:w=>{h.current=!0,l(w),p(!1),v(j=>j+1)},onCancel:()=>p(!1)}),a&&!f&&n.jsx(yM,{v2:e,agentId:t,batch:a,onBatch:l}),!a&&!f&&n.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Give it rows you already have answers for. It runs on each in order, learning as it goes, and is told the right answer after each one."})]})}function hM({v2:e,agentId:t,onStarted:s,onCancel:r}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState([]),[g,v]=x.useState(""),[h,m]=x.useState(String(dM)),[b,w]=x.useState(!1),[j,N]=x.useState(null),R=async C=>{var L;const T=(L=C.target.files)==null?void 0:L[0];if(!T)return;N(null);const A=uM(await T.text());if("error"in A){l(null),u(A.error);return}u(A.rows.length>Nw?`A batch takes at most ${Nw} rows: this file has ${A.rows.length}.`:null),l({name:T.name,columns:A.columns,rows:A.rows});const F=A.columns.at(-1);v(F),p(A.columns.filter(z=>z!==F))},$=Number(h),S=!!a&&!c&&f.length>0&&!!g&&!f.includes(g)&&Number.isFinite($)&&$>0,E=async()=>{var C,T;if(!(!a||!S)){w(!0),N(null);try{s(await e.startLearningBatch(t,{inputs:f,answer:g,rows:a.rows,max_cost_usd:$}))}catch(A){N(A instanceof Ee?((T=(C=A.fields)==null?void 0:C[0])==null?void 0:T.message)??A.message:A instanceof Error?A.message:String(A)),w(!1)}}};return n.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[n.jsx(Bs,{label:"CSV file",note:"A header line, then one row for each thing to learn from. The file is read here; its rows go to the server.",children:n.jsx("input",{type:"file",accept:".csv,text/csv",onChange:C=>void R(C),"aria-label":"CSV file",className:"block w-full font-mono text-body file:mr-3 file:border file:border-input file:bg-background file:px-3 file:py-1.5 file:font-mono"})}),c&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),a&&!("error"in a)&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[a.name,": ",a.rows.length," rows, ",a.columns.length," columns"]}),n.jsx(Bs,{label:"The agent is given",group:!0,note:"The columns each run reads. The answer column is never one of them.",children:n.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:a.columns.map(C=>n.jsx(E3,{label:C,checked:f.includes(C),disabled:C===g,onChange:T=>p(A=>T.target.checked?a.columns.filter(F=>A.includes(F)||F===C):A.filter(F=>F!==C))},C))})}),n.jsx(Bs,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:n.jsx(Lt,{label:"The answer column",value:g,onChange:C=>{v(C),p(T=>T.filter(A=>A!==C))},options:a.columns.map(C=>({value:C,label:C}))})}),n.jsx(Bs,{label:"Cap, in dollars",note:"Caps what the runs spend (each run, its look-back and its review). A row starts only when what is left covers it. Grades are counted in the cost but not capped.",hint:S?`Up to ${fo($)} for ${a.rows.length} rows.`:void 0,children:n.jsx(Ue,{inputMode:"decimal",value:h,onChange:C=>m(C.target.value),className:"max-w-40","aria-label":"Cap, in dollars"})}),n.jsx(gM,{columns:[...f,g].filter(Boolean),rows:a.rows.slice(0,3)})]}),j&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:j}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(V,{variant:"primary",disabled:!S||b,onClick:()=>void E(),children:b?"Starting":"Learn"}),n.jsx(V,{variant:"ghost",onClick:r,disabled:b,children:"Cancel"})]})]})}function gM({columns:e,rows:t}){return n.jsx("div",{className:"overflow-x-auto","aria-label":"The first rows",children:n.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.map(s=>n.jsx("th",{className:"caps border-b px-2 py-1 text-left font-semibold",children:s},s))})}),n.jsx("tbody",{children:t.map((s,r)=>n.jsx("tr",{children:e.map(a=>n.jsx("td",{className:"max-w-64 truncate border-b px-2 py-1",children:s[a]},a))},r))})]})})}const xM={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function yM({v2:e,agentId:t,batch:s,onBatch:r}){const[a,l]=x.useState(!1),[c,u]=x.useState(null),f=async()=>{l(!0),u(null);try{r(await e.cancelLearningBatch(t,s.id))}catch(v){u(v instanceof Error?v.message:String(v))}l(!1)},p=fM(s),g=s.cost_usd===null?"unknown":fo(s.cost_usd);return n.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ce,{tone:xM[s.status],children:s.status}),n.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),gh(s)&&n.jsx(V,{size:"sm",variant:"destructive",disabled:a,onClick:()=>void f(),children:"Cancel"})]}),n.jsx("div",{className:"h-2 w-full bg-muted",role:"progressbar","aria-label":"Rows done","aria-valuemin":0,"aria-valuemax":s.total,"aria-valuenow":s.finished,children:n.jsx("div",{className:"h-full bg-primary",style:{width:`${s.total?s.finished/s.total*100:0}%`}})}),p&&n.jsx(On,{tone:"warning",children:p}),s.status==="completed"&&n.jsx(On,{tone:"success",children:"Every row ran. The results are below."}),c&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),n.jsxs("dl",{className:"grid grid-cols-2 gap-3 font-mono text-body sm:grid-cols-4",children:[n.jsx(so,{label:"Right",value:`${s.right}`}),n.jsx(so,{label:"Wrong",value:`${s.wrong}`}),n.jsx(so,{label:"Failed",value:`${s.failed}`}),n.jsx(so,{label:"Cost so far",value:`${g} of ${fo(s.max_cost_usd)}`}),n.jsx(so,{label:"Notes learned",value:`${s.lessons.notes.length}`}),n.jsx(so,{label:"Skills learned",value:`${s.lessons.skills.length}`}),n.jsx(so,{label:"Workflow revisions",value:`${s.revisions.length}`}),n.jsx(so,{label:"Paths",value:`${s.paths.agent} by hand, ${s.paths.handed_back} handed back, ${s.paths.workflow} workflow`})]}),s.lessons.notes.length+s.lessons.skills.length+s.lessons.workflows.length>0&&n.jsxs("p",{className:"text-body text-muted-foreground",children:["Learned: ",[...s.lessons.notes,...s.lessons.skills.map(v=>`${v} (skill)`),...s.lessons.workflows.map(v=>`${v} (workflow)`)].join(", "),"."]}),n.jsx("div",{className:"max-h-96 overflow-auto",children:n.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsx("tr",{children:["Row","Result","Path","Cost","Answer","Reference"].map(v=>n.jsx("th",{className:"caps sticky top-0 border-b bg-card px-2 py-1 text-left font-semibold",children:v},v))})}),n.jsx("tbody",{children:s.rows.map(v=>n.jsxs("tr",{"aria-current":s.current===v.n?"step":void 0,children:[n.jsx("td",{className:"border-b px-2 py-1",children:v.n}),n.jsx("td",{className:"border-b px-2 py-1",children:v.state==="done"?n.jsx(Ce,{tone:v.right?"success":"error",children:v.right?"right":"wrong"}):v.state==="failed"?n.jsx(Ce,{tone:"error",title:v.error,children:"failed"}):n.jsx(Ce,{tone:v.state==="running"?"active":"muted",children:v.state==="running"?"running":"waiting"})}),n.jsx("td",{className:"border-b px-2 py-1",children:v.path?mM[v.path]:""}),n.jsx("td",{className:"border-b px-2 py-1",children:v.total_usd==null?"":fo(v.total_usd)}),n.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:v.answer??void 0,children:v.answer??""}),n.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:v.reference,children:v.reference})]},v.n))})]})})]})}const so=({label:e,value:t})=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:e}),n.jsx("dd",{className:"break-words",children:t})]}),bM="Run the agent on jobs it never learned from and record the counts: agentrun learning record-eval <agent> --body @eval.json (POST /v2/agents/{id}/learning/evals).",Cp=e=>`${Math.round(e*1e3)/10}%`;function vM(e){const{cost_per_task_usd:t,baseline_cost_per_task_usd:s}=e,r=t!==null&&s!==null,a=r&&t>0?s/t:null,[l,c]=e.ci;return{accuracy:Cp(e.accuracy),accuracyVs:`95% interval ${Cp(l)} to ${Cp(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?a===null||s===0?Nr(t):a>=1?`${hh(a)} cheaper`:`${hh(t/s)} the cost`:t!==null?Nr(t):"Not counted",costVs:r?`${Nr(t)} a task vs ${Nr(s)} by hand`:t!==null?`${Nr(t)} a task; by hand not counted`:"The test did not count the cost a task."}}function _w({v2:e,agentId:t,quiet:s=!1}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,f]=x.useState(0);return x.useEffect(()=>{let p=!0;return c(null),Promise.resolve().then(()=>e.learningEvals(t)).then(g=>{p&&a(g)},g=>{p&&c(g??new Error("unknown"))}),()=>{p=!1}},[e,t,u]),s&&!(r!=null&&r.latest)?null:l&&!r?n.jsx(Pn,{problem:ur(l,"the held-out test"),onRetry:()=>f(p=>p+1),className:""}):r?n.jsx(wM,{result:r.latest}):n.jsx(Bt,{className:"h-[116px] w-full"})}function wM({result:e}){return n.jsxs("section",{className:"min-w-0 border","aria-label":"Held-out test","data-testid":"held-out-test",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[n.jsx("h3",{className:"caps text-small font-semibold",children:"Held-out test"}),e&&n.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[e.n.toLocaleString("en-US")," jobs it never learned from · ",e.name," · ",ft(e.recorded_at),e.learned_revision?` · revision ${e.learned_revision.slice(0,7)}`:""]})]}),e?n.jsx(kM,{result:e}):n.jsxs("div",{className:"px-4 py-4",role:"status",children:[n.jsx("p",{className:"font-mono text-body",children:"Not measured yet."}),n.jsx("p",{className:"mt-1 max-w-prose text-body text-muted-foreground",children:bM})]})]})}function kM({result:e}){const t=vM(e),s=[{label:"Held-out accuracy",value:t.accuracy,lines:[t.accuracyVs]},{label:"Cost a task",value:t.cost,lines:[t.costVs]}];return n.jsxs(n.Fragment,{children:[n.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2",children:s.map((r,a)=>n.jsxs("div",{className:a?"border-t px-4 py-3 sm:border-l sm:border-t-0":"px-4 py-3",children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:r.label}),n.jsx("dd",{className:"mt-1 font-mono text-figure font-semibold tabular-nums",children:r.value}),r.lines.map(l=>n.jsx("dd",{className:"mt-0.5 font-mono text-small text-muted-foreground",children:l},l))]},r.label))}),e.label_source&&n.jsxs("p",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["Labels: ",e.label_source]})]})}const jM="http://www.w3.org/2000/svg",Ua=16,Ut=240,NM=40,SM=58,Tp=16,Rp=26,Au=18,Wa=14,$w=16,_M=26,$M=14,EM=22,ks=14,Ew=16,Ou=16,CM=4,TM=10,RM=18,AM=30,OM=5,Sl=124,xh=34,MM=4,Ap=10*.6,PM=12.5*.6,ql=10.5*.6,Cw=11*.6,Dg=9*.66,Tw=10.5*.6,LM={agent:"agent",decide:"agent",extract:"agent",report:"agent",artifact:"agent",judge:"jev",pick:"jev",sift:"jev",route:"jev",call:"tool",code:"code",escalate:"exit",chain:"control",parallel:"control",map:"control",loop:"control",workflow:"control"},Fg=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Nd={review:"needs review","not-run":"",pending:""};function Je(e,t,...s){const r=document.createElementNS(jM,e);if(t)for(const[a,l]of Object.entries(t))r.setAttribute(a,String(l));for(const a of s)is(r,a);return r}function is(e,t){if(t!=null){if(Array.isArray(t)){for(const s of t)is(e,s);return}e.appendChild(typeof t=="string"?document.createTextNode(t):t)}}const or=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,IM=(e,t)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=t?or(e,t):`${or(s[1],Math.max(2,t-s[2].length-1))} ${s[2]}`},co=(e,t)=>Math.max(2,Math.floor(e/t)),xo=(e,t)=>Math.ceil(e.length*t),Ss=(e,t,s,r,a)=>Je("line",{x1:e,y1:t,x2:s,y2:r,class:a?`wire ${a}`:"wire"});function fN(e){const t={},s={};for(const a of e)t[a.path]=a;const r=a=>{var l;return((l=t[a])==null?void 0:l.kind)??""};for(const a of e){let l;const c={node:a,order:0,name:null};let u=null;(l=/^(.*)\/steps\/(\d+)$/.exec(a.path))&&r(l[1])==="chain"?(u=l[1],c.order=Number(l[2])):(l=/^(.*)\/branches\/([^/]*)\/body$/.exec(a.path))&&r(l[1])==="route"?(u=l[1],c.name=l[2].replace(/~1/g,"/").replace(/~0/g,"~")):(l=/^(.*)\/branches\/(\d+)$/.exec(a.path))&&r(l[1])==="parallel"?(u=l[1],c.order=Number(l[2])):((l=/^(.*)\/body$/.exec(a.path))&&(r(l[1])==="map"||r(l[1])==="loop")||(l=/^(.*)\/workflow\/root$/.exec(a.path))&&r(l[1])==="workflow")&&(u=l[1]),u!==null&&(s[u]??(s[u]=[])).push(c)}for(const a of Object.values(s))a.sort((l,c)=>l.order-c.order);return{byPath:t,kids:s}}function Ug(e,t){var f,p,g,v;const{diff:s={},status:r={},fired:a}=e.marks,l=t===a?"escalated":r[t],c=l&&Fg.has(l)?l:"",u=(f=s.added)!=null&&f.includes(t)?"NEW":(p=s.edited)!=null&&p.includes(t)?"EDITED":(g=s.moved)!=null&&g.includes(t)?"MOVED":"";return{state:c,tag:u,fired:t===a,selected:((v=e.marks.selected)==null?void 0:v.path)===t&&e.marks.selected.item==null}}function uc(e,t,s){var h,m,b;const r=Ug(e,t.path),a=(h=e.marks.meta)==null?void 0:h[t.path],l=a!=null&&a.tool?cc(a.tool):null,c=(m=e.marks.ran)==null?void 0:m[t.path],u=a!=null&&a.decision?(c==null?void 0:c.model)??a.model:a==null?void 0:a.model;let f=`${t.label} (${t.kind}${l?`: ${l.tool} on ${l.server}, an MCP server's tool`:t.via?` via ${t.via}`:""}${a!=null&&a.provider?`, ${a.provider}${u?` ${u}`:""}`:""}${c&&!(a!=null&&a.decision)?`, ${F1(c)}`:""})`;r.state&&(f+=`: ${r.state.replace("-"," ")}`),r.tag&&(f+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(b=a==null?void 0:a.questions)!=null&&b.length&&(f+=`
539
+ ${a.questions.map(w=>`• ${w.text}`).join(`
540
+ `)}`);const p=a!=null&&a.decision&&a.provider?`who-${a.provider==="parallel"||a.provider==="openrouter"?a.provider:"jev"}`:t.kind==="route"&&a&&!a.decision?"who-control":`who-${LM[t.kind]??"code"}`;let g=`node ${s} ${p}`;r.state&&(g+=` ${r.state}`),r.fired&&(g+=" fired"),r.tag&&(g+=` ${r.tag.toLowerCase()}`),r.selected&&(g+=" selected");const v=Je("g",{class:g,"data-path":t.path},Je("title",null,f));return e.svg.appendChild(v),v}const si=e=>xo(e,Dg)+10;function Xu(e,t,s,r,a="tag"){const l=si(r);return is(e,[Je("rect",{x:t,y:s,width:l,height:13,class:`${a}-box`}),Je("text",{x:t+l/2,y:s+9.5,class:a,"text-anchor":"middle"},r)]),l}const zM=(e,t)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[t.path])!=null&&r.decision)},df=(e,t)=>zM(e,t)?SM:NM;function Wg(e,t,s,r,a){var N,R,$,S,E;const l=Ug(e,s.path),c=(N=e.marks.meta)==null?void 0:N[s.path],u=df(e,s),f=(R=e.marks.verdict)==null?void 0:R[s.path],p=l.state in Nd?Nd[l.state]:l.state,g=(($=c==null?void 0:c.questions)==null?void 0:$.length)??0,v=c!=null&&c.tool?cc(c.tool):null,h=(S=e.marks.ran)==null?void 0:S[s.path],m=(h&&!(c!=null&&c.decision)?Lg(s.kind,h):s.kind)+(v?` · ${v.tool} on ${v.server}`:c!=null&&c.tool?` · ${c.tool}`:s.via?` · ${s.via}`:"")+(c!=null&&c.decision&&g?` · ${g} ${g===1?"question":"questions"}`:""),b=[(E=c==null?void 0:c.images)!=null&&E.length?"IMG":"",c!=null&&c.web?"WEB":"",v?"MCP":""].filter(Boolean),w=b.reduce((C,T)=>C+si(T)+4,0);l.selected&&t.appendChild(Je("rect",{x:r-4,y:a-4,width:Ut+8,height:u+8,class:"sel"})),is(t,[Je("rect",{x:r,y:a,width:Ut,height:u,class:"box"}),Je("rect",{x:r+10,y:a+9,width:8,height:8,class:"swatch"}),Je("text",{x:r+24,y:a+17,class:"label"},or(s.label,co(Ut-34-w,PM))),Je("text",{x:r+24,y:a+31,class:"kind"},or(m,co(Ut-34-(p?xo(p,Dg)+8:0),ql))),p?Je("text",{x:r+Ut-10,y:a+31,class:"state","text-anchor":"end"},p):null]);let j=r+Ut-8;for(const C of b.reverse())j-=si(C),Xu(t,j,a+7,C,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const C=Xu(t,r+24,a+38,c.provider,"chip"),T=f?IM(f,co(Ut-44-C-20,Tw)):"",A=Ut-40-C-(T?xo(T,Tw)+10:0),F=(h==null?void 0:h.model)??c.model;F&&A>24&&t.appendChild(Je("text",{x:r+24+C+6,y:a+47.5,class:"model"},or(F,co(A,ql)))),T&&t.appendChild(Je("text",{x:r+Ut-10,y:a+47.5,class:"verdict","text-anchor":"end"},T))}else f&&t.appendChild(Je("text",{x:r+Ut-10,y:a+17,class:"verdict","text-anchor":"end"},f));l.tag&&Xu(t,r+Ut-si(l.tag),a-7,l.tag)}function DM(e,t){return{w:Ut,h:df(e,t),cx:Ut/2,place:(s,r)=>Wg(e,uc(e,t,"card"),t,s,r)}}function mN(e,t,s){const r=Ug(e,t.path),a=r.state==="done"?"passed":r.state in Nd?Nd[r.state]:r.state,l=or(t.label===t.kind?"exit":`exit: ${t.label}`,40),c=xo(l,ql)+16;return{w:Wa+c+(r.tag?6+si(r.tag):0)+(a?6+xo(a,Dg):0),h:Rp,cx:0,exit:!0,place:(u,f)=>{const p=uc(e,t,"exit"),g=f+Rp/2;let v=u+Wa+c;s&&p.appendChild(Ss(u,f,u,f+Rp,"spine")),r.selected&&p.appendChild(Je("rect",{x:u+Wa-3,y:g-Au/2-3,width:c+6,height:Au+6,class:"sel"})),is(p,[Ss(u,g,u+Wa,g,"exit-wire"),Je("rect",{x:u+Wa,y:g-Au/2,width:c,height:Au,class:"exit-box"}),Je("text",{x:u+Wa+8,y:g+3.5,class:"exit-text"},l)]),r.tag&&(Xu(p,v+6,g-6.5,r.tag),v+=6+si(r.tag)),a&&p.appendChild(Je("text",{x:v+6,y:g+3.5,class:"state"},a))}}}function FM(e,t,s){const r=s.map(u=>u.node.kind==="escalate"?mN(e,u.node,!1):ff(e,u.node));let a=Ut/2,l=Ut/2,c=-Tp;for(const u of r)a=Math.max(a,u.cx),l=Math.max(l,u.w-u.cx),c+=u.h+Tp;return{w:a+l,h:c,cx:a,place:(u,f)=>{const p=uc(e,t,"chain"),g=u+a;let v=f,h=null;r.forEach((m,b)=>{b&&(v+=Tp),m.exit?h===null&&(h=v):h!==null&&p.appendChild(Ss(g,h,g,v,"spine")),m.place(m.exit?g:g-m.cx,v),v+=m.h,m.exit||(h=v)}),r[r.length-1].exit&&h!==null&&p.appendChild(Ss(g,h,g,v,"spine"))}}}function UM(e,t,s){const r=df(e,t),a=s.map(m=>({kid:m,box:ff(e,m.node),x:0,c:0}));let l=0,c=0;a.forEach((m,b)=>{b&&(l+=EM),m.x=l,m.c=l+m.box.cx,l+=m.box.w,c=Math.max(c,m.box.h)});const u=a.length-1,f=Math.round((a[0].c+a[u].c)/2),p=Math.min(0,f-Ut/2),g=Math.max(l,f+Ut/2),v=r+$w+_M,h=v+c+$M;return{w:g-p,h,cx:f-p,place:(m,b)=>{const w=uc(e,t,"card"),j=m-p,N=b+r+$w,R=b+h;Wg(e,w,t,j+f-Ut/2,b),w.appendChild(Ss(j+f,b+r,j+f,N)),u&&is(w,[Ss(j+a[0].c,N,j+a[u].c,N),Ss(j+a[0].c,R,j+a[u].c,R)]),a.forEach(($,S)=>{const E=j+$.c,C=$.kid.node.path,T=e.taken.has(C);if(w.appendChild(Je("line",{x1:E,y1:N,x2:E,y2:b+v,class:T?"wire branch taken":"wire branch","data-to":C})),$.kid.name!==null){const A=(S<u?a[S+1].c-6:$.x+$.box.w)-$.c-12,F=or($.kid.name,co(A,ql)),L=Je("text",{x:E+6,y:N+15,class:T?"branch-name taken":"branch-name"},F);w.appendChild(F===$.kid.name?L:Je("g",null,Je("title",null,$.kid.name),L))}w.appendChild(Ss(E,b+v+$.box.h,E,R,T?"taken":void 0)),$.box.place(j+$.x,b+v)})}}}const WM=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function HM(e,t,s,r,a,l){const c=Fg.has(s.status)?s.status:"pending",u=s.label?WM(s.label):`#${s.index+1}`,f=s.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),p=s.p!==void 0?s.p.toFixed(2):"",g=`#${s.index+1}${s.label?` ${s.label}`:""}: ${c==="review"?"needs review":c.replace("-"," ")}${s.outcome?`, ${s.outcome}`:""}${s.pNote?` (${s.pNote})`:""}`,v=Je("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${l?" picked":""}`,"data-path":t.path,"data-item":s.index},Je("title",null,g),Je("rect",{x:r,y:a,width:Sl,height:xh,class:"cell"}),Je("rect",{x:r,y:a,width:3,height:xh,class:"cell-edge"}),Je("text",{x:r+9,y:a+14,class:"cell-name"},or(u,co(Sl-14,Ap))),Je("text",{x:r+9,y:a+27,class:"cell-out"},or(f,co(Sl-18-(p?xo(p,Ap)+6:0),Ap))),p?Je("text",{x:r+Sl-6,y:a+27,class:"cell-p","text-anchor":"end"},p):null);e.appendChild(v)}function BM(e,t){var j;const s=((j=e.marks.items)==null?void 0:j[t.path])??[];if(!s.length)return null;const r=s.length<=AM,[a,l,c]=r?[Sl,xh,MM]:[Ou,Ou,CM],u=Math.min(s.length,r?OM:TM),f=Math.ceil(s.length/u),p=u*(a+c)-c,g=f*(l+c)-c+RM+(r?4:0),v={};for(const N of s)v[N.status]=(v[N.status]??0)+1;const h={};for(const N of s)N.outcome&&(h[N.outcome]=(h[N.outcome]??0)+1);const m=Object.entries(h).map(([N,R])=>`${R} ${N}`),w=[`${v.done??0}/${s.length} done`,v.working?`${v.working} working`:"",v.held?`${v.held} held`:"",v.failed?`${v.failed} failed`:"",v.review?`${v.review} review`:"",...m].filter(Boolean).join(" · ");return{w:Math.max(p,xo(w,ql)),h:g,place:(N,R,$)=>{const S=R-p/2,E=e.marks.selected;s.forEach((C,T)=>{const A=S+T%u*(a+c),F=$+Math.floor(T/u)*(l+c),L=Fg.has(C.status)?C.status:"pending",z=(E==null?void 0:E.path)===t.path&&E.item===C.index;if(r){HM(N,t,C,A,F,z);return}is(N,Je("rect",{x:A,y:F,width:Ou,height:Ou,class:`cell ${L}${z?" picked":""}`,"data-path":t.path,"data-item":C.index},Je("title",null,`#${C.index+1}${C.label?` ${C.label}`:""}: ${L==="review"?"needs review":L.replace("-"," ")}`)))}),is(N,Je("text",{x:R,y:$+g-4,class:"caption","text-anchor":"middle"},w))}}}function GM(e,t,s){const r=ff(e,s),a=df(e,t),l=t.kind==="map"?BM(e,t):null,c=l?l.h+ks:0,u=Math.max(Ut/2,r.cx,l?l.w/2:0)+ks,f=Math.max(Ut/2,r.w-r.cx,l?l.w/2:0)+ks,p=a+ks+c+r.h+ks;return{w:u+f,h:p,cx:u,place:(g,v)=>{const h=uc(e,t,"card"),m=g+u;if(is(h,Je("rect",{x:g,y:v+a/2,width:u+f,height:p-a/2,class:"frame"})),l?(is(h,Ss(m,v+a,m,v+a+ks)),is(h,Ss(m,v+a+ks+l.h,m,v+a+ks+c))):is(h,Ss(m,v+a,m,v+a+ks)),is(h,Ss(m,v+a+ks+c+r.h,m,v+p)),Wg(e,h,t,m-Ut/2,v),l){const b=Je("g",{class:"items"});l.place(b,m,v+a+ks),h.appendChild(b)}r.place(m-r.cx,v+a+ks+c)}}}function pN(e,t){return e.kind==="escalate"?"exit":t.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function ff(e,t){const s=e.kids[t.path]??[],r=pN(t,s);return r==="exit"?mN(e,t,!0):r==="leaf"?DM(e,t):r==="chain"?FM(e,t,s):r==="fan"?UM(e,t,s):GM(e,t,s[0].node)}function Hg(e){const{byPath:t,kids:s}=fN(hN(e)),r=a=>{const l=s[a.path]??[],c=pN(a,l),u=c==="frame"?r(l[0].node):c==="chain"||c==="fan"?l.reduce((f,p)=>f+r(p.node),0):0;return(c==="chain"?0:1)+u};return t["/root"]?r(t["/root"]):0}const mf=e=>`${e} ${e===1?"node":"nodes"}`,hN=e=>(e&&Array.isArray(e.nodes)?e.nodes:[]).filter(t=>t&&typeof t.path=="string"&&typeof t.kind=="string").map(t=>({path:t.path,kind:t.kind,label:String(t.label??t.kind),via:typeof t.via=="string"?t.via:""}));function qM(e,t,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=fN(hN(t)),a=(v,h)=>(e.setAttribute("viewBox",`0 0 ${v} ${h}`),e.setAttribute("width",String(v)),e.setAttribute("height",String(h)),e.style.setProperty("min-width",`${Math.min(v,480)}px`),{w:v,h});if(!r.byPath["/root"])return a(0,0);const l={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=ff(l,r.byPath["/root"]);c.place(Ua,Ua);let u=c.w,f=c.h;const p=(((g=s.diff)==null?void 0:g.removed)??[]).map(v=>`${v.label} (${v.kind})`);if(p.length){const v=["Removed:",...p.map(m=>or(m,co(Math.max(u,300),Cw)))],h=Je("g",{class:"removed-list"},Je("title",null,`Removed: ${p.join(", ")}`));v.forEach((m,b)=>{h.appendChild(Je("text",{x:Ua,y:Ua+f+33+b*Ew,class:"removed"},m)),u=Math.max(u,xo(m,Cw))}),e.appendChild(h),f+=22+v.length*Ew}return a(u+2*Ua,f+2*Ua)}function VM(e){var a,l;const t=e,s=(a=t==null?void 0:t.closest)==null?void 0:a.call(t,"[data-item]");if(s)return{path:s.getAttribute("data-path"),item:Number(s.getAttribute("data-item"))};const r=(l=t==null?void 0:t.closest)==null?void 0:l.call(t,"g[data-path]");return!r||r.classList.contains("chain")?null:{path:r.getAttribute("data-path"),item:null}}const KM=1600;function dc({graph:e,marks:t,onSelect:s,className:r,label:a="Workflow graph",minScale:l=.8,maxScale:c=1.3}){const u=x.useRef(null),[f,p]=x.useState({w:0,h:0}),[g,v]=x.useState(0),h=x.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,t??null]),[e,t]);x.useEffect(()=>{if(!u.current)return;const b=qM(u.current,e,t);p(w=>w.w===b.w&&w.h===b.h?w:b),u.current.style.setProperty("--wf-phase",`-${Date.now()%KM}ms`)},[h]),x.useEffect(()=>{var j;const b=(j=u.current)==null?void 0:j.parentElement;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(([N])=>v(N.contentRect.width));return w.observe(b),()=>w.disconnect()},[]);const m=f.w&&g?Math.min(c,Math.max(l,g/f.w)):1;return n.jsx("svg",{ref:u,role:"img","aria-label":a,className:oe("wf select-none",r),style:f.w?{width:f.w*m,height:f.h*m,maxWidth:"none",minWidth:0}:void 0,onClick:b=>{const w=VM(b.target);w&&s&&s(w)}})}function fc({run:e=!1}){const t=[["hsl(var(--wf-jev))","Jev"],["hsl(var(--wf-parallel))","Parallel"],["hsl(var(--wf-openrouter))","OpenRouter"],["hsl(var(--wf-tool))","Tool"],["hsl(var(--muted-foreground))","Code"],["hsl(var(--primary))","Agent"]],s=[["border-success bg-success/40","Done"],["border-primary bg-primary/20","Working"],["border-dashed border-warning","Held (paused)"],["border-warning bg-warning/60","Needs review"],["border-destructive bg-destructive/60","Failed"],["border-dashed border-border-strong","Pending"]];return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 font-mono text-label text-muted-foreground",children:[t.map(([r,a])=>n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block size-2",style:{background:r}}),a]},a)),e&&n.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&s.map(([r,a])=>n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:oe("inline-block size-2.5 border",r)}),a]},a))]})}const Op=e=>{const t=[...new Set(e)],s=t.slice(0,3).map(r=>`"${r}"`).join(", ");return t.length>3?`${s} and ${t.length-3} more`:s},Rw=(e,t,s=`${t}s`)=>`${e} ${e===1?t:s}`;function XM(e,t,s,r,a){const l=[e.length&&`added ${Rw(e.length,"node")} (${Op(e)})`,t.length&&`edited ${Op(t)}`,s.length&&`removed ${Rw(s.length,"node")} (${Op(s)})`].filter(Boolean);if(!l.length)return r?"Nodes reordered":a?"Connections changed":"No node changed";const c=l.join(", ");return c.charAt(0).toUpperCase()+c.slice(1)}function YM(e){const t=[];let s=null,r=0;for(const a of e){let l=null,c=null;try{l=a.text===null?null:JSON.parse(a.text),c=l===null?null:oi(l)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const u=s?E0(s,c):null,f=u?u.added.map(w=>w.path):c.nodes.map(w=>w.path),p=w=>{var j;return((j=c.nodes.find(N=>N.path===w))==null?void 0:j.kind)!=="chain"},g=u?[...u.changed.map(w=>w.next),...u.rewritten.map(w=>w.next)]:[],v=u?u.moved.map(w=>w.next):[],h=new Map(c.nodes.map(w=>[w.path,w.label])),m=u?u.removed.filter(w=>w.kind!=="chain").map(w=>w.label):[],b=u?u.edges.added.length+u.edges.removed.length:0;t.push({commit:a.commit,at:a.at,run:"run"in a.by?a.by.run:null,reason:a.reason,graph:c,marks:{meta:rc(l,c),diff:{added:f,edited:g,moved:v,removed:u?u.removed.map(({label:w,kind:j})=>({label:w,kind:j})):[]}},added:f,edited:g,removed:m,line:u?XM(f.filter(p).map(w=>h.get(w)??w),g.filter(p).map(w=>h.get(w)??w),m,v.length,b):`First version: ${mf(Hg(c))}`}),s=c}return{steps:t,unreadable:r}}const QM=50,ZM=1800;function JM({v2:e,agentId:t,workflows:s}){const r=s.filter(u=>u.status==="active").map(u=>u.name),[a,l]=x.useState(null),c=a!==null&&r.includes(a)?a:r[0]??null;return c===null?null:n.jsx(eP,{v2:e,agentId:t,name:c,choices:r,onPick:l},c)}function eP({v2:e,agentId:t,name:s,choices:r,onPick:a}){const[l,c]=x.useState(null),[u,f]=x.useState(null),[p,g]=x.useState(0);x.useEffect(()=>{let h=!0;return f(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(t,s,QM)).then(m=>{h&&c(m)},m=>{h&&f(m??new Error("unknown"))}),()=>{h=!1}},[e,t,s,p]);const v=n.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[n.jsx("h2",{className:"caps min-w-0 flex-1 text-small font-semibold",children:"How the workflow changed"}),r.length>1&&n.jsx(Lt,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:a,options:r.map(h=>({value:h,label:h}))})]});return u&&!l?n.jsxs("section",{className:"border","aria-label":"How the workflow changed",children:[v,n.jsx("div",{className:"p-4",children:n.jsx(Pn,{problem:ur(u,"how the workflow changed"),onRetry:()=>g(h=>h+1),className:""})})]}):l?n.jsxs("section",{className:"border","aria-label":"How the workflow changed",children:[v,n.jsx(tP,{data:l})]}):n.jsxs("section",{className:"border","aria-label":"How the workflow changed","aria-busy":!0,children:[v,n.jsx("div",{className:"p-4",children:n.jsx(Bt,{className:"h-48 w-full"})})]})}function tP({data:e,stepMs:t=ZM}){const{steps:s,unreadable:r}=x.useMemo(()=>YM(e.revisions),[e.revisions]),[a,l]=x.useState(Math.max(0,s.length-1)),[c,u]=x.useState(!1);if(x.useEffect(()=>{l(Math.max(0,s.length-1)),u(!1)},[s]),x.useEffect(()=>{if(!c)return;const m=setInterval(()=>l(b=>Math.min(b+1,s.length-1)),t);return()=>clearInterval(m)},[c,s.length,t]),x.useEffect(()=>{c&&a>=s.length-1&&u(!1)},[c,a,s.length]),!e.revisions.length)return null;if(!s.length)return n.jsxs("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:["This workflow's revisions can't be read as a workflow",r?`: ${r} ${r===1?"revision":"revisions"} did not read`:"","."]});const f=s[Math.min(a,s.length-1)],p=s.length,g=m=>{u(!1),l(Math.max(0,Math.min(p-1,m)))},v=()=>{if(c)return u(!1);a>=p-1&&l(0),u(!0)},h=`Revision ${Math.min(a,p-1)+1} of ${p}, ${ft(f.at)}`;return n.jsxs("div",{className:"space-y-3 p-4",children:[p>1&&n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsxs(V,{size:"sm",onClick:v,"aria-label":c?"Pause the replay":"Play the replay","aria-pressed":c,children:[c?n.jsx(ii,{"aria-hidden":!0}):n.jsx(yi,{"aria-hidden":!0}),c?"Pause":"Play"]}),n.jsx(V,{size:"icon",onClick:()=>g(a-1),disabled:a<=0,"aria-label":"Previous revision",children:n.jsx(P_,{"aria-hidden":!0})}),n.jsx(V,{size:"icon",onClick:()=>g(a+1),disabled:a>=p-1,"aria-label":"Next revision",children:n.jsx(Rs,{"aria-hidden":!0})}),n.jsx(bA,{min:1,max:p,value:a+1,onChange:m=>g(m-1),label:"Revision",valueText:h,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[n.jsx("span",{children:p>1?`Revision ${a+1} of ${p}`:"One revision"})," · ",n.jsx("time",{dateTime:f.at,children:ft(f.at)})," · ",f.run?n.jsxs("a",{href:`#/runs/${encodeURIComponent(f.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ua(f.run)]}):"a person"]}),n.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:f.line}),f.reason&&n.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:f.reason})]}),n.jsx("div",{className:"flex min-h-[280px] overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] p-4",children:n.jsx(dc,{graph:f.graph,marks:f.marks,label:`The workflow at revision ${a+1} of ${p}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(fc,{}),n.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[n.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",n.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed"]})]}),(e.total>e.revisions.length||e.truncated||r>0)&&n.jsxs("p",{className:"text-body text-muted-foreground",children:[e.total>e.revisions.length&&`The latest ${e.revisions.length} of ${e.total} revisions. `,e.truncated&&"Older changes are past the log this server keeps. ",r>0&&`${r} ${r===1?"revision":"revisions"} could not be read as a workflow and ${r===1?"is":"are"} left out.`]})]})}function gN({id:e,checked:t,onChange:s,busy:r,disabled:a,quiet:l,server:c,problem:u,className:f}){return n.jsxs("div",{className:oe("space-y-2",f),children:[n.jsxs("div",{className:oe("flex gap-4",l?"items-center":"items-start"),children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{id:e,className:"text-lead font-semibold",children:"Learns from its runs"}),!l&&n.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:"After each run, it looks back and keeps a short note when something will help next time; later runs read them first."})]}),n.jsx(wA,{checked:t,onChange:s,busy:r,disabled:a,labelledBy:e})]}),c==="off"&&n.jsx("p",{className:"font-mono text-label text-warning-text",children:"This server has learning turned off, so no run learns until it's on."}),u]})}function nP({fields:e,onFields:t,saved:s,server:r,error:a,warning:l}){const c=e.learning??s,u=c===!0||c==="notes",f=p=>t({learning:p===!1&&s===void 0?void 0:p});return n.jsxs("div",{children:[n.jsx("div",{className:"mb-2",children:n.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),n.jsx(gN,{id:"learning-switch",className:"border px-4 py-3",checked:u,server:r,onChange:p=>f(p?s==="notes"?"notes":!0:!1)}),u&&n.jsx("fieldset",{"aria-label":"What it learns",className:"mt-2 space-y-2",children:[[!0,"Notes, skills and workflows","Once a job repeats, it can learn it as a workflow and run it as one step."],["notes","Notes and skills only","It never runs a learned workflow, and is never asked to draft one."]].map(([p,g,v])=>n.jsxs("label",{className:oe("flex items-start gap-3 border px-3 py-2.5",c===p&&"border-foreground"),children:[n.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:c===p,onChange:()=>f(p)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono text-body",children:g}),n.jsx("span",{className:"block text-small text-muted-foreground",children:v})]})]},String(p)))}),a&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:a}),l&&n.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:l})]})}const sP=["ready","unavailable"],Yu=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Aw=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function pf(e){if(Yu(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function Ow(e){const t=Yu(e)?e.places:void 0;if(!Yu(t)||!Array.isArray(t.modes)||!Array.isArray(t.boxes))return null;const s=t.boxes.filter(Yu).filter(a=>typeof a.id=="string").map(a=>({id:a.id,available:a.available===!0,...typeof a.reason=="string"?{reason:a.reason}:{},...sP.includes(a.state)?{state:a.state}:{}})),r=pf(t.default_place);return r?{modes:t.modes.filter(a=>typeof a=="string"),boxes:s,defaultPlace:r}:null}const Mp=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,rP=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",oP=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",aP={v:2,name:"decision",schemas:{Input:{type:"object",required:["case_id","payment"],properties:{case_id:{type:"string"},payment:{type:"object",required:["descriptor"],properties:{descriptor:{type:"string"},memo:{type:"string"},merchant_site:{type:"string"},amount:{type:"string"}},description:"What the payment says about itself: card descriptor, memo, and the merchant's own site text."}},examples:[{case_id:"case-1",payment:{descriptor:"TILEWORKS SUPPLY CO 8885550142 OH",memo:"Invoice 4471: 40 pallets glazed ceramic floor tile",amount:"USD 18,420.00",merchant_site:"Tileworks Supply sells porcelain and ceramic tile to contractors across the Midwest."}}]},Verdict:{type:"object",additionalProperties:!1,required:["verdict"],properties:{verdict:{type:"string",enum:["gambling","not_gambling","unclear"],description:"Is the payment described in `payment` a payment for gambling: staking money or a paid currency on a game of chance or skill for a chance to win money or prizes redeemable for money, including sweepstakes casinos and social casinos that pay out cash prizes?",criteria:{gambling:"It is a payment for gambling, as described.",not_gambling:"It pays for something else: goods, services or a transfer with no stake on a game.",unclear:"What the payment says about itself is not enough to tell."}}}}},input:{schemaId:"Input"},output:{schemaId:"Verdict",path:"judged"},root:{node:"chain",steps:[{node:"judge",label:"judge",timeoutMs:6e4,state:{case_id:"{case_id}",payment:"{payment}"},out:"Verdict",as:"judged"},{node:"escalate",label:"unclear",when:{predicate:"field_equals",path:"judged.verdict",value:"unclear"},kind:"review",stage:"decision",summary:"A person decides case {case_id}: what the payment says is not enough to tell."},{node:"escalate",label:"no-confidence",when:{predicate:"not",of:{predicate:"field_type",path:"judged$answers.answers.verdict.confidence",type:"number"}},kind:"review",stage:"decision",summary:"A person decides case {case_id}: the judge gave no confidence."},{node:"escalate",label:"low-confidence",when:{predicate:"lt",path:"judged$answers.answers.verdict.confidence",n:.7},kind:"review",stage:"decision",summary:"A person decides case {case_id}: the judge leaned {judged.verdict}, below the confidence this decision needs."}]}},iP=["jev","parallel"];function lP(e="jev"){const t=structuredClone(aP);return e!=="jev"&&Object.assign(t.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),t}const cP={v:2,name:"workflow",schemas:{Input:{type:"object",required:["task"],additionalProperties:!1,properties:{task:{type:"string",minLength:1,description:"What the step is asked to do."}},examples:[{task:"Write three lines on what this workflow could do next."}]},Answer:{type:"object",required:["answer"],additionalProperties:!1,properties:{answer:{type:"string"}}}},input:{schemaId:"Input"},output:{schemaId:"Answer",path:"step"},root:{node:"chain",steps:[{node:"agent",label:"step",state:{task:"{task}"},out:"Answer",as:"step",effort:"low",instructions:"Do what `task` asks and put your answer in `answer`."}]}},uP=()=>structuredClone(cP);function Bg(e,t,s){const{name:r,description:a,...l}=t,c={...e.definition,...l},u={...e.definition};c.computer!==void 0&&(delete c.place,delete u.place),e.kind==="workflow"&&(delete c.thinking,delete c.instructions,delete c.model),c.model===""&&delete c.model,c.tool_settings&&!Object.keys(c.tool_settings).length&&delete c.tool_settings;for(const p of Object.keys(c))c[p]===void 0&&delete c[p];const f=Al({...c,version:0},{...u,version:0});return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function Al(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const s=Object.keys(e).filter(a=>e[a]!==void 0),r=Object.keys(t).filter(a=>t[a]!==void 0);return s.length===r.length&&s.every(a=>Al(e[a],t[a]))}const Gg="decision",xN="workflow",yN={[Gg]:lP,[xN]:uP},bN=e=>e!==void 0&&Object.hasOwn(yN,e);function dP(e){var s,r;if(!((s=e==null?void 0:e.adapters)!=null&&s.includes("runJudge")))return;const t=(r=e.decisions)==null?void 0:r.providers;return t?iP.find(a=>t.some(l=>l.id===a&&l.available)):"jev"}const fP="You are a helpful agent. Do the task you're given and report what you found.";function mP(e){var t;return bN(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:yN[e.harness](e.decisionProvider),skills:[],tools:[]}}:{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},instructions:e.instructions,harness:e.harness,...e.thinking?{thinking:e.thinking}:{},...(t=e.model)!=null&&t.trim()?{model:e.model.trim()}:{},...e.computer?{computer:e.computer}:{},...e.learning?{learning:e.learning}:{},...e.max_cost_usd!==void 0?{max_cost_usd:e.max_cost_usd}:{},skills:[],tools:e.tools,...e.tool_settings&&Object.keys(e.tool_settings).length?{tool_settings:e.tool_settings}:{},...e.approvals==="never"?{approvals:"never"}:{}}}}function Mw(e){const t=(e??"").trim();if(!t)return{ok:!0,value:void 0};const s=t.replace(/^\$\s*/,""),r=Number(s);return s&&Number.isFinite(r)?{ok:!0,value:r}:{ok:!1,message:"A spend cap is a number of dollars, such as 2.50; empty means none."}}function pP(e){return(Array.isArray(e)?e:[]).flatMap(t=>{if(!t||typeof t!="object"||typeof t.name!="string")return[];const{name:s,available:r,summary:a,blurb:l,missing:c,reason:u,harnesses:f,call_only:p,sandbox_only:g,nodes:v}=t;return[{name:s,available:r!==!1,...typeof a=="string"&&a?{summary:a}:{},...typeof l=="string"&&l.trim()?{blurb:l.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof u=="string"&&u?{reason:u}:{},harnesses:Array.isArray(f)?f:[],...p===!0?{call_only:!0}:{},...g===!0?{sandbox_only:!0}:{},...typeof v=="boolean"?{nodes:v}:{}}]})}function hf(e,t){return t.filter(s=>!s.call_only&&s.harnesses.includes(e))}function yh(e,t,s,{mcpHarnesses:r,workflow:a=!1}={}){if(t.startsWith("mcp:"))return!r||r.includes(e);const l=s.find(c=>c.name===t);return l?l.call_only?a:hf(e,s).some(c=>c.name===t):!0}const bh=e=>wN[e]??e,Pw=e=>e.map(bh).join(" and ");function Lw(e,t,s,r){var l;if(t.startsWith("mcp:"))return`${bh(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${Pw(r)} do`:""}`;const a=((l=s.find(c=>c.name===t))==null?void 0:l.harnesses)??[];return a.length?`Runs on ${Pw(a)} here, not on ${bh(e)}`:"No harness runs it here"}function hP(e,t,s,r,a={}){const l=[...t,...s.filter(c=>!t.includes(c))];return{tools:l.filter(c=>yh(e,c,r,a)),held:l.filter(c=>!yh(e,c,r,a))}}const gP=(e,t)=>e.sandbox_only&&(t==null?void 0:t.mode)!=="sandbox"?"Sandbox-only: it runs in a box, and this agent's place is the runner":void 0,qg=new Set(["browser"]),Vg=(e,t,s)=>e||t.some(r=>qg.has(r))||!s?{mode:"runner"}:s.defaultPlace;function vN(e,t){const s=pf(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",a=e.definition.tools??[];if(!(!r&&!a.some(l=>qg.has(l))&&!t))return{place:Vg(r,a,t),byDefault:!0}}const Pp=(e,t,s)=>hf(e,t).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!qg.has(r.name):!r.sandbox_only)).map(r=>r.name),xP=["web_fetch","web_search"],Iw=e=>e.some(t=>xP.includes(t)),wN={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},yP=["pi","claude-agent","codex","opencode"];function bP(e,t){const s=yP.flatMap(r=>{const a=e.find(l=>l.id===r);return a?[{id:r,label:wN[r],available:a.available,reason:a.reason}]:[]});return t&&(s.push({id:Gg,label:"Decision",available:t.available,reason:t.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),s.push({id:xN,label:"Workflow",available:!0,reason:void 0})),s}function vP(e){var t;return e.status===412||e.code==="precondition_failed"?{kind:"conflict",message:e.message}:e.status===422&&((t=e.fields)!=null&&t.length)?{kind:"invalid",message:e.message,fields:Object.fromEntries(e.fields.map(s=>[s.field,s.message]))}:{kind:"other",message:e.message}}function gf(e,t=!1){var s,r,a;return e.status===412||e.code==="precondition_failed"?t?{kind:"taken"}:{kind:"conflict"}:(s=e.problems)!=null&&s.length?{kind:"refused",problems:e.problems}:{kind:"other",message:((a=(r=e.fields)==null?void 0:r[0])==null?void 0:a.message)??e.message,code:e.code}}function wP(e,t){const s=`definition.${t}`;return(e??[]).filter(r=>r.field===s||r.field.startsWith(`${s}[`)||r.field.startsWith(`${s}.`)||r.field.startsWith(`${s}/`))}const da=(e,t,s)=>({...ur(e,t),title:s}),kP=(e,t)=>{const s=e.get(t);return s!=null&&s.title?mn(s):`run ${ua(t)}`},kN="text-lead leading-[1.65] [&_a]:text-primary-text [&_a]:underline [&_a]:underline-offset-2 [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_code]:text-body [&_h1]:mb-2 [&_h1]:text-prose [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-3 [&_h2]:text-lead [&_h2]:font-semibold [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:mb-0.5 [&_ol]:mb-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:mb-2 [&_p:last-child]:mb-0 [&_pre]:mb-2 [&_pre]:overflow-x-auto [&_pre]:border [&_pre]:bg-background [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-small [&_ul]:mb-2 [&_ul]:list-disc [&_ul]:pl-5",jP=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),zw=20;function NP({agent:e,v2:t,focus:s=[],server:r,onAgent:a,places:l,onChanged:c}){var et;const[u,f]=x.useState(null),[p,g]=x.useState(null),[v,h]=x.useState([]),[m,b]=x.useState({items:[],cursor:null,pages:0}),[w,j]=x.useState({items:[],cursor:null,pages:0}),[N,R]=x.useState(!1),[$,S]=x.useState(0),E=x.useRef(0),C=x.useRef(!1),T=()=>{const se=++E.current;C.current=!1,g(null);const ke=t.agentLearning(e.agent_id).then(Se=>{se===E.current&&(f(Se),b({items:[],cursor:Se.notes.next_cursor,pages:0}),j({items:[],cursor:Se.log.next_cursor,pages:0}))},Se=>{se===E.current&&g(Se??new Error("unknown"))});return t.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(Se=>{se===E.current&&h(Se.runs)},()=>{}),ke};x.useEffect(()=>{T()},[t,e.agent_id]);const A=()=>(c==null||c(),T()),F=()=>{if(!m.cursor||C.current)return;const se=E.current;C.current=!0,t.learningNotes(e.agent_id,m.cursor).then(ke=>{se===E.current&&(C.current=!1,b(Se=>({items:[...Se.items,...ke.items.filter(Fe=>!Se.items.some(fe=>fe.file===Fe.file))],cursor:ke.next_cursor,pages:Se.pages+1})))},ke=>{se===E.current&&(C.current=!1,b(Se=>({...Se,error:ke??new Error("unknown")})))})},L=e.definition.learning===!0||e.definition.learning==="notes",z=!!e.archived_at,W=x.useMemo(()=>[...(u==null?void 0:u.notes.items)??[],...m.items],[u,m.items]),U=W.filter(se=>se.status==="active"),D=W.filter($1),K=(u==null?void 0:u.skills)??[],P=(u==null?void 0:u.workflows)??[],[G,I]=x.useState(void 0),q=D.length>0||[...K,...P].some(se=>se.status==="pending")||P.some(se=>se.status==="active");x.useEffect(()=>{if(!q||G!==void 0)return;let se=!0;return Promise.resolve().then(()=>t.capabilities()).then(ke=>{se&&I(qA(ke))},()=>{se&&I("password")}),()=>{se=!1}},[q]);const O=W.filter(se=>se.status==="superseded"||se.status==="retired"),B=x.useMemo(()=>{const se=new Map(W.map(Se=>[Se.file,Se])),ke=new Map;for(const Se of W){if(Se.status==="superseded")continue;const fe=[...new Set([...nO(Se.text),...W.filter(Le=>Le.status==="superseded"&&Le.superseded_by===Se.file).map(Le=>Le.file)])].flatMap(Le=>{const He=se.get(Le);return He?He.status==="superseded"&&He.superseded_by===Se.file?[{file:Le,name:He.name}]:[]:[{file:Le,name:null}]});fe.length&&ke.set(Se.file,fe)}return ke},[W]),ee=x.useMemo(()=>new Map(v.map(se=>[se.run_id,se])),[v]),le=x.useMemo(()=>uO([...(u==null?void 0:u.log.items)??[],...w.items]),[u,w.items]),ie=s.filter(se=>!W.some(ke=>ke.file===se)).length>0;x.useEffect(()=>{u&&ie&&m.cursor&&m.error===void 0&&m.pages<zw&&F()},[u,ie,m.cursor,m.pages]);const ue=W.some(se=>!le.has(se.file));x.useEffect(()=>{if(!u||!ue||!w.cursor||w.pages>=zw)return;const se=E.current;t.learningLog(e.agent_id,w.cursor).then(ke=>{se===E.current&&j(Se=>({items:[...Se.items,...ke.items],cursor:ke.next_cursor,pages:Se.pages+1}))},()=>{se===E.current&&j(ke=>({...ke,cursor:null}))})},[u,ue,w.cursor]);const ae=v.filter(se=>se.learning&&(se.learning.state==="merged"||se.learning.state==="dropped")).length;if(p&&!u)return n.jsx(Pn,{problem:ur(p,"what this agent learned"),onRetry:T,className:""});if(!u)return n.jsx(_P,{});const ce=p?n.jsx(SP,{error:p,onRetry:T}):null,he=se=>n.jsx(EP,{agent:e,v2:t,onAgent:a,server:r,disabled:z,quiet:se});return!W.length&&!K.length&&!P.length&&!N?n.jsxs("div",{className:"space-y-6",children:[ce,n.jsx(TP,{on:L,lookedBack:ae,switchRow:he(!0),onAdd:z?void 0:()=>R(!0)}),n.jsx(_w,{v2:t,agentId:e.agent_id,quiet:!0}),L&&!z&&n.jsx(Sw,{v2:t,agentId:e.agent_id,onFinished:()=>{S(se=>se+1),T()}}),n.jsx(vw,{v2:t,agentId:e.agent_id,on:L,quiet:!0},$),n.jsx(Fw,{runs:v})]}):n.jsxs("div",{className:"space-y-6",children:[D.length>0&&n.jsxs("section",{className:"border border-warning/50","aria-label":"Waiting for your OK",children:[n.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b border-warning/50 px-4 py-3 text-small font-semibold",children:["Waiting for your OK",n.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:D.length})]}),n.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:VA}),((et=vN(e,l))==null?void 0:et.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&n.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:KA}),n.jsx("ul",{className:"space-y-3 p-4",children:D.map(se=>n.jsx("li",{children:n.jsx(Dw,{note:se,v2:t,agentId:e.agent_id,readOnly:z,focused:s.includes(se.file),from:le.get(se.file),runs:ee,onChanged:A,approves:G,replaces:B.get(se.file)})},se.file))})]}),n.jsx(_w,{v2:t,agentId:e.agent_id}),JA(u.impact)&&n.jsx($P,{impact:u.impact}),L&&!z&&n.jsx(Sw,{v2:t,agentId:e.agent_id,onFinished:()=>{S(se=>se+1),T()}}),n.jsx(vw,{v2:t,agentId:e.agent_id,on:L},$),n.jsx(JM,{v2:t,agentId:e.agent_id,workflows:P}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[n.jsxs("div",{className:"min-w-0 space-y-6",children:[n.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Notes",children:[n.jsxs("div",{className:"flex flex-wrap items-end gap-x-4 gap-y-2",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"What it has learned"}),n.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:U.length?`${ei(U.length)} in use. Every later run reads ${U.length===1?"it":"them"} before it starts.`:[...K,...P].some(se=>se.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!z&&!N&&n.jsxs(V,{size:"sm",onClick:()=>R(!0),children:[n.jsx(Ol,{"aria-hidden":!0})," Add a note"]})]}),ce,!L&&n.jsx(CP,{server:r}),N&&n.jsx($N,{title:"New note",v2:t,agentId:e.agent_id,taken:W.map(se=>se.file),onDone:se=>{R(!1),se&&A()}},"new"),n.jsx("ul",{className:"space-y-3",children:U.map(se=>n.jsx("li",{children:n.jsx(Dw,{note:se,v2:t,agentId:e.agent_id,readOnly:z,focused:s.includes(se.file),from:le.get(se.file),runs:ee,onChanged:A,replaces:B.get(se.file)})},se.file))}),m.error!==void 0&&n.jsx(Pn,{problem:ur(m.error,"more notes"),onRetry:F,className:""}),m.cursor&&n.jsx("div",{className:"flex justify-center",children:n.jsx(V,{size:"sm",onClick:F,children:"Load more notes"})}),O.length>0&&n.jsx(PP,{notes:O,all:W,from:le,focus:s,runs:ee,v2:t,agentId:e.agent_id,readOnly:z,onChanged:A})]}),["skill","workflow"].map(se=>{const ke=se==="skill"?K:P;if(!ke.length)return null;const Se=se==="skill"?"Skills it learned":"Workflows it learned",Fe=ke.filter(Le=>Le.status!=="retired"),fe=ke.filter(Le=>Le.status==="retired");return n.jsxs("section",{className:"min-w-0 space-y-3","aria-label":Se,children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold",children:Se}),n.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:Fe.length?se==="skill"?`${hd(Fe.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${hd(Fe.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${se} is in use: the next run gets none.`})]}),Fe.length>0&&n.jsx("ul",{className:"space-y-3",children:Fe.map(Le=>n.jsx("li",{children:n.jsx(RP,{item:Le,kind:se,v2:t,agentId:e.agent_id,readOnly:z,runs:ee,approves:G,onChanged:A})},Le.file))}),fe.length>0&&n.jsx(LP,{kind:se,items:fe,v2:t,agentId:e.agent_id,runs:ee,readOnly:z,onChanged:A})]},se)})]}),n.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[n.jsx(jN,{title:"Learning",children:he(!1)}),n.jsx(Fw,{runs:v}),n.jsx(zP,{index:u.index,skills:K.filter(se=>se.status==="active").map(se=>se.name),off:!L||r==="off"})]})]})]})}function SP({error:e,onRetry:t}){const s=ur(e,"the notes"),r=[s.said,s.code].filter(Boolean).join(" · ");return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border border-destructive/40 px-3 py-2 text-body",role:"alert",title:r||void 0,children:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't refresh the notes: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)," What's shown may be out of date."]}),n.jsx(V,{type:"button",onClick:t,size:"sm",children:"Try again"})]})}function jN({title:e,children:t,label:s}){return n.jsxs("section",{className:"border","aria-label":s??e,children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),t]})}function _P(){const e="block bg-muted motion-safe:animate-pulse";return n.jsxs("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading what it learned",children:[n.jsx("span",{"aria-hidden":!0,className:oe(e,"h-6 w-56")}),[0,1,2].map(t=>n.jsxs("div",{"aria-hidden":!0,className:"space-y-3 border p-5",children:[n.jsx("span",{className:oe(e,"h-4 w-1/3")}),n.jsx("span",{className:oe(e,"h-3 w-2/3 bg-muted/70")}),n.jsx("span",{className:oe(e,"h-3 w-1/2 bg-muted/70")})]},t)),n.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function $P({impact:e}){const{before:t,after:s}=e,r=[{label:"Answers in",now:yd(s.median_duration_s),was:yd(t.median_duration_s),delta:sw(t.median_duration_s,s.median_duration_s)},...R1(e)?[{label:"A run costs",now:ti(s.median_cost_usd),was:ti(t.median_cost_usd),delta:sw(t.median_cost_usd,s.median_cost_usd)}]:[]],a=A1(e),l=[`Medians of ${po(t.runs)} before it first learned and ${po(s.runs)} that started from what it learned (a note, a skill or a workflow).`,`Costs are of the ${t.cost_runs} and ${s.cost_runs} runs whose cost is known.`].join(" ");return n.jsx("section",{className:"border","aria-label":ZA(e),children:n.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4 px-4 py-3",children:[n.jsxs("div",{className:"flex items-baseline gap-2.5",children:[n.jsx("span",{className:"caps text-small font-semibold",children:"Since it learned"}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",title:l,children:["on ",po(s.runs)]})]}),n.jsxs("dl",{className:"flex flex-1 flex-wrap items-baseline gap-x-10 gap-y-3","aria-hidden":!0,children:[r.map(c=>n.jsxs("div",{className:"flex items-baseline gap-3",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:c.label}),n.jsxs("dd",{className:"flex items-baseline gap-2 font-mono",children:[n.jsx("span",{className:"text-figure font-semibold leading-none",children:c.now}),n.jsxs("span",{className:"text-small text-muted-foreground",children:["instead of ",c.was]}),c.delta!==null&&c.delta!==0&&n.jsxs("span",{className:oe("text-small",c.delta<0?"text-primary-text":"text-warning-text"),children:[c.delta>0?"+":"−",Math.abs(c.delta),"%"]})]})]},c.label)),a!==null&&n.jsxs("div",{className:"flex items-baseline gap-3",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Learning itself"}),n.jsxs("dd",{className:"font-mono text-body text-muted-foreground",children:[ti(a)," a run"]})]})]})]})})}function EP({agent:e,v2:t,onAgent:s,server:r,disabled:a,quiet:l}){const[c,u]=x.useState(!1),[f,p]=x.useState(null),[g,v]=x.useState(null),h=async m=>{u(!0),p(null),v(m);try{const{agent:b,etag:w}=await t.getAgent(e.agent_id),j=Bg(b,{learning:m},m?"Learning on":"Learning off");if(j.unchanged)s==null||s(b);else{const{unchanged:N,...R}=j;s==null||s((await t.updateDefinition(e.agent_id,R,w)).agent)}}catch(b){p(b??new Error("unknown"))}v(null),u(!1)};return n.jsx(gN,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:l,checked:g??(e.definition.learning===!0||e.definition.learning==="notes"),onChange:m=>void h(m),busy:c,disabled:a,server:r,problem:f?n.jsx(Pn,{problem:da(f,"the agent","Learning was not changed."),className:"mt-2"}):null})}function CP({server:e}){return n.jsxs(On,{tone:"warning",children:["Learning is off",e==="off"?" on this server":"",", so later runs don't read these notes. They're kept for when it's back on."]})}function TP({on:e,lookedBack:t,switchRow:s,onAdd:r}){return n.jsxs("section",{className:"mx-auto max-w-xl border","aria-label":"Learning",children:[n.jsxs("div",{className:"px-6 py-12 text-center",children:[n.jsx(qh,{className:"mx-auto mb-3 size-5 text-primary-text","aria-hidden":!0}),n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:e?"Nothing learned yet.":"Learning is off for this agent."}),n.jsx("p",{className:"mx-auto mt-2 max-w-md text-lead text-muted-foreground",children:e?"After each run, it looks back and keeps a note when something will help next time. Its notes show here, and every later run reads them first.":"With learning on, it keeps short notes on what worked after each run, and every later run reads them before it starts."}),e&&t>0&&n.jsxs("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:[po(t)," looked back: nothing worth keeping yet."]})]}),n.jsx("div",{className:"border-t",children:s}),r&&n.jsx("div",{className:"flex justify-center border-t px-4 py-3",children:n.jsxs(V,{size:"sm",variant:"ghost",onClick:r,children:[n.jsx(Ol,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function Dw({note:e,v2:t,agentId:s,readOnly:r,focused:a,from:l,runs:c,onChanged:u,approves:f,replaces:p=[]}){const[g,v]=x.useState(!1),[h,m]=x.useState(!1),[b,w]=x.useState(!1),[j,N]=x.useState(a),[R,$]=x.useState(null),[S,E]=x.useState(!1),[C,T]=x.useState(null),A=x.useRef(null),F=$1(e),L=async()=>{const U=D=>n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:D});E(!0),T(null);try{await t.approveNote(s,e.file,e.etag)}catch(D){E(!1),T(D instanceof Ee&&gf(D).kind==="conflict"?U(`${of} Reload the tab to see the newest version.`):n.jsx(Pn,{problem:da(D,"the note","The note was not approved."),className:""}));return}await u(),E(!1)};if(x.useEffect(()=>{var D,K;if(!a)return;N(!0),(K=(D=A.current)==null?void 0:D.scrollIntoView)==null||K.call(D,{block:"center",behavior:"smooth"});const U=setTimeout(()=>N(!1),2600);return()=>clearTimeout(U)},[a]),x.useEffect(()=>{if(!R)return;const U=setTimeout(()=>$(null),2400);return()=>clearTimeout(U)},[R]),g)return n.jsx($N,{title:"Edit note",v2:t,agentId:s,file:e.file,seen:e,onDone:U=>{v(!1),U&&($("Saved"),u())}});const z=Hl(e.text),W=vh(e.last_change);return n.jsxs("article",{ref:A,id:`note-${e.file}`,tabIndex:-1,"aria-label":e.name,className:oe("border bg-card/40 outline-none focus-visible:border-primary transition-[border-color,box-shadow] duration-slow",j&&"border-primary ring-1 ring-primary"),children:[n.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"min-w-0 break-words text-prose font-semibold leading-snug",children:e.name}),n.jsx(Ce,{children:k1(e.type)}),e.origin==="you"&&n.jsx(Ce,{tone:"muted",children:"From you"}),R&&n.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:R})]}),n.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),F&&f==="password"&&n.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:E1})]}),!r&&!b&&n.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[F?f==="yes"&&n.jsx(V,{size:"sm",variant:"solid",onClick:()=>void L(),disabled:S,"aria-label":`Approve ${e.name}`,children:S?"Approving":"Approve"}):n.jsxs(V,{size:"sm",variant:"ghost",onClick:()=>v(!0),"aria-label":`Edit ${e.name}`,children:[n.jsx(Xl,{"aria-hidden":!0})," Edit"]}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>w(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),C&&n.jsx("div",{className:"px-5 pt-3",children:C}),z.trim()&&n.jsx(yf,{text:z}),n.jsxs("footer",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[(l==null?void 0:l.run)&&n.jsx(xf,{run:l.run.id,runs:c,at:l.run.at,reason:l.run.reason}),W&&n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(Vh,{className:"size-3","aria-hidden":!0}),W]}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(Zu,{className:"size-3","aria-hidden":!0}),"Given to ",po(e.runs.given)]}),e.runs.read>0&&n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(Zu,{className:"size-3","aria-hidden":!0}),"Read in ",po(e.runs.read)]}),p.length>0&&n.jsxs("button",{type:"button",onClick:()=>m(U=>!U),"aria-expanded":h,className:"flex items-center gap-1.5 hover:text-foreground",children:[n.jsx(H_,{className:"size-3","aria-hidden":!0}),"Replaces ",p.length," older ",p.length===1?"note":"notes",n.jsx(aa,{className:oe("size-3 transition-transform",h&&"rotate-180"),"aria-hidden":!0})]})]}),h&&p.length>0&&n.jsx("ul",{"aria-label":"Notes it replaces",className:"space-y-1 border-t px-5 py-2.5 text-body text-muted-foreground",children:p.map(U=>n.jsx("li",{className:oe("break-words",U.name===null&&"font-mono text-small"),children:U.name??U.file},U.file))}),b&&n.jsx(SN,{name:e.name,kind:"note",retire:()=>t.retireNote(s,e.file,e.etag),onDone:async U=>{U&&await u(),w(!1)}})]})}function RP({item:e,kind:t,v2:s,agentId:r,readOnly:a,runs:l,approves:c,onChanged:u}){const[f,p]=x.useState(!1),[g,v]=x.useState(null),[h,m]=x.useState(null),[b,w]=x.useState(null),[j,N]=x.useState(!1),[R,$]=x.useState(!1),[S,E]=x.useState(!1),C=x.useRef(Ks()).current,[T,A]=x.useState(null),[F,L]=x.useState(null),z=e.status==="pending",W=t==="workflow"&&e.status==="active"&&c==="yes",U=async()=>{w(null),v(null),m(null);try{const I=await s.readNote(r,e.file);v(I.note),m(I.etag)}catch(I){w(I??new Error("unknown"))}},D=async()=>{if(f)return p(!1);p(!0),g===null&&await U()};x.useEffect(()=>{g===null&&h===null||(f?U():(v(null),m(null)))},[e.etag]);const K=t==="skill"&&f&&h?h:e.etag,P=async()=>{N(!0),L(null);try{await s.approveNote(r,ch(e),K)}catch(I){N(!1),L(I instanceof Ee&&gf(I).kind==="conflict"?n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${of} Reload the tab to see the newest version.`}):n.jsx(Pn,{problem:da(I,`the ${t}`,`The ${t} was not approved.`),className:""}));return}await u(),N(!1)},G=`the ${t} ${e.name}`;return n.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[n.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),z&&n.jsxs(Ce,{tone:"warning",children:[n.jsx(Bh,{className:"size-3","aria-hidden":!0}),"Waits for your OK"]})]}),e.description&&n.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),z&&c==="password"&&n.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:E1})]}),n.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!a&&!R&&!S&&n.jsxs(n.Fragment,{children:[z&&c==="yes"&&n.jsx(V,{size:"sm",variant:"solid",onClick:()=>void P(),disabled:j,"aria-label":`Approve ${e.name}`,children:j?"Approving":"Approve"}),W&&n.jsx(V,{size:"sm",onClick:()=>{A(null),E(!0)},"aria-label":`Make ${e.name} an agent`,children:"Make this an agent"}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>$(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),n.jsxs(V,{size:"sm",variant:"ghost",onClick:()=>void D(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${G}`,children:[n.jsx(aa,{className:oe("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),F&&n.jsx("div",{className:"px-5 pt-3",children:F}),T&&n.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",n.jsx("a",{href:`#/agents/${encodeURIComponent(T.agent_id)}`,className:"font-mono underline underline-offset-2",children:T.definition.name}),". Open it to run it."]}),f&&(b!==null?n.jsx("div",{className:"px-5 pt-3",children:n.jsx(Pn,{problem:ur(b,G),onRetry:()=>void U(),className:""})}):g===null?n.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${G}`,children:n.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):t==="skill"?n.jsx(yf,{text:Hl(g)}):n.jsx(AP,{name:e.name,text:g})),n.jsxs("footer",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[e.run&&n.jsx(xf,{run:e.run,runs:l}),vh(e.last_change)&&n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(Vh,{className:"size-3","aria-hidden":!0}),vh(e.last_change)]}),n.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),R&&n.jsx(SN,{name:e.name,kind:t,retire:()=>s.retireNote(r,ch(e),K),onDone:async I=>{I&&await u(),$(!1)}}),S&&n.jsx(MP,{name:e.name,keys:C,promote:I=>s.promoteWorkflow(r,e.name,I),onDone:I=>{E(!1),I&&A(I)}})]})}function AP({name:e,text:t}){const{doc:s,graph:r}=x.useMemo(()=>{try{const c=JSON.parse(t);return{doc:c,graph:oi(c)}}catch{return{doc:null,graph:null}}},[t]),a=x.useMemo(()=>r?{meta:rc(s,r)}:void 0,[s,r]),l=n.jsx("pre",{className:"max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:t});return r!=null&&r.nodes.length?n.jsxs("div",{className:"mx-5 mt-3 space-y-2",children:[n.jsx("div",{className:"overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-4",children:n.jsx(dc,{graph:r,marks:a,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),n.jsx(fc,{}),n.jsxs("details",{children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"workflow.json"}),n.jsx("div",{className:"mt-2",children:l})]})]}):n.jsx("div",{className:"mx-5 mt-3",children:l})}function vh(e){return e&&e.kind!=="learned"?`${v1(e.kind,e.by)} · ${ft(e.at)}`:null}function NN(e){return(e==null?void 0:e.by)==="host"?LA:e?`${v1("retired",e.by)} · ${ft(e.at)}`:"Retired"}function xf({run:e,runs:t,at:s,reason:r}){return n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap",title:r?`Kept because: ${r}`:void 0,children:[n.jsx(qh,{className:"size-3 shrink-0 text-primary-text","aria-hidden":!0}),"Learned in"]}),n.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"shrink-0 font-mono text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",title:kP(t,e),children:ua(e)}),s&&n.jsxs("span",{className:"shrink-0",children:["· ",ft(s)]})]})}function yf({text:e}){const[t,s]=x.useState(!1),r=e.split(`
541
+ `).length>8||e.length>520,a=x.useMemo(()=>mo(e),[e]);return n.jsxs("div",{className:"px-5 pb-4 pt-3",children:[n.jsxs("div",{className:oe("relative",r&&!t&&"max-h-[9.5rem] overflow-hidden"),children:[n.jsx("div",{className:kN,dangerouslySetInnerHTML:{__html:a}}),r&&!t&&n.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-background to-transparent","aria-hidden":!0})]}),r&&n.jsxs("button",{type:"button",onClick:()=>s(l=>!l),className:"caps mt-2 flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(aa,{className:oe("size-3.5 transition-transform",t&&"rotate-180"),"aria-hidden":!0}),t?"Show less":"Show all"]})]})}const OP={note:"Later runs stop reading it. It stays under Earlier notes.",skill:"Later runs stop getting it. It stays under Earlier skills.",workflow:"Later runs stop getting it. It stays under Earlier workflows."};function SN({name:e,kind:t,retire:s,onDone:r}){const[a,l]=x.useState(!1),[c,u]=x.useState(null),f=x.useRef(null);x.useEffect(()=>{var v;(v=f.current)==null||v.focus()},[]);const p=v=>n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:v}),g=async()=>{l(!0),u(null);try{await s()}catch(v){l(!1),u(v instanceof Ee&&gf(v).kind==="conflict"?p(`${of} Reload the tab to see the newest version.`):n.jsx(Pn,{problem:da(v,`the ${t}`,`The ${t} was not retired.`),className:""}));return}await r(!0)};return n.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),r(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",OP[t]]}),c&&n.jsx("div",{className:"w-full",children:c}),n.jsx(V,{ref:f,size:"sm",variant:"destructive",onClick:()=>void g(),disabled:a,children:a?"Retiring":"Yes, retire"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:()=>void r(!1),disabled:a,children:"Keep"})]})}function MP({name:e,keys:t,promote:s,onDone:r}){const[a,l]=x.useState(!1),[c,u]=x.useState(null),f=x.useRef(null);x.useEffect(()=>{var g;(g=f.current)==null||g.focus()},[]);const p=async()=>{var v;l(!0),u(null);let g;try{g=await s(t.keyFor("promote",e))}catch(h){return l(!1),h instanceof Ee&&h.status<500&&t.done(),h instanceof Ee&&h.status===403?void u(n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:FA})):h instanceof Ee&&((v=h.problems)!=null&&v.length)?void u(n.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[n.jsxs("p",{children:["No agent was made: ",h.message]}),n.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:h.problems.map((m,b)=>n.jsx("li",{children:m.detail},b))})]})):void u(n.jsx(Pn,{problem:da(h,"the agent","No agent was made."),className:""}))}t.done(),r(g)};return n.jsxs("div",{role:"alertdialog","aria-label":`Make ${e} an agent?`,onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),a||r(null))},className:"flex flex-wrap items-center gap-3 border-t px-5 py-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Make it an agent?"})," ",DA(e)]}),c&&n.jsx("div",{className:"w-full",children:c}),n.jsx(V,{ref:f,size:"sm",variant:"solid",onClick:()=>void p(),disabled:a,children:a?"Making the agent":"Yes, make the agent"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:()=>r(null),disabled:a,children:"Cancel"})]})}function _N({name:e,kind:t,from:s,restore:r,onChanged:a,onDone:l}){const[c,u]=x.useState(!1),[f,p]=x.useState(null),g=x.useRef(null);x.useEffect(()=>{var m;(m=g.current)==null||m.focus()},[]);const v=m=>n.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:m}),h=async()=>{var m;u(!0),p(null);try{await r()}catch(b){if(u(!1),b instanceof Ee&&(b.status===412||b.code==="precondition_failed")){p(v(of)),await a();return}if(b instanceof Ee&&b.status===403)return void p(v(UA));if(b instanceof Ee&&((m=b.problems)!=null&&m.length))return void p(n.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[n.jsxs("p",{children:["Not restored: ",b.message]}),n.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:b.problems.map((w,j)=>n.jsx("li",{children:w.detail},j))})]}));if(b instanceof Ee&&b.status===400){await a(),l();return}return void p(n.jsx(Pn,{problem:da(b,`the ${t}`,`The ${t} was not restored.`),className:""}))}await a(),l()};return n.jsxs("div",{role:"alertdialog","aria-label":`Restore ${e}?`,onKeyDown:m=>{m.key==="Escape"&&(m.stopPropagation(),l())},className:"flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[n.jsx("span",{className:"font-semibold",children:"Restore it?"})," ",zA(s)]}),f&&n.jsx("div",{className:"w-full",children:f}),n.jsx(V,{ref:g,size:"sm",variant:"solid",onClick:()=>void h(),disabled:c,children:c?"Restoring":"Yes, restore"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:l,disabled:c,children:"Keep"})]})}function $N({title:e,v2:t,agentId:s,file:r,seen:a,taken:l=[],onDone:c}){const[u,f]=x.useState(a?bd(a.text):{name:"",description:"",type:"feedback",body:`
542
+ `,rest:[]}),[p,g]=x.useState((a==null?void 0:a.etag)??null),[v,h]=x.useState(null),[m,b]=x.useState(!1),[w,j]=x.useState([]),[N,R]=x.useState(null),[$,S]=x.useState(!1),[E,C]=x.useState(null),T=x.useRef(null),A=async()=>{if(r)try{const U=await t.readNote(s,r);f(bd(U.note)),g(U.etag),h(null)}catch(U){h(U??new Error("unknown"))}};x.useEffect(()=>{var U;(U=T.current)==null||U.focus()},[]);const F=U=>f(D=>({...D,...U})),L=u.name.trim()!==""&&u.description.trim()!==""&&!m,z=async()=>{if(!L)return;if(R(null),j([]),S(!1),r&&!p){R(Np);return}b(!0);const U=tO(u);try{await t.writeNote(s,r??ow(u.name,l),U,r?{etag:p??""}:{create:!0}),c(!0)}catch(D){b(!1);const K=D instanceof Ee?gf(D,!r):null;(K==null?void 0:K.kind)==="conflict"?(C(U),await A()):(K==null?void 0:K.kind)==="refused"?j(K.problems):(K==null?void 0:K.kind)==="taken"?S(!0):R(D??new Error("unknown"))}},W=U=>{U.key==="Escape"?(U.preventDefault(),U.stopPropagation(),c(!1)):U.key==="Enter"&&(U.metaKey||U.ctrlKey||U.target.tagName==="INPUT")&&(U.preventDefault(),z())};return n.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:W,children:[n.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-2.5",children:[n.jsx("h3",{className:"caps text-label font-semibold",children:e}),n.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[n.jsxs("kbd",{children:[jP?"⌘":"Ctrl","+Enter"]})," save · ",n.jsx("kbd",{children:"Esc"})," cancel"]})]}),v!==null&&n.jsx(Pn,{problem:ur(v,"the note"),onRetry:()=>{h(null),A()},className:"m-5"}),n.jsxs("div",{className:"space-y-4 px-5 py-4",children:[E&&n.jsxs("div",{className:"border border-warning/50 bg-warning/10 px-4 py-3 text-body",role:"alert",children:[n.jsxs("p",{className:"flex items-center gap-2 font-semibold",children:[n.jsx(ar,{className:"size-4 text-warning-text","aria-hidden":!0}),"Changed since you opened it"]}),n.jsx("p",{className:"mt-1 text-muted-foreground",children:"This is the newest version. Your edit wasn't saved; it's below to copy."}),n.jsxs("details",{className:"mt-2",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"Your edit"}),n.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words border bg-background p-3 font-mono text-small",children:E})]})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Name"}),n.jsx(Ue,{ref:T,value:u.name,onChange:U=>F({name:U.target.value}),placeholder:"e.g., Try /policies/refund-policy first"})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Description"}),n.jsx("span",{className:"-mt-0.5 mb-1.5 block text-small text-muted-foreground",children:"One line: what the next run sees before it opens the note."}),n.jsx(Ue,{value:u.description,onChange:U=>F({description:U.target.value}),placeholder:"When it applies, and what to do"})]}),n.jsxs("fieldset",{children:[n.jsx("legend",{className:"caps mb-1.5 text-label font-semibold",children:"Type"}),n.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Type",children:w1.map(U=>n.jsxs("label",{className:oe("caps cursor-pointer border px-3 py-1.5 text-label",u.type===U?"border-foreground":"text-muted-foreground hover:text-foreground"),title:U,children:[n.jsx("input",{type:"radio",name:`type-${r??"new"}`,className:"sr-only",checked:u.type===U,onChange:()=>F({type:U})}),k1(U)]},U))}),n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:HA[u.type]})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Note"}),n.jsx(As,{value:u.body.replace(/^\n/,""),onChange:U=>F({body:`
543
+ ${U.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),w.length>0&&n.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[n.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: the note doesn't pass the checks."}),n.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:w.map((U,D)=>n.jsx("li",{children:U.detail},D))})]}),$&&n.jsx("p",{className:"text-body text-destructive-text",role:"alert",children:"Not saved: a note by this name exists already. Change its name."}),N===Np?n.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",Np]}):N!==null&&n.jsx(Pn,{problem:da(N,"the note","The note was not saved."),className:""}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(V,{size:"sm",variant:"solid",onClick:()=>void z(),disabled:!L,children:m?"Saving":r?"Save":"Add note"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:()=>c(!1),disabled:m,children:"Cancel"}),!r&&u.name.trim()&&n.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:ow(u.name,l)})]})]})]})}function PP({notes:e,all:t,from:s,focus:r,runs:a,v2:l,agentId:c,readOnly:u,onChanged:f}){const[p,g]=x.useState(null),[v,h]=x.useState(e.some($=>r.includes($.file))),[m,b]=x.useState(new Set),w=$=>b(S=>{const E=new Set(S);return E.has($)?E.delete($):E.add($),E}),j=e.some($=>r.includes($.file));x.useEffect(()=>{j&&h(!0)},[j]);const N=$=>{var S;return((S=t.find(E=>E.file===$))==null?void 0:S.name)??$},R=$=>{var E;const S=document.getElementById(`note-${$}`);(E=S==null?void 0:S.scrollIntoView)==null||E.call(S,{block:"center",behavior:"smooth"}),S==null||S.focus({preventScroll:!0})};return n.jsx(EN,{title:"Earlier notes",count:`${e.length} no longer read`,open:v,onToggle:()=>h($=>!$),children:e.map($=>{var T,A;const S=$.status==="retired",E=S&&m.has($.file),C=(T=s.get($.file))==null?void 0:T.run;return n.jsxs("li",{id:`note-${$.file}`,className:oe("border-b px-4 py-3 last:border-b-0",r.includes($.file)&&"bg-primary/5"),children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"text-lead text-muted-foreground line-through decoration-muted-foreground/40",children:$.name}),n.jsx(Ce,{tone:"muted",children:S?"Retired":"Replaced"}),S&&n.jsx(CN,{open:E,label:`the note ${$.name}`,onClick:()=>w($.file)}),S&&!u&&$.etag&&p!==$.file&&n.jsxs(V,{size:"sm",onClick:()=>g($.file),"aria-label":`Restore ${$.name}`,children:[n.jsx(z0,{"aria-hidden":!0})," Restore"]})]}),n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:$.status==="superseded"&&$.superseded_by?n.jsxs(n.Fragment,{children:["Replaced by ",n.jsx("button",{type:"button",onClick:()=>R($.superseded_by),className:"text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",children:N($.superseded_by)})]}):S?NN($.retired):null}),p===$.file&&n.jsx("div",{className:"-mx-4 mt-2",children:n.jsx(_N,{name:$.name,kind:"note",from:(A=$.retired)==null?void 0:A.from,restore:()=>l.restoreNote(c,$.file,$.etag),onChanged:f,onDone:()=>g(null)})}),E&&n.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[n.jsx("p",{className:"mt-2 px-5 text-body text-muted-foreground",children:$.description}),Hl($.text).trim()&&n.jsx(yf,{text:Hl($.text)}),C&&n.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:n.jsx(xf,{run:C.id,runs:a,at:C.at,reason:C.reason})})]})]},$.file)})})}function EN({title:e,count:t,open:s,onToggle:r,children:a}){return n.jsxs("section",{className:"border","aria-label":e,children:[n.jsxs("button",{type:"button","aria-expanded":s,onClick:r,className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[n.jsx(aa,{className:oe("size-3.5 text-muted-foreground transition-transform",!s&&"-rotate-90"),"aria-hidden":!0}),n.jsx("span",{className:"caps text-small font-semibold",children:e}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:t})]}),s&&n.jsx("ul",{className:"border-t",children:a})]})}function LP({kind:e,items:t,v2:s,agentId:r,runs:a,readOnly:l,onChanged:c}){const[u,f]=x.useState(!1),[p,g]=x.useState(null),[v,h]=x.useState(new Set),m=b=>h(w=>{const j=new Set(w);return j.has(b)?j.delete(b):j.add(b),j});return n.jsx(EN,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${t.length} no longer given`,open:u,onToggle:()=>f(b=>!b),children:t.map(b=>{var w;return n.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:b.name}),n.jsx(Ce,{tone:"muted",children:"Retired"}),n.jsx(CN,{open:v.has(b.file),label:`the ${e} ${b.name}`,onClick:()=>m(b.file)}),!l&&p!==b.file&&n.jsxs(V,{size:"sm",onClick:()=>g(b.file),"aria-label":`Restore ${b.name}`,children:[n.jsx(z0,{"aria-hidden":!0})," Restore"]})]}),b.description&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:b.description}),n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:NN(b.retired)}),p===b.file&&n.jsx("div",{className:"-mx-4 mt-2",children:n.jsx(_N,{name:b.name,kind:e,from:(w=b.retired)==null?void 0:w.from,restore:()=>s.restoreNote(r,ch(b),b.etag),onChanged:c,onDone:()=>g(null)})}),v.has(b.file)&&n.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[n.jsx(IP,{v2:s,agentId:r,file:b.file,etag:b.etag,kind:e,label:`the ${e} ${b.name}`}),b.run&&n.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:n.jsx(xf,{run:b.run,runs:a})})]})]},b.file)})})}function CN({open:e,label:t,onClick:s}){return n.jsxs(V,{size:"sm",variant:"ghost",className:"ml-auto",onClick:s,"aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${t}`,children:[n.jsx(aa,{className:oe("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function IP({v2:e,agentId:t,file:s,etag:r,kind:a,label:l}){const[c,u]=x.useState(null),[f,p]=x.useState(null),g=x.useRef(0),v=async()=>{const h=++g.current;p(null),u(null);try{const m=await e.readNote(t,s);h===g.current&&u(m.note)}catch(m){h===g.current&&p(m??new Error("unknown"))}};return x.useEffect(()=>{v()},[s,r]),f!==null?n.jsx("div",{className:"px-5 pt-3",children:n.jsx(Pn,{problem:ur(f,l),onRetry:()=>void v(),className:""})}):c===null?n.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${l}`,children:n.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):a==="skill"?n.jsx(yf,{text:Hl(c)}):n.jsx("pre",{className:"mx-5 mt-3 max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:c})}function Fw({runs:e}){const t=e.filter(a=>{var l;return((l=a.learning)==null?void 0:l.state)==="dropped"}),s=t.filter(a=>xd(a.learning.reason)!=="nothing").slice(0,6),r=t.length-t.filter(a=>xd(a.learning.reason)!=="nothing").length;return t.length?n.jsxs(jN,{title:"Kept nothing",children:[s.length>0&&n.jsx("ul",{children:s.map(a=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:`#/runs/${encodeURIComponent(a.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[n.jsx("span",{className:"block text-body",children:Og(a.learning)}),n.jsxs("span",{className:"mt-1 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 truncate",title:mn(a),children:mn(a)}),n.jsxs("span",{className:"shrink-0",children:["· ",ft(a.created_at)]})]})]})},a.run_id))}),r>0&&n.jsxs("p",{className:oe("px-4 py-3 font-mono text-label text-muted-foreground",s.length>0&&"border-t"),children:[s.length?`${r} more ${r===1?"run":"runs"} had`:`${po(r)} had`," nothing new to remember."]})]}):null}function zP({index:e,skills:t,off:s}){const[r,a]=x.useState(!1),l=s?0:e.split(`
544
+ `).filter(p=>p.trim()).length,c=x.useMemo(()=>mo(e.trim()),[e]),u=s?[]:t,f=u.length?`${u.length} ${u.length===1?"skill":"skills"}`:"";return n.jsxs("section",{className:"border","aria-label":"What the next run reads",children:[n.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(p=>!p),className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[n.jsx(aa,{className:oe("size-3.5 text-muted-foreground transition-transform",!r&&"-rotate-90"),"aria-hidden":!0}),n.jsx("span",{className:"caps text-small font-semibold",children:"What the next run reads"}),n.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:[l?ei(l):"",f].filter(Boolean).join(" · ")||"nothing"})]}),r&&n.jsxs("div",{className:"border-t",children:[s?n.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:"Learning is off: the next run gets no notes or skills."}):l?n.jsx("div",{className:oe(kN,"max-h-72 overflow-auto break-words px-4 py-3 text-body"),dangerouslySetInnerHTML:{__html:c}}):n.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:u.length?"No note is in use.":"Nothing yet: no note is in use."}),u.length>0&&n.jsxs("p",{className:"break-words border-t px-4 py-3 font-mono text-small leading-[1.7]",children:["Active skills: ",u.join(", ")]}),n.jsx("p",{className:"border-t px-4 py-2 text-label text-muted-foreground",children:"Read-only: the notes in use, one line each, and the agent's active skills."})]})]})}function Sd(e,t){return t&&e.startsWith(`${t}/`)&&e.length>t.length+1?{text:e.slice(t.length+1),title:e}:{text:e}}function DP(e,t){var s;return((s=t==null?void 0:t.find(r=>r.id===e))==null?void 0:s.models)??[]}function TN(e,t){var s;return((s=t==null?void 0:t.find(r=>r.id===e))==null?void 0:s.default_model)??void 0}const FP="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",UP="none yet: add a model key in Settings → Model keys";class wh extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const Uw=e=>Math.min(1e4,1e3*2**e),Ww=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),WP=e=>(e==null?void 0:e.name)==="AbortError",Hw=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function HP({fetch:e=(a,l)=>globalThis.fetch(a,l),probe:t="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let a={state:"online"};const l=new Set,c=new Set;let u=[],f,p=null,g=null;const v=S=>{a=S;for(const E of[...l])E()},h=S=>{const E=Uw(S);clearTimeout(f),v({state:"offline",attempt:S,retryAt:Date.now()+E}),f=setTimeout(()=>void j(),E)},m=()=>{a.state!=="offline"&&h(0)},b=()=>{if(a.state!=="offline")return;clearTimeout(f),v({state:"resumed"});const S=u;u=[];for(const E of S)E();for(const E of[...c])E();f=setTimeout(()=>{a.state==="resumed"&&v({state:"online"})},s)};async function w(S){const E=setTimeout(()=>S.abort(),r);try{return!Ww(await e(t,{method:"GET",cache:"no-store",credentials:"same-origin",signal:S.signal}))}catch{return!1}finally{clearTimeout(E)}}async function j(){if(a.state!=="offline")return;clearTimeout(f),p==null||p.abort();const S=p=new AbortController,E=await w(S);p===S&&(p=null,a.state==="offline"&&(E?b():h(a.attempt+1)))}const N=()=>g??(g=w(new AbortController).finally(()=>{g=null})),R=S=>new Promise((E,C)=>{if(S!=null&&S.aborted)return C(Hw(S));const T=()=>{u=u.filter(F=>F!==A),C(Hw(S))},A=()=>{S==null||S.removeEventListener("abort",T),E()};u.push(A),S==null||S.addEventListener("abort",T,{once:!0})});return{fetch:async(S,E)=>{var A;const C=((E==null?void 0:E.method)??"GET").toUpperCase(),T=C==="GET"||C==="HEAD";for(let F=0;;F++){let L,z;try{L=await e(S,E)}catch(W){if((A=E==null?void 0:E.signal)!=null&&A.aborted||WP(W))throw W;z=W}if(L&&!Ww(L))return b(),L;if(a.state!=="offline"&&await N()){if(L)return L;if(!T)throw new wh;if(F>=2)throw z;await new Promise(W=>setTimeout(W,Uw(F)));continue}if(m(),!T)throw new wh;await R(E==null?void 0:E.signal)}},link:()=>a,subscribe:S=>(l.add(S),()=>{l.delete(S)}),onResume:S=>(c.add(S),()=>{c.delete(S)}),retryNow:()=>void j()}}const BP=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),RN=e=>e instanceof wh||e instanceof TypeError&&/fetch|network/i.test(e.message);function fn(e,t){const s=`${BP(t)} could not be read.`;if(RN(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof Ee))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=e.message,a=[e.code,e.requestId].filter(Boolean).join(" · "),l=(c,u)=>({title:s,why:c,next:u,said:r,code:a});return e.status===401?l("This browser is signed out.","Reload the page to sign in again."):e.status===403?l("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?l("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===429?l("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?l("The server is busy.","Try again in a moment."):e.status>=500?l("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):l("The server turned the request down.","Its words say why: change what they name, then try again.")}function GP(e){return RN(e)?"Can't reach agentrun-serve":e instanceof Ee?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}const qP=[{id:"runs",label:"Runs",shows:()=>!0,Body:KP},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:XP},{id:"learning",label:"Learning",shows:(e,t)=>e.kind==="agentic"&&t.learning!==!1,Body:e=>n.jsx(NP,{agent:e.agent,v2:e.v2,focus:e.focus,server:e.learning,onAgent:e.onAgent,places:e.places,onChanged:e.onChanged})},{id:"analytics",label:"Analytics",shows:(e,t)=>t.analytics,Body:fA}],Gs=(e,t)=>`#/agents/${encodeURIComponent(e)}${t?`/${t}`:e==="new"?"/runs":""}`;function VP({v2:e,agentId:t,routePrefix:s,harnesses:r,efforts:a=[],go:l,tab:c,limits:u,learning:f,notes:p,places:g}){var et;const[v,h]=x.useState(null),[m,b]=x.useState(null),[w,j]=x.useState(0),[N,R]=x.useState(void 0),[$,S]=x.useState(!1);x.useEffect(()=>{let se=!0;return h(null),b(null),R(void 0),e.getAgent(t).then(ke=>{se&&h(ke.agent)},ke=>{se&&b({cause:ke})}),e.statsOver({from:Ng(g1),agent:t}).then(ke=>{se&&R(ke)},()=>{se&&R(null)}),()=>{se=!1}},[e,t,w]);const E=gd(v),C=x.useRef(0),T=x.useRef(0),A=x.useRef(0),[F,L]=x.useState(!1),z=(se=!1,ke=!se)=>{const Se=++C.current;return ke&&(A.current=Se),e.getAgent(t).then(Fe=>(Se>T.current&&Se>=A.current&&(T.current=Se,h(fe=>fe&&fe.agent_id===Fe.agent.agent_id?Fe.agent:fe),L(!1)),T.current>=Se),()=>(Se===C.current&&!se&&L(!0),T.current>=Se))},W=se=>{h(ke=>({...se,tools:(ke==null?void 0:ke.tools)??se.tools})),z()},U=()=>void z(),D=()=>void z(!0,!1),K=()=>z(!0,!0),P=N===void 0?void 0:N!==null;if(m)return m.cause instanceof Ee&&m.cause.status===404?n.jsx(q1,{what:"agent",id:t,list:{href:"#/agents",label:"Open the agents list"}}):n.jsx(Mn,{problem:fn(m.cause,"the agent"),onRetry:()=>j(se=>se+1)});if(!v)return n.jsx(W5,{});const G=v.definition,I=v.kind==="workflow",Y=I?ia:Fh,q=TN(G.harness??"pi",r),O=G.model?Sd(G.model,s):q?(({text:se,title:ke})=>({text:`${se} (default)`,title:ke}))(Sd(q,s)):{text:UP},B=I||r==null?void 0:r.find(se=>se.id===(G.harness??"pi")&&se.available===!1),ee=B?`${B.id} doesn't run on this server${B.reason?`: ${B.reason}`:"."}`:void 0,le=vN(v,g),ie=`${rP(le==null?void 0:le.place)}${le!=null&&le.byDefault?" (server default)":""}`,ue=[...I?[]:[["Harness",G.harness??"pi"],["Model",O.text,O.title],["Thinking",G.thinking??"default"],["Runs",ie]],["Revision",`rev ${G.version} of ${v.revisions}`]],ae=qP.filter(se=>se.shows(v,{analytics:P===!0,learning:f===void 0?c==="learning"?void 0:!1:!!f})),ce=ae.find(se=>se.id===c)??ae[0],he=c==="analytics"&&P===void 0;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[n.jsxs("div",{"data-phone-row":!0,className:"flex flex-col gap-3 max-sm:flex-row max-sm:items-center",children:[n.jsxs("button",{type:"button",onClick:()=>l(v.archived_at?"#/agents?archived=true":"#/agents"),className:"caps flex items-center gap-2 self-start text-label text-muted-foreground hover:text-foreground max-sm:-m-1 max-sm:self-center max-sm:p-1",children:[n.jsx(qs,{className:"size-3.5","aria-hidden":!0})," ",n.jsx("span",{className:"max-sm:sr-only",children:"Agents"})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-3 max-sm:min-w-0 max-sm:flex-1 max-sm:flex-nowrap max-sm:gap-2",children:[n.jsx(Y,{className:"size-5 shrink-0 text-muted-foreground max-sm:hidden","aria-hidden":!0}),n.jsx("h1",{className:"min-w-0 truncate font-mono text-xl font-semibold max-sm:text-lg",children:G.name}),n.jsx(Ce,{children:v.kind}),v.archived_at&&n.jsx(Ce,{tone:"muted",children:"Archived"}),G.approvals==="never"&&n.jsx(Ce,{tone:"warning",title:"Never ask: a call of this agent never waits for you. A tool set to deny, and a template's pins, still hold.",children:"Unattended"}),n.jsx("span",{className:"flex-1"}),n.jsxs(V,{size:"sm",onClick:()=>l(Gs(v.agent_id,"edit")),title:"Edit",className:"max-sm:w-8 max-sm:shrink-0 max-sm:px-0",children:[n.jsx(Xl,{"aria-hidden":!0})," ",n.jsx("span",{className:"max-sm:sr-only",children:"Edit"})]}),n.jsx(Tg,{context:{kind:"edit",agentId:v.agent_id,revision:v.revision},label:"Edit with your coding agent",iconOnPhone:!0})]})]}),G.description&&n.jsx("p",{id:"agent-description",className:oe("mt-2 max-w-3xl text-lead text-muted-foreground",!$&&"max-sm:line-clamp-2"),children:G.description}),n.jsxs("button",{type:"button","aria-expanded":$,"aria-controls":G.description?"agent-description agent-facts":"agent-facts",onClick:()=>S(se=>!se),className:"mt-1.5 flex w-full min-w-0 items-center gap-1.5 text-left font-mono text-small text-muted-foreground sm:hidden",children:[n.jsx(Rs,{className:oe("size-3.5 shrink-0 transition-transform",$&&"rotate-90"),"aria-hidden":!0}),n.jsx("span",{className:"truncate",children:ue.map(([,se])=>se).join(" · ")})]}),n.jsxs("dl",{id:"agent-facts",className:oe("mt-3 flex flex-wrap gap-x-6 gap-y-2",!$&&"max-sm:hidden"),"aria-label":"Current revision",children:[ue.map(([se,ke,Se])=>n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:se}),n.jsx("dd",{className:"font-mono text-small",title:Se,children:ke})]},se)),!I&&n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Tools"}),n.jsx("dd",{className:"font-mono text-small",children:(et=v.tools)!=null&&et.length?n.jsx("ul",{className:"flex flex-wrap gap-x-4 gap-y-1","aria-label":"Tools",children:v.tools.map(se=>n.jsxs("li",{children:[n.jsx("span",{title:se.blurb,children:se.name}),se.provider?` · ${kd(se.provider,se.name)}`:"",se.permission?` · ${se.permission}`:"",Q1(se.resolved,se.name).unavailable&&n.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:se.resolved,children:" · unavailable"})]},se.name))}):"none"})]})]}),F&&n.jsxs("p",{role:"alert",className:"mt-3 flex items-center gap-3 text-body text-warning-text",children:["Couldn't refresh this agent.",n.jsx(V,{size:"sm",variant:"outline",onClick:()=>z(),children:"Retry"})]}),ee&&n.jsx("p",{className:"mt-3 font-mono text-small text-warning-text",role:"status","aria-label":"Harness not available",children:ee}),n.jsx(G5,{agent:v,v2:e,onAgent:h,poll:D,refresh:K})]}),!v.archived_at&&n.jsx(D5,{agent:v,efforts:a,v2:e,go:l,blocked:ee,limits:u}),n.jsx(x1,{tabs:ae.map(se=>se.id==="learning"?{...se,label:n.jsxs(n.Fragment,{children:[se.label,n.jsx(mO,{n:E,className:"ml-1.5"})]})}:se),value:ce.id,onChange:se=>l(Gs(v.agent_id,se))}),n.jsx("div",{role:"tabpanel","aria-label":he?void 0:ce.label,className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-8",children:he?n.jsx(Os,{label:"Loading the tab",rows:4}):n.jsx(ce.Body,{agent:v,v2:e,go:l,stats:N,focus:p,learning:f,onAgent:W,onChanged:U,places:g})})]})}function KP({agent:e,v2:t}){const[s,r]=x.useState(null),[a,l]=x.useState(null),[c,u]=x.useState(!1),[f,p]=x.useState(null),g=x.useRef(0),v=h=>{const m=++g.current;p(null),h&&u(!0),t.listAgentRuns(e.agent_id,50,h,!!e.archived_at).then(b=>{m===g.current&&(r(w=>h?aN(w??[],b.runs):b.runs),l(b.next_cursor))}).catch(b=>{m===g.current&&p(fn(b,h?"more runs":"the runs"))}).finally(()=>{m===g.current&&u(!1)})};return x.useEffect(()=>{v(null)},[t,e.agent_id]),f&&!s?n.jsx(Mn,{problem:f,onRetry:()=>v(null),className:""}):s?s.length?n.jsxs(n.Fragment,{children:[n.jsx(h5,{v2:t,run:s[0],onRun:h=>r(m=>m&&m.map(b=>b.run_id===h.run_id?h:b))},s[0].run_id),n.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[s.length,a?"+":""," ",s.length===1&&!a?"run":"runs"]}),n.jsx("ul",{className:"border","aria-label":"Runs",children:s.map(h=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex flex-wrap items-center gap-x-4 gap-y-1 px-4 py-3 hover:bg-accent",children:[n.jsx(lc,{run:h}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-lead",title:mn(h),children:mn(h)}),n.jsx(lf,{run:h}),h.effort&&n.jsxs(Ce,{children:["effort ",h.effort]}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ft(h.created_at)}),h.ended_at&&n.jsx("span",{className:"font-mono text-small text-muted-foreground",title:"How long it ran",children:fi(Date.parse(h.ended_at)-Date.parse(h.created_at))}),h.cost&&(h.cost.usd!==null||Si(h.cost))&&n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:go(h.cost,{ended:ra(h.status)})})]})},h.run_id))}),f&&n.jsx(Mn,{problem:f,className:"mt-4"}),a&&n.jsx("div",{className:"mt-4 flex justify-center",children:n.jsx(V,{type:"button",size:"sm",onClick:()=>v(a),disabled:c,children:c?"Loading":"Load more"})})]}):n.jsxs("div",{className:"border px-4 py-12 text-center",children:[n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent yet."}),!e.archived_at&&n.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Start one above: its timeline shows here as the agent works."})]}):n.jsx(Os,{label:"Loading the runs",rows:5})}function XP({agent:e,go:t}){const s=e.definition.workflow,r=x.useMemo(()=>oi(s),[s]),a=x.useMemo(()=>({meta:rc(s,r)}),[s,r]);return n.jsxs("section",{className:"border",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[mf(Hg(r))," · rev ",e.definition.version]}),n.jsx("span",{className:"flex-1"}),n.jsxs(V,{size:"sm",onClick:()=>t(Gs(e.agent_id,"edit")),children:[n.jsx(Xl,{"aria-hidden":!0})," Edit the workflow"]})]}),n.jsx("div",{className:"min-h-[360px] overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5",children:r.nodes.length?n.jsx(dc,{graph:r,marks:a,label:"The workflow's graph",minScale:.55}):n.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"This revision's workflow has no root node to draw."})}),n.jsx("div",{className:"border-t px-4 py-2",children:n.jsx(fc,{})})]})}const YP=140,QP=32,ZP=40,JP=60;function AN({value:e,name:t,note:s,blurb:r,description:a,tag:l,why:c,alert:u,on:f,disabled:p,warn:g,onToggle:v}){const[h,m]=x.useState(!1),b=x.useRef(null),w=x.useRef(null),j=x.useRef(null),N=x.useRef(null),R=Mu(b,"width",h,t),$=Mu(w,"height",h,a),S=Mu(j,"width",h,l),E=Mu(N,"width",h,u),C=R??t.length>QP,T=!!a&&($??a.length>YP),A=!!l&&(S??l.length>ZP),F=!!u&&(E??u.length>JP),L=!!c&&(c!==l||A),z=!!a&&(!!r||T)||L||F||C,W=(D,K)=>!h&&D&&K?D:void 0,U=D=>{D.preventDefault(),D.stopPropagation(),m(K=>!K)};return n.jsxs("label",{"data-tool-card":e,className:oe("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",h?"min-h-36":"h-36 overflow-hidden",f&&"border-foreground",g&&"border-warning/60",p?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[n.jsx("input",{type:"checkbox",value:e,checked:f,disabled:p,onChange:v,className:"shrink-0 accent-primary"}),n.jsx("span",{ref:b,title:W(t,C),className:oe("min-w-0",h?"[overflow-wrap:anywhere]":"truncate"),children:t}),s&&n.jsx("span",{className:"shrink-0 font-sans text-label text-muted-foreground",children:s})]}),r?n.jsx("span",{"data-line":!0,className:"mt-1 truncate font-sans text-small text-muted-foreground",children:r}):a&&!h?n.jsx("span",{ref:w,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:W(a,T),children:a}):null,l&&n.jsx("span",{ref:j,"data-tag":!0,title:W(c,L),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:l}),u&&!h&&n.jsx("span",{ref:N,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:W(u,F),children:u}),h&&n.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[a&&n.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:a}),c&&c!==a&&n.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),u&&n.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:u})]}),z&&n.jsx("button",{type:"button",onClick:U,"aria-expanded":h,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:h?"Less":"More"})]})}function Mu(e,t,s,r){const[a,l]=x.useState(null);return x.useLayoutEffect(()=>{const c=e.current;if(s||!c)return;const u=()=>{(t==="width"?c.clientWidth>0:c.clientHeight>0)&&l(t==="width"?c.scrollWidth>c.clientWidth+1:c.scrollHeight>c.clientHeight+1)};u();const f=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return f==null||f.observe(c),()=>f==null?void 0:f.disconnect()},[e,t,s,r]),a}function eL({servers:e,tools:t,harness:s,harnesses:r,onChange:a,onRetry:l}){const c=m=>a(t.includes(m)?t.filter(b=>b!==m):[...t,m]),u=t.filter(m=>wd(m)),f=!r||r.includes(s),p=(m,b,w,j,N,R)=>{const $=t.includes(m),S=(!f||!!N)&&!$,E=j??N??($&&!f?`Won't run on ${s}.`:void 0);return n.jsx("li",{className:"min-w-0",children:n.jsx(AN,{value:m,name:b,note:R,description:w,alert:E,on:$,disabled:S,warn:!!j,onToggle:()=>c(m)})},m)},g=m=>n.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:m}),v=!f&&n.jsxs("p",{className:"text-small text-warning-text",children:[s," doesn't run MCP tools on this server",r!=null&&r.length?`: ${r.join(" and ")} do`:"","."]});if(e==="failed")return n.jsxs("div",{className:"mt-4 space-y-2",children:[n.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",l&&n.jsx(V,{type:"button",onClick:l,size:"xs",className:"ml-1",children:"Retry"})]}),u.length>0&&g(u.map(m=>p(m,m,"Can't check right now whether its server still lists it.")))]});if(!e)return u.length?n.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const h=e5(t,e);return!e.length&&!h.length?n.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"No MCP server is saved: add one in Settings → MCP servers to grant its tools."}):n.jsxs("div",{className:"mt-4 space-y-4",children:[v,e.map(m=>n.jsxs("section",{"aria-label":`MCP server ${m.name}`,children:[n.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[m.name," · MCP server"]}),g(m.tools.map(b=>{var w;return p(YO(m.name,b.name),b.name,[b.title,b.description].filter(Boolean).join(": ")||void 0,void 0,JO(m.name,b,s)??(b.permission==="deny"?zg:void 0),(w=m.not_metered)!=null&&w.includes(b.name)?"not metered":void 0)}))]},m.name)),h.length>0&&n.jsxs("section",{"aria-label":"MCP grants that can't run",children:[n.jsx("p",{className:"caps mb-2 text-label font-semibold text-warning-text",children:"Granted, but not on a saved server"}),g(h.map(m=>p(m.grant,m.grant,void 0,m.why)))]})]})}const tL=e=>e.offered&&(e.kind==="none"||e.providers.some(t=>t.ready)),nL=e=>{var t;return e.why??((t=e.providers.find(s=>!s.ready))==null?void 0:t.why)};function sL(e,t){var a;if(e.kind==="none")return{kind:"none"};const r=((t==null?void 0:t.kind)===e.kind&&e.providers.some(l=>l.ready&&l.id===t.provider)?t.provider:void 0)??((a=e.providers.find(l=>l.ready))==null?void 0:a.id);return r?{kind:e.kind,provider:r}:{kind:e.kind}}const rL=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},Kg="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",Xg=new Set(["sandbox","desktop","phone"]),oL=e=>e.charAt(0).toUpperCase()+e.slice(1);function aL({kinds:e,value:t,onChange:s,error:r,warning:a}){const l=e.find(c=>c.kind===t.kind);return n.jsxs("div",{children:[n.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Kind"}),n.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-5",role:"radiogroup","aria-label":"Kind",children:e.map(c=>{const u=tL(c),f=u?void 0:nL(c),p=c.providers.filter(g=>g.ready).map(g=>g.name).join(", ");return n.jsxs("div",{"data-kind":c.kind,className:oe("border px-4 py-3",t.kind===c.kind?"border-foreground":"border-border",!u&&"opacity-60"),children:[n.jsxs("label",{className:oe("flex items-start gap-3",u?"cursor-pointer":"cursor-not-allowed"),children:[n.jsx("input",{type:"radio",name:"computer-kind",value:c.kind,checked:t.kind===c.kind,disabled:!u&&t.kind!==c.kind,onChange:()=>s(sL(c,t)),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-lead font-semibold",children:oL(c.kind)}),n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:u?c.kind==="none"?"The run's folder only":p:"Not available here"})]})]}),f&&n.jsxs("p",{className:"mt-2 break-words text-small text-muted-foreground",children:[f," ",n.jsx("a",{href:"#/settings/computers",className:"underline underline-offset-2 hover:text-foreground",children:"Computers settings"})]})]},c.kind)})}),l&&l.kind!=="none"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mb-2 mt-5 caps text-small font-semibold",children:"Provider"}),n.jsx("ul",{className:"border",role:"radiogroup","aria-label":"Provider",children:l.providers.map(c=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("label",{className:oe("flex items-start gap-3 px-4 py-2.5",c.ready?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[n.jsx("input",{type:"radio",name:"computer-provider",value:c.id,checked:t.provider===c.id,disabled:!c.ready&&t.provider!==c.id,onChange:()=>s({kind:l.kind,provider:c.id}),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("span",{className:"text-body font-semibold",children:c.name}),c.metered&&n.jsx("span",{className:"caps text-label text-muted-foreground",children:"Metered"})]}),c.metered&&Xg.has(l.kind)&&n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:Kg}),!c.ready&&c.why&&n.jsx("span",{className:"mt-0.5 block text-small",children:c.why})]})]})},c.id))})]}),l&&l.tools.length>0&&n.jsxs("p",{className:"mt-4 border bg-muted/40 px-4 py-2.5 text-small","aria-label":"Tools this computer adds",children:["This computer adds these tools: ",n.jsx("span",{className:"font-mono",children:l.tools.join(", ")})]}),r&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:r}),a&&n.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:a})]})}function iL({value:e,saved:t,places:s,tools:r,picked:a,onChange:l,error:c,warning:u}){var S;const f=e??pf(t),p=(f??Vg(!1,a,s)).mode,g=(S=s.boxes.find(E=>E.available))==null?void 0:S.id,v=(f==null?void 0:f.mode)==="sandbox"?f.box:g,h=!g&&p!=="sandbox",m=new Set(r.filter(E=>E.sandbox_only).map(E=>E.name)),[b,w]=x.useState([]),j=()=>{const E=a.filter(C=>m.has(C));w(E),l({place:{mode:"runner"},...E.length?{tools:a.filter(C=>!m.has(C))}:{}})},N=E=>{w([]),E&&l({place:{mode:"sandbox",box:E}})},R=E=>E.map(C=>C.charAt(0).toUpperCase()+C.slice(1)).join(" and "),$=(E,C,T,A,F=!1)=>n.jsxs("label",{className:oe("flex items-start gap-3 border px-4 py-3",p===E?"border-foreground":"border-border",F?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[n.jsx("input",{type:"radio",name:"place",value:E,checked:p===E,disabled:F,onChange:A,className:"mt-1 accent-primary"}),n.jsxs("span",{children:[n.jsx("span",{className:"block text-lead font-semibold",children:C}),n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:T})]})]});return n.jsxs("div",{children:[n.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),n.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[$("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),$("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>N(v),h)]}),h&&n.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[n.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),n.jsx("ul",{className:"mt-1",children:s.boxes.map(E=>n.jsxs("li",{children:[n.jsx("span",{className:"font-mono",children:E.id}),E.reason?`: ${E.reason}`:""]},E.id))})]}),p==="sandbox"&&n.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map(E=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("label",{className:oe("flex items-start gap-3 px-4 py-2.5",E.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[n.jsx("input",{type:"radio",name:"box",value:E.id,checked:v===E.id,disabled:!E.available&&v!==E.id,onChange:()=>N(E.id),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block font-mono text-body",children:E.id}),!E.available&&E.reason&&n.jsx("span",{className:"mt-0.5 block text-small",children:E.reason})]})]})},E.id))}),p==="runner"&&b.length>0&&n.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[R(b)," ",b.length===1?"runs":"run"," only in a sandbox, so ",b.length===1?"it's":"they're"," turned off for this agent."]}),c&&n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),u&&n.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:u})]})}function ON(e,t,s=t.map(r=>r.name)){return[...new Set([...s.filter(a=>e.some(l=>l.name===a)||t.some(l=>l.name===a)),...t.map(a=>a.name),...e.map(a=>a.name)])].map(a=>{const l=e.find(u=>u.name===a),c=t.find(u=>u.name===a);return{name:a,...l?{choice:l}:{},...c?{gate:c}:{}}})}function kh({setting:e,label:t="Pinned",also:s=!1}){return e!=null&&e.pin_broken?n.jsx("p",{className:"max-w-[640px] text-small text-warning-text",role:"note",children:R5}):e!=null&&e.pin?n.jsxs("p",{className:"max-w-[640px] text-small text-muted-foreground",role:"note",children:[n.jsxs("span",{className:"text-foreground",children:[t,":"]})," ",C5(e.pin),". ",T5,s?" This server pins it too; both hold.":""]}):null}const lL="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function MN({label:e,rows:t,settings:s,fallbackOf:r,permissionFallbackOf:a=m=>m.default_permission,resolvesOf:l,issues:c,busy:u=!1,refused:f=()=>!1,locked:p=!1,unattended:g=!1,noteOf:v,onEdit:h}){const m=t.some(R=>R.choice),b=t.some(R=>R.gate),w=t.some(R=>{var $;return(($=R.gate)==null?void 0:$.ask_needs)==="password"}),j=["Tool",...b?["Permission"]:[],...m?["Provider","Resolves to"]:[]],N=n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return n.jsxs(n.Fragment,{children:[w&&n.jsx("p",{className:"mb-2 text-small text-warning-text",children:lL}),n.jsx("div",{className:"relative overflow-x-auto",children:n.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[j.map(R=>n.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:R},R)),n.jsx("th",{children:n.jsx("span",{className:"sr-only",children:"Reset"})})]})}),n.jsx("tbody",{children:t.map(({name:R,choice:$,gate:S})=>{var G,I,Y;const E=$?r($):"",C=(G=s[R])==null?void 0:G.provider,T=$!==void 0&&C!==void 0&&C!==E,A=T?C:E,F=q=>h(O=>S5(O,R,q,E)),L=S?a(S):"allow",z=(I=s[R])==null?void 0:I.permission,W=S!==void 0&&z!==void 0&&z!==L,U=W?z:L,D=S!==void 0&&f(R,U),K=D&&p,P=K?"deny":U;return n.jsxs(x.Fragment,{children:[n.jsxs("tr",{"data-tool":R,"data-set":T||W?"":void 0,className:"border-b align-top last:border-b-0",children:[n.jsx("td",{className:"px-3 py-2.5 font-mono text-body",children:R}),b&&n.jsx("td",{className:"px-3 py-2",children:S?n.jsxs(n.Fragment,{children:[n.jsx(Lt,{small:!0,label:`${R} permission`,value:P,disabled:u||K,onChange:q=>{const O=q;h(B=>_5(B,R,O,L))},className:oe("w-36",W&&"border-primary text-primary"),options:S.permissions.map(q=>({value:q,label:`${q}${q===L?" (default)":""}`,...q==="ask"&&S.ask_needs==="password"&&!g?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),W&&!K&&n.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",L]}),D&&n.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:zg}),P==="deny"&&n.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:w5}),P==="ask"&&g&&!D&&n.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),P==="ask"&&S.ask_needs==="password"&&!g&&n.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Each call is refused: no one can approve it here."})]}):N}),m&&n.jsx("td",{className:"px-3 py-2",children:$?n.jsxs(n.Fragment,{children:[n.jsx(Lt,{small:!0,label:`${R} provider`,value:A,disabled:u,onChange:q=>F(q),className:oe("w-56 max-w-full",T&&"border-primary text-primary"),options:$.providers.map(q=>({value:q,label:`${kd(q,R)}${q===E?" (default)":""}`}))}),gw(A,R)&&n.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:gw(A,R)}),T&&n.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",kd(E,R)]})]}):N}),m&&n.jsx("td",{className:"px-3 py-2.5",children:$?l($,A):N}),n.jsx("td",{className:"px-2 py-2 text-right",children:T&&n.jsx(V,{size:"sm",variant:"ghost",disabled:u,"aria-label":`Reset ${R} to its default`,onClick:()=>F(void 0),children:"Reset"})})]}),v!=null&&v(R)?n.jsx("tr",{"data-note":R,children:n.jsx("td",{colSpan:j.length+1,className:"px-3 pb-2.5",children:v(R)})}):null,(Y=c[R])!=null&&Y.length?n.jsx("tr",{children:n.jsx("td",{colSpan:j.length+1,className:"px-3 pb-2.5",children:c[R].map(q=>n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:q},q))})}):null]},R)})})]})})]})}function jh({value:e,prefix:t,tool:s}){const r=Q1(e,s);return n.jsxs("span",{className:oe("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[t,r.text]})}const cL=({choice:e,harnesses:t=[]})=>n.jsx(n.Fragment,{children:x5.map(s=>{const r=t.find(a=>a.id===s&&!a.available);return r?n.jsxs("span",{title:r.reason,className:"block font-mono text-small text-muted-foreground opacity-60",children:[s,": not offered here"]},s):n.jsx(jh,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function uL({agent:e,harness:t,model:s,tools:r,choices:a,gates:l=[],mcpServers:c,serverSettings:u,focus:f,callTools:p,value:g,issues:v,unattended:h=!1,onChange:m}){const b=new Set(r),w=a.filter(z=>b.has(z.name)||!z.available),j=l.some(z=>z.ask_needs==="password"),N=z=>{var W;return(W=e==null?void 0:e.tools)==null?void 0:W.find(U=>U.name===z)},R=z=>{var U;const W=wd(z);return W?(U=c==null?void 0:c.find(D=>D.name===W.server))==null?void 0:U.tools.find(D=>D.name===W.tool):void 0},$=z=>{var U;const W=wd(z);return W?(U=g[`mcp:${W.server}/*`])==null?void 0:U.permission:void 0},S=p?p.flatMap(z=>l.filter(W=>W.name===z)):[...new Set(r)].flatMap(z=>{var D;const W=l.find(K=>K.name===z);if(W)return[W];const U=N(z)??R(z);return!((D=U==null?void 0:U.permissions)!=null&&D.length)||!U.default_permission?[]:[{name:z,permission:U.permission??U.default_permission,default_permission:U.default_permission,permissions:U.permissions,...j&&U.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),E=ON(w,S,[...l.map(z=>z.name),...a.map(z=>z.name)]),C=x.useRef(null);if(x.useEffect(()=>{var U,D;if(!f)return;const z=`${f} permission`,W=[...((U=C.current)==null?void 0:U.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(K=>K.getAttribute("aria-label")===z);(D=W==null?void 0:W.scrollIntoView)==null||D.call(W,{block:"center"}),W==null||W.focus()},[]),!E.length)return null;const T=(e==null?void 0:e.definition.tool_settings)??{},A=h!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:F,rest:L}=J1(v,"definition.tool_settings",E.map(z=>z.name));return n.jsxs("section",{"aria-label":"Tool settings",ref:C,children:[n.jsx("div",{className:"mb-2",children:n.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),n.jsxs("p",{className:"-mt-1 mb-2 text-small text-muted-foreground",children:["Each of these tools takes this server's setting (its default here) unless it is changed here. ",p?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":h?"Never ask is on: a tool on ask runs without waiting for you. A tool set to deny still holds.":"A tool on ask makes the run wait for your approval at each call."]}),n.jsx(MN,{label:"This agent's tool settings",unattended:h,rows:E,settings:g,fallbackOf:z=>z.provider,issues:F,onEdit:z=>m(z(g)),noteOf:z=>{const W=g[z],U=u==null?void 0:u[z],D=!!(W!=null&&W.pin||W!=null&&W.pin_broken);return!D&&!(U!=null&&U.pin)&&!(U!=null&&U.pin_broken)?null:n.jsxs(n.Fragment,{children:[D&&n.jsx(kh,{setting:W,label:"Pinned for this agent",also:!!(U!=null&&U.pin)}),(!D||(U==null?void 0:U.pin_broken))&&n.jsx(kh,{setting:U,label:"Pinned on this server"})]})},refused:z=>X1(z,l,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:z=>{var W;return $(z.name)??((W=N(z.name))==null?void 0:W.default_permission)??z.permission},resolvesOf:z=>{var P,G,I,Y,q,O;const W=(((P=g[z.name])==null?void 0:P.provider)??null)!==(((G=T[z.name])==null?void 0:G.provider)??null)||(((I=g[z.name])==null?void 0:I.permission)??null)!==(((Y=T[z.name])==null?void 0:Y.permission)??null)||A,U=(q=e==null?void 0:e.tools)==null?void 0:q.find(B=>B.name===z.name),D=U&&U.provider===(((O=g[z.name])==null?void 0:O.provider)??z.provider)?U.resolved:void 0,K=(s??"")===((e==null?void 0:e.definition.model)??"");return!W&&t===((e==null?void 0:e.definition.harness)??"pi")&&K&&D?n.jsx(jh,{value:D,prefix:`${t}: `,tool:z.name}):!W&&!T[z.name]&&!s?n.jsx(jh,{value:z.resolves[t],prefix:`${t}: `,tool:z.name}):n.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),L.map(z=>n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:z},z))]})}const Pu=20,dL=400;function fL(e,t,s,r,a){const[l,c]=x.useState(null),[u,f]=x.useState(0),p=(r??[]).join(",");x.useEffect(()=>{if(!a||!s||l==="unsupported")return;const v=new AbortController,h=setTimeout(()=>{a({workflow:t,...r?{tools:r}:{}},v.signal).then(m=>{v.signal.aborted||c({text:e,check:m})},m=>{v.signal.aborted||((m==null?void 0:m.status)===404||(m==null?void 0:m.status)===405?c("unsupported"):c({text:e,failed:(m==null?void 0:m.message)||`the server answered ${(m==null?void 0:m.status)??"nothing"}`}))})},dL);return()=>{clearTimeout(h),v.abort()}},[e,s,p,a,u]);const g=()=>{c(null),f(v=>v+1)};return l==="unsupported"||!a?{mode:"lint",retry:g}:l&&l.text===e?"failed"in l?{mode:"failed",failed:l.failed,retry:g}:{mode:"server",check:l.check,retry:g}:{mode:"pending",retry:g}}function Bw({text:e,onText:t,base:s,baseLabel:r,serverIssues:a,readOnly:l=!1,validate:c,tools:u}){var K;const f=x.useRef(null),p=x.useRef(null),[g,v]=x.useState(0),h=x.useMemo(()=>Q4(e),[e]),m=x.useRef(null);h.ok&&(m.current={value:h.value,spans:h.spans});const b=(K=m.current)==null?void 0:K.value,w=x.useMemo(()=>oi(b),[b]),j=x.useMemo(()=>s===void 0?null:oi(s),[s]),N=x.useMemo(()=>j?E0(j,w):null,[j,w]),R=fL(e,h.ok?h.value:void 0,h.ok,u,l?void 0:c),$=x.useMemo(()=>h.ok&&!l?tA(h.value):[],[h,l]),S=x.useMemo(()=>R.mode!=="server"?$:[...R.check.issues.map(P=>({path:P.path,message:P.message,severity:"error"})),...R.check.warnings.map(P=>typeof P=="string"?{path:"",message:P,severity:"warning"}:{path:P.path??"",message:P.message,severity:"warning"})],[R.mode,R.mode==="server"?R.check:null,$]),E=h.ok?nA(h.spans,w.nodes.map(P=>P.path),g):null,C=x.useMemo(()=>({meta:rc(b,w),diff:N?{added:N.added.map(P=>P.path),edited:[...N.changed,...N.rewritten].map(P=>P.next),moved:N.moved.map(P=>P.next),removed:N.removed.map(({label:P,kind:G})=>({label:P,kind:G}))}:void 0,selected:E?{path:E}:null}),[b,w,N,E]),T=e.split(`
545
+ `).length,A=P=>Z4(e,P),F=[];h.ok||F.push({...A(h.error.offset),message:`JSON: ${h.error.message}`,severity:"error",offset:h.error.offset});for(const P of S){const G=h.ok?Vv(h.spans,P.path):void 0,I=(G==null?void 0:G.start)??0;F.push({...A(I),message:P.message,severity:P.severity,offset:I,path:P.path})}for(const P of[...a??[]].reverse()){const G=P.path&&h.ok?Vv(h.spans,P.path):void 0;F.unshift({...G?A(G.start):{line:0,col:0},message:`Server: ${P.message}`,severity:"error",offset:(G==null?void 0:G.start)??-1})}const L=new Map;for(const P of F)P.line&&L.get(P.line)!=="error"&&L.set(P.line,P.severity);const z=(P,G=P)=>{const I=f.current;!I||P<0||(I.focus(),I.setSelectionRange(P,G),I.scrollTop=Math.max(0,(A(P).line-4)*Pu),v(P))};x.useEffect(()=>{const P=h.ok?h.spans.get("/root"):void 0;P&&f.current&&(f.current.scrollTop=Math.max(0,(A(P.start).line-2)*Pu))},[]);const W=N?N.edges.added.length+N.edges.removed.length:0,U=N?N.added.length+N.changed.length+N.rewritten.length+N.removed.length+N.moved.length+W:0,D=F.filter(P=>P.severity==="error").length;return n.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[n.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[n.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[T," lines"]}),n.jsx("span",{className:"flex-1"}),l?n.jsx("span",{className:"caps text-label text-muted-foreground",children:"Read-only"}):n.jsxs(n.Fragment,{children:[R.mode==="failed"&&h.ok?n.jsxs("span",{className:"font-mono text-label text-warning-text",title:R.failed,children:["server check failed, showing local checks ",n.jsx(V,{type:"button",onClick:R.retry,size:"xs",className:"ml-1",children:"Retry"})]}):R.mode!=="lint"&&h.ok&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:R.mode==="pending"?"checking...":"checked by the server"}),D?n.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[n.jsx(ai,{className:"size-3.5","aria-hidden":!0})," ",D," ",D===1?"problem":"problems"]}):n.jsx("span",{className:"caps text-label text-success-text",children:R.mode==="server"?"Valid":"Valid shape"})]})]}),n.jsxs("div",{className:"relative flex h-[560px] min-h-0 xl:h-[calc(100vh-390px)] xl:min-h-[440px]",children:[n.jsx("div",{ref:p,"aria-hidden":!0,className:"w-12 shrink-0 select-none overflow-hidden border-r bg-card py-3 text-right font-mono text-label text-muted-foreground",style:{lineHeight:`${Pu}px`},children:Array.from({length:T},(P,G)=>n.jsx("div",{className:oe("pr-2",L.get(G+1)==="error"&&"bg-destructive/15 text-destructive-text",L.get(G+1)==="warning"&&"bg-warning/15 text-warning-text"),children:G+1},G))}),n.jsx(As,{bare:!0,ref:f,value:e,readOnly:l,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:P=>{l||t(P.target.value),v(P.target.selectionStart)},onSelect:P=>v(P.target.selectionStart),onScroll:P=>{p.current&&(p.current.scrollTop=P.target.scrollTop)},onKeyDown:P=>{if(P.key!=="Tab"||l)return;P.preventDefault();const G=P.currentTarget,I=G.selectionStart,Y=G.selectionEnd;t(`${e.slice(0,I)} ${e.slice(Y)}`),requestAnimationFrame(()=>G.setSelectionRange(I+2,I+2))},className:"flex-1 resize-none overflow-auto bg-background px-3 py-3 text-small selection:bg-primary/[0.28] selection:text-foreground focus-visible:outline focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-ring",style:{lineHeight:`${Pu}px`,tabSize:2}})]}),!l&&n.jsxs("ul",{className:"max-h-48 min-h-[44px] overflow-auto border-t font-mono text-small","aria-label":"Problems",children:[F.length===0&&n.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:R.mode==="server"?"No problems: the server's validator takes this workflow as it is.":"No problems the console can see. The server checks the workflow again when you save."}),F.map((P,G)=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>z(P.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[P.severity==="error"?n.jsx(ai,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):n.jsx(ar,{className:"mt-0.5 size-3.5 shrink-0 text-warning-text","aria-hidden":!0}),n.jsx("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",children:P.line?`L${P.line}:${P.col}`:"—"}),n.jsx("span",{className:"min-w-0 flex-1 break-words",children:P.message})]})},G))]})]}),n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[n.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:mf(Hg(w))}),N&&(U?n.jsxs("span",{className:"font-mono text-label",children:[[N.added.length&&`${N.added.length} new`,N.changed.length+N.rewritten.length&&`${N.changed.length+N.rewritten.length} edited`,N.removed.length&&`${N.removed.length} removed`,N.moved.length&&`${N.moved.length} moved`,!N.moved.length&&W&&`${W} ${W===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",n.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),n.jsx("span",{className:"flex-1"}),!h.ok&&m.current&&n.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),n.jsx("div",{className:oe("min-h-[360px] flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5 xl:h-[calc(100vh-330px)] xl:min-h-[480px]",!h.ok&&"opacity-60"),children:w.nodes.length?n.jsx(dc,{graph:w,marks:C,label:"The workflow's graph",minScale:.55,onSelect:P=>{const G=h.ok?h.spans.get(`${P.path}/label`)??h.spans.get(P.path):void 0;G&&z(G.start,G.end)}}):n.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),n.jsx("div",{className:"border-t px-4 py-2",children:n.jsx(fc,{})})]})]})}const mL="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function PN(){return n.jsxs(n.Fragment,{children:["A run on Sonnet needs about $0.10 to take a few steps; under that it pauses before its next step (",n.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:mL,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let Ga=null;function Lu(e,t){return Ga?Ga({to:e,replay:t}):!1}function pL(e){const[t,s]=x.useState(null),r=x.useRef(location.hash);return x.useEffect(()=>{if(!e)return;const a=c=>c.to===r.current?!1:(s(c),!0);Ga=a;const l=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",l),()=>{Ga===a&&(Ga=null),window.removeEventListener("beforeunload",l)}},[e]),{asking:t!==null,stay:()=>s(null),leave:()=>{var a;if(t!==null){if(s(null),t.to===null){(a=t.replay)==null||a.call(t);return}if(Ga=null,!t.replay){location.hash=t.to;return}location.hash!==r.current?window.addEventListener("hashchange",t.replay,{once:!0}):t.replay()}}}}const LN="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",Lp="custom",Gw=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function hL(e,t){if((e==null?void 0:e.kind)!=="invalid")return null;const s=Object.entries(e.fields).filter(([r])=>r==="definition.workflow"||r.startsWith("definition.workflow/")).map(([r,a])=>({path:r.slice(19),message:a}));return s.length?s:t?[{path:"",message:e.message}]:null}function gL(e){var s;const t=(s=/^definition\.([a-z_]+)/.exec(e))==null?void 0:s[1];if(t){if(["name","description","instructions"].includes(t))return"context";if(["tools","tool_settings","approvals","skills"].includes(t))return"tools";if(["harness","thinking","model","max_cost_usd","learning"].includes(t))return"settings";if(["place","computer"].includes(t))return"computer";if(t==="workflow")return"workflow"}}const xL=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:gi},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:ia},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:xi},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Ju},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:D0},{id:"history",label:"History",note:"Revisions and the current one",Icon:Hh}];function yL({agent:e,revisions:t=[],caps:s,onSave:r,onMakeCurrent:a,onArchive:l,onReload:c,onBack:u,step:f,problem:p=null,notice:g,draft:v,validate:h,providerChoices:m=[],permissionGates:b=[],focusTool:w,mcpServers:j=null,serverToolSettings:N,onRetryMcp:R}){var Xn,Yn,Qn,an,Zn,dr,yt;const $=!e,S=e==null?void 0:e.definition,[E,C]=x.useState(f??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),T=$?Mp(s.places):void 0,[A,F]=x.useState({name:(S==null?void 0:S.name)??"",description:(S==null?void 0:S.description)??"",instructions:(S==null?void 0:S.instructions)??($?fP:""),harness:(S==null?void 0:S.harness)??"pi",thinking:S==null?void 0:S.thinking,model:S==null?void 0:S.model,tools:$?Pp("pi",s.tools,T):(S==null?void 0:S.tools)??[],maxCostText:typeof(S==null?void 0:S.max_cost_usd)=="number"&&S.max_cost_usd>0?String(S.max_cost_usd):"",...T?{place:T}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:v??JSON.stringify(S.workflow,null,2)}:{}}),[L,z]=x.useState(!1),W=x.useRef(A);W.current=A;const[U,D]=x.useState(A),K=Q=>{const{maxCostText:Ae,workflowText:qe,...ut}=Q,xt=Mw(Ae),Vt=Gw(qe),Kt={...ut,maxCost:xt.ok?xt.value??0:Ae,...qe!==void 0?{workflowSent:Vt!==void 0?Vt:qe}:{}},mt=e?{...Bg(e,Kt,"").definition}:{...Kt};return delete mt.version,mt.tool_settings&&!Object.keys(mt.tool_settings).length&&delete mt.tool_settings,{...mt,tools:[...mt.tools??[]].sort(),approvals:Q.approvals??(S==null?void 0:S.approvals)??"ask"}},P=!Al(K(A),K(U)),[G,I]=x.useState([]),[Y,q]=x.useState(!1),O=s.tools.map(Q=>`${Q.name}:${Q.available}:${(Q.harnesses??[]).join("+")}`).join(","),B=JSON.stringify(Mp(s.places)??null);x.useEffect(()=>{if(!$)return;const Q=Ae=>{const qe=Ae.place??Mp(s.places);return{...Ae,...qe?{place:qe}:{},...Y?{}:{tools:Pp(Ae.harness??"pi",s.tools,qe)}}};F(Q),D(Q)},[O,B]);const[ee,le]=x.useState(""),[ie,ue]=x.useState(!1),[ae,ce]=x.useState(!1),[he,et]=x.useState(p),[se,ke]=x.useState(null),Se=Q=>{ke(null),C(Q)},Fe=Q=>(he==null?void 0:he.kind)==="invalid"&&Object.entries(he.fields).filter(([Ae])=>Ae===`definition.${Q}`||Ae.startsWith(`definition.${Q}[`)||Ae.startsWith(`definition.${Q}.`)).map(([,Ae])=>Ae).join(" ")||void 0,fe=(e==null?void 0:e.warnings)??[],Le=Q=>wP(fe,Q).map(Ae=>Ae.message).join(" ")||void 0,He=Q=>{$&&ae||F(Ae=>({...Ae,...Q}))},It=x.useRef(null);x.useEffect(()=>{var Q;((he==null?void 0:he.kind)==="invalid"||(he==null?void 0:he.kind)==="other")&&((Q=It.current)==null||Q.focus())},[he]);const We=(e==null?void 0:e.kind)==="workflow",we=$&&bN(A.harness),lt=[...(Xn=A.name)!=null&&Xn.trim()?[]:["Give the agent a name to create it."],...!We&&!we&&!((Yn=A.instructions)!=null&&Yn.trim())?["Write its instructions to create it."]:[]],jt=A.approvals??(S==null?void 0:S.approvals)??"ask",Nt=bP(s.harnesses,$?{available:!!s.decisionProvider}:void 0),on={mcpHarnesses:s.mcpHarnesses,workflow:We},en=Q=>{if(Q.mode==="sandbox")return;const Ae=new Set(s.tools.filter(qe=>qe.sandbox_only).map(qe=>qe.name));I(qe=>qe.filter(ut=>!Ae.has(ut)))},Ot=Q=>{if($&&!Y){He({harness:Q,tools:Pp(Q,s.tools,A.place)}),I([]);return}const Ae=hP(Q,A.tools??[],G,s.tools,on);He({harness:Q,tools:Ae.tools}),I(Ae.held)},Wt=t.find(Q=>Q.revision===(e==null?void 0:e.revision))??t.find(Q=>Q.current),Et=xL.filter(Q=>!($&&Q.id==="history")&&(Q.id!=="workflow"||We)&&!(we&&Q.id==="tools")&&(Q.id!=="computer"||!We&&!we&&!!(s.computers||s.places))),ct=Et.some(Q=>Q.id===E)?E:Et[0].id,Ie=Et.findIndex(Q=>Q.id===ct),st=async()=>{if(!r)return;const Q=A;ce(!0);let Ae={...A,workflowText:void 0,maxCostText:void 0};if(!we){const xt=Mw(A.maxCostText);if(!xt.ok){ce(!1),et({kind:"invalid",message:xt.message,fields:{"definition.max_cost_usd":xt.message}});return}const Vt=typeof(S==null?void 0:S.max_cost_usd)=="number"&&S.max_cost_usd>0,Kt=xt.value??0;(Kt!==0||Vt)&&(Ae={...Ae,max_cost_usd:Kt})}if(We)try{Ae={...Ae,workflow:JSON.parse(A.workflowText??"")}}catch(xt){ce(!1),et({kind:"invalid",message:`The workflow is not JSON: ${xt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${xt.message}`}});return}const qe=await r(Ae,ee),ut=Al(W.current.tool_settings??{},Ae.tool_settings??{});ce(!1),et(qe),!qe&&(le(""),W.current.harness===Q.harness&&I([]),D(ut?(({tool_settings:xt,...Vt})=>Vt)(Q):Q),ut&&F(({tool_settings:xt,...Vt})=>Vt))},gt=pL(!ae&&P),Xe=TN(A.harness??"pi",s.harnesses),St=Xe?Sd(Xe,s.routePrefix):void 0,qt=DP(A.harness??"pi",s.harnesses),Ln=L||A.model!==void 0&&!qt.includes(A.model),Kn=[{value:"",label:St?`Server default (${St.text})`:"Server default"},...qt.map(Q=>({value:Q,label:Sd(Q,s.routePrefix).text})),{value:Lp,label:"Custom..."}],fs=hf(A.harness??"pi",s.tools).filter(Q=>Iw([Q.name])).map(Q=>Q.name);return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4 md:px-8",children:[n.jsx(V,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:u,children:n.jsx(qs,{"aria-hidden":!0})}),n.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:$?void 0:S.name,children:$?"New agent":S.name}),e&&n.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[n.jsx(Ce,{children:e.kind}),n.jsxs("span",{className:"caps text-label text-muted-foreground",children:[Wt?`rev ${Wt.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),l&&n.jsxs(V,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>l(!e.archived_at),children:[n.jsx(Kl,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(he==null?void 0:he.kind)==="conflict"&&n.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-card px-5 py-3 md:px-8",role:"alert",children:[n.jsx(ar,{className:"size-4 text-warning-text","aria-hidden":!0}),n.jsx("p",{className:"min-w-0 flex-1 text-body",children:"This agent changed since you opened it: another revision was saved first, so this save was not made. Reload to see the current revision; it replaces your unsaved edits here."}),n.jsx(V,{size:"sm",onClick:c,children:"Reload"})]}),g&&n.jsx("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-warning-text md:px-8",role:"alert",children:g}),fe.length>0&&n.jsxs("div",{className:"border-b bg-card px-5 py-3 md:px-8",role:"status","aria-label":"Save warnings",children:[n.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[n.jsx(ar,{className:"size-4 shrink-0","aria-hidden":!0})," Saved. A run of this revision is refused until the server has what each line names:"]}),n.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:fe.map((Q,Ae)=>{const qe=Et.find(ut=>ut.id===gL(Q.field));return n.jsxs("li",{children:[qe?n.jsx("button",{type:"button",title:Q.field,onClick:()=>Se(qe.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:qe.label}):n.jsx("span",{className:"text-muted-foreground",children:Q.field})," ",Q.message]},`${Q.field}:${Ae}`)})})]}),n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[n.jsx("ol",{className:oe("relative flex shrink-0 gap-1 overflow-x-auto border-b p-3 md:flex-col md:gap-0 md:border-b-0 md:border-r md:p-4",ct==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:Et.map((Q,Ae)=>n.jsx("li",{className:"shrink-0",children:n.jsxs("button",{type:"button","aria-current":ct===Q.id?"step":void 0,onClick:()=>Se(Q.id),className:oe("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",ct===Q.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[n.jsx("span",{className:oe("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",ct===Q.id?"border-foreground bg-foreground text-background":Ae<Ie?"border-border-strong":"border-border"),children:Ae<Ie?n.jsx(Ld,{className:"size-3","aria-hidden":!0}):Ae+1}),n.jsxs("span",{className:oe("hidden min-w-0",ct!=="workflow"&&"md:block"),title:ct==="workflow"?Q.label:void 0,children:[n.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[n.jsx(Q.Icon,{className:"size-3.5","aria-hidden":!0})," ",Q.label]}),n.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:Q.note})]}),n.jsx("span",{className:"sr-only md:hidden",children:Q.label})]})},Q.id))}),n.jsx("section",{className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-10",children:n.jsxs("fieldset",{disabled:$&&ae,className:"m-0 min-w-0 border-0 p-0",children:[n.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Step ",Ie+1]}),n.jsx("h2",{className:"caps mb-6 border-b pb-4 text-prose font-semibold",children:Et[Ie].label}),ct==="context"&&n.jsxs("div",{className:"max-w-3xl space-y-6",children:[n.jsx(Us,{label:"Name",id:"agent-name",required:$,note:$?void 0:"Set when the agent was created; an edit keeps it.",error:Fe("name"),warning:Le("name"),children:n.jsx(Ue,{id:"agent-name",value:A.name,readOnly:!$,onChange:Q=>He({name:Q.target.value}),placeholder:"e.g., Invoice checker"})}),n.jsx(Us,{label:"Description",id:"agent-description",optional:!0,note:$?void 0:"Set when the agent was created; an edit keeps it.",error:Fe("description"),warning:Le("description"),children:n.jsx(Ue,{id:"agent-description",value:A.description,readOnly:!$,onChange:Q=>He({description:Q.target.value}),placeholder:$?"Short summary for the agent list":"No description"})}),we?n.jsx(Us,{label:"Workflow",children:n.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:A.harness===Gg?"A decision agent is a workflow. It starts from a starter decision workflow: one typed question, and a person when the answer is unclear or not confident enough. Create it, then edit its nodes in the Workflow step.":"A workflow agent starts from a one-step workflow: an agent node that does what its input's task asks. Create it, then edit its nodes, or paste a workflow's JSON over it, in the Workflow step."})}):We?n.jsx(Us,{label:"Workflow",note:"This agent is a workflow. Edit its nodes in the Workflow step: the graph redraws as you type and the server checks it.",warning:Le("workflow"),children:n.jsxs(V,{size:"sm",onClick:()=>C("workflow"),children:[n.jsx(ia,{"aria-hidden":!0})," Open the workflow"]})}):n.jsxs(Us,{label:"Instructions",id:ie?void 0:"agent-instructions",required:!0,error:Fe("instructions"),warning:Le("instructions"),aside:n.jsx("span",{className:"flex",children:["Preview","Edit"].map(Q=>n.jsx(V,{type:"button",size:"xs","aria-pressed":Q==="Preview"===ie,onClick:()=>ue(Q==="Preview"),className:oe("-ml-px first:ml-0",Q==="Preview"===ie?"relative border-foreground bg-foreground text-background hover:bg-foreground":"text-muted-foreground"),children:Q},Q))}),children:[ie?n.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:mo(A.instructions||"")}}):n.jsx(As,{id:"agent-instructions",value:A.instructions,onChange:Q=>He({instructions:Q.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:"resize-y leading-[1.7]"}),n.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(A.instructions??"").length," characters"]})]})]}),ct==="workflow"&&n.jsx(Bw,{text:A.workflowText??"",onText:Q=>He({workflowText:Q}),base:We?S.workflow:void 0,baseLabel:Wt?`rev ${Wt.version}`:void 0,validate:h,tools:A.tools,serverIssues:hL(he,We)}),ct==="computer"&&!We&&!we&&s.computers&&n.jsx("div",{className:"max-w-4xl space-y-8",children:n.jsx(aL,{kinds:s.computers,value:A.computer??(S==null?void 0:S.computer)??Aw(A.place??{mode:"runner"}),onChange:Q=>{const Ae=rL(Q),qe=new Set(s.tools.filter(ut=>ut.sandbox_only).map(ut=>ut.name));He({computer:Q,place:Ae,...Ae.mode==="runner"?{tools:(A.tools??[]).filter(ut=>!qe.has(ut))}:{}}),en(Ae)},error:Fe("computer")??Fe("place"),warning:Le("computer")??Le("place")})}),ct==="computer"&&!We&&!we&&!s.computers&&s.places&&n.jsx("div",{className:"max-w-3xl space-y-8",children:n.jsx(iL,{value:A.place,saved:S==null?void 0:S.place,places:s.places,tools:s.tools,picked:A.tools??[],onChange:Q=>{He({...Q,...Q.place?{computer:Aw(Q.place)}:{}}),Q.place&&en(Q.place)},error:Fe("computer")??Fe("place"),warning:Le("computer")??Le("place")})}),ct==="tools"&&n.jsxs("div",{className:"max-w-3xl space-y-6",children:[n.jsxs(Us,{label:"Tools",note:"On by default: the tools this agent's harness runs on this server. Untick one to take it away.",error:Fe("tools"),warning:Le("tools"),children:[n.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[s.tools.filter(Q=>{var Ae;return We||!Q.call_only||((Ae=A.tools)==null?void 0:Ae.includes(Q.name))}).map(Q=>{var jn,ms;const Ae=yh(A.harness??"pi",Q.name,s.tools,on),qe=((jn=A.tools)==null?void 0:jn.includes(Q.name))??!1,ut=m.find(zn=>zn.name===Q.name),xt=(ms=(A.tool_settings??(S==null?void 0:S.tool_settings)??{})[Q.name])==null?void 0:ms.provider,Vt=!!ut&&xt!==void 0&&xt!==ut.provider,Kt=gP(Q,A.place??pf(S==null?void 0:S.place)??Vg(We,A.tools??[],s.places)),mt=X1(Q.name,b,e==null?void 0:e.tools)?zg:Q.call_only&&!We?"Workflow-only: a workflow's call node runs it, not an agent":Ae?Kt??(!Q.available&&!Vt?(ut==null?void 0:ut.reason)??Q.reason??`Needs ${(Q.missing??[]).join(", ")}`:void 0):Lw(A.harness??"pi",Q.name,s.tools),In=mt?Q.call_only&&!We?"Workflow only":Kt&&Ae&&mt===Kt?"Sandbox-only":mt:void 0;return n.jsx("li",{className:"min-w-0",children:n.jsx(AN,{value:Q.name,name:Q.name,blurb:Q.blurb,description:Q.summary,why:mt,tag:In,on:qe,disabled:!!mt&&!qe,onToggle:()=>{q(!0),He({tools:qe?A.tools.filter(zn=>zn!==Q.name):[...A.tools??[],Q.name]})}})},Q.name)}),s.mcp&&!We&&n.jsx("li",{className:"sm:col-span-2",children:n.jsx(eL,{servers:j,tools:A.tools??[],harness:A.harness??"pi",harnesses:s.mcpHarnesses,onRetry:R,onChange:Q=>{q(!0),He({tools:Q})}})})]}),!We&&!Iw(A.tools??[])&&n.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",fs.length?`tick ${fs.join(" or ")} in Tools.`:`${A.harness??"pi"} runs no web tool on this server.`]})]}),n.jsx(uL,{agent:e,unattended:!We&&jt==="never",harness:A.harness??"pi",model:A.model,tools:A.tools??[],choices:We?[]:m,gates:b,mcpServers:Array.isArray(j)?j:void 0,serverSettings:N,focus:w,callTools:We?y5(Gw(A.workflowText)??(S==null?void 0:S.workflow)):void 0,value:A.tool_settings??(S==null?void 0:S.tool_settings)??{},issues:(he==null?void 0:he.kind)==="invalid"?he.fields:{},onChange:Q=>!ae&&Al(Q,(S==null?void 0:S.tool_settings)??{})?F(({tool_settings:Ae,...qe})=>qe):He({tool_settings:Q})}),!We&&!we&&n.jsxs("fieldset",{"aria-label":"Approvals",className:"space-y-2",children:[n.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),[["ask","Ask me","A call whose permission is ask waits for your answer."],["never","Never ask (run unattended)","For an agent that runs on a trigger, with no one there to answer."]].map(([Q,Ae,qe])=>n.jsxs("label",{className:oe("flex items-start gap-3 border px-3 py-2.5",jt===Q&&"border-foreground"),children:[n.jsx("input",{type:"radio",name:"approvals",value:Q,className:"mt-1 accent-primary",checked:jt===Q,disabled:ae,onChange:()=>He({approvals:Q})}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono text-body",children:Ae}),n.jsx("span",{className:"block text-small text-muted-foreground",children:qe})]})]},Q)),jt==="never"&&n.jsx("p",{className:"text-small text-warning-text",children:LN})]}),n.jsx(Us,{label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:(Qn=S==null?void 0:S.skills)!=null&&Qn.length?n.jsx("ul",{className:"border",children:S.skills.map(Q=>n.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:Q},Q))}):n.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),ct==="settings"&&n.jsxs("div",{className:"max-w-3xl space-y-8",children:[!We&&n.jsxs(Us,{named:!0,label:"Harness",note:"What runtime runs this agent.",error:Fe("harness"),warning:Le("harness"),children:[n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,9rem),1fr))] gap-3",role:"radiogroup","aria-label":"Harness",children:Nt.map(Q=>{const Ae=n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"radio",name:"harness",value:Q.id,checked:A.harness===Q.id,disabled:!Q.available&&A.harness!==Q.id,onChange:()=>Ot(Q.id),className:"mt-1 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block break-words font-mono text-body font-semibold",children:Q.label}),n.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:Q.available?Q.id:"Not available here"})]})]}),qe=oe("min-w-0 border px-4 py-3",A.harness===Q.id?"border-foreground":"border-border");return Q.available?n.jsx("label",{className:oe(qe,"flex cursor-pointer items-start gap-3"),children:Ae},Q.id):n.jsxs("div",{className:oe(qe,"opacity-60"),children:[n.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Ae}),Q.reason&&n.jsxs("details",{className:"mt-2 font-mono text-label text-muted-foreground",children:[n.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Why, and what to do"}),n.jsx("p",{className:"mt-1 break-words leading-[1.6]",children:Q.reason})]})]},Q.id)})}),G.length>0&&n.jsxs("div",{className:"mt-3 border px-3 py-2 font-mono text-small",role:"status","aria-label":"Tools this harness doesn't run",children:[n.jsxs("p",{className:"text-warning-text",children:[((an=Nt.find(Q=>Q.id===A.harness))==null?void 0:an.label)??A.harness," doesn't run ",G.length===1?"this tool":"these tools"," here, so ",G.length===1?"it's":"they're"," unticked. Switching back ticks ",G.length===1?"it":"them"," again."]}),n.jsx("ul",{className:"mt-1 space-y-0.5",children:G.map(Q=>n.jsxs("li",{children:[Q,": ",n.jsx("span",{className:"text-muted-foreground",children:Lw(A.harness??"pi",Q,s.tools,s.mcpHarnesses)})]},Q))})]})]}),!We&&!we&&n.jsx(Us,{named:!0,label:"Thinking",note:"How hard the model thinks before it answers.",error:Fe("thinking"),warning:Le("thinking"),children:n.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(Q=>n.jsxs("label",{className:oe("caps cursor-pointer border px-3 py-2 text-small",A.thinking===Q?"border-foreground":"text-muted-foreground"),children:[n.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:A.thinking===Q,onChange:()=>He({thinking:Q})}),Q]},Q))})}),!we&&n.jsxs(Us,{label:"Model",id:"agent-model",optional:!0,note:St?n.jsxs(n.Fragment,{children:["Empty uses the server's default (",n.jsx("span",{title:St.title,children:St.text}),")."]}):FP,error:Fe("model"),warning:Le("model"),children:[n.jsx(Lt,{id:"agent-model",label:"Model",className:"w-full",value:Ln?Lp:A.model??"",options:Kn,onChange:Q=>{if(Q===Lp){z(!0);return}z(!1),He({model:Q||void 0})}}),Ln&&n.jsx(Ue,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:A.model??"",onChange:Q=>{z(!0),He({model:Q.target.value||void 0})},placeholder:"provider/model"})]}),!we&&n.jsx(Us,{label:"Default spend cap per run, $",id:"agent-max-cost",optional:!0,note:"A run started without a cap of its own, and a trigger with none, stops at this spend. Empty means none.",hint:n.jsx(PN,{}),error:Fe("max_cost_usd"),warning:Le("max_cost_usd"),children:n.jsx(Ue,{id:"agent-max-cost",inputMode:"decimal",value:A.maxCostText??"",onChange:Q=>He({maxCostText:Q.target.value}),placeholder:"e.g., 2.50"})}),!We&&!we&&s.learning&&n.jsx(nP,{fields:A,onFields:He,saved:S==null?void 0:S.learning,server:s.learning,error:Fe("learning"),warning:Le("learning")})]}),ct==="history"&&se&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsxs(V,{size:"sm",variant:"ghost",onClick:()=>ke(null),children:[n.jsx(qs,{"aria-hidden":!0})," Back to History"]}),n.jsxs("span",{className:"caps text-small",children:["rev ",se.version]}),n.jsx("span",{className:"min-w-0 flex-1 text-lead",children:se.note??n.jsx("span",{className:"text-muted-foreground",children:"No note"})}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ft(se.created_at)}),n.jsx(V,{size:"sm",onClick:()=>a==null?void 0:a(se.revision),disabled:!a,children:"Make current"})]}),n.jsx(Bw,{readOnly:!0,text:JSON.stringify((Zn=se.definition)==null?void 0:Zn.workflow,null,2),onText:()=>{},base:S.workflow,baseLabel:Wt?`rev ${Wt.version}, the current one`:"the current revision"})]}),ct==="history"&&!se&&n.jsx("ul",{className:"max-w-3xl border",children:t.map(Q=>{var Ae;return n.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[n.jsxs("span",{className:"caps w-14 text-small",children:["rev ",Q.version]}),n.jsx("span",{className:"min-w-0 flex-[1_1_14rem] break-words text-lead",children:Q.note??n.jsx("span",{className:"text-muted-foreground",children:"No note"})}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ft(Q.created_at)}),We&&!Q.current&&((Ae=Q.definition)==null?void 0:Ae.workflow)!==void 0&&n.jsxs(V,{size:"sm",variant:"ghost",onClick:()=>ke(Q),"aria-label":`View rev ${Q.version}`,children:[n.jsx(M0,{"aria-hidden":!0})," View"]}),Q.current?n.jsx(Ce,{tone:"success",children:"Current"}):n.jsx(V,{size:"sm",onClick:()=>a==null?void 0:a(Q.revision),disabled:!a,children:"Make current"})]},Q.revision)})})]})})]}),n.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[n.jsxs(V,{size:"sm",variant:"ghost",disabled:Ie===0,onClick:()=>Se(Et[Ie-1].id),children:[n.jsx(qs,{"aria-hidden":!0})," Previous"]}),ct!=="history"&&n.jsx(Ue,{value:ee,onChange:Q=>le(Q.target.value),placeholder:$?"":"What changed (a note on this revision)","aria-label":"Revision note",className:oe("h-9 min-w-0 flex-1",$&&"invisible")}),ct==="history"&&n.jsx("span",{className:"flex-1"}),Ie<Et.length-1&&n.jsxs(V,{size:"sm",onClick:()=>Se(Et[Ie+1].id),children:["Next ",n.jsx(Dh,{"aria-hidden":!0})]}),!se&&n.jsx(V,{ref:It,size:"sm",variant:"solid",onClick:st,disabled:!r||ae||!$&&!P||!((dr=A.name)!=null&&dr.trim())||!We&&!we&&!((yt=A.instructions)!=null&&yt.trim()),children:$?ae?"Creating…":"Create":ae?"Saving…":P?"Save revision":Wt?`Saved · rev ${Wt.version}`:"Saved"}),$&&!ae&&!se&&lt.map(Q=>n.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:Q},Q)),(he==null?void 0:he.kind)==="invalid"&&n.jsxs("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:["The server refused the save: ",he.message]}),(he==null?void 0:he.kind)==="other"&&n.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:he.message})]}),n.jsxs(gA,{open:gt.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:gt.leave,onCancel:gt.stay,children:[$?"This new agent is not saved yet.":"Your changes to this agent are not saved."," Leave drops them; Stay keeps them here."]})]})}const Us=({named:e,...t})=>n.jsx(Bs,{...t,group:t.id?!1:e?"heading":!0});function bL({agents:e,archived:t=!1,onArchivedChange:s,actions:r={},error:a,handoff:l}){const[c,u]=x.useState(""),f=(e??[]).filter(p=>`${p.definition.name} ${p.definition.description??""}`.toLowerCase().includes(c.toLowerCase()));return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[n.jsxs("label",{className:oe("flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3",Oj),children:[n.jsx(s$,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx(Ue,{bare:!0,value:c,onChange:p=>u(p.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"flex-1 max-sm:portrait:placeholder:text-transparent"})]}),n.jsxs(V,{size:"lg",variant:t?"primary":"outline","aria-pressed":t,onClick:()=>s==null?void 0:s(!t),children:[n.jsx(Kl,{"aria-hidden":!0})," Archived"]}),!t&&l,!t&&n.jsxs(V,{size:"lg",variant:"primary",onClick:r.onNew,children:[n.jsx(Ol,{"aria-hidden":!0})," New agent"]})]}),a?n.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:a}):e?f.length?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[f.length," ",f.length===1?"agent":"agents"]}),n.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:f.map(p=>n.jsx(vL,{agent:p,actions:r},p.agent_id))})]}):n.jsxs("div",{className:"border px-4 py-12 text-center",children:[n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:c?"No agent matches.":t?"No archived agents.":"No agents yet."}),!c&&!t&&n.jsxs(V,{className:"mt-4",variant:"primary",onClick:r.onNew,children:[n.jsx(Ol,{"aria-hidden":!0})," New agent"]})]}):n.jsx(Os,{label:"Loading the agents",rows:6})]})}function vL({agent:e,actions:t}){const s=e.kind==="workflow"?ia:Fh,r=!!e.archived_at,a=gd(e);return n.jsxs("li",{className:oe("flex flex-col border p-4",r&&"opacity-70"),children:[n.jsxs("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:()=>{var l;return(l=t.onOpen)==null?void 0:l.call(t,e.agent_id)},children:[n.jsx(s,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-prose font-semibold",children:e.definition.name}),n.jsx(Ce,{children:e.kind}),e.kind==="agentic"&&n.jsx(Ce,{children:e.definition.harness??"pi"}),r&&n.jsx(Ce,{tone:"muted",children:"Archived"})]}),n.jsx("span",{className:"mt-1.5 line-clamp-2 block font-mono text-small leading-relaxed text-muted-foreground",children:e.definition.description||(e.kind==="workflow"?sA(e.definition.workflow):"No description.")})]})]}),n.jsxs("div",{"data-testid":"agent-card-footer",className:"mt-auto flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 pt-4",children:[n.jsxs("div",{"data-testid":"agent-card-chips",className:"flex min-w-0 flex-auto flex-wrap items-center gap-x-2 gap-y-1.5 py-1.5",children:[n.jsxs(Ce,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&n.jsxs(Ce,{className:"shrink-0 whitespace-nowrap",children:[e.runs.count," ",e.runs.count===1?"run":"runs",e.runs.live?` · ${e.runs.live} live`:""]}),a>0&&n.jsxs(V,{size:"xs","aria-label":Ag(a),onClick:()=>{var l;return(l=t.onLearning)==null?void 0:l.call(t,e.agent_id)},className:"h-5 shrink-0 whitespace-nowrap border-warning/50 bg-warning/10 px-1.5 text-micro text-warning-text hover:bg-warning/20",children:["Learning · ",a]})]}),n.jsxs("div",{"data-testid":"agent-card-actions",className:"ml-auto flex shrink-0 items-center gap-2",children:[n.jsx(V,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`Edit ${e.definition.name}`,onClick:()=>{var l;return(l=t.onEdit)==null?void 0:l.call(t,e.agent_id)},children:n.jsx(Xl,{"aria-hidden":!0})}),n.jsx(V,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var l;return(l=t.onRuns)==null?void 0:l.call(t,e.agent_id)},children:n.jsx(Hh,{"aria-hidden":!0})}),n.jsx(V,{size:"icon",variant:"outline",className:"shrink-0","aria-label":`${r?"Unarchive":"Archive"} ${e.definition.name}`,onClick:()=>{var l;return(l=t.onArchive)==null?void 0:l.call(t,e.agent_id,!r)},children:r?n.jsx(T0,{"aria-hidden":!0}):n.jsx(Kl,{"aria-hidden":!0})})]})]})]})}const qo=e=>e instanceof Ee?vP(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function wL({v2:e,archived:t,go:s}){const[r,a]=x.useState(null),[l,c]=x.useState(null),u=x.useRef(0),f=()=>{const p=++u.current;a(null),c(null),ao(g=>e.listAgents({archived:t,cursor:g}),g=>g.agents).then(g=>{p===u.current&&a(g)}).catch(g=>{p===u.current&&c(qo(g).message)})};return x.useEffect(f,[e,t]),n.jsx(bL,{agents:r,archived:t,onArchivedChange:p=>s(p?"#/agents?archived=true":"#/agents"),error:l,handoff:n.jsx(Tg,{context:{kind:"create"},label:"Build with your coding agent",size:"lg",iconOnPhone:!0,className:"max-sm:w-11"}),actions:{onOpen:p=>s(Gs(p)),onEdit:p=>s(Gs(p,"edit")),onNew:()=>s("#/agents/new"),onRuns:p=>s(Gs(p,"runs")),onLearning:p=>s(Gs(p,"learning")),onArchive:async(p,g)=>{try{await(g?e.archiveAgent(p):e.unarchiveAgent(p)),f()}catch(v){c(qo(v).message)}}}})}function kL({v2:e,caps:t,choices:s=[],gates:r=[],focusTool:a,agentId:l,go:c}){const[u,f]=x.useState(null),[p,g]=x.useState(null),[v,h]=x.useState([]),[m,b]=x.useState(null),[w,j]=x.useState(null),[N,R]=x.useState(0),[$,S]=x.useState(null),E=x.useRef(!0);x.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]);const C=I=>ao(Y=>e.listRevisions(I,Y),Y=>Y.revisions),T=async()=>{if(l)try{const[{agent:I,etag:Y},q]=await Promise.all([e.getAgent(l),C(l)]);f(I),g(Y),h(q),S(I.revision),R(O=>O+1),j(null),b(null)}catch(I){u?j(`The agent could not be reloaded: ${qo(I).message}`):b(qo(I).message)}};x.useEffect(()=>{T()},[l]);const[A,F]=x.useState(null),L=x.useRef(0);x.useEffect(()=>{const I=++L.current;e.computers().then(Y=>{I===L.current&&F(Y.kinds)},()=>{I===L.current&&F(null)})},[e]);const[z,W]=x.useState(void 0);x.useEffect(()=>{let I=!0;return Promise.resolve().then(()=>e.toolSettings()).then(Y=>{I&&W(Y)},()=>{}),()=>{I=!1}},[e]);const[U,D]=x.useState(null),K=x.useRef(0),P=()=>{if(!t.mcp)return;const I=++K.current;D(null),e.listMcpServers().then(Y=>{I===K.current&&D(Y.servers)},()=>{I===K.current&&D("failed")})};x.useEffect(P,[e,t.mcp]);const G=async(I,Y)=>{let q;try{q=await Y()}catch(O){j(`${I} did not finish: ${qo(O).message}`);return}f(q);try{const{agent:O,etag:B}=await e.getAgent(q.agent_id),ee=await C(q.agent_id).catch(()=>v);f(O),g(B),h(ee),O.revision!==$?(S(O.revision),R(le=>le+1),j(I==="Make current"?null:`${I} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(O){j(`${I} done. The page could not be refreshed: ${qo(O).message}. Reload to see the current state.`)}};return l&&m&&!u?n.jsx("p",{className:"m-8 border p-4 font-mono text-body text-destructive-text",role:"alert",children:m}):l&&!u?n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading the agent..."}):n.jsx(yL,{agent:u,revisions:v,caps:{...t,computers:A},providerChoices:s,permissionGates:r,mcpServers:U,serverToolSettings:z,onRetryMcp:P,...a?{focusTool:a,step:"tools"}:{},notice:w,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{T(),P()},onSave:async(I,Y)=>{let q;try{if(!u){const le=await e.createAgent(mP({name:I.name??"",description:I.description??"",instructions:I.instructions??"",harness:I.harness??"pi",tools:I.tools??[],approvals:I.approvals,tool_settings:I.tool_settings,thinking:I.thinking,model:I.model,computer:I.computer,learning:I.learning,max_cost_usd:I.max_cost_usd,decisionProvider:t.decisionProvider}));return E.current&&c(Gs(le.agent_id,le.kind==="workflow"?"workflow":void 0)),null}const O=Bg(u,I,Y);if(O.unchanged)return{kind:"other",message:"Nothing to save: the definition is the current revision's, and a note alone makes no new revision."};const{unchanged:B,...ee}=O;q=await e.updateDefinition(u.agent_id,ee,p)}catch(O){return qo(O)}return f(q.agent),g(q.etag),S(q.agent.revision),e.getAgent(q.agent.agent_id).then(O=>f(B=>B&&B.revision===O.agent.revision?{...B,tools:O.agent.tools}:B)).catch(()=>{}),C(q.agent.agent_id).then(h).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:I=>{u&&G("Make current",()=>e.setCurrent(u.agent_id,I))},onArchive:I=>{u&&G(I?"Archive":"Unarchive",()=>I?e.archiveAgent(u.agent_id):e.unarchiveAgent(u.agent_id))}},`${(u==null?void 0:u.agent_id)??"new"}:${N}`)}function fa({error:e,title:t="The run failed"}){return n.jsxs("section",{className:"flex gap-3 bg-card px-4 py-4 md:px-5",role:"alert",children:[n.jsx(ar,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"caps text-small font-semibold",children:t}),n.jsx("p",{className:"mt-2 break-words font-mono text-body leading-relaxed",children:e.message}),n.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[e.code,e.retryable?" · retryable":"",e.request_id?` · ${e.request_id}`:""]})]})]})}const jL={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},NL={anthropic:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z",openrouter:"M16.778 1.844v1.919q-.569-.026-1.138-.032-.708-.008-1.415.037c-1.93.126-4.023.728-6.149 2.237-2.911 2.066-2.731 1.95-4.14 2.75-.396.223-1.342.574-2.185.798-.841.225-1.753.333-1.751.333v4.229s.768.108 1.61.333c.842.224 1.789.575 2.185.799 1.41.798 1.228.683 4.14 2.75 2.126 1.509 4.22 2.11 6.148 2.236.88.058 1.716.041 2.555.005v1.918l7.222-4.168-7.222-4.17v2.176c-.86.038-1.611.065-2.278.021-1.364-.09-2.417-.357-3.979-1.465-2.244-1.593-2.866-2.027-3.68-2.508.889-.518 1.449-.906 3.822-2.59 1.56-1.109 2.614-1.377 3.978-1.466.667-.044 1.418-.017 2.278.02v2.176L24 6.014Z"},SL=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function _L({id:e,className:t}){const[s,r]=x.useState(!1),a=jL[e],l=NL[e];return a&&!s?n.jsx("img",{"data-provider-icon":e,src:SL(a),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:oe("size-4 shrink-0 object-contain",t)}):l?n.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:oe("size-4 shrink-0",t),"aria-hidden":!0,children:n.jsx("path",{d:l})}):n.jsx(Qo,{className:oe("size-4 shrink-0 text-muted-foreground",t),"aria-hidden":!0})}const $L=/^(which|what|who|whom|whose|where|when|why|how|should|shall|do|does|did|is|are|was|were|can|could|would|will|may|might)\b/i,EL=40;function CL(e){const t=e.trim().replace(/\?+$/,""),s=t.lastIndexOf(":"),r=(s>=0?t.slice(s+1):t.split(new RegExp("(?<=[.!?])\\s+")).at(-1)??"").trim();if(s<0&&$L.test(r))return[];const a=r.split(/,?\s+or\s+|,\s+/i).map(c=>c.trim()).filter(Boolean);if(a.length<2||a.length>4||!/\bor\b/i.test(r))return[];const l=a.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return l.some(c=>!c||c.length>EL)?[]:l.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function TL(e){var r,a;const t=new Map;for(const l of e){if(l.imported_from)continue;const c=((a=(r=l.error)==null?void 0:r.message)==null?void 0:a.trim())||"The run failed.";t.set(c,[...t.get(c)??[],l])}const s=l=>Date.parse(l.ended_at??l.created_at);return[...t].map(([l,c])=>({message:l,runs:c.sort((u,f)=>s(f)-s(u))})).sort((l,c)=>s(c.runs[0])-s(l.runs[0]))}const IN=e=>e.filter(t=>!t.imported_from).length,RL=864e5;function AL(e,t){return e.some(s=>!s.imported_from)||t.some(s=>s.source==="live"&&s.runs>0)}function mc(e,t){const s=Math.max(0,Math.round((t-Date.parse(e))/1e3));return s<60?`${s} s`:s<3600?`${Math.floor(s/60)} min`:s<86400?`${Math.floor(s/3600)} h`:`${Math.floor(s/86400)} days`}const OL=2e3;function ML(e,t){var r;if(e.kind==="workflow")return{refusal:`"${e.title}" is a workflow run: start it again from its agent's page`};if(!t)return{refusal:`"${e.title}": its first message could not be read`};if(t.length>=OL&&t.endsWith("..."))return{refusal:`"${e.title}": its first message is longer than the timeline keeps; start it again from its agent's page`};if(/\n\nFiles for this run: [^\n]*$/.test(t))return{refusal:`"${e.title}" was given files, which a run started again can't take along: start it again from its agent's page with them`};const s=(r=e.cost)==null?void 0:r.cap_usd;return{body:{input:{content:t},...e.effort?{effort:e.effort}:{},...typeof s=="number"?{max_cost_usd:s}:{}}}}function PL(e,t){let s=!1,r;const a=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(a,t))})};return a(),()=>{s=!0,clearTimeout(r)}}const zN=e=>e.pending!=null,LL=e=>e.status==="input_required"&&e.state!=="waiting"&&!zN(e),IL=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function qw(e,t){const s={asking:(e==null?void 0:e.asking)??[],failed:(e==null?void 0:e.failed)??[],live:(e==null?void 0:e.live)??[]},r=[];return IL.forEach(([a,l],c)=>{const u=t[c];(u==null?void 0:u.status)==="fulfilled"?s[a]=u.value:u&&r.push(`${l} could not be read: ${u.reason instanceof Error?u.reason.message:String(u.reason)}`)}),{needs:s,problem:r.length?r.join(" · "):null}}const zL={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},DL={tool:1,model:1,mcp:2,computer:2,source:2};function _d(e,t){const s=e.split(":"),r=DL[s[0]];return(r===void 0?"":s.slice(r).join(":"))||t||s.slice(1).join(":")}const FL="Sign in with your password to change secrets.",UL="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",WL="Open the console from the server's link to change secrets.",pc={sign_in:FL,no_accounts:UL,token:WL},DN=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,HL=e=>{var t;return((t=DN(e))==null?void 0:t.secrets_writable)===!0};function BL(e){const t=DN(e);return t!=null&&t.secrets_reason?t.secrets_reason:(t==null?void 0:t.accounts)===!1?"no_accounts":"sign_in"}function GL(e){const[t,s]=x.useState({writable:!1,whyNot:"sign_in"});return x.useEffect(()=>{let r=!0;return e.session().then(a=>{r&&s({writable:HL(a),whyNot:BL(a)})},()=>{}),()=>{r=!1}},[e]),t}function bf({field:e,label:t,writable:s,required:r=!0,stateSaid:a=!1,now:l=Date.now,note:c,onPaste:u,onRemove:f}){const p=e.source==="env",g=s&&!p;return n.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:oe("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",p&&"opacity-60"),children:[n.jsxs("span",{children:[_d(e.name,t),!r&&n.jsx("span",{className:"ml-2 font-sans text-label text-muted-foreground",children:"Optional"})]}),n.jsx("span",{"data-state":e.set?"set":r?"missing":"optional-missing",className:a?"sr-only":c?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&n.jsx("span",{className:"text-muted-foreground",children:zL[e.source]}),e.changed_at&&n.jsxs("span",{className:"text-muted-foreground",children:["Changed ",mc(e.changed_at,l())," ago"]}),c&&n.jsx("span",{className:"text-warning-text",children:c}),g&&n.jsxs("span",{className:"ml-auto flex gap-2 font-sans",children:[u&&n.jsx(V,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:u,children:e.set?"Replace":"Paste"}),f&&e.set&&n.jsx(V,{type:"button",size:"sm",variant:"destructive",onClick:f,children:"Remove"})]})]})}const Vw={anthropic:{url:"https://console.anthropic.com/settings/keys",placeholder:"sk-ant-…"},openai:{url:"https://platform.openai.com/api-keys",placeholder:"sk-…"},openrouter:{url:"https://openrouter.ai/keys",placeholder:"sk-or-…"}},qL=e=>Object.prototype.hasOwnProperty.call(Vw,e)?Vw[e]:void 0,VL={seal_key_changed:"This server's seal key changed since these keys were saved, so they can't be opened.",file_unreadable:"The file this server keeps the saved keys in is damaged, so they can't be opened."},Kw=e=>e instanceof Ee?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function Xw(e,t){return t?t.state==="accepted"?`${e} accepted this key · ${ft(t.at)}`:`Not checked: ${t.reason}${t.at?` · ${ft(t.at)}`:""}`:null}const KL="can't be opened: paste it again",XL=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],FN="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function YL({v2:e,onChange:t,writable:s,whyNot:r="sign_in"}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState(null),[g,v]=x.useState(null),h=x.useRef(0),m=()=>{const S=++h.current;e.listToolKeys().then(E=>{S===h.current&&(l(E),u(null))}).catch(E=>{S===h.current&&u(Kw(E))})};x.useEffect(m,[e]);const b=S=>p(E=>E===S?null:E),w=S=>{b(S),m(),t==null||t()},j=(S,E,C,T)=>{v({id:S,title:E,error:Kw(C)}),C instanceof Ee&&C.code==="key_set_by_server"&&(b(T),m())};if(!a)return c?n.jsx(Yw,{error:c,onRetry:m}):n.jsx("div",{className:"p-5 md:p-8",children:n.jsx(Os,{label:"Loading the tool keys",rows:3})});const N=a.reenter,R=XL.map(S=>({...S,keys:a.keys.filter(E=>E.kind==="model"==(S.kind==="model"))})).filter(S=>S.keys.length),$=S=>n.jsx(QL,{tool:S,writable:s,again:!!N&&S.fields.some(E=>E.stored_unreadable||N.fields.includes(E.name)),open:(f==null?void 0:f.id)===S.id?f.mode:null,problem:(g==null?void 0:g.id)===S.id?g:null,onOpen:E=>{p(E?{id:S.id,mode:E}:null),v(null)},onSave:async E=>{const C=f;try{await e.saveToolKey(S.id,E)}catch(T){return T instanceof Ee&&T.status===422?T:(j(S.id,"The key was not saved",T,C),null)}return w(C),null},onRemove:async()=>{const E=f;try{await e.removeToolKey(S.id)}catch(C){j(S.id,"The key was not removed",C,E);return}w(E)}},S.id);return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Keys"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A model provider's key, which every agent runs on, and a tool's key, for every agent that uses the tool, kept on this server. A saved key is never shown again."})]}),!s&&n.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:pc[r]}),c&&n.jsx(Yw,{inline:!0,error:c,onRetry:m}),N&&n.jsxs(On,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[n.jsx("p",{children:VL[N.reason]}),n.jsx("p",{className:"mt-2 font-mono",children:N.fields.length?N.fields.join(", "):"Which keys it held is not known: enter again each key you had saved."})]}),R.map(S=>n.jsxs("section",{"aria-label":S.label,children:[R.length>1&&n.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:S.label}),S.kind==="model"&&n.jsx("p",{className:"mb-2 text-body text-muted-foreground",children:FN}),n.jsx("ul",{className:"border",children:S.keys.map($)})]},S.label))]})})}function Yw({error:e,onRetry:t,inline:s=!1}){return n.jsx(On,{tone:"error",className:s?void 0:"m-8",actions:n.jsx(V,{type:"button",size:"xs",onClick:t,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The tool keys could not be read: ",e.code,": ",e.message]})})}function QL({tool:e,writable:t,again:s,open:r,problem:a,onOpen:l,onSave:c,onRemove:u}){var h;const f=m=>e.secrets.find(b=>_d(b.name)===m.name),p=m=>e.fields.find(b=>b.name===_d(m.name)),g=e.fields.filter(m=>{var b;return((b=f(m))==null?void 0:b.source)!=="env"}),v=e.secrets.filter(m=>m.set).length;return n.jsxs("li",{className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[n.jsx(_L,{id:e.id,className:"mt-1"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-prose font-semibold",children:e.label}),n.jsx(Ce,{tone:v===e.secrets.length?"success":"plain",children:v===e.secrets.length?"set":v?`${v} of ${e.secrets.length} set`:"not set"}),s&&n.jsx(Ce,{tone:"warning",children:"enter again"})]}),n.jsxs("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:[e.kind==="model"?"Model provider":`Unlocks ${e.unlocks.join(", ")}`,e.harnesses.length>0&&` · Harnesses ${e.harnesses.length===1?`${e.harnesses[0]} only`:e.harnesses.join(", ")}`]}),Xw(e.label,e.check)&&n.jsx("p",{className:`mt-1.5 text-small ${((h=e.check)==null?void 0:h.state)==="accepted"?"text-success-text":"text-muted-foreground"}`,children:Xw(e.label,e.check)}),n.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(m=>{var b;return n.jsx(bf,{field:m,stateSaid:e.secrets.length===1,writable:t&&r===null,note:(b=p(m))!=null&&b.stored_unreadable?KL:void 0,onPaste:()=>l("edit"),onRemove:m.source==="console"?()=>l("remove"):void 0},m.name)})}),!g.length&&n.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"Set when the server starts, and that one wins: change it where the server is started."})]})]}),r==="edit"&&n.jsx(UN,{tool:e,fields:g,onSave:c,onCancel:()=>l(null)}),r==="remove"&&n.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(m=>m.source==="env")?" The one set in the environment stays.":""]}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>void u(),children:"Remove"}),n.jsx(V,{size:"sm",onClick:()=>l(null),children:"Keep"})]}),a&&n.jsx("div",{className:"mt-4 border",children:n.jsx(fa,{error:a.error,title:a.title})})]})}function UN({tool:e,fields:t,onSave:s,onCancel:r}){const a=x.useRef(null),[l,c]=x.useState(!1),[u,f]=x.useState(!1),[p,g]=x.useState(null),v=()=>t.some(w=>{var j,N;return(N=(j=a.current)==null?void 0:j.elements.namedItem(w.name))==null?void 0:N.value}),h=()=>{var w;(w=a.current)==null||w.reset(),c(!1)},m=async w=>{var S,E;w.preventDefault();const j={};for(const C of t){const T=(E=(S=a.current)==null?void 0:S.elements.namedItem(C.name))==null?void 0:E.value;T&&(j[C.name]=T)}if(!Object.keys(j).length)return;f(!0),g(null);const N=await s(j);if(f(!1),!N){h();return}const R={},$=[];for(const C of N.fields??[]){const T=C.field.startsWith("values.")?C.field.slice(7):null;T&&t.some(A=>A.name===T)?R[T]=C.message:$.push(C.message)}g({fields:R,message:$.length?$.join(" "):Object.keys(R).length?null:N.message})},b=qL(e.id);return n.jsxs("form",{ref:a,autoComplete:"off",onSubmit:w=>void m(w),onInput:()=>c(!!v()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[b&&n.jsxs("p",{className:"text-body text-muted-foreground",children:[n.jsx("span",{className:"font-semibold text-foreground",children:e.label})," · No key yet?"," ",n.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-2",children:"Get a key"})," (opens in a new tab)"]}),t.map(w=>n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:w.name}),w.set&&n.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"Saved already. A new value replaces it; leave it empty to keep it."}),n.jsx(Ue,{type:"password",name:w.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:b&&t.length===1?b.placeholder:void 0}),(p==null?void 0:p.fields[w.name])&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[w.name]})]},w.name)),(p==null?void 0:p.message)&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:p.message}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:!l||u,children:u?"Saving":"Save"}),n.jsx(V,{type:"button",size:"sm",onClick:()=>{h(),r()},children:"Cancel"})]})]})}const hc=x.createContext(null);function Qw({connection:e,children:t}){return n.jsx(hc.Provider,{value:e,children:t})}const ZL={state:"online"},JL=()=>()=>{},Zw=()=>ZL;function Yg(){const e=x.useContext(hc);return x.useSyncExternalStore(e?e.subscribe:JL,e?e.link:Zw,Zw)}function WN(e){const t=x.useContext(hc),s=x.useRef(e);s.current=e,x.useEffect(()=>t==null?void 0:t.onResume(()=>s.current()),[t])}function HN(e){const[t,s]=x.useState(()=>Date.now());return x.useEffect(()=>{if(e===null)return;s(Date.now());const r=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(r)},[e]),e===null?0:Math.max(0,Math.ceil((e-t)/1e3))}function eI(){const e=x.useContext(hc),t=Yg(),s=HN(t.state==="offline"?t.retryAt:null);return!e||t.state==="online"?null:t.state==="resumed"?n.jsxs(On,{bar:!0,tone:"success",icon:t$,"data-connection":"resumed",children:[n.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):n.jsxs(On,{bar:!0,tone:"warning",icon:H0,"data-connection":"offline",actions:n.jsx(V,{type:"button",onClick:e.retryNow,size:"xs",children:"Retry now"}),children:[n.jsxs("span",{className:"font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]})," Reconnecting… next try in ",s," s. The page shows what it had."]})}function tI(){const e=x.useContext(hc),t=Yg(),s=HN(t.state==="offline"?t.retryAt:null);return n.jsxs("div",{"data-connection":"offline",role:"status",className:"mx-auto mt-[12vh] max-w-md border bg-card p-6",children:[n.jsx(H0,{className:"size-5 text-warning-text","aria-hidden":!0}),n.jsxs("p",{className:"mt-3 text-base font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]}),n.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Is it running? This page connects by itself as soon as the server answers."}),n.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[n.jsx(V,{type:"button",onClick:e==null?void 0:e.retryNow,size:"sm",children:"Retry now"}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["Next try in ",s," s"]})]})]})}const nI=[{id:"keys",label:"Tool keys"},{id:"tools",label:"Tools"},{id:"mcp",label:"MCP servers"},{id:"github",label:"GitHub"},{id:"computers",label:"Computers"},{id:"workspace",label:"Workspace"},{id:"webhook",label:"Webhook"}];function sI({active:e,offered:t,children:s}){return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.length>1&&n.jsx("nav",{"aria-label":"Settings",className:"flex shrink-0 gap-1 border-b px-6",children:nI.filter(r=>t.includes(r.id)).map(r=>n.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:oe("caps -mb-px border-b-2 px-3 py-3 text-small",e===r.id?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground"),children:r.label},r.id))}),n.jsx("div",{className:"min-h-0 flex-1",children:s})]})}const Jw=e=>e instanceof Ee?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function rI({v2:e,choices:t,gates:s=[],harnesses:r,onSaved:a,onOpen:l}){const[c,u]=x.useState(null),[f,p]=x.useState(null),[g,v]=x.useState(null),[h,m]=x.useState(!1),[b,w]=x.useState(null),j=x.useRef(0),N=()=>{const D=++j.current;e.toolSettings().then(K=>{D===j.current&&(u(K),p(null))},K=>{D===j.current&&p(Jw(K))})};x.useEffect(N,[e]);const[R,$]=x.useState("reading"),S=()=>{$("reading"),Promise.resolve(l==null?void 0:l()).then(D=>$(D===!1?"failed":"landed"))},E=()=>{N(),S()};if(x.useEffect(S,[]),!c)return f?n.jsx(On,{tone:"error",className:"m-8",actions:n.jsx(V,{type:"button",size:"xs",onClick:N,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",f.code,": ",f.message]})}):n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const C=xw(c,t),T=b?b(C):C,A=ON(t,s),F=Object.entries(T).filter(([,D])=>(D==null?void 0:D.pin)||(D==null?void 0:D.pin_broken)),L=D=>{var P;const K=s.find(G=>G.name===D);return!K||(((P=T[D])==null?void 0:P.permission)??K.default_permission)===K.permission},{byTool:z,rest:W}=J1((g==null?void 0:g.fields)??{},"",A.map(D=>D.name)),U=async D=>{var I;const K=b?Y=>D(b(Y)):D;m(!0),v(null);const P=++j.current;let G;try{G=await e.toolSettings()}catch{w(()=>K),v({fields:{},error:null,unread:!0}),m(!1);return}try{const Y=await e.saveToolSettings(K(xw(G,t)));w(null),P===j.current&&(u(Y),p(null)),a()}catch(Y){v(Y instanceof Ee&&Y.status===422&&((I=Y.fields)!=null&&I.length)?{fields:Object.fromEntries(Y.fields.map(q=>[q.field,q.message])),error:null}:{fields:{},error:Jw(Y)})}m(!1)};return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"This server's provider for each tool that has a choice, and what it resolves to on each harness. A change is saved at once and applies to every run launched from then on. An agent with a provider of its own keeps it."}),s.length>0&&n.jsxs("p",{className:"mt-2 text-lead text-muted-foreground",children:["Each tool's permission: ",n.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",n.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",n.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]}),n.jsxs("section",{"aria-label":"This server's providers",children:[A.length?n.jsx(MN,{label:"This server's tool settings",rows:A,settings:T,fallbackOf:D=>D.default_provider,issues:z,busy:h,onEdit:D=>void U(D),refused:(D,K)=>K==="deny",resolvesOf:(D,K)=>K===D.provider&&L(D.name)?n.jsx(cL,{choice:D,harnesses:r}):R==="reading"?n.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"reading…"}):n.jsxs("span",{className:"block text-small text-muted-foreground",children:[R==="failed"?"What it resolves to couldn't be read.":"It changed while this page read it."," ",n.jsx(V,{type:"button",onClick:E,disabled:h,size:"xs",className:"ml-1",children:"Retry"})]})}):n.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"This server offers no tool with a choice of provider."}),W.map(D=>n.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:D},D)),(g==null?void 0:g.error)&&n.jsx("div",{className:"mt-3 border",children:n.jsx(fa,{error:g.error,title:"The change was not saved"})}),(g==null?void 0:g.unread)&&n.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[n.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),n.jsx(V,{type:"button",size:"xs",className:"mt-2",onClick:()=>void U(D=>D),disabled:h,children:"Try again"})]}),f&&n.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[n.jsxs("p",{className:"font-mono text-small text-destructive-text",children:["The tool settings could not be read again: ",f.code,": ",f.message]}),n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),n.jsx(V,{type:"button",onClick:E,disabled:h,size:"xs",className:"mt-2",children:"Try again"})]})]}),F.length>0&&n.jsxs("section",{"aria-label":"Pinned tools",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:"Pinned tools"}),n.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"A pin bounds a tool's calls for every agent on this server, its own pin beside it."}),n.jsx("ul",{className:"mt-2 border",children:F.map(([D,K])=>n.jsxs("li",{"data-pin":D,className:"border-b px-3 py-2.5 last:border-b-0",children:[n.jsx("p",{className:"font-mono text-body",children:D}),n.jsx(kh,{setting:K})]},D))})]})]})})}function oI(e){const t=new URLSearchParams(e??""),s=t.get("github");if(s==="connected")return{ok:!0};if(s==="error"){const r=t.get("reason");return r?{ok:!1,reason:r}:{ok:!1}}}const e0={state_invalid:"That connection was started elsewhere or has expired. Start again.",conversion_failed:"GitHub didn't hand back the App. Try connecting again.",installation_unverified:"The App's install couldn't be confirmed. Install it again from GitHub.",already_connected:"Another GitHub App was connected while this one was being created. Delete the new App on GitHub."},aI=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(e0,e.reason)?e0[e.reason]:"The connection didn't finish. Try again.";function iI(e,t){const s=t(e);if(!s)return;const r=new URL(s);return r.protocol==="https:"&&r.hostname==="github.com"?s:void 0}function Yo(e){if(!(typeof e!="string"||!e))try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function lI({note:e}){const t=e.lastIndexOf(": "),s=t>=0?e.slice(t+2).trim():"",r=s?Yo(s):void 0;return r?n.jsxs(n.Fragment,{children:[e.slice(0,t+2),n.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"break-all underline underline-offset-2",children:s})]}):n.jsx(n.Fragment,{children:e})}function cI({v2:e,returned:t}){const[s,r]=x.useState(void 0),[a,l]=x.useState(null),[c,u]=x.useState(""),[f,p]=x.useState(!1),[g,v]=x.useState(null),[h,m]=x.useState(null),[b,w]=x.useState(null),[j,N]=x.useState(!1),[R,$]=x.useState(null),S=x.useRef(!1),E=x.useRef(null),C=x.useCallback(async()=>{try{const L=await e.githubConnection();r(L.connected?L:null),l(null)}catch(L){l(L instanceof Error?L.message:String(L))}},[e]);x.useEffect(()=>{C()},[C]),x.useEffect(()=>{t&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),x.useEffect(()=>{var L;g&&((L=E.current)==null||L.submit())},[g]);const T=async()=>{var L;if(!S.current){S.current=!0,p(!0),m(null),w(null),$(null);try{const z=await e.connectGitHub(c.trim()||void 0),W=iI(z.action,Yo);if(!W){m("GitHub's address didn't look right, so nothing was sent."),S.current=!1,p(!1);return}v({action:W,manifest:JSON.stringify(z.manifest)})}catch(z){if(S.current=!1,p(!1),m(z instanceof Error?z.message:String(z)),z instanceof Ee&&z.code==="github_wrong_origin"){const W=(L=z.details)==null?void 0:L.public_url;w(typeof W=="string"&&Yo(W)||null)}z instanceof Ee&&z.code==="github_already_connected"&&C()}}},A=async()=>{N(!1),p(!0),m(null),w(null);try{$(await e.disconnectGitHub()),r(null)}catch(L){L instanceof Ee&&(L.status===404||L.code==="github_not_connected")?await C():m(L instanceof Error?L.message:String(L))}finally{p(!1)}},F=s?Yo(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"GitHub"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One GitHub App for this server: its templates and triggers reach GitHub through it."})]}),t&&n.jsx("p",{"aria-label":"From GitHub",role:"status",className:oe("border p-4 text-lead",t.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:aI(t)}),(h||b)&&n.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:b?n.jsxs("p",{children:["Open this server at ",n.jsx("a",{href:b,className:"break-all underline underline-offset-2",children:b})," to connect GitHub."]}):n.jsx("p",{children:h})}),R&&n.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[n.jsx("p",{children:n.jsx(lI,{note:R.note})}),n.jsx("p",{className:"mt-1 text-muted-foreground",children:R.triggers_off?`${R.triggers_off} GitHub ${R.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),a&&n.jsx(On,{tone:"error",actions:n.jsx(V,{type:"button",size:"xs",onClick:()=>void C(),children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["GitHub's connection could not be read: ",a]})}),s===void 0&&!a&&n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),s===null&&n.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[n.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[n.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),n.jsx(Ue,{name:"org",value:c,onChange:L=>u(L.target.value),disabled:f,placeholder:"your-org",className:"h-9 w-auto"})]}),n.jsxs(V,{type:"button",variant:"solid",onClick:()=>void T(),disabled:f,children:[n.jsx(Pb,{"aria-hidden":!0}),g?"Opening GitHub…":"Connect GitHub"]})]}),n.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"GitHub asks you to create the App, then to install it on the accounts it may use. You come back here after."})]}),s&&n.jsxs("section",{"aria-label":"GitHub App",className:"border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-lead",children:[n.jsx(Pb,{className:"size-4 text-muted-foreground","aria-hidden":!0}),F?n.jsx("a",{href:F,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):n.jsx("span",{className:"font-mono",children:s.slug}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?n.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(L=>n.jsx("li",{children:L.account},L.id))}):n.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),j?n.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[n.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),n.jsx(V,{type:"button",variant:"destructive",disabled:f,onClick:()=>void A(),children:"Disconnect GitHub"}),n.jsx(V,{type:"button",variant:"ghost",onClick:()=>N(!1),children:"Cancel"})]}):n.jsx(V,{type:"button",variant:"outline",className:"mt-4",disabled:f,onClick:()=>N(!0),children:"Disconnect"})]}),g&&n.jsx("form",{"data-github-manifest":!0,ref:E,method:"post",action:g.action,hidden:!0,children:n.jsx("input",{type:"hidden",name:"manifest",defaultValue:g.manifest})})]})})}const uI=8,dI={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function fI({v2:e,signIn:t,add:s,writable:r,whyNot:a="sign_in",open:l=c=>location.assign(c)}){var S,E,C;const[c,u]=x.useState(null),[f,p]=x.useState(null),[g,v]=x.useState(s?{add:s}:null),h=s==null?void 0:s.name,m=s==null?void 0:s.auth,b=x.useRef(`${h??""}|${m??""}`);x.useEffect(()=>{const T=`${h??""}|${m??""}`;T!==b.current&&(b.current=T,v(h?{add:{name:h,...m?{auth:m}:{}}}:null))},[h,m]);const[w,j]=x.useState(!1),N=x.useRef(0),R=()=>{const T=++N.current;e.listMcpServers().then(A=>{T===N.current&&(u(A.servers),p(null))},A=>{T===N.current&&p(hi(A))})};x.useEffect(R,[e]),x.useEffect(()=>{t&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[t]);const $=async(T,A)=>l((await e.startMcpSignIn(T,A)).authorization_url);return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"MCP servers"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A remote MCP server's tools, for any agent you grant them to in its Tools step. A saved credential is never shown again."})]}),!g&&!w&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx(V,{size:"sm",variant:"primary",onClick:()=>v({}),children:"Add server"}),n.jsx(V,{size:"sm",disabled:!r,onClick:()=>j(!0),children:"Add from Composio"})]})]}),t&&n.jsx("p",{className:`border p-4 text-body ${t.ok?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:t.ok?`Signed in to ${t.server}. Its tools are saved.`:`Signing in to ${t.server} failed: ${n5(t.error)}.`}),!r&&n.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:pc[a]}),f&&n.jsx(On,{tone:"error",actions:n.jsx(V,{type:"button",size:"xs",onClick:R,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",f.text]})}),g&&n.jsx(yI,{v2:e,saved:g.saved,add:g.add,given:g.problem,writable:r,signIn:$,onCancel:()=>v(null),onSaved:(T=>()=>{v(A=>A===T?null:A),R()})(g)},`${((S=g.saved)==null?void 0:S.name)??"new"}|${((E=g.add)==null?void 0:E.name)??""}|${((C=g.add)==null?void 0:C.auth)??""}`),w&&n.jsx(hI,{v2:e,onClose:()=>j(!1),onSaved:R}),c&&(c.length?n.jsx("ul",{className:"border",children:c.map(T=>n.jsx(mI,{v2:e,server:T,writable:r&&!g,signIn:$,onChange:A=>v({saved:T,...A?{problem:A}:{}}),onChanged:R},T.name))}):n.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."})),n.jsx(pI,{v2:e})]})})}const vf=({problem:e})=>n.jsxs("div",{role:"alert",children:[n.jsx("p",{className:"font-mono text-body text-destructive-text",children:e.text}),e.detail&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.detail})]});function mI({v2:e,server:t,writable:s,signIn:r,onChange:a,onChanged:l}){var $,S;const[c,u]=x.useState(!1),[f,p]=x.useState(!1),[g,v]=x.useState(null),[h,m]=x.useState(null),b=async E=>{u(!0),m(null);try{await E()}catch(C){m(hi(C))}u(!1)},[w,j]=t.credential?dI[t.credential]??[t.credential,"plain"]:["no credential","plain"],N=t.auth.type==="oauth",R=g&&[["Added",g.added],["Removed",g.removed],["Changed",g.changed]].filter(([,E])=>E.length).map(([E,C])=>`${E} ${C.join(", ")}`);return n.jsxs("li",{"data-server":t.name,className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[n.jsx(e$,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-mono text-prose font-semibold",children:t.name}),n.jsx(Ce,{tone:j,children:w}),!!(($=t.not_metered)!=null&&$.length)&&n.jsx(Ce,{tone:"plain",children:"not metered"})]}),n.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:t.url}),t.auth.type==="github_app"&&n.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed with this server's GitHub App: a token narrowed to the run's repository is made for each run",(S=t.auth.headers)!=null&&S.length?` · headers ${t.auth.headers.join(", ")}`:""]}),N&&t.oauth&&n.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed in with OAuth",t.oauth.scopes.length?` · ${t.oauth.scopes.join(" ")}`:"",t.oauth.client==="pre-registered"&&t.oauth.client_id?` · client ${t.oauth.client_id}`:"",t.credential==="expired"?" · sign-in expired: sign in again":t.oauth.expires_at?` · token until ${ft(t.oauth.expires_at)}`:""]}),n.jsxs("details",{className:"mt-2",children:[n.jsxs("summary",{className:"cursor-pointer font-mono text-small",children:[t.tools.length," tool",t.tools.length===1?"":"s"]}),n.jsx("ul",{className:"mt-1 space-y-0.5",children:t.tools.map(E=>{var C,T;return n.jsxs("li",{className:"font-mono text-small",children:[E.name,((C=t.prices)==null?void 0:C[E.name])!==void 0&&n.jsxs("span",{className:"text-muted-foreground",children:[" · $",t.prices[E.name]," a call"]}),((T=t.not_metered)==null?void 0:T.includes(E.name))&&n.jsx("span",{className:"text-muted-foreground",children:" · not metered"})]},E.name)})})]}),t.secret&&n.jsx("ul",{className:"mt-2",children:n.jsx(bf,{field:t.secret,label:xI[t.auth.type],writable:s,onPaste:N?void 0:()=>a()})}),R&&n.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:R.length?R.join(" · "):"No change: it lists the same tools."})]}),!f&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[N&&t.credential!=="sealed"&&s&&n.jsx(V,{size:"sm",variant:"primary",disabled:c,onClick:()=>void b(()=>{var E;return r(t.name,{url:t.url,...(E=t.oauth)!=null&&E.scopes.length?{scopes:t.oauth.scopes}:{}})}),children:"Sign in again"}),n.jsx(V,{size:"sm",disabled:c,onClick:()=>void b(async()=>{try{v(await e.refreshMcpServer(t.name))}finally{l()}}),children:"Refresh"}),n.jsx(V,{size:"sm",disabled:c,onClick:()=>a(),children:"Change"}),n.jsx(V,{size:"sm",variant:"destructive",disabled:c,onClick:()=>p(!0),children:"Delete"})]})]}),f&&n.jsxs("div",{role:"alertdialog","aria-label":`Delete ${t.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",t.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),n.jsx(V,{size:"sm",variant:"destructive",disabled:c,onClick:()=>void b(async()=>{await e.deleteMcpServer(t.name),l()}),children:"Delete"}),n.jsx(V,{size:"sm",onClick:()=>p(!1),children:"Keep"})]}),h&&n.jsxs("div",{className:"mt-3",children:[n.jsx(vf,{problem:h}),h.needsClient&&s&&n.jsx(V,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>a(h),children:"Enter a Client ID"})]})]})}function pI({v2:e}){const[t,s]=x.useState(null),[r,a]=x.useState(null),[l,c]=x.useState(null),[u,f]=x.useState(!1),[p,g]=x.useState(""),v=()=>void e.mcpPrivateHosts().then(b=>{s(b.hosts),a(null)},b=>a(hi(b)));x.useEffect(v,[e]);const h=async b=>{f(!0),c(null);try{return s((await e.saveMcpPrivateHosts(b)).hosts),!0}catch(w){return c(hi(w)),!1}finally{f(!1)}},m=async b=>{b.preventDefault(),t&&p.trim()&&await h([...t,p.trim()])&&g("")};return n.jsxs("section",{"aria-labelledby":"mcp-private-hosts",className:"space-y-3 border bg-card p-4",children:[n.jsx("h2",{id:"mcp-private-hosts",className:"caps text-small font-semibold",children:"Private network hosts"}),n.jsx("p",{className:"text-body text-muted-foreground",children:"Off by default. A host listed here may run an MCP server's sign-in on your private network (10.x, 172.16–31.x, 192.168.x, 100.64–127.x, fc00::/7), over https only; never this machine, loopback or a link-local address such as cloud metadata."}),r&&n.jsxs("div",{role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",r.text]}),n.jsx(V,{size:"sm",onClick:v,className:"mt-3",children:"Try again"})]}),t&&(t.length?n.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border bg-background",children:t.map(b=>n.jsxs("li",{"data-host":b,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[n.jsx("span",{className:"break-all font-mono text-body",children:b}),n.jsx(V,{size:"sm",disabled:u,onClick:()=>void h(t.filter(w=>w!==b)),children:"Remove"})]},b))}):n.jsx("p",{className:"border bg-background px-3 py-3 font-mono text-body text-muted-foreground",children:"No host is allowed: a sign-in on a private network is refused."})),t&&n.jsxs("form",{onSubmit:b=>void m(b),"aria-label":"Allow a private network host",className:"flex gap-2",children:[n.jsx(Ue,{name:"mcp-private-host","aria-label":"Host name or IP address",value:p,onChange:b=>g(b.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:u||!p.trim(),children:"Allow"})]}),l&&n.jsx(vf,{problem:l})]})}function hI({v2:e,onClose:t,onSaved:s}){var F;const r=x.useRef(null),[a,l]=x.useState(""),[c,u]=x.useState(""),[f,p]=x.useState(null),[g,v]=x.useState([]),[h,m]=x.useState(null),[b,w]=x.useState(null),[j,N]=x.useState(!1),R=()=>{var L,z;return(((z=(L=r.current)==null?void 0:L.elements.namedItem("composio-key"))==null?void 0:z.value)??"").trim()},$=async L=>{N(!0),w(null);try{await L()}catch(z){w(hi(z))}N(!1)},S=x.useRef(0),E=()=>{S.current++,p(null)},C=()=>$(async()=>{const L=++S.current;p(null),v([]);const z=await e.composioTools(R(),a.trim().toLowerCase());L===S.current&&p(z)}),T=()=>$(async()=>{var z,W;const L=await e.saveComposioServer(c.trim(),R(),f.toolkit,g);(z=r.current)==null||z.reset(),s(),L.connect_url||(W=L.not_served)!=null&&W.length?m({connect:L.connect_url,notServed:L.not_served}):t()}),A=L=>v(z=>z.includes(L)?z.filter(W=>W!==L):[...z,L]);return h?n.jsxs("section",{"aria-label":"Composio server saved",className:"space-y-3 border bg-card p-4",children:[n.jsxs("p",{className:"text-body",children:["Saved.",h.connect?` Its tools need your ${f==null?void 0:f.toolkit} account: connect it on Composio, then refresh the server.`:""]}),h.connect&&n.jsx("p",{children:n.jsxs("a",{href:h.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",f==null?void 0:f.toolkit," account"]})}),(F=h.notServed)!=null&&F.length?n.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",h.notServed.join(", "),": a run can't call ",h.notServed.length===1?"it":"them","."]}):null,n.jsx(V,{size:"sm",onClick:t,children:"Done"})]}):n.jsxs("form",{ref:r,autoComplete:"off",onSubmit:L=>{L.preventDefault(),f&&g.length&&c.trim()&&T()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:L=>{L.target.name==="composio-key"&&E()},children:[n.jsx("p",{className:"text-small text-muted-foreground",children:"Composio runs the toolkit's actions for you. This saves an MCP server that grants only the actions you tick, with your Composio key sealed like any credential."}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),n.jsx(Ue,{name:"composio-key",...Qu})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),n.jsx(Ue,{name:"composio-toolkit",value:a,onChange:L=>{l(L.target.value),E()},placeholder:"github",spellCheck:!1})]}),b&&n.jsx(vf,{problem:b}),f&&n.jsxs("fieldset",{className:"space-y-2",children:[n.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),f.tools.length?n.jsx("ul",{className:"divide-y border",children:f.tools.map(L=>n.jsx("li",{className:"px-3 py-2",children:n.jsxs("label",{className:"flex items-start gap-2 text-body",children:[n.jsx("input",{type:"checkbox",value:L.slug,checked:g.includes(L.slug),onChange:()=>A(L.slug),className:"mt-1 accent-primary"}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono",children:L.name}),n.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:L.slug}),L.description&&n.jsx("span",{className:"block text-small text-muted-foreground",children:L.description})]})]})},L.slug))}):n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This toolkit lists no actions."}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),n.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",c.trim()||"<name>","/<tool>."]}),n.jsx(Ue,{name:"composio-name",value:c,onChange:L=>u(L.target.value),spellCheck:!1})]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(V,{type:"button",size:"sm",disabled:j||!a.trim(),onClick:()=>void C(),children:"Load actions"}),f&&n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:j||!g.length||!c.trim(),children:j?"Working":"Save"}),n.jsx(V,{type:"button",size:"sm",disabled:j,onClick:()=>{var L;(L=r.current)==null||L.reset(),t()},children:"Cancel"})]})]})}const Qu={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},gI=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],xI={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function yI({v2:e,saved:t,add:s,given:r,writable:a,signIn:l,onCancel:c,onSaved:u}){var B,ee,le,ie,ue;const f=x.useRef(null),[p,g]=x.useState((t==null?void 0:t.name)??(s==null?void 0:s.name)??""),[v,h]=x.useState((t==null?void 0:t.url)??((s==null?void 0:s.auth)==="github_app"?lw:"")),[m,b]=x.useState((t==null?void 0:t.auth.type)??(s==null?void 0:s.auth)??"none"),[w,j]=x.useState(Math.max(1,((B=t==null?void 0:t.auth.headers)==null?void 0:B.length)??0)),[N,R]=x.useState(null),[$,S]=x.useState(r??null),[E,C]=x.useState(!1),T=x.useRef(0),A=()=>{T.current++,R(null)},F=ae=>{var ce,he;return(((he=(ce=f.current)==null?void 0:ce.elements.namedItem(ae))==null?void 0:he.value)??"").trim()},[L,z]=x.useState(!1),W=ae=>{try{return new URL(ae).origin}catch{return ae}},U=(ae=m)=>{var ce;return z(!!t&&ae==="oauth"&&(t.auth.type!=="oauth"||F("mcp-scopes")!==(((ce=t.oauth)==null?void 0:ce.scopes.join(" "))??"")||!!F("mcp-client-id")||!!F("mcp-client-secret")||W(F("mcp-url"))!==W(t.url)))};x.useEffect(()=>U(),[m]);const D=()=>{if(m==="bearer")return F("mcp-token")?{type:m,token:F("mcp-token")}:{type:m};if(m!=="headers"&&m!=="github_app")return{type:m};const ae=Object.fromEntries(Array.from({length:w},(ce,he)=>[F(`mcp-header-name-${he}`),F(`mcp-header-value-${he}`)]).filter(([ce,he])=>ce&&he));return Object.keys(ae).length?{type:m,headers:ae}:{type:m}},K=async ae=>{C(!0),S(null);try{await ae()}catch(ce){S(hi(ce))}C(!1)},P=!!($!=null&&$.needsClient);x.useEffect(()=>{P&&b("oauth")},[P]),x.useEffect(()=>{var ae,ce;P&&m==="oauth"&&((ce=(ae=f.current)==null?void 0:ae.elements.namedItem("mcp-client-id"))==null||ce.focus())},[P,m]);const G=()=>K(()=>{const ae=F("mcp-scopes").split(/\s+/).filter(Boolean),ce=F("mcp-client-id");return l(p.trim(),{url:v.trim(),...ae.length?{scopes:ae}:{},...ce?{client_id:ce,...F("mcp-client-secret")?{client_secret:F("mcp-client-secret")}:{}}:{}})}),I=()=>{const ae=T.current;K(async()=>{try{const ce=await e.previewMcpServer(v.trim(),D(),t==null?void 0:t.name);ae===T.current&&R(ce)}catch(ce){if(ae===T.current)throw ce}})},Y=ae=>{if(ae.preventDefault(),m==="oauth"&&(!t||L))return void G();K(async()=>{var ce;await e.saveMcpServer(p.trim(),v.trim(),D()),(ce=f.current)==null||ce.reset(),u()})},q=!E&&!!p.trim()&&!!v.trim()&&(!!t||!!N),O=ae=>(t==null?void 0:t.credential)==="sealed"&&t.auth.type===m&&n.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",ae]});return n.jsxs("form",{ref:f,autoComplete:"off",onSubmit:Y,"aria-label":t?`Change ${t.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:ae=>{ae.target.name!=="mcp-name"&&A(),U()},children:[n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),n.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",p.trim()||"<name>","/<tool>."]}),n.jsx(Ue,{name:"mcp-name",value:p,readOnly:!!t,onChange:ae=>g(ae.target.value),spellCheck:!1})]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),n.jsx(Ue,{name:"mcp-url",value:v,onChange:ae=>{h(ae.target.value),$!=null&&$.needsClient&&S(null)},placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),n.jsxs("fieldset",{children:[n.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Credential"}),n.jsx("div",{className:"flex flex-wrap gap-4",children:gI.map(([ae,ce])=>n.jsxs("label",{className:"flex items-center gap-2 text-body",children:[n.jsx("input",{type:"radio",name:"mcp-auth",value:ae,checked:m===ae,disabled:!a&&ae!=="none",onChange:()=>{b(ae),ae==="github_app"&&!v.trim()&&h(lw),A()},className:"accent-primary"}),ce]},ae))})]}),m==="bearer"&&n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),O("A new token replaces it; leave this empty to keep it."),n.jsx(Ue,{name:"mcp-token",...Qu})]}),m==="github_app"&&n.jsx("p",{className:"text-small text-muted-foreground",children:"Uses this server's GitHub App (Settings → GitHub): a token for the repository of each run is made when the run starts, and an agent never sees it. The address is GitHub's hosted MCP, the only one this credential goes to. Headers are optional."}),(m==="headers"||m==="github_app")&&n.jsxs("div",{className:"space-y-2",children:[O(`Its headers: ${(ee=t==null?void 0:t.auth.headers)==null?void 0:ee.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:w},(ae,ce)=>{var he;return n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Ue,{name:`mcp-header-name-${ce}`,"aria-label":`Header ${ce+1} name`,placeholder:"X-Api-Key",defaultValue:(he=t==null?void 0:t.auth.headers)==null?void 0:he[ce],spellCheck:!1}),n.jsx(Ue,{name:`mcp-header-value-${ce}`,"aria-label":`Header ${ce+1} value`,...Qu})]},ce)}),w<uI&&n.jsx(V,{type:"button",size:"sm",variant:"ghost",onClick:()=>j(ae=>ae+1),children:"Add header"})]}),m==="oauth"&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("p",{className:"text-small text-muted-foreground",children:"This server signs in for you and keeps the tokens; an agent never sees one. Sign in opens the server's own page to approve it, and its tools are saved once you do."}),((le=t==null?void 0:t.oauth)==null?void 0:le.client_id)&&n.jsxs("p",{className:"text-small text-muted-foreground",children:["Signing in again uses the client it signed in with (",t.oauth.client_id,"); a client ID here replaces it."]}),n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Scopes (optional)"}),n.jsx(Ue,{name:"mcp-scopes",placeholder:"read write",defaultValue:(ie=t==null?void 0:t.oauth)==null?void 0:ie.scopes.join(" "),spellCheck:!1})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("label",{className:"block flex-1",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:P?"Client ID (this server needs one)":"Client ID (optional)"}),n.jsx(Ue,{name:"mcp-client-id",spellCheck:!1})]}),a&&n.jsxs("label",{className:"block flex-1",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:P?"Client secret (if its app has one)":"Client secret (optional)"}),n.jsx(Ue,{name:"mcp-client-secret",...Qu})]})]})]}),$&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(vf,{problem:$}),$.signIn&&m!=="oauth"&&a&&n.jsx(V,{type:"button",size:"sm",variant:"primary",disabled:E||!p.trim(),onClick:()=>void G(),children:"Sign in"})]}),N&&n.jsxs("section",{"aria-label":"Preview",className:"border bg-background p-3",children:[n.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["MCP ",N.protocol,(ue=N.server_info)!=null&&ue.name?` · ${N.server_info.name}${N.server_info.version?` ${N.server_info.version}`:""}`:""," · ",N.tools.length," tool",N.tools.length===1?"":"s"]}),N.instructions&&n.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:N.instructions}),n.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:XO}),n.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:N.tools.map(ae=>n.jsxs("li",{className:"px-3 py-2",children:[n.jsx("span",{className:"font-mono text-body",children:ae.name}),ae.title&&n.jsx("span",{className:"ml-2 text-small",children:ae.title}),ae.description&&n.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:ae.description})]},ae.name))})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[m==="oauth"&&!a?null:m==="oauth"&&L?n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:E||!v.trim(),children:"Sign in again with these settings"}):m==="oauth"?n.jsx(V,{type:"button",size:"sm",variant:"solid",disabled:E||!p.trim()||!v.trim(),onClick:()=>void G(),children:t?"Sign in again":"Sign in"}):n.jsx(V,{type:"button",size:"sm",disabled:E||!v.trim(),onClick:I,children:"Preview"}),(m!=="oauth"||t&&!L)&&n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:!q,children:E?"Working":"Save"}),n.jsx(V,{type:"button",size:"sm",onClick:()=>{var ae;(ae=f.current)==null||ae.reset(),c()},children:"Cancel"})]})]})}const t0=e=>e instanceof Ee?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function bI({v2:e,needs:t,model:s,onSaved:r,writable:a,whyNot:l="sign_in"}){const[c,u]=x.useState(null),[f,p]=x.useState(null),[g,v]=x.useState(null),[h,m]=x.useState(null),b=x.useRef(0),w=()=>{const E=++b.current;e.listToolKeys().then(C=>{E===b.current&&(u(C.keys.filter(T=>T.kind==="model")),p(null))}).catch(C=>{E===b.current&&p(t0(C))})};x.useEffect(()=>{t!=="model"&&w()},[e,t]);const j=s!=null&&s.includes("/")?s.slice(0,s.indexOf("/")):void 0,N=c==null?void 0:c.find(E=>E.id===j),R=N?[N]:c,$=c==null?void 0:c.find(E=>E.id===g),S=($==null?void 0:$.fields.filter(E=>{var C;return((C=$.secrets.find(T=>_d(T.name)===E.name))==null?void 0:C.source)!=="env"}))??[];return n.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:n.jsxs("div",{className:"mx-auto flex max-w-[1600px] gap-3",children:[n.jsx(Qo,{className:"mt-1 size-4 shrink-0 text-warning-text","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[n.jsx("h2",{className:"text-prose font-semibold",children:t==="model"?"This server's default model doesn't run":"Add a model key to run agents"}),t==="model"?n.jsx("p",{className:"text-body text-muted-foreground",children:"The server's AGENT_MODEL names a model it doesn't know, so an agent that names no model can't run. Set AGENT_MODEL to a provider/model-id where the server starts, or name a model in each agent."}):N?n.jsxs("p",{className:"text-body text-muted-foreground",children:["This server's default model is ",n.jsx("span",{className:"font-mono",children:s}),", and no ",N.label," key is set, so an agent that names no model can't run. Save the ",N.label," key: such an agent then runs on that model."]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-body text-muted-foreground",children:"No model provider's key is set on this server, so an agent that names no model can't run. Save one: such an agent then runs on that provider's everyday model."}),n.jsx("p",{className:"text-body text-muted-foreground",children:FN})]}),t!=="model"&&f&&n.jsxs("div",{role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",f.code,": ",f.message]}),n.jsx(V,{type:"button",onClick:w,size:"sm",className:"mt-2",children:"Try again"})]}),t!=="model"&&c&&!a&&n.jsx("p",{className:"text-body",role:"status",children:pc[l]}),t!=="model"&&c&&a&&n.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:R.map(E=>n.jsx(V,{size:"sm",variant:g===E.id?"solid":"primary","aria-pressed":g===E.id,onClick:()=>{v(g===E.id?null:E.id),m(null)},children:E.label},E.id))}),$&&a&&(S.length?n.jsx(UN,{tool:$,fields:S,onCancel:()=>v(null),onSave:async E=>{m(null);try{await e.saveToolKey($.id,E)}catch(C){return C instanceof Ee&&C.status===422?C:(m(t0(C)),null)}return v(null),w(),r==null||r(),null}},$.id):n.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",$.label," key when it starts: change it there."]})),h&&n.jsx("div",{className:"border",children:n.jsx(fa,{error:h,title:"The key was not saved"})}),n.jsxs("p",{className:"text-small text-muted-foreground",children:["Every key is in ",n.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"#/settings/keys",children:"Settings"}),"."]})]})]})})}function vI({needs:e,settings:t,model:s,source:r}){return n.jsx("p",{role:"status","aria-label":"No model",className:"border-b bg-card px-5 py-3 text-body text-warning-text md:px-8",children:e==="model"?"This server's default model doesn't run here: set AGENT_MODEL to a model it knows, and restart.":n.jsxs(n.Fragment,{children:["No model yet."," ",r==="gateway"?n.jsxs(n.Fragment,{children:["This server sends its models to a gateway: name the gateway's model in AGENT_MODEL where AgentRun starts, and restart",t?n.jsxs(n.Fragment,{children:[", or ",n.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"add a model key in Settings → Model keys"})]}):null,"."]}):s?`This server's default model is ${s}: set its provider's key where AgentRun starts, and restart.`:t?n.jsxs(n.Fragment,{children:[n.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Add a key in Settings → Model keys"})," (one OpenRouter key gives every harness its model), and it takes effect at once. Or set OPENROUTER_API_KEY, ANTHROPIC_API_KEY or OPENAI_API_KEY where AgentRun starts, and restart."]}):"Set OPENROUTER_API_KEY (one key gives every harness its model), or ANTHROPIC_API_KEY or OPENAI_API_KEY, and restart."]})})}const n0=e=>e instanceof Ee?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},wI={unreadable:"Its secret can't sign here: it was sealed under another key, or is damaged. Nothing is sent until the webhook is removed and set again."};function kI({v2:e}){const[t,s]=x.useState(null),[r,a]=x.useState([]),[l,c]=x.useState(null),[u,f]=x.useState(null),[p,g]=x.useState(null),[v,h]=x.useState(null),[m,b]=x.useState(!1),[w,j]=x.useState(!1),[N,R]=x.useState(""),$=x.useRef(0),S=()=>{const T=++$.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([A,F])=>{T===$.current&&(s(A),a(F.attempts),c(null))}).catch(A=>{T===$.current&&c(n0(A))})};x.useEffect(S,[e]);const E=async(T,A)=>{g(null),j(!0);try{await A()}catch(F){g({title:T,error:n0(F)})}finally{j(!1)}S()},C=T=>{T.preventDefault(),E("The webhook was not saved",async()=>{const A=await e.saveWebhook(N.trim());A.signing_secret&&f(A.signing_secret);const{signing_secret:F,...L}=A;s(L)})};return t?n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Webhook"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One URL this server POSTs to when a run needs its person (`run.needs_input`) and when it ends (`run.ended`), signed by the Standard Webhooks spec, so a receiver checks each message with any of that spec's libraries."})]}),p&&n.jsx(fa,{error:p.error,title:p.title}),l&&n.jsx(On,{tone:"error",actions:n.jsx(V,{type:"button",size:"xs",onClick:S,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",l.code,": ",l.message,". What is shown may be out of date."]})}),u&&n.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Webhook secret",children:[n.jsx("p",{className:"caps text-small font-semibold text-warning-text",children:"The signing secret, shown this once"}),n.jsx("p",{className:"mt-2 break-all font-mono text-body",children:u}),n.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:["Keep it where the receiver checks ",n.jsx("span",{className:"font-mono",children:"webhook-signature"}),". This server never shows it again."]}),n.jsx(V,{type:"button",variant:"outline",className:"mt-3",onClick:()=>f(null),children:"Done"})]}),n.jsxs("section",{className:"border bg-card p-4","aria-label":"Webhook URL",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ml,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.configured?n.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:t.url}):n.jsx("span",{className:"text-body text-muted-foreground",children:"No webhook is set."}),t.configured&&(t.disabled?n.jsx(Ce,{tone:"error",children:"off"}):t.signing==="sealed"?n.jsx(Ce,{tone:"success",children:"on"}):n.jsx(Ce,{tone:"warning",children:"not signing"}))]}),t.configured&&t.disabled&&n.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",t.disabled.reason,", ",ft(t.disabled.at),". Nothing is sent until the URL is saved again: enter it below."]}),t.configured&&t.signing!=="sealed"&&n.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[n.jsx(ar,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),wI[t.signing]]}),n.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:C,children:[n.jsx(Ue,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:t.configured?"The whole URL, to change it or save it again":"https://...",value:N,onChange:T=>R(T.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),n.jsx(V,{type:"submit",variant:"solid",disabled:w||!N.trim(),children:"Save"}),t.configured&&n.jsx(V,{type:"button",variant:"outline",disabled:w,onClick:()=>E("The test was not sent",async()=>h(await e.testWebhook())),children:"Send a test"}),t.configured&&!m&&n.jsx(V,{type:"button",variant:"outline",disabled:w,onClick:()=>b(!0),children:"Remove"})]}),m&&n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[n.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),n.jsx(V,{type:"button",variant:"destructive",disabled:w,onClick:()=>{b(!1),R(""),h(null),E("The webhook was not removed",async()=>{await e.removeWebhook(),s({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),f(null)})},children:"Remove the webhook"}),n.jsx(V,{type:"button",variant:"ghost",onClick:()=>b(!1),children:"Cancel"})]}),v&&n.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",s0(v)]})]}),n.jsxs("section",{"aria-label":"Deliveries",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"caps text-small font-semibold text-muted-foreground",children:"Last deliveries"}),n.jsx(V,{type:"button",variant:"ghost",onClick:S,children:"Refresh"})]}),r.length===0?n.jsx("p",{className:"mt-2 border p-4 text-body text-muted-foreground",children:"No message has been tried yet."}):n.jsx("ul",{className:"mt-2 border",children:r.map((T,A)=>n.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 text-body last:border-b-0",children:[n.jsx("span",{className:"w-[170px] shrink-0 text-muted-foreground",children:ft(T.at)}),n.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:T.type}),n.jsx("span",{className:T.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:s0(T)}),T.redelivery&&n.jsx(Ce,{children:"redelivery"}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:T.webhook_id,children:[T.webhook_id.slice(0,12),"…"]}),n.jsx(V,{type:"button",variant:"outline",size:"sm",disabled:w,onClick:()=>E("The message was not sent again",()=>e.redeliverWebhook(T.webhook_id)),children:"Redeliver"})]},`${T.webhook_id}:${T.at}:${A}`))})]})]})}):l?n.jsx(On,{tone:"error",className:"m-8",actions:n.jsx(V,{type:"button",size:"xs",onClick:S,children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",l.code,": ",l.message]})}):n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."})}function s0(e){const t=e.error??`${e.status_code}`,s=e.status_code!==null?`, ${e.latency_ms} ms`:"";return`${t}${s}${e.retry_at?`; tried again ${ft(e.retry_at)}`:""}`}const jI={none:{label:"None",gives:"The run's folder only."},sandbox:{label:"Sandbox",gives:"A Linux container."},desktop:{label:"Desktop",gives:"A screen, with a pointer and keys."},phone:{label:"Phone",gives:"A phone's screen and its apps."},browser:{label:"Browser",gives:"A browser the agent drives."}},Nh=e=>jI[e]??{label:e,gives:""},NI=e=>e instanceof Ee?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},Sh=e=>e.slice(e.lastIndexOf(":")+1),SI=2e3;function _I({v2:e,writable:t,whyNot:s="sign_in"}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,f]=x.useState(null),[p,g]=x.useState(null),[v,h]=x.useState({}),[m,b]=x.useState(new Set),w=x.useRef(0),j=x.useCallback(()=>{const E=++w.current;c(null),e.computers().then(C=>{E===w.current&&a(C)},C=>{E===w.current&&c(NI(C))})},[e]);if(x.useEffect(j,[j]),!r)return l?n.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",l.code,": ",l.message]}),n.jsx(V,{size:"sm",onClick:j,className:"mt-3",children:"Try again"})]}):n.jsx("div",{className:"p-5 md:p-8",children:n.jsx(Os,{label:"Loading the computers",rows:3})});const N=new Set(r.paired.map(E=>E.id)),R=E=>r.kinds.filter(C=>C.providers.some(T=>T.id===E)).map(C=>C.kind),$=async(E,C,T)=>{g(null);try{await e.saveComputerKeys(C.id,T)}catch(A){return A instanceof Ee&&A.status===422?A:(g({at:E,words:Jt(A)}),null)}return f(null),j(),null},S=async E=>{b(T=>new Set(T).add(E.id));let C;try{const T=await e.testComputer(E.id);C=T.ok?{ok:!0,words:T.detail,at:new Date().toISOString()}:{ok:!1,words:T.why,at:new Date().toISOString()}}catch(T){C={ok:!1,words:Jt(T),at:new Date().toISOString()}}h(T=>({...T,[E.id]:C})),b(T=>{const A=new Set(T);return A.delete(E.id),A})};return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Computers"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The computers an agent can be given, and who provides them. An agent can have a kind once one of its providers is ready. Keys are kept sealed on this server and never shown again."})]}),n.jsx(CI,{v2:e,paired:r.paired,reload:j}),!t&&n.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:pc[s]}),r.kinds.map(E=>n.jsx(TI,{kind:E,providers:E.providers.filter(C=>!N.has(C.id)),own:E.providers.filter(C=>N.has(C.id)).map(C=>C.name),children:E.providers.filter(C=>!N.has(C.id)).map(C=>{const T=`${E.kind}/${C.id}`;return n.jsx(RI,{v2:e,kind:E.kind,provider:C,writable:t,serves:R(C.id),tested:v[C.id],testing:m.has(C.id),open:(u==null?void 0:u.at)===T?u.mode:null,problem:(p==null?void 0:p.at)===T?p.words:null,onOpen:A=>{f(A?{at:T,mode:A}:null),g(null)},onSave:A=>$(T,C,A),onRemove:async A=>{var L;const F=await $(T,C,{[A]:null});F&&g({at:T,words:((L=F.fields)==null?void 0:L.map(z=>z.message).join(" "))||F.message})},onTest:()=>void S(C)},C.id)})},E.kind))]})})}function $I(e){const t=e.device?`${e.device.maker} ${e.device.model}`:null,s=e.os_version?`${e.os} ${e.os_version}`:e.os,r=e.screen?`screen ${e.screen.width}×${e.screen.height} at ${e.screen.scale}x`:null;return[e.serves.map(a=>Nh(a).label).join(", ")||Nh(e.kind).label,t,s,e.arch,r].filter(Boolean).join(" · ")}function EI(e){const t=Object.entries(e.features??{}).flatMap(([s,r])=>r!==!0&&typeof(r==null?void 0:r.off)=="string"?[`${s} off: ${r.off}`]:[]);return[`Offers ${e.groups.join(", ")}`,...t].join(" · ")}function CI({v2:e,paired:t,reload:s}){const[r,a]=x.useState(null),[l,c]=x.useState(!1),[u,f]=x.useState(()=>Date.now()),[p,g]=x.useState(null),[v,h]=x.useState(null),[m,b]=x.useState(null),w=r?Date.parse(r.code.expires_at)-u:0,j=r!==null&&w>0;x.useEffect(()=>{if(!j)return;const S=setInterval(()=>f(Date.now()),1e3),E=setInterval(s,SI);return()=>{clearInterval(S),clearInterval(E)}},[j,s]),x.useEffect(()=>{if(!r)return;const S=t.find(E=>E.pairing===r.code.id);S&&(g(S.name),a(null))},[t,r]);const N=async()=>{c(!0),b(null),g(null);try{const S=await e.createPairing();f(Date.now()),a({code:S})}catch(S){b(Jt(S))}c(!1)},R=async S=>{b(null);try{await e.removeComputer(S)}catch(E){b(Jt(E));return}h(null),s()},$=`${Math.floor(Math.max(0,w)/6e4)}:${String(Math.floor(Math.max(0,w)%6e4/1e3)).padStart(2,"0")}`;return n.jsxs("section",{"aria-label":"Your computers",children:[n.jsxs("h2",{className:"mb-2 flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"caps text-small font-semibold",children:"Your computers"}),n.jsx("span",{className:"text-small text-muted-foreground",children:"A computer or phone of your own, attached by the driver you run on it. An agent can be given it as its computer."})]}),r?n.jsxs("div",{"data-pairing":!0,className:"mb-3 space-y-3 border bg-card p-4",children:[n.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Server address"}),n.jsx("p",{"data-address":!0,className:"mt-1 font-mono text-prose font-semibold",children:window.location.origin})]}),n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Pairing code"}),n.jsx("p",{"data-code":!0,className:"mt-1 font-mono text-2xl font-semibold",children:r.code.code})]})]}),j?n.jsxs("p",{className:"text-body",children:["Type both into the driver on the computer. The code pairs one computer, once, in the next ",n.jsx("span",{"data-countdown":!0,className:"font-mono",children:$}),"."]}):n.jsx("p",{role:"status",className:"text-body text-muted-foreground",children:"This code has expired. Make a new one."}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(V,{size:"sm",onClick:()=>void N(),disabled:l,children:l?"Making…":"New code"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:()=>a(null),children:"Done"})]})]}):n.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-3",children:[n.jsx(V,{size:"sm",variant:"primary",onClick:()=>void N(),disabled:l,children:l?"Making…":"Pair a computer"}),p&&n.jsxs("p",{role:"status",className:"text-body text-success-text",children:["Paired ",p,"."]})]}),m&&n.jsx("p",{role:"alert",className:"mb-3 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:m}),t.length?n.jsx("ul",{className:"border",children:t.map(S=>n.jsxs("li",{"data-paired":S.id,className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[S.serves.includes("phone")?n.jsx(U0,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):n.jsx(xi,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:S.name}),S.online?n.jsx(Ce,{tone:"success",children:"Online"}):n.jsx(Ce,{tone:"muted",children:"Offline"}),S.held_by_run&&n.jsxs(Ce,{tone:"active",children:["In use by run ",ua(S.held_by_run)]}),S.unserved&&n.jsx(Ce,{tone:"warning",children:"No agent can use it"})]}),S.unserved&&n.jsx("p",{"data-unserved":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:S.unserved}),S.held_by_run&&S.held_until&&n.jsxs("p",{"data-held-until":!0,className:"mt-1.5 text-small text-muted-foreground",children:["The run's hold ends by ",ft(S.held_until),", released or not."]}),!S.online&&n.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:"Open its driver on that computer: it dials this server."}),n.jsx("p",{"data-machine":!0,className:"mt-2 text-small text-muted-foreground",children:$I(S)}),S.groups.length>0&&n.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:EI(S)}),n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${S.driver} · paired ${ft(S.created_at)}${S.seen_at?` · last attached ${ft(S.seen_at)}`:""}`})]}),n.jsx(V,{size:"sm",onClick:()=>{h(S.id),b(null)},disabled:v!==null,children:"Remove"})]}),v===S.id&&n.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",S.name,"? Its driver stops dialing and asks for a new code",S.held_by_run?", and the run using it loses it":"","."]}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>void R(S.id),children:"Remove"}),n.jsx(V,{size:"sm",onClick:()=>h(null),children:"Cancel"})]})]},S.id))}):n.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"None paired yet. Pair a computer, then type the server address and its code into the driver on it."})]})}function TI({kind:e,providers:t,own:s,children:r}){const{label:a,gives:l}=Nh(e.kind);return n.jsxs("section",{"aria-label":a,children:[n.jsxs("h2",{className:"mb-2 flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"caps text-small font-semibold",children:a}),l&&n.jsx("span",{className:"text-small text-muted-foreground",children:l}),!e.offered&&n.jsx(Ce,{tone:"muted",children:"Not offered here"})]}),!e.offered&&e.why&&n.jsx("p",{className:"mb-2 font-mono text-small text-muted-foreground",children:e.why}),s.length>0&&n.jsxs("p",{className:"mb-2 text-small text-muted-foreground",children:["Also served by your computers: ",s.join(", "),"."]}),t.length?n.jsx("ul",{className:"border",children:r}):n.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:e.kind==="none"?"Nothing to set up.":s.length?"No other provider serves it on this server.":"No provider serves it on this server."})]})}function RI({v2:e,kind:t,provider:s,writable:r,serves:a,tested:l,testing:c,open:u,problem:f,onOpen:p,onSave:g,onRemove:v,onTest:h}){const m=u&&"paste"in u?u.paste:null,b=u&&"remove"in u?u.remove:null;return n.jsxs("li",{className:"border-b p-4 last:border-b-0",children:[n.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[n.jsx(xi,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:s.name}),s.ready?n.jsx(Ce,{tone:"success",children:"Ready"}):n.jsx(Ce,{children:"Not ready"}),s.metered&&n.jsx("span",{"data-metered":!0,className:"text-small text-muted-foreground",children:"Metered"})]}),!s.ready&&s.why&&n.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:s.why}),s.metered&&Xg.has(t)&&n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Kg}),s.secrets.length>0&&n.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(w=>{var R;const j=Sh(w.name),N=((R=s.picked)==null?void 0:R.includes(w.name))??!1;return n.jsx(bf,{field:w,required:s.required.includes(w.name),writable:r&&!u,...N?{}:{onPaste:()=>p({paste:j})},onRemove:()=>p({remove:j})},w.name)})}),s.picked&&s.picked.length>0&&s.required.every(w=>s.secrets.some(j=>j.name===w&&j.set))&&n.jsx(AI,{v2:e,provider:s,writable:r&&!u,onSave:g}),l&&n.jsx("p",{"data-test":!0,className:`mt-2 text-small ${l.ok?"text-success-text":"text-destructive-text"}`,children:`${l.ok?"Passed":"Failed"} · ${rf(l.at)} · ${l.words}`}),n.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",a.join(", ")]})]}),n.jsx("div",{className:"flex gap-2",children:n.jsx(V,{size:"sm",onClick:h,disabled:c,children:c?"Testing…":"Test connection"})})]}),r&&m&&n.jsx(OI,{provider:s.name,name:m,set:s.secrets.some(w=>Sh(w.name)===m&&w.set),onSave:g,onCancel:()=>p(null)}),r&&b&&n.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",b," saved on this server?"]}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>void v(b),children:"Remove"}),n.jsx(V,{size:"sm",onClick:()=>p(null),children:"Cancel"})]}),f&&n.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:f})]})}function AI({v2:e,provider:t,writable:s,onSave:r}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState(null),g=t.secrets.map(h=>`${h.name}:${h.set}:${h.changed_at??""}`).join(" ");x.useEffect(()=>{let h=!0;return l(null),u(null),e.computerChoices(t.id).then(m=>{h&&l(m)},m=>{h&&u(Jt(m))}),()=>{h=!1}},[e,t.id,g]);const v=async(h,m)=>{var w;p({key:h.key,value:m}),u(null);const b=await r({[h.key]:m});p(null),b&&u(((w=b.fields)==null?void 0:w.map(j=>j.message).join(" "))||b.message)};return c&&!a?n.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${c}`}):a?n.jsxs("div",{className:"mt-3 space-y-3",children:[a.choices.map(h=>{const m=t.secrets.find(w=>Sh(w.name)===h.key),b=(m==null?void 0:m.source)==="env";return n.jsxs("div",{"data-choices":h.key,className:"border bg-card p-3",children:[n.jsx("p",{className:"caps mb-2 text-small font-semibold",children:h.key}),"why"in h?n.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:h.why}):n.jsxs(n.Fragment,{children:[n.jsx(Lt,{label:`${t.name} ${h.key}`,value:(f==null?void 0:f.key)===h.key?f.value:h.saved??"",disabled:!s||b||f!==null,options:h.options.map(w=>({value:w.value,label:w.label})),placeholder:"Pick one",onChange:w=>void v(h,w),className:"w-full max-w-md"}),n.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${m!=null&&m.set&&h.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:b?`Set in the environment where AgentRun starts, and that one is used: change ${h.key} there.`:h.saved!==void 0?"Picked and saved on this server.":m!=null&&m.set?`The ${h.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:h.options.length===1?`The only one, ${h.options[0].label}, is used while none is picked.`:`${h.options.length} to pick from. Pick the one this server's computers use.`})]})]},h.key)}),c&&n.jsx("p",{role:"alert",className:"font-mono text-small text-destructive-text",children:c})]}):n.jsx("p",{role:"status",className:"mt-3 text-small text-muted-foreground",children:"Reading the choices…"})}function OI({provider:e,name:t,set:s,onSave:r,onCancel:a}){const l=x.useRef(null),[c,u]=x.useState(!1),[f,p]=x.useState(!1),[g,v]=x.useState(null),h=()=>{var w,j;return((j=(w=l.current)==null?void 0:w.elements.namedItem(t))==null?void 0:j.value)??""},m=()=>{var w;(w=l.current)==null||w.reset(),u(!1)},b=async w=>{var S;w.preventDefault();const j=h();if(!j)return;p(!0),v(null);const N=await r({[t]:j});if(p(!1),!N){m();return}const R=(S=N.fields)==null?void 0:S.find(E=>E.field===t),$=(N.fields??[]).filter(E=>E.field!==t).map(E=>E.message);v(R?{field:R.message,message:$.join(" ")}:{field:null,message:$.join(" ")||N.message})};return n.jsxs("form",{ref:l,autoComplete:"off",onSubmit:w=>void b(w),onInput:()=>u(!!h()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e} ${t}`,children:[n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:t}),s&&n.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"A new value replaces the one saved."}),n.jsx(Ue,{type:"password",name:t,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(g==null?void 0:g.field)&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:g.field})]}),(g==null?void 0:g.message)&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g.message}),n.jsx("p",{className:"text-small text-muted-foreground",children:"Kept sealed on this server. It is never shown again, here or anywhere."}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:!c||f,children:f?"Saving":"Save"}),n.jsx(V,{type:"button",size:"sm",onClick:()=>{m(),a()},children:"Cancel"})]})]})}const MI="Each agent keeps its runs' folders on its own Archil disk, made on its first run in this region. The server never mounts one; computers that support it mount a run's folder.",r0=[{name:"region",label:"Region"},{name:"s3Url",label:"S3 URL",placeholder:"https://"},{name:"image",label:"Image",placeholder:"serve's default, Debian with git 2.47 (recommended)"}],PI=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),kr="ARCHIL_API_KEY",LI=e=>e instanceof Ee?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function II({v2:e,writable:t,whyNot:s="sign_in"}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,f]=x.useState({region:"",s3Url:"",image:""}),[p,g]=x.useState(null),[v,h]=x.useState(null),[m,b]=x.useState(!1),[w,j]=x.useState(null),[N,R]=x.useState(!1),[$,S]=x.useState(!1),[E,C]=x.useState(!1),[T,A]=x.useState(!1),F=x.useRef(null),L=x.useRef(0),z=x.useCallback(I=>{a(I),f(PI(I))},[]),W=x.useCallback(()=>{const I=++L.current;c(null),e.archil().then(Y=>{I===L.current&&z(Y)},Y=>{I===L.current&&c(LI(Y))})},[e,z]);if(x.useEffect(W,[W]),!r)return l?n.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[n.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",l.code,": ",l.message]}),n.jsx(V,{size:"sm",onClick:W,className:"mt-3",children:"Try again"})]}):n.jsx("div",{className:"p-5 md:p-8",children:n.jsx(Os,{label:"Loading Archil's settings",rows:2})});const U=()=>{var I,Y;return((Y=(I=F.current)==null?void 0:I.elements.namedItem(kr))==null?void 0:Y.value)??""},D=async I=>{const Y={region:u.region,s3Url:u.s3Url,...u.image?{image:u.image}:{},...I!==void 0?{keys:{[kr]:I}}:{}};b(!0),g(null),h(null);try{const q=await e.saveArchil(Y);C(!1),A(!1),z(q)}catch(q){if(q instanceof Ee&&q.status===422){const O={},B=[];for(const ee of q.fields??[]){const le=ee.field.startsWith("keys.")?ee.field.slice(5):ee.field;r0.some(ie=>ie.name===le)||le===kr?O[le]=ee.message:B.push(ee.message)}g({fields:O,message:B.length?B.join(" "):Object.keys(O).length?null:q.message})}else h(Jt(q))}finally{b(!1)}},K=I=>{I.preventDefault(),D(E&&U()?U():void 0)},P=async()=>{R(!0);try{const I=await e.testArchil();j(I.ok?{ok:!0,words:I.detail,at:new Date().toISOString()}:{ok:!1,words:I.why,at:new Date().toISOString()})}catch(I){j({ok:!1,words:Jt(I),at:new Date().toISOString()})}finally{R(!1)}},G=async()=>{h(null);try{z(await e.archilOff()),S(!1)}catch(I){h(Jt(I))}};return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1100px] space-y-6 px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),n.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Workspace"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:MI})]}),!t&&n.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:pc[s]}),n.jsxs("section",{"aria-label":"Archil",className:"border p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsx(W_,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),n.jsx("span",{"data-archil-state":!0,children:r.on?n.jsx(Ce,{tone:"success",children:"On"}):n.jsx(Ce,{children:"Off"})}),r.on&&n.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:r.region??""}),n.jsx("span",{className:"flex-1"}),n.jsx(V,{size:"sm",onClick:()=>void P(),disabled:N,children:N?"Testing…":"Test"}),r.on&&n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>S(!0),children:"Turn off"})]}),w&&n.jsx("p",{"data-test":!0,className:`mt-3 text-small ${w.ok?"text-success-text":"text-destructive-text"}`,children:`${w.ok?"Passed":"Failed"} · ${rf(w.at)} · ${w.words}`}),$&&n.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>void G(),children:"Turn off"}),n.jsx(V,{size:"sm",onClick:()=>S(!1),children:"Cancel"})]}),v&&n.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:v}),n.jsxs("form",{ref:F,autoComplete:"off",onSubmit:K,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[r0.map(I=>n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:I.label}),n.jsx(Ue,{name:I.name,value:u[I.name],placeholder:I.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:Y=>{const q=Y.currentTarget.value;f(O=>({...O,[I.name]:q}))}}),(p==null?void 0:p.fields[I.name])&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[I.name]})]},I.name)),n.jsx("ul",{children:n.jsx(bf,{field:r.secret,label:kr,writable:t&&!E&&!T,onPaste:()=>C(!0),onRemove:()=>A(!0)})}),t&&T&&n.jsxs("div",{"data-confirm-key":!0,className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[n.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",kr," saved on this server?"]}),n.jsx(V,{type:"button",size:"sm",variant:"destructive",onClick:()=>void D(null),children:"Remove"}),n.jsx(V,{type:"button",size:"sm",onClick:()=>A(!1),children:"Cancel"})]}),t&&E&&n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:kr}),n.jsx(Ue,{type:"password",name:kr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(p==null?void 0:p.fields[kr])&&n.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:p.fields[kr]})]}),t&&E&&n.jsx(V,{type:"button",size:"sm",onClick:()=>C(!1),children:"Cancel"}),(p==null?void 0:p.message)&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:p.message}),n.jsx(V,{type:"submit",size:"sm",variant:"solid",disabled:m,children:m?"Saving":r.on?"Save":"Turn on"})]})]})]})})}const BN=x.createContext(new Map),zI={schedule:"Schedule",webhook:"Webhook",github:"GitHub"};function GN({run:e}){const t=x.useContext(BN);if(!e.trigger)return null;const{id:s}=e.trigger,r=t.get(s),a=r?`${zI[r.kind]??"Trigger"}: ${r.name}`:`Trigger: ${s}`;return n.jsx("a",{href:`#/triggers/${encodeURIComponent(s)}`,onClick:l=>l.stopPropagation(),className:"inline-flex max-w-full",title:a,children:n.jsxs(Ce,{className:"max-w-full",children:[n.jsx(Pd,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:a})]})})}const Iu=(e,t,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=t&&r<=s?r:null};function DI(e){const t=e.trim().split(/\s+/);if(t.length!==5)return null;const[s,r,a,l,c]=t,u=Iu(s,0,59);if(u===null||l!=="*")return null;if(r==="*")return a==="*"&&c==="*"?{kind:"hourly",minute:u}:null;const f=Iu(r,0,23);if(f===null)return null;const p={hour:f,minute:u};if(a==="*"&&c==="*")return{kind:"daily",at:p};if(a==="*"&&c==="1-5")return{kind:"weekdays",at:p};if(a==="*"){const g=Iu(c,0,6);return g===null?null:{kind:"weekly",day:g,at:p}}if(c==="*"){const g=Iu(a,1,31);return g===null?null:{kind:"monthly",date:g,at:p}}return null}function FI(e){if(e.kind==="hourly")return`${e.minute} * * * *`;const t=`${e.at.minute} ${e.at.hour}`;return e.kind==="daily"?`${t} * * *`:e.kind==="weekdays"?`${t} * * 1-5`:e.kind==="weekly"?`${t} * * ${e.day}`:`${t} ${e.date} * *`}function UI(e,t){const s=t&&"at"in t?t.at:{hour:9,minute:(t==null?void 0:t.kind)==="hourly"?t.minute:0};return e==="hourly"?{kind:e,minute:s.minute}:e==="weekly"?{kind:e,day:(t==null?void 0:t.kind)==="weekly"?t.day:1,at:s}:e==="monthly"?{kind:e,date:(t==null?void 0:t.kind)==="monthly"?t.date:1,at:s}:{kind:e,at:s}}const o0=e=>String(e).padStart(2,"0"),WI=e=>`${o0(e.hour)}:${o0(e.minute)}`;function HI(e){const t=/^(\d{2}):(\d{2})/.exec(e);if(!t)return null;const s=Number(t[1]),r=Number(t[2]);return s<=23&&r<=59?{hour:s,minute:r}:null}var Ip={exports:{}},a0;function BI(){return a0||(a0=1,(function(e,t){(function(r,a){e.exports=a()})(globalThis,()=>(()=>{var s={6949(c,u,f){Object.defineProperty(u,"__esModule",{value:!0}),u.CronParser=void 0;var p=f(9515),g=(function(){function v(h,m,b){m===void 0&&(m=!0),b===void 0&&(b=!1),this.expression=h,this.dayOfWeekStartIndexZero=m,this.monthStartIndexZero=b}return v.prototype.parse=function(){var h,m,b=(h=this.expression)!==null&&h!==void 0?h:"";if(b==="@reboot")return m=["@reboot","","","","","",""],m;if(b.startsWith("@")){var w=this.parseSpecial(this.expression);m=this.extractParts(w)}else m=this.extractParts(this.expression);return this.normalize(m),this.validate(m),m},v.prototype.parseSpecial=function(h){var m={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},b=m[h];if(!b)throw new Error("Unknown special expression.");return b},v.prototype.extractParts=function(h){if(!this.expression)throw new Error("cron expression is empty");for(var m=h.trim().split(/[ ]+/),b=0;b<m.length;b++)if(m[b].includes(",")){var w=m[b].split(",").map(function(N){return N.trim()}).filter(function(N){return N!==""}).map(function(N){return isNaN(Number(N))?N:Number(N)}).filter(function(N){return N!==null&&N!==""});w.length===0&&w.push("*"),w.sort(function(N,R){return N!==null&&R!==null?N-R:0}),m[b]=w.map(function(N){return N!==null?N.toString():""}).join(",")}if(m.length<5)throw new Error("Expression has only ".concat(m.length," part").concat(m.length==1?"":"s",". At least 5 parts are required."));if(m.length==5)m.unshift(""),m.push("");else if(m.length==6){var j=/\d{4}$/.test(m[5])||m[4]=="?"||m[2]=="?";j?m.unshift(""):m.push("")}else if(m.length>7)throw new Error("Expression has ".concat(m.length," parts; too many!"));return m},v.prototype.normalize=function(h){var m=this;h[3]=h[3].replace("?","*"),h[5]=h[5].replace("?","*"),h[2]=h[2].replace("?","*"),h[0].indexOf("0/")==0&&(h[0]=h[0].replace("0/","*/")),h[1].indexOf("0/")==0&&(h[1]=h[1].replace("0/","*/")),h[2].indexOf("0/")==0&&(h[2]=h[2].replace("0/","*/")),h[3].indexOf("1/")==0&&(h[3]=h[3].replace("1/","*/")),!this.monthStartIndexZero&&h[4].indexOf("1/")==0&&(h[4]=h[4].replace("1/","*/")),h[6].indexOf("1/")==0&&(h[6]=h[6].replace("1/","*/")),h[5]=h[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function(C){var T=C.replace(/\D/,""),A=T;return m.dayOfWeekStartIndexZero?T=="7"&&(A="0"):A=(parseInt(T)-1).toString(),C.replace(T,A)}),h[5]=="L"&&(h[5]="6"),h[3]=="?"&&(h[3]="*");var b=/^\d{1,2}W[+-]\d{1,2}$/;if(h[3].indexOf("W")>-1&&(h[3].indexOf(",")>-1||/[-+]/.test(h[3]))&&!b.test(h[3]))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var w={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in w)h[5]=h[5].replace(new RegExp(j,"gi"),w[j].toString());h[4]=h[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function(C){var T=C.replace(/\D/,""),A=T;return m.monthStartIndexZero&&(A=(parseInt(T)+1).toString()),C.replace(T,A)});var N={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var R in N)h[4]=h[4].replace(new RegExp(R,"gi"),N[R].toString());h[0]=="0"&&(h[0]=""),!/\*|\-|\,|\//.test(h[2])&&(/\*|\//.test(h[1])||/\*|\//.test(h[0]))&&(h[2]+="-".concat(h[2]));for(var $=0;$<h.length;$++)if(h[$].indexOf(",")!=-1&&(h[$]=h[$].split(",").filter(function(C){return C!==""}).join(",")||"*"),h[$]=="*/1"&&(h[$]="*"),h[$].indexOf("/")>-1&&!/^\*|\-|\,/.test(h[$])){var S=null;switch($){case 4:S="12";break;case 5:S="6";break;case 6:S="9999";break;default:S=null;break}if(S!==null){var E=h[$].split("/");h[$]="".concat(E[0],"-").concat(S,"/").concat(E[1])}}},v.prototype.validate=function(h){var m="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(h[0],m),this.validateOnlyExpectedCharactersFound(h[1],m),this.validateOnlyExpectedCharactersFound(h[2],m),this.validateOnlyExpectedCharactersFound(h[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(h[4],m),this.validateOnlyExpectedCharactersFound(h[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(h[6],m),this.validateAnyRanges(h)},v.prototype.validateAnyRanges=function(h){h.forEach(function(m){return p.default.stepRange(m)}),p.default.secondRange(h[0]),p.default.minuteRange(h[1]),p.default.hourRange(h[2]),p.default.dayOfMonthRange(h[3]),p.default.monthRange(h[4],this.monthStartIndexZero),p.default.dayOfWeekRange(h[5],this.dayOfWeekStartIndexZero)},v.prototype.validateOnlyExpectedCharactersFound=function(h,m){var b=h.match(new RegExp("[^".concat(m,"]+"),"gi"));if(b&&b.length)throw new Error("Expression contains invalid values: '".concat(b.toString(),"'"))},v})();u.CronParser=g},8333(c,u,f){Object.defineProperty(u,"__esModule",{value:!0}),u.ExpressionDescriptor=void 0;var p=f(1823),g=f(6949),v=(function(){function h(m,b){if(this.expression=m,this.options=b,this.expressionParts=new Array(5),!this.options.locale&&h.defaultLocale&&(this.options.locale=h.defaultLocale),!h.locales[this.options.locale]){var w=Object.keys(h.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(w,"'.")),this.options.locale=w}this.i18n=h.locales[this.options.locale],b.use24HourTimeFormat===void 0&&(b.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return h.toString=function(m,b){var w=b===void 0?{}:b,j=w.throwExceptionOnParseError,N=j===void 0?!0:j,R=w.verbose,$=R===void 0?!1:R,S=w.dayOfWeekStartIndexZero,E=S===void 0?!0:S,C=w.monthStartIndexZero,T=C===void 0?!1:C,A=w.use24HourTimeFormat,F=w.trimHoursLeadingZero,L=F===void 0?!1:F,z=w.locale,W=z===void 0?null:z,U=w.logicalAndDayFields,D=U===void 0?!1:U,K={throwExceptionOnParseError:N,verbose:$,dayOfWeekStartIndexZero:E,monthStartIndexZero:T,use24HourTimeFormat:A,trimHoursLeadingZero:L,locale:W,logicalAndDayFields:D};K.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var P=new h(m,K);return P.getFullDescription()},h.initialize=function(m,b){b===void 0&&(b="en"),h.specialCharacters=["/","-",",","*"],h.defaultLocale=b,m.load(h.locales)},h.prototype.getFullDescription=function(){var m,b,w="";try{var j=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((b=(m=this.i18n).atReboot)===null||b===void 0?void 0:b.call(m))||"Run once, at startup";var N=this.getTimeOfDayDescription(),R=this.getDayOfMonthDescription(),$=this.getMonthDescription(),S=this.getDayOfWeekDescription(),E=this.getYearDescription();w+=N+R+S+$+E,w=this.transformVerbosity(w,!!this.options.verbose),w=w.charAt(0).toLocaleUpperCase()+w.substr(1)}catch(C){if(!this.options.throwExceptionOnParseError)w=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(C)}return w},h.prototype.getTimeOfDayDescription=function(){var m=this.expressionParts[0],b=this.expressionParts[1],w=this.expressionParts[2],j="";if(!p.StringUtilities.containsAny(b,h.specialCharacters)&&!p.StringUtilities.containsAny(w,h.specialCharacters)&&!p.StringUtilities.containsAny(m,h.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(w,b,m);else if(!m&&b.indexOf("-")>-1&&!(b.indexOf(",")>-1)&&!(b.indexOf("/")>-1)&&!p.StringUtilities.containsAny(w,h.specialCharacters)){var N=b.split("-");j+=p.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(w,N[0],""),this.formatTime(w,N[1],""))}else if(!m&&w.indexOf(",")>-1&&w.indexOf("-")==-1&&w.indexOf("/")==-1&&!p.StringUtilities.containsAny(b,h.specialCharacters)){var R=w.split(",");j+=this.i18n.at();for(var $=0;$<R.length;$++)j&&(j+=" "),j+=this.formatTime(R[$],b,""),$<R.length-2&&(j+=","),$==R.length-2&&(j+=this.i18n.spaceAnd())}else{var S=this.getSecondsDescription(),E=this.getMinutesDescription(),C=this.getHoursDescription();if(j+=S,j&&E&&(j+=", "),j+=E,E===C)return j;j&&C&&(j+=", "),j+=C}return j},h.prototype.getSecondsDescription=function(){var m=this,b=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(w){return w},function(w){return p.StringUtilities.format(m.i18n.everyX0Seconds(w),w)},function(w){return m.i18n.secondsX0ThroughX1PastTheMinute()},function(w){return w=="0"?"":parseInt(w)<20?m.i18n.atX0SecondsPastTheMinute(w):m.i18n.atX0SecondsPastTheMinuteGt20()||m.i18n.atX0SecondsPastTheMinute(w)},{min:0,max:59});return b},h.prototype.getMinutesDescription=function(){var m=this,b=this.expressionParts[0],w=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(N){return N},function(N){return p.StringUtilities.format(m.i18n.everyX0Minutes(N),N)},function(N){return m.i18n.minutesX0ThroughX1PastTheHour()},function(N){var R,$;try{return N=="0"&&w.indexOf("/")==-1&&b==""?m.i18n.everyHour():N=="0"?(($=(R=m.i18n).onTheHour)===null||$===void 0?void 0:$.call(R))||m.i18n.atX0MinutesPastTheHour(N):parseInt(N)<20?m.i18n.atX0MinutesPastTheHour(N):m.i18n.atX0MinutesPastTheHourGt20()||m.i18n.atX0MinutesPastTheHour(N)}catch{return m.i18n.atX0MinutesPastTheHour(N)}},{min:0,max:59});return j},h.prototype.getHoursDescription=function(){var m=this,b=this.expressionParts[2],w=0,j=[];b.split("/")[0].split(",").forEach(function($){var S=$.split("-");S.length===2&&j.push({value:S[1],index:w+1}),w+=S.length});var N=0,R=this.getSegmentDescription(b,this.i18n.everyHour(),function($){var S=j.find(function(C){return C.value===$&&C.index===N}),E=S&&m.expressionParts[1]!=="0";return N++,E?m.formatTime($,"59",""):m.formatTime($,"0","")},function($){return p.StringUtilities.format(m.i18n.everyX0Hours($),$)},function($){return m.i18n.betweenX0AndX1()},function($){return m.i18n.atX0()},{min:0,max:23});return R},h.prototype.getDayOfWeekDescription=function(){var m=this,b=this.i18n.daysOfTheWeek(),w=null;return this.expressionParts[5]=="*"?w="":w=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,N){var R=j;j.indexOf("#")>-1?R=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&(R=R.replace("L",""));var $=parseInt(R),S=m.i18n.daysOfTheWeekInCase?m.i18n.daysOfTheWeekInCase(N)[$]:b[$];if(j.indexOf("#")>-1){var E=null,C=j.substring(j.indexOf("#")+1),T=j.substring(0,j.indexOf("#"));switch(C){case"1":E=m.i18n.first(T);break;case"2":E=m.i18n.second(T);break;case"3":E=m.i18n.third(T);break;case"4":E=m.i18n.fourth(T);break;case"5":E=m.i18n.fifth(T);break}S=E+" "+S}return S},function(j){return parseInt(j)==1?"":p.StringUtilities.format(m.i18n.commaEveryX0DaysOfTheWeek(j),j)},function(j){var N=j.substring(0,j.indexOf("-")),R=m.expressionParts[3]!="*";return R?m.i18n.commaAndX0ThroughX1(N):m.i18n.commaX0ThroughX1(N)},function(j){var N=null;if(j.indexOf("#")>-1){var R=j.substring(j.indexOf("#")+1),$=j.substring(0,j.indexOf("#"));N=m.i18n.commaOnThe(R,$).trim()+m.i18n.spaceX0OfTheMonth()}else if(j.indexOf("L")>-1)N=m.i18n.commaOnTheLastX0OfTheMonth(j.replace("L",""));else{var S=m.expressionParts[3]!="*";S?m.options.logicalAndDayFields?N=m.i18n.commaOnlyOnX0(j):N=m.i18n.commaAndOnX0():N=m.i18n.commaOnlyOnX0(j)}return N}),w},h.prototype.getMonthDescription=function(){var m=this,b=this.i18n.monthsOfTheYear(),w=this.getSegmentDescription(this.expressionParts[4],"",function(j,N){return N&&m.i18n.monthsOfTheYearInCase?m.i18n.monthsOfTheYearInCase(N)[parseInt(j)-1]:b[parseInt(j)-1]},function(j){return parseInt(j)==1?"":p.StringUtilities.format(m.i18n.commaEveryX0Months(j),j)},function(j){return m.i18n.commaMonthX0ThroughMonthX1()||m.i18n.commaX0ThroughX1()},function(j){return m.i18n.commaOnlyInMonthX0?m.i18n.commaOnlyInMonthX0():m.i18n.commaOnlyInX0()});return w},h.prototype.getDayOfMonthDescription=function(){var m=this,b,w,j,N,R=null,$=this.expressionParts[3];switch($){case"L":R=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":R=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var S=$.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(S){var E=parseInt(S[1]||S[2]),C=E==1?this.i18n.firstWeekday():p.StringUtilities.format(this.i18n.weekdayNearestDayX0(),E.toString()),T=S[4];T?S[3]=="-"?R=p.StringUtilities.format(((w=(b=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||w===void 0?void 0:w.call(b,T))||", %s days before the %s of the month",T,C):R=p.StringUtilities.format(((N=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||N===void 0?void 0:N.call(j,T))||", %s days after the %s of the month",T,C):R=p.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),C);break}else{var A=$.match(/L-(\d{1,2})/);if(A){var F=A[1];R=p.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(F),F);break}else{if($=="*"&&this.expressionParts[5]!="*")return"";R=this.getSegmentDescription($,this.i18n.commaEveryDay(),function(L){return L=="L"?m.i18n.lastDay():m.i18n.dayX0?p.StringUtilities.format(m.i18n.dayX0(),L):L},function(L){return L=="1"?m.i18n.commaEveryDay():m.i18n.commaEveryX0Days(L)},function(L){return m.i18n.commaBetweenDayX0AndX1OfTheMonth(L)},function(L){return m.i18n.commaOnDayX0OfTheMonth(L)})}break}}return R},h.prototype.getYearDescription=function(){var m=this,b=this.getSegmentDescription(this.expressionParts[6],"",function(w){return/^\d+$/.test(w)?new Date(parseInt(w),1).getFullYear().toString():w},function(w){return p.StringUtilities.format(m.i18n.commaEveryX0Years(w),w)},function(w){return m.i18n.commaYearX0ThroughYearX1()||m.i18n.commaX0ThroughX1()},function(w){return m.i18n.commaOnlyInYearX0?m.i18n.commaOnlyInYearX0():m.i18n.commaOnlyInX0()});return b},h.prototype.getSegmentDescription=function(m,b,w,j,N,R,$){var S=null,E=m.indexOf("/")>-1,C=m.indexOf("-")>-1,T=m.indexOf(",")>-1;if(!m)S="";else if(m==="*")S=b;else if(!E&&!C&&!T)S=p.StringUtilities.format(R(m),w(m));else if(T){for(var A=m.split(","),F="",L=this.i18n.spaceAnd(),z=0;z<A.length;z++)if(z>0&&A.length>2&&(F+=",",z<A.length-1&&(F+=" ")),z>0&&A.length>1&&(z==A.length-1||A.length==2)&&(F+=L==","&&A.length>2?" ":"".concat(L," ")),A[z].indexOf("/")>-1||A[z].indexOf("-")>-1){var W=A[z].indexOf("-")>-1&&A[z].indexOf("/")==-1,U=this.getSegmentDescription(A[z],b,w,j,W?this.i18n.commaX0ThroughX1:N,R);W?U=U.replace(", ",""):z>0&&U.startsWith(", ")&&(U=U.substring(2)),F+=U}else if(!E)F+=w(A[z]);else{var D=this.getSegmentDescription(A[z],b,w,j,N,R);z>0&&D&&D.startsWith(", ")&&(D=D.substring(2)),F+=D}E?S=F:S=p.StringUtilities.format(R(m),F)}else if(E){var A=m.split("/");if(S=p.StringUtilities.format(j(A[1]),A[1]),A[0].indexOf("-")>-1){var K=this.generateRangeSegmentDescription(A[0],N,w);K.indexOf(", ")!=0&&(S+=", "),S+=K}else if(A[0].indexOf("*")==-1){var P=p.StringUtilities.format(R(A[0]),w(A[0]));P=P.replace(", ",""),S+=p.StringUtilities.format(this.i18n.commaStartingX0(),P)}S+=this.getWrappingIncrementDescription(m,$,b,w,j,N,R)}else C&&(S=this.generateRangeSegmentDescription(m,N,w));return S},h.prototype.getWrappingIncrementDescription=function(m,b,w,j,N,R,$){if(!this.options.verbose||!b)return"";var S=m.split("/"),E=S[0],C=S[1],T=parseInt(C),A=b.max-b.min+1,F=E==="*",L=Number.isInteger(T)&&T>1,z=L&&A%T===0;if(!F||!L||z)return"";for(var W=[],U=b.min;U<=b.max;U+=T)W.push(U);if(W.length<2)return"";var D=this.getSegmentDescription(W.join(","),w,j,N,R,$);return D?", ".concat(D):""},h.prototype.generateRangeSegmentDescription=function(m,b,w){var j="",N=m.split("-"),R=w(N[0],1),$=w(N[1],2),S=b(m);return j+=p.StringUtilities.format(S,R,$),j},h.prototype.formatTime=function(m,b,w){var j=0,N=0,R=parseInt(m)+j,$=parseInt(b)+N;$>=60?($-=60,R+=1):$<0&&($+=60,R-=1),R>=24?R=R-24:R<0&&(R=24+R);var S="",E=!1;this.options.use24HourTimeFormat||(E=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),S=E?"".concat(this.getPeriod(R)," "):" ".concat(this.getPeriod(R)),R>12&&(R-=12),R===0&&(R=12));var C="";w&&(C=":".concat(("00"+w).substring(w.length)));var T=R.toString(),A=("00"+T).substring(T.length),F=$.toString(),L=("00"+F).substring(F.length),z=this.options.trimHoursLeadingZero?T:A;return"".concat(E?S:"").concat(z,":").concat(L).concat(C).concat(E?"":S)},h.prototype.transformVerbosity=function(m,b){if(!b&&(m=m.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),m=m.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),m=m.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),m=m.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var w=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());w<j.length;w++){var N=j[w],R=N[0],$=N[1];m=m.replace(new RegExp(R,"g"),$)}return m},h.prototype.getPeriod=function(m){return m>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},h.locales={},h})();u.ExpressionDescriptor=v},3747(c,u,f){Object.defineProperty(u,"__esModule",{value:!0}),u.enLocaleLoader=void 0;var p=f(9486),g=(function(){function v(){}return v.prototype.load=function(h){h.en=new p.en},v})();u.enLocaleLoader=g},9486(c,u){Object.defineProperty(u,"__esModule",{value:!0}),u.en=void 0;var f=function(g){return Number(g)===1},p=(function(){function g(){}return g.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},g.prototype.atX0MinutesPastTheHourGt20=function(){return null},g.prototype.commaMonthX0ThroughMonthX1=function(){return null},g.prototype.commaYearX0ThroughYearX1=function(){return null},g.prototype.use24HourTimeFormatByDefault=function(){return!1},g.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},g.prototype.everyMinute=function(){return"every minute"},g.prototype.everyHour=function(){return"every hour"},g.prototype.atSpace=function(){return"At "},g.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},g.prototype.at=function(){return"At"},g.prototype.spaceAnd=function(){return" and"},g.prototype.everySecond=function(){return"every second"},g.prototype.everyX0Seconds=function(v){return f(v)?"every %s second":"every %s seconds"},g.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},g.prototype.atX0SecondsPastTheMinute=function(v){return f(v)?"at %s second past the minute":"at %s seconds past the minute"},g.prototype.everyX0Minutes=function(v){return f(v)?"every %s minute":"every %s minutes"},g.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},g.prototype.atX0MinutesPastTheHour=function(v){return f(v)?"at %s minute past the hour":"at %s minutes past the hour"},g.prototype.everyX0Hours=function(v){return f(v)?"every %s hour":"every %s hours"},g.prototype.betweenX0AndX1=function(){return"between %s and %s"},g.prototype.atX0=function(){return"at %s"},g.prototype.commaEveryDay=function(){return", every day"},g.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},g.prototype.commaX0ThroughX1=function(){return", %s through %s"},g.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},g.prototype.first=function(){return"first"},g.prototype.second=function(){return"second"},g.prototype.third=function(){return"third"},g.prototype.fourth=function(){return"fourth"},g.prototype.fifth=function(){return"fifth"},g.prototype.commaOnThe=function(){return", on the "},g.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},g.prototype.lastDay=function(){return"the last day"},g.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},g.prototype.commaOnlyOnX0=function(){return", only on %s"},g.prototype.commaAndOnX0=function(){return", and on %s"},g.prototype.commaEveryX0Months=function(){return", every %s months"},g.prototype.commaOnlyInX0=function(){return", only in %s"},g.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},g.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},g.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(v){return f(v)?", %s day before the last day of the month":", %s days before the last day of the month"},g.prototype.firstWeekday=function(){return"first weekday"},g.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},g.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},g.prototype.commaDaysBeforeTheX0OfTheMonth=function(v){return f(v)?", %s day before the %s of the month":", %s days before the %s of the month"},g.prototype.commaDaysAfterTheX0OfTheMonth=function(v){return f(v)?", %s day after the %s of the month":", %s days after the %s of the month"},g.prototype.commaEveryX0Days=function(){return", every %s days in a month"},g.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},g.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},g.prototype.commaEveryHour=function(){return", every hour"},g.prototype.commaEveryX0Years=function(v){return f(v)?", every %s year":", every %s years"},g.prototype.commaStartingX0=function(){return", starting %s"},g.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},g.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},g.prototype.atReboot=function(){return"Run once, at startup"},g.prototype.onTheHour=function(){return"on the hour"},g})();u.en=p},9515(c,u){Object.defineProperty(u,"__esModule",{value:!0});function f(v,h){if(!v)throw new Error(h)}function p(v){var h=[];if(!isNaN(parseInt(v,10))){h.push(parseInt(v,10));var m=v.match(/^\d+-(-?\d+)/);m&&h.push(parseInt(m[1],10))}return h}var g=(function(){function v(){}return v.stepRange=function(h){for(var m=h.split(","),b=0;b<m.length;b++){var w=m[b].split("/")[1];f(w===void 0||!/^0+$/.test(w),"step value must be greater than 0")}},v.secondRange=function(h){for(var m=h.split(","),b=0;b<m.length;b++)for(var w=0,j=p(m[b]);w<j.length;w++){var N=j[w];f(N>=0&&N<=59,"seconds part must be >= 0 and <= 59")}},v.minuteRange=function(h){for(var m=h.split(","),b=0;b<m.length;b++)for(var w=0,j=p(m[b]);w<j.length;w++){var N=j[w];f(N>=0&&N<=59,"minutes part must be >= 0 and <= 59")}},v.hourRange=function(h){for(var m=h.split(","),b=0;b<m.length;b++)for(var w=0,j=p(m[b]);w<j.length;w++){var N=j[w];f(N>=0&&N<=23,"hours part must be >= 0 and <= 23")}},v.dayOfMonthRange=function(h){for(var m=h.split(","),b=0;b<m.length;b++)for(var w=0,j=p(m[b]);w<j.length;w++){var N=j[w];f(N>=1&&N<=31,"DOM part must be >= 1 and <= 31")}},v.monthRange=function(h,m){for(var b=h.split(","),w=0;w<b.length;w++)for(var j=0,N=p(b[w]);j<N.length;j++){var R=N[j];f(R>=1&&R<=12,m?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},v.dayOfWeekRange=function(h,m){for(var b=h.split(","),w=0;w<b.length;w++){if(b[w].indexOf("#")>-1){var j=b[w].substring(b[w].indexOf("#")+1);f(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var N=0,R=p(b[w]);N<R.length;N++){var $=R[N];f($>=0&&$<=6,m?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},v})();u.default=g},1823(c,u){Object.defineProperty(u,"__esModule",{value:!0}),u.StringUtilities=void 0;var f=(function(){function p(){}return p.format=function(g){for(var v=[],h=1;h<arguments.length;h++)v[h-1]=arguments[h];return g.replace(/%s/g,function(m){return v.shift()})},p.containsAny=function(g,v){return v.some(function(h){return g.indexOf(h)>-1})},p})();u.StringUtilities=f}},r={};function a(c){var u=r[c];if(u!==void 0)return u.exports;var f=r[c]={exports:{}};return s[c](f,f.exports,a),f.exports}var l={};return(()=>{var c=l;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var u=a(8333),f=a(3747);u.ExpressionDescriptor.initialize(new f.enLocaleLoader),c.default=u.ExpressionDescriptor;var p=u.ExpressionDescriptor.toString;c.toString=p})(),l})())})(Ip)),Ip.exports}var GI=BI();const qI=_0(GI),qa=(e,t)=>t&&e===$h(t)?t:rz(e),$i=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",qN=(e="")=>({name:"",kind:"cron",cron:"",timezone:$i(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),VN={seconds:1,minutes:60,hours:3600};function KN(e){const[t,s]=e%3600===0?[e/3600,"hour"]:e%60===0?[e/60,"minute"]:[e,"second"];return t===1?s:`${t} ${s}s`}function XN(e){try{return qI.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Vo=e=>String(e).padStart(2,"0"),$d=(e,t)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:t});function YN(e,t){const s=l=>{var c;return((c=new Intl.DateTimeFormat(l,{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(u=>u.type==="timeZoneName"))==null?void 0:c.value)??t},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const a=s("en-GB");return/^GMT[+-]/.test(a)?r:a}const i0=(e,t)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:t}).replace(",","")}, ${$d(s,t)} ${YN(s,t)}`};function l0(e,{zone:t=$i(),now:s=Date.now()}={}){const r=new Date(e),a=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:t});return`Pick a time in the future: ${a(r)===a(new Date(s))?`${$d(r,t)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:t})}, ${$d(r,t)} ${YN(r,t)}`} has already passed.`}function Ed(e,t){const s={};for(const{type:r,value:a}of new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(e))s[r]=a;return Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),Number(s.hour),Number(s.minute))}function VI(e,t,s,r){const a=new Date(Ed(e,t)),l=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),s,r);let c=l;for(let u=0;u<2;u++)c+=l-Ed(new Date(c),t);return new Date(c)}const KI=e=>{const t=e.trim().split(/\s+/);return t.length!==5||!/^\d{1,2}$/.test(t[0])||!/^\d{1,2}$/.test(t[1])?null:{minute:Number(t[0]),hour:Number(t[1]),days:t.slice(2).some(s=>s!=="*"&&s!=="?")}};function XI(e,t,s,r,a){const l=XN(e),c=t!==s,u=KI(e),f=u&&`At ${Vo(u.hour)}:${Vo(u.minute)}`;if(u&&f&&l.startsWith(f))try{const p=r??VI(a,t,u.hour,u.minute),g=u.days?Math.floor(Ed(p,s)/864e5)-Math.floor(Ed(p,t)/864e5):0,v=g>0?" the next day":g<0?" the day before":"";return`At ${$d(p,s)} your time${v}${c?` (${f.slice(3)} ${t})`:""}${l.slice(f.length)}`}catch{}return`${l}${c?` (${t})`:""}`}function Qg(e,t,{zone:s=$i(),instead:r,now:a=Date.now()}={}){const l=r?` · ${r}`:t?` · next ${i0(t,s)}`:" · no next time";return"cron"in e?`${XI(e.cron,e.timezone,s,t?new Date(t):null,new Date(a))}${l}`:"at"in e?`Once, ${i0(e.at,s)}${!r&&t&&Date.parse(t)===Date.parse(e.at)?"":l}`:`Every ${KN(e.every_s)}${l}`}const Ei=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,YI=e=>`${Ei(e)} a run`,QI=(e,t)=>typeof e=="number"?YI(e):typeof t=="number"&&t>0?`Agent's default (${Ei(t)})`:"Agent's default";function Zg(e,t,s=[]){if(e.source.kind!=="schedule"||!("at"in e.source)||e.next_at!==null)return null;const r=Date.parse(e.source.at);if(r>t)return null;const a=[e.last_firing,...s].find(l=>l&&l.status==="started"&&Date.parse(l.nominal_at)===r);return a?{ran:a}:{passed:e.source.at}}const Jg=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",ZI=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",JI=e=>e.source.kind==="github"&&e.target.kind==="start_run",QN=[{event:"pull_request",action:"opened",label:"A pull request is opened"},{event:"pull_request",action:"synchronize",label:"A pull request gets new commits"},{event:"pull_request",action:"reopened",label:"A pull request is reopened"},{event:"issue_comment",action:"created",label:"Someone comments on an issue or pull request"}],Vl=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,ex="This server's address as this page sees it: behind a proxy, use its public address.",_h={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)",composio:"Composio's (webhook-signature, keyed by its secret as given)"},ez=e=>"in"in e?`${e.pointer} is one of ${e.in.map(t=>JSON.stringify(t)).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"is there":"is absent"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,Cd=(e,t=!0)=>{var s,r;return`${e.event}${(s=e.actions)!=null&&s.length?` (${e.actions.join(", ")})`:""}${t&&((r=e.where)!=null&&r.length)?` where ${e.where.map(ez).join(" and ")}`:""}`},ZN=e=>{var t;return(t=e.accept)!=null&&t.length?`Only signed requests for ${e.accept.map(s=>Cd(s,!1)).join(" or ")}`:"On each signed request"},tz={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event"},JN=e=>`On GitHub ${e.accept.map(t=>Cd(t,!1)).join(" or ")}`;function Td(e,t){const s=e.disabled;return s?s.reason==="source_unreadable"?`Turned off: its source can't be read (${s.detail}).`:s.reason!=="auto_paused"?`Turned off: ${s.detail}`:t?`Turned off after ${t} failures in a row.`:"Turned off after failures in a row.":null}function eS(e){var s;const t=(r,a)=>a?`${r}: ${a}`:r;switch(e.status){case"started":return"Started";case"skipped":return t("Skipped",e.reason);case"missed":return t(`Missed ${e.count??1} ${e.count===1||e.count===void 0?"time":"times"}`,e.reason);case"failed":return t("Failed",((s=e.error)==null?void 0:s.message)??e.reason);case"due":return e.retry_at?`Due: the server was full, tries again at ${rf(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const nz={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},sz=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function rz(e){if(!sz.test(e))return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString().replace(/\.\d{3}Z$/,"Z")}function $h(e){const t=new Date(e);return`${t.getFullYear()}-${Vo(t.getMonth()+1)}-${Vo(t.getDate())}T${Vo(t.getHours())}:${Vo(t.getMinutes())}${t.getSeconds()?`:${Vo(t.getSeconds())}`:""}`}const c0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function oz(e){const t=KN(e);return/^\d/.test(t)?`At least ${t}.`:`At least ${t==="hour"?"an":"a"} ${t}.`}const Eh="A number is needed.",Ch=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function u0(e,t=!1){var l,c;const s={};let r;if(e.kind==="cron")e.cron.trim()||(s["source.cron"]="Pick when it runs."),r={kind:"schedule",cron:e.cron.trim(),timezone:e.timezone.trim()||$i()};else if(e.kind==="at"){const u=qa(e.at,(l=e.read)==null?void 0:l.at);u===null&&(s["source.at"]="A time is needed."),r={kind:"schedule",at:u??""}}else{const u=Ch(e.every);e.every.trim()?u===void 0&&(s["source.every_s"]=Eh):s["source.every_s"]="A number is needed.";const f=e.startAt?qa(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((u??0)*VN[e.everyUnit]),...f?{start_at:f}:{}}}e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const a=Ch(e.maxCost);return e.maxCost.trim()?a===void 0&&(s["target.max_cost_usd"]=Eh):t||(s["target.max_cost_usd"]="A cost cap is needed: every run a schedule starts is capped."),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},enabled:e.enabled,source:r,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...a!==void 0?{max_cost_usd:a}:{}}}}}const az=()=>({name:"",signature:"standard",agentId:"",content:"",maxCost:""});function iz(e,t=!1){return tS(e,{kind:"webhook",signature:e.signature},{},t,"a webhook")}const lz=()=>({name:"",events:["pull_request:opened"],agentId:"",content:"",maxCost:""});function cz(e,t=!1){const s=[];for(const{event:r,action:a}of QN.filter(l=>e.events.includes(`${l.event}:${l.action}`))){const l=s.find(c=>c.event===r);l?l.actions.push(a):s.push({event:r,actions:[a]})}return tS(e,{kind:"github",accept:s},s.length?{}:{"source.accept":"Pick at least one event."},t,"a GitHub trigger")}function tS(e,t,s,r,a){e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const l=Ch(e.maxCost);return e.maxCost.trim()?l===void 0&&(s["target.max_cost_usd"]=Eh):r||(s["target.max_cost_usd"]=`A cost cap is needed: every run ${a} starts is capped.`),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},source:t,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...l!==void 0?{max_cost_usd:l}:{}}}}}function uz(e){const t=e.source,s="cron"in t?t.timezone:$i(),r={...qN(e.target.agent_id),name:e.name,timezone:s,content:typeof e.target.input.content=="string"?e.target.input.content:"",maxCost:typeof e.target.max_cost_usd=="number"?String(e.target.max_cost_usd):"",enabled:e.enabled};if("cron"in t)return{...r,kind:"cron",cron:t.cron};if("at"in t)return{...r,kind:"at",at:$h(t.at),read:{at:t.at}};const a=t.every_s%3600===0?"hours":t.every_s%60===0?"minutes":"seconds";return{...r,kind:"every",every:String(t.every_s/VN[a]),everyUnit:a,startAt:$h(t.start_at),read:{startAt:t.start_at}}}const Th=(e,t)=>{if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const[s,r]=[Object.keys(e),Object.keys(t)];return s.length===r.length&&s.every(a=>Th(e[a],t[a]))};function d0(e,t){const s=t.source&&"every_s"in t.source&&!t.source.start_at&&"every_s"in e.source?{...t.source,start_at:e.source.start_at}:t.source,r=t.target&&{...t.target,input:{...e.target.input,...t.target.input},...e.target.effort!==void 0&&t.target.effort===void 0?{effort:e.target.effort}:{}};return{...t.name!==void 0&&t.name!==e.name?{name:t.name}:{},...s&&!Th(s,e.source)?{source:s}:{},...r&&!Th(r,e.target)?{target:r}:{}}}const dz=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function tx(e){var r;if(!(e instanceof Ee))return{fields:{},rest:[e instanceof Error?e.message:String(e)]};if(e.status!==422||!((r=e.fields)!=null&&r.length))return{fields:{},rest:[`${e.code}: ${e.message}`]};const t={},s=[];for(const a of e.fields){const l=a.field.startsWith("target.input")?"target.input":a.field;dz.includes(l)&&!t[l]?t[l]=a.message:s.push(a.message)}return{fields:t,rest:s}}const fz=[{value:"hourly",label:"Every hour"},{value:"daily",label:"Every day"},{value:"weekdays",label:"Every weekday (Monday to Friday)"},{value:"weekly",label:"Every week"},{value:"monthly",label:"Every month"},{value:"custom",label:"Custom schedule"}],mz=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),pz=Array.from({length:31},(e,t)=>({value:String(t+1),label:String(t+1)})),hz=Array.from({length:60},(e,t)=>({value:String(t),label:`:${String(t).padStart(2,"0")}`}));function nS({value:e,onChange:t,label:s,name:r}){const a=DI(e),[l,c]=x.useState(()=>e.trim()!==""&&!a),u=x.useId(),f=l||e.trim()!==""&&!a,p=h=>t(FI(h)),g=h=>{if(h==="custom"){c(!0);return}c(!1),p(UI(h,a))},v=a&&"at"in a?a.at:null;return n.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(Lt,{label:s,className:"min-w-56 flex-1",value:f?"custom":(a==null?void 0:a.kind)??"",onChange:g,placeholder:"Pick when it runs",options:fz}),!f&&(a==null?void 0:a.kind)==="weekly"&&n.jsx(Lt,{id:`${u}-day`,label:"Day of the week",className:"w-40",value:String(a.day),onChange:h=>p({...a,day:Number(h)}),options:mz}),!f&&(a==null?void 0:a.kind)==="monthly"&&n.jsx(Lt,{id:`${u}-date`,label:"Day of the month",className:"w-24",value:String(a.date),onChange:h=>p({...a,date:Number(h)}),options:pz}),!f&&(a==null?void 0:a.kind)==="hourly"&&n.jsx(Lt,{id:`${u}-minute`,label:"Minutes past the hour",className:"w-24",value:String(a.minute),onChange:h=>p({...a,minute:Number(h)}),options:hz}),!f&&a&&v&&n.jsx(Ue,{id:`${u}-at`,type:"time","aria-label":"At",className:"w-32",value:WI(v),onChange:h=>{const m=HI(h.target.value);m&&p({...a,at:m})}})]}),f&&n.jsxs(n.Fragment,{children:[n.jsx(Ue,{id:`${u}-line`,name:r,"aria-label":"Custom schedule",value:e,onChange:h=>t(h.target.value),placeholder:"30 1 * * *",spellCheck:!1}),n.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?XN(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const f0=Intl.supportedValuesOf,zu=typeof f0=="function"?f0("timeZone"):[],Du=zu.length&&!zu.includes("UTC")?["UTC",...zu]:zu;function sS({value:e,onChange:t,label:s,name:r,id:a,className:l}){if(!Du.length)return n.jsx(Ue,{id:a,name:r,"aria-label":s,className:l,value:e,onChange:u=>t(u.target.value),placeholder:"Europe/Madrid"});const c=e&&!Du.includes(e)?[e,...Du]:Du;return n.jsx(Lt,{id:a,name:r,label:s,className:l,value:e,onChange:t,placeholder:"Pick a time zone",options:c.map(u=>({value:u,label:u.replace(/_/g," ")}))})}const uo=e=>`#/triggers/${encodeURIComponent(e)}`,Rd=e=>ft(e),gz={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function xz({v2:e,view:t,go:s,agentName:r,minEvery:a,failuresToPause:l,refreshMs:c=15e3,now:u=Date.now}){return t.trigger===void 0?n.jsx(vz,{v2:e,go:s,agentName:r,every:c*2,now:u,failuresToPause:l}):t.trigger===null?t.kind==="webhook"?n.jsx($z,{v2:e,go:s}):t.kind==="github"?n.jsx(Ez,{v2:e,go:s}):n.jsx(cS,{v2:e,go:s,minEvery:a,now:u}):t.edit?n.jsx(Sz,{v2:e,go:s,id:t.trigger,minEvery:a,now:u},t.trigger):n.jsx(Nz,{v2:e,go:s,agentName:r,id:t.trigger,every:c,now:u,failuresToPause:l},t.trigger)}function rS(e,t,s){const r=x.useRef(e);r.current=e,x.useEffect(()=>{const a=()=>document.visibilityState!=="hidden",l=setInterval(()=>{a()&&r.current()},t),c=()=>{a()&&r.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(l),document.removeEventListener("visibilitychange",c)}},[t,...s])}const oS=e=>e?"ran"in e?`Done · ran ${Rd(e.ran.nominal_at)}`:`Its time passed · ${Rd(e.passed)}`:null,yz=/has already passed\.?$/;function aS({trigger:e}){return e.disabled?n.jsx(Ce,{tone:"warning",children:"Turned off"}):n.jsx(Ce,{tone:"muted",children:"Paused"})}const bz=e=>e.last_firing?`${eS(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${Rd(e.last_firing.nominal_at)}`:"Not fired yet";function vz({v2:e,go:t,agentName:s,every:r,now:a,failuresToPause:l}){const[c,u]=x.useState(null),[f,p]=x.useState(null),[g,v]=x.useState(0),h=x.useRef(!1),m=x.useRef(!0);x.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const b=()=>{h.current||(h.current=!0,e.listTriggers().then(w=>{m.current&&(u(w.triggers),p(null))},w=>{m.current&&p(fn(w,"the triggers"))}).finally(()=>{h.current=!1}))};return x.useEffect(b,[e,g]),rS(b,r,[e]),n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[n.jsx("h1",{className:"mr-auto font-mono text-2xl font-semibold",children:"Triggers"}),!(c&&!c.length)&&n.jsxs(n.Fragment,{children:[n.jsxs(V,{size:"lg",onClick:()=>t("#/triggers/new-github"),children:[n.jsx(Wh,{"aria-hidden":!0})," New GitHub trigger"]}),n.jsxs(V,{size:"lg",onClick:()=>t("#/triggers/new-webhook"),children:[n.jsx(Ml,{"aria-hidden":!0})," New webhook"]}),n.jsxs(V,{size:"lg",variant:"solid",onClick:()=>t("#/triggers/new"),children:[n.jsx(Ol,{"aria-hidden":!0})," New schedule"]})]})]}),f&&!c?n.jsx(Mn,{problem:f,onRetry:()=>v(w=>w+1),className:""}):c?c.length?n.jsx("ul",{className:"border",children:c.map(w=>n.jsxs("li",{"data-trigger":w.id,className:"grid grid-cols-1 gap-x-6 gap-y-1.5 border-b px-4 py-3 last:border-b-0 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("a",{href:uo(w.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:w.name}),n.jsx(Ce,{children:kz[w.source.kind]}),!w.enabled&&!Zg(w,a())&&n.jsx(aS,{trigger:w})]}),n.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:iS(w),children:jz(w,s,a())}),Td(w,l)&&n.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:Td(w,l)})]}),n.jsx("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:n.jsx("p",{className:"break-words",children:bz(w)})})]},w.id))}):n.jsx(wz,{go:t}):n.jsx(Os,{label:"Loading the triggers",rows:4}),c&&f&&n.jsx(Mn,{problem:f,className:"mt-4"})]})}function wz({go:e}){const t=[{Icon:Pd,name:"Schedule",what:"At the times you set: every day or week at a time, every few minutes or hours, or once.",action:"New schedule",to:"#/triggers/new"},{Icon:Ml,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:Wh,name:"GitHub",what:"On the events you pick from this server's GitHub App. Connect GitHub in Settings first.",action:"New GitHub trigger",to:"#/triggers/new-github"}];return n.jsxs("section",{"aria-labelledby":"first-trigger",className:"border border-primary/50 bg-primary/5 p-5",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"No triggers yet"}),n.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),n.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A trigger starts a run of an agent for you, and each run it starts stops at a spend cap. Pick what should start it."}),n.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-3",children:t.map(({Icon:s,name:r,what:a,action:l,to:c})=>n.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[n.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[n.jsx(s,{className:"size-4 text-primary-text","aria-hidden":!0}),r]}),n.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:a}),n.jsx(V,{size:"sm",variant:c==="#/triggers/new"?"solid":"outline",className:"mt-4 self-start",onClick:()=>e(c),children:l})]},r))})]})}const kz={schedule:"Schedule",webhook:"Webhook",github:"GitHub"},iS=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function jz(e,t,s){return`${e.source.kind==="schedule"?Qg(e.source,e.next_at,{instead:oS(Zg(e,s)),now:s}):e.source.kind==="github"?JN(e.source):ZN(e.source)} · ${e.target.kind==="start_run"?t(e.target.agent_id)||e.target.agent_id:`messages run ${ua(e.target.run_id)}`}`}function lS(){return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(qs,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),n.jsx("p",{className:"mt-4 border px-4 py-6 text-body text-muted-foreground",children:"This trigger sends its firings to a run: this page doesn't open it yet."})]})}function Nz({v2:e,go:t,agentName:s,id:r,every:a,now:l,failuresToPause:c}){var Le,He,It,We;const[u,f]=x.useState(null),[p,g]=x.useState([]),[v,h]=x.useState(null),[m,b]=x.useState(null),[w,j]=x.useState(null),[N,R]=x.useState(!1),[$,S]=x.useState(!1),[E,C]=x.useState(!1),[T,A]=x.useState(""),[F,L]=x.useState(!1),[z,W]=x.useState(null),U=x.useRef(!1),[D,K]=x.useState(!1),[P,G]=x.useState(0),I=x.useRef(!1),Y=x.useRef(!1),q=x.useRef(0),O=()=>{Y.current=!0;const we=q.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([lt,jt])=>{we===q.current&&(f(lt),g(jt.firings),h(null))}).finally(()=>{Y.current=!1})};x.useEffect(()=>{O().catch(we=>h(fn(we,"the trigger")))},[e,r,P]),rS(()=>{!Y.current&&!I.current&&O().catch(()=>{})},a,[e,r]);const[B,ee]=x.useState(void 0),le=u&&u.target.kind==="start_run"&&typeof u.target.max_cost_usd!="number"?u.target.agent_id:null;if(x.useEffect(()=>{if(!le)return;let we=!0;return e.getAgent(le).then(lt=>{we&&ee(typeof lt.agent.definition.max_cost_usd=="number"?lt.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{we=!1}},[e,le]),!u)return v?n.jsx(Mn,{problem:v,onRetry:()=>G(we=>we+1),link:{href:"#/triggers",label:"All triggers"}}):n.jsx(Os,{label:"Loading the trigger",rows:4});const ie=ZI(u)?u:null,ue=JI(u)?u:null;if(!ie&&!ue&&!Jg(u))return n.jsx(lS,{});const ae=u,ce=Zg(u,l(),p),he=async(we,lt,jt)=>{j(we),b(null);try{await lt()}catch(Nt){b(fn(Nt,jt))}finally{j(null)}},et=()=>he("pause",async()=>{q.current++;const we=await e.updateTrigger(r,{enabled:!u.enabled});q.current++,f(we)},u.enabled?"the pause":"the resume"),se=()=>he("delete",async()=>{await e.deleteTrigger(r),t("#/triggers")},"the delete"),ke=async()=>{if(!U.current){U.current=!0,K(!0),b(null);try{await e.rotateTriggerSecret(r,{secret:T.trim()}),C(!1),A(""),L(!0)}catch(we){b(fn(we,"the secret"))}finally{U.current=!1,K(!1)}}},Se=async()=>{if(!U.current){U.current=!0,K(!0),b(null),W(null);try{W((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(we){b(fn(we,"the new secret"))}finally{U.current=!1,K(!1)}}},Fe=async()=>{if(!I.current){I.current=!0,j("fire"),b(null),q.current++;try{const we=await e.fireTrigger(r,cf());q.current++,g(lt=>[we,...lt.filter(jt=>jt.key!==we.key)]),await O().catch(()=>{})}catch(we){b(fn(we,"the run now"))}finally{I.current=!1,j(null)}}},fe=typeof ae.target.input.content=="string"?ae.target.input.content:null;return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(qs,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),n.jsxs("div",{className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 sm:flex-row",children:[n.jsxs("div",{className:"min-w-0 flex-1 self-stretch",children:[n.jsxs("h1",{className:"flex flex-wrap items-center gap-2 break-words text-2xl font-semibold leading-tight",children:[u.name,!u.enabled&&!ce&&n.jsx(aS,{trigger:u})]}),n.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:ie?`Webhook · ${ZN(ie.source)}`:ue?`GitHub · ${JN(ue.source)}`:n.jsx("span",{title:iS(u),children:Qg(ae.source,u.next_at,{instead:oS(ce),now:l()})})})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs(V,{size:"sm",variant:"solid",onClick:()=>void Fe(),disabled:w==="fire",children:[n.jsx(l$,{"aria-hidden":!0})," ",w==="fire"?"Starting":"Run now"]}),!(ce&&"ran"in ce)&&n.jsx(V,{size:"sm",onClick:()=>void et(),disabled:w!==null,children:u.enabled?n.jsxs(n.Fragment,{children:[n.jsx(ii,{"aria-hidden":!0})," Pause"]}):n.jsxs(n.Fragment,{children:[n.jsx(yi,{"aria-hidden":!0})," Resume"]})}),!ie&&!ue&&n.jsxs(V,{size:"sm",onClick:()=>t(`${uo(r)}/edit`),children:[n.jsx(Xl,{"aria-hidden":!0})," Edit"]}),ie&&ie.source.signature==="composio"&&(E?n.jsxs("form",{className:"flex items-center gap-2",onSubmit:we=>{we.preventDefault(),ke()},children:[n.jsx(Ue,{name:"secret",type:"password",autoComplete:"off","aria-label":"Composio's webhook secret",className:"w-64",value:T,onChange:we=>A(we.target.value)}),n.jsx(V,{size:"sm",variant:"solid",type:"submit",disabled:!T.trim()||D,children:"Save"}),n.jsx(V,{size:"sm",variant:"ghost",type:"button",onClick:()=>{C(!1),A("")},children:"Cancel"})]}):n.jsxs(V,{size:"sm",onClick:()=>C(!0),disabled:w!==null||D,children:[n.jsx(Qo,{"aria-hidden":!0})," Set secret"]})),ie&&ie.source.signature!=="composio"&&($?n.jsxs("span",{className:"flex items-center gap-2 border border-warning/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Make a new secret?",children:[n.jsx("span",{children:"The old secret stops signing at once."}),n.jsx(V,{size:"sm",variant:"solid",onClick:()=>{S(!1),Se()},children:"Yes, make a new one"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:"Keep"})]}):n.jsxs(V,{size:"sm",onClick:()=>S(!0),disabled:w!==null||D,children:[n.jsx(Qo,{"aria-hidden":!0})," Rotate secret"]})),N?n.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Delete this trigger?",children:[n.jsx("span",{children:"Delete for good? Its runs stay."}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>{R(!1),se()},children:"Yes, delete"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:()=>R(!1),children:"Keep"})]}):n.jsxs(V,{size:"sm",variant:"destructive",onClick:()=>R(!0),disabled:w!==null,children:[n.jsx(i$,{"aria-hidden":!0})," Delete"]})]})]}),Td(u,c)&&n.jsxs("p",{role:"status","data-disabled":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:[Td(u,c)," ",((Le=u.disabled)==null?void 0:Le.reason)==="source_unreadable"?"Edit its when, then Resume.":((He=u.disabled)==null?void 0:He.reason)==="auto_paused"?ce&&"passed"in ce?"Its time has passed: edit its time first, then Resume.":ce?"":"Resume turns it on again.":""]}),m&&n.jsx(Mn,{problem:m,className:"mt-4"}),ie&&z&&n.jsx(rx,{label:"The webhook's new secret",secret:z}),n.jsxs("dl",{className:"mt-5 grid grid-cols-1 gap-x-6 gap-y-3 border p-4 text-body sm:grid-cols-[max-content_minmax(0,1fr)]",children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),n.jsx("dd",{className:"min-w-0 break-words",children:n.jsx("a",{href:`#/agents/${encodeURIComponent(ae.target.agent_id)}`,className:"hover:underline",children:s(ae.target.agent_id)||ae.target.agent_id})}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Each run is asked"}),n.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-words",children:fe??JSON.stringify(ae.target.input)}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),n.jsx("dd",{className:"font-mono",children:QI(ae.target.max_cost_usd,B)}),ie?n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"URL"}),n.jsxs("dd",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("code",{className:"min-w-0 break-all font-mono text-small",children:Vl(ie)}),n.jsx(uS,{text:Vl(ie),label:"Copy URL"}),n.jsx("span",{className:"basis-full text-small text-muted-foreground",children:ex})]}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),n.jsxs("dd",{children:[_h[ie.source.signature??"standard"],ie.source.signature==="composio"&&!F&&!((It=u.secret)!=null&&It.set)?" (no secret set yet: every request is refused)":""]}),n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),n.jsx("dd",{className:"min-w-0 break-words",children:(We=ie.source.accept)!=null&&We.length?n.jsx("ul",{className:"space-y-1 font-mono text-small",children:ie.source.accept.map((we,lt)=>n.jsx("li",{children:Cd(we)},lt))}):"Every signed request"})]}):ue?n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),n.jsxs("dd",{className:"min-w-0 break-words",children:[n.jsx("ul",{className:"space-y-1 font-mono text-small",children:ue.source.accept.map((we,lt)=>n.jsx("li",{children:Cd(we)},lt))}),n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"caps text-label text-muted-foreground",children:"While a run is going"}),n.jsx("dd",{children:"The next time is skipped."})]})]}),n.jsxs("section",{className:"mt-6","aria-label":"Firings",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Firings"}),p.length?n.jsx("ul",{className:"mt-3 border",children:p.map(we=>n.jsxs("li",{"data-firing":we.key,className:"flex flex-col gap-1 border-b px-4 py-2.5 text-body last:border-b-0 sm:flex-row sm:items-start sm:gap-4",children:[n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(Ce,{tone:gz[we.status],children:nz[we.status]}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Rd(we.nominal_at)})]}),n.jsx("span",{className:"min-w-0 flex-1 break-words",children:we.status==="started"?`${tz[we.by]}${we.catch_up?", caught up late":""}`:`${eS(we)}${we.catch_up?" · caught up late":""}${we.by==="manual"?" · Run now":""}`}),we.run_id&&n.jsxs("a",{href:`#/runs/${encodeURIComponent(we.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",ua(we.run_id)]})]},we.key))}):n.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function Sz({v2:e,go:t,id:s,minEvery:r,now:a}){const[l,c]=x.useState(null),[u,f]=x.useState(null),[p,g]=x.useState(0);return x.useEffect(()=>{e.getTrigger(s).then(c,v=>f(fn(v,"the trigger")))},[e,s,p]),l?Jg(l)?n.jsx(cS,{v2:e,go:t,trigger:l,minEvery:r,now:a}):n.jsx(lS,{}):u?n.jsx(Mn,{problem:u,onRetry:()=>g(v=>v+1)}):n.jsx(Os,{label:"Loading the schedule",rows:4})}function dn({label:e,field:t,issue:s,hint:r,children:a}){return n.jsx(Bs,{className:"min-w-0",label:e,hint:r,error:s?n.jsx("span",{"data-issue":t,children:s}):void 0,children:a})}const nx=e=>e!==void 0?`${Ei(e)}, the agent's default`:void 0;async function sx(e){const t=[];let s=null;for(let r=0;r<20;r++){const a=await e.listAgents({cursor:s});if(t.push(...a.agents),s=a.next_cursor,!s)break}return t}function cS({v2:e,go:t,trigger:s,minEvery:r,now:a=Date.now}){var U,D,K;const[l,c]=x.useState(()=>s?uz(s):qN()),[u,f]=x.useState(null),[p,g]=x.useState({}),[v,h]=x.useState([]),[m,b]=x.useState(!1),w=x.useRef(Ks()).current;x.useEffect(()=>{sx(e).then(f,()=>f([]))},[e]);const j=P=>G=>c(I=>({...I,[P]:G})),N=P=>{var I;j("at")(P);const G=qa(P,(I=l.read)==null?void 0:I.at);G!==null&&Date.parse(G)>a()?g(({"source.at":Y,...q})=>q):G!==null&&g(Y=>Y["source.at"]?{...Y,"source.at":l0(G,{now:a()})}:Y)},R=new Set(["name","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd",...s?[]:["enabled"]]),$=(U=(u??[]).find(P=>P.agent_id===l.agentId))==null?void 0:U.definition.max_cost_usd,S=typeof $=="number"&&$>0?$:void 0,E=S!==void 0||!!s&&typeof s.target.max_cost_usd!="number"&&l.agentId===s.target.agent_id,C=async P=>{var Y;P.preventDefault();const{body:G,issues:I}=u0(l,E);if(h([]),!G){g(I??{});return}g({}),b(!0);try{if(s){const q=d0(s,G);Object.keys(q).length&&await e.updateTrigger(s.id,q),t(uo(s.id))}else{const q=await e.createTrigger(G,w.keyFor("createTrigger",G));t(uo(q.id))}}catch(q){const O=tx(q),B=l.kind==="at"?qa(l.at,(Y=l.read)==null?void 0:Y.at):null,ee=O.fields["source.at"];ee&&B!==null&&(Date.parse(B)<=a()||yz.test(ee))&&(O.fields["source.at"]=l0(B,{now:a()})),g(Object.fromEntries(Object.entries(O.fields).filter(([le])=>R.has(le)))),h([...O.rest,...Object.entries(O.fields).filter(([le])=>!R.has(le)).map(([,le])=>le)]),b(!1)}},T=s?u0(l,E).body:void 0,A=!!(s&&T&&d0(s,T).source),F=l.kind==="at"?qa(l.at,(D=l.read)==null?void 0:D.at):null,L=l.startAt?qa(l.startAt,(K=l.read)==null?void 0:K.startAt):null,z=tf((u??[]).filter(P=>!P.archived_at||P.agent_id===l.agentId)),W=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return n.jsxs("form",{onSubmit:P=>void C(P),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[n.jsxs("a",{href:s?uo(s.id):"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(qs,{className:"size-3.5","aria-hidden":!0})," ",s?s.name:"Triggers"]}),n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(Pd,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),v.length>0&&n.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:v.map((P,G)=>n.jsx("p",{children:P},G))}),n.jsxs("div",{className:"mt-5 space-y-5",children:[n.jsx(dn,{label:"Name",field:"name",issue:p.name,children:n.jsx(Ue,{name:"name",value:l.name,onChange:P=>j("name")(P.target.value),placeholder:"nightly triage"})}),n.jsxs("fieldset",{className:"min-w-0",children:[n.jsx("legend",{className:"caps text-label text-muted-foreground",children:"When"}),n.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:W.map(({kind:P,label:G})=>n.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${l.kind===P?"border-primary text-primary-text":""}`,children:[n.jsx("input",{type:"radio",name:"kind",value:P,checked:l.kind===P,onChange:()=>j("kind")(P),className:"accent-primary"}),G]},P))}),n.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[l.kind==="cron"&&n.jsx(dn,{label:"Runs",field:"source.cron",issue:p["source.cron"],children:n.jsx(nS,{label:"Runs",name:"cron",value:l.cron,onChange:j("cron")})}),l.kind==="at"&&n.jsx(dn,{label:"At, your time",field:"source.at",issue:p["source.at"],hint:F?`= ${c0(F)}`:void 0,children:n.jsx(Ue,{name:"at",type:"datetime-local",step:60,value:l.at,onChange:P=>N(P.target.value)})}),l.kind==="every"&&n.jsx(dn,{label:"Every",field:"source.every_s",issue:p["source.every_s"],hint:r?oz(r):void 0,children:n.jsxs("span",{className:"flex gap-2",children:[n.jsx(Ue,{name:"every",inputMode:"decimal",value:l.every,onChange:P=>j("every")(P.target.value),placeholder:"5"}),n.jsx(Lt,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:l.everyUnit,onChange:P=>j("everyUnit")(P),options:["seconds","minutes","hours"].map(P=>({value:P,label:P}))})]})}),l.kind==="cron"&&n.jsx(dn,{label:"Time zone",field:"source.timezone",issue:p["source.timezone"],hint:"The time zone this schedule runs in.",children:n.jsx(sS,{name:"timezone",label:"Time zone",className:"w-full",value:l.timezone,onChange:j("timezone")})}),l.kind==="every"&&n.jsx(dn,{label:"Starting, your time (optional)",field:"source.start_at",issue:p["source.start_at"],hint:L?`= ${c0(L)}`:void 0,children:n.jsx(Ue,{name:"startAt",type:"datetime-local",step:60,value:l.startAt,onChange:P=>j("startAt")(P.target.value)})})]}),A&&n.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),n.jsx(dn,{label:"Agent",field:"target.agent_id",issue:p["target.agent_id"],children:n.jsx(Lt,{name:"agent",label:"Agent",className:"w-full",value:l.agentId,onChange:P=>j("agentId")(P),options:[{value:"",label:u?"Pick an agent":"Loading the agents"},...z.map(P=>({value:P.agent_id,label:`${P.definition.name||P.agent_id}${P.kind==="workflow"?" (workflow)":""}`})),...l.agentId&&u&&!z.some(P=>P.agent_id===l.agentId)?[{value:l.agentId,label:l.agentId}]:[]]})}),n.jsx(dn,{label:"Each run is asked",field:"target.input",issue:p["target.input"],children:n.jsx(As,{name:"content",rows:4,className:"p-3 font-sans",value:l.content,onChange:P=>j("content")(P.target.value)})}),n.jsx(dn,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:p["target.max_cost_usd"],hint:S!==void 0?`Uses the agent's default (${Ei(S)}) if empty.`:E?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:n.jsx(Ue,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:l.maxCost,onChange:P=>j("maxCost")(P.target.value),placeholder:nx(S)})}),!s&&n.jsxs("div",{children:[n.jsxs("label",{className:"flex items-center gap-2 text-body",children:[n.jsx("input",{type:"checkbox",name:"enabled",checked:l.enabled,onChange:P=>j("enabled")(P.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),p.enabled&&n.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:p.enabled})]})]}),n.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[n.jsx(V,{type:"submit",size:"lg",variant:"solid",disabled:m,children:m?"Saving":s?"Save changes":"Create schedule"}),n.jsx(V,{type:"button",size:"lg",variant:"ghost",onClick:()=>t(s?uo(s.id):"#/triggers"),children:"Cancel"})]})]})}function uS({text:e,label:t}){const[s,r]=x.useState(null),a="The browser won't copy here. Select it and copy it.",l=()=>{const c=typeof navigator<"u"?navigator.clipboard:void 0;if(!(c!=null&&c.writeText)){r(a);return}c.writeText(e).then(()=>r("Copied"),()=>r(a))};return n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[n.jsxs(V,{type:"button",size:"sm",onClick:l,children:[n.jsx(Id,{"aria-hidden":!0})," ",t]}),s&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function rx({label:e,secret:t,url:s}){return n.jsxs("section",{"aria-label":e,className:"mt-4 space-y-3 border border-primary/50 p-4 text-body",children:[s&&n.jsx(Rh,{title:"URL",text:s,label:"Copy URL",hint:ex}),n.jsx(Rh,{title:"Signing secret",text:t,label:"Copy secret"}),n.jsx("p",{className:"text-warning-text",role:"note",children:"You won't see this secret again."})]})}function Rh({title:e,text:t,label:s,hint:r}){return n.jsxs("div",{className:"min-w-0",children:[n.jsx("span",{className:"caps text-label text-muted-foreground",children:e}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("code",{className:"min-w-0 break-all border bg-muted/40 px-2 py-1 font-mono text-small",children:t}),n.jsx(uS,{text:t,label:s})]}),r&&n.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const _z=["standard","github","composio"];function $z({v2:e,go:t}){var C;const[s,r]=x.useState(az),[a,l]=x.useState(null),[c,u]=x.useState({}),[f,p]=x.useState([]),[g,v]=x.useState(!1),[h,m]=x.useState(null),b=x.useRef(Ks()).current;x.useEffect(()=>{sx(e).then(l,()=>l([]))},[e]);const w=T=>A=>r(F=>({...F,[T]:A})),j=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd"]),N=(C=(a??[]).find(T=>T.agent_id===s.agentId))==null?void 0:C.definition.max_cost_usd,R=typeof N=="number"&&N>0?N:void 0,$=async T=>{T.preventDefault();const{body:A,issues:F}=iz(s,R!==void 0);if(p([]),!A){u(F??{});return}u({}),v(!0);try{m(await e.createTrigger(A,b.keyFor("createTrigger",A)))}catch(L){const z=tx(L);u(Object.fromEntries(Object.entries(z.fields).filter(([W])=>j.has(W)))),p([...z.rest,...Object.entries(z.fields).filter(([W])=>!j.has(W)).map(([,W])=>W)])}finally{v(!1)}},S=n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(qs,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(h)return n.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[S,n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(Ml,{className:"size-5 text-primary-text","aria-hidden":!0}),h.name]}),n.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:h.source.kind==="webhook"&&h.source.signature==="composio"?"Register this URL as your Composio project's webhook subscription, then set the secret Composio gives you on this trigger with Set secret. Until then every request is refused; after, each Composio event starts a run.":`Send each request to this URL, signed with this secret (${_h[h.source.kind==="webhook"?h.source.signature??"standard":"standard"]}). Each one starts a run.`}),h.signing_secret?n.jsx(rx,{label:"The webhook's URL and secret",url:Vl(h),secret:h.signing_secret}):n.jsxs("section",{"aria-label":"The webhook's URL and secret",className:"mt-4 space-y-3 border p-4 text-body",children:[n.jsx(Rh,{title:"URL",text:Vl(h),label:"Copy URL",hint:ex}),h.note&&n.jsx("p",{role:"note",children:h.note})]}),n.jsx("div",{className:"mt-6",children:n.jsx(V,{type:"button",size:"lg",variant:"solid",onClick:()=>t(uo(h.id)),children:"Done"})})]});const E=tf((a??[]).filter(T=>!T.archived_at));return n.jsxs("form",{onSubmit:T=>void $(T),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[S,n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(Ml,{className:"size-5 text-primary-text","aria-hidden":!0}),"New webhook"]}),n.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each signed request to its URL starts a capped run of the agent. Its URL and signing secret show once it is made."}),f.length>0&&n.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:f.map((T,A)=>n.jsx("p",{children:T},A))}),n.jsxs("div",{className:"mt-5 space-y-5",children:[n.jsx(dn,{label:"Name",field:"name",issue:c.name,children:n.jsx(Ue,{name:"name",value:s.name,onChange:T=>w("name")(T.target.value),placeholder:"on deploy"})}),n.jsxs("fieldset",{className:"min-w-0",children:[n.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),n.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:_z.map(T=>n.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===T?"border-primary text-primary-text":""}`,children:[n.jsx("input",{type:"radio",name:"signature",value:T,checked:s.signature===T,onChange:()=>w("signature")(T),className:"accent-primary"}),_h[T]]},T))}),c["source.signature"]&&n.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:c["source.signature"]})]}),s.signature==="composio"&&n.jsx("p",{className:"text-small text-muted-foreground",children:"Composio makes this webhook's secret when you register the trigger's URL as your project's webhook subscription: set it on the trigger then."}),n.jsx(dn,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:n.jsx(Lt,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:T=>w("agentId")(T),options:[{value:"",label:a?"Pick an agent":"Loading the agents"},...E.map(T=>({value:T.agent_id,label:`${T.definition.name||T.agent_id}${T.kind==="workflow"?" (workflow)":""}`}))]})}),n.jsx(dn,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:n.jsx(As,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:T=>w("content")(T.target.value)})}),n.jsx(dn,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:c["target.max_cost_usd"],hint:R!==void 0?`Uses the agent's default (${Ei(R)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:n.jsx(Ue,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:T=>w("maxCost")(T.target.value),placeholder:nx(R)})})]}),n.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[n.jsx(V,{type:"submit",size:"lg",variant:"solid",disabled:g,children:g?"Creating":"Create webhook"}),n.jsx(V,{type:"button",size:"lg",variant:"ghost",onClick:()=>t("#/triggers"),children:"Cancel"})]})]})}function Ez({v2:e,go:t}){var U;const[s,r]=x.useState(null),[a,l]=x.useState(null),[c,u]=x.useState(0),[f,p]=x.useState(lz),[g,v]=x.useState(null),[h,m]=x.useState({}),[b,w]=x.useState([]),[j,N]=x.useState(!1),R=x.useRef(Ks()).current,$=x.useRef(!0);x.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]),x.useEffect(()=>{let D=!0;return l(null),e.githubConnection().then(K=>{D&&r(!!K&&"app_id"in K&&!!K.app_id)},K=>{D&&(K instanceof Ee&&K.status===404?r(!1):l(fn(K,"GitHub's connection")))}),()=>{D=!1}},[e,c]),x.useEffect(()=>{sx(e).then(v,()=>v([]))},[e]);const S=D=>K=>p(P=>({...P,[D]:K})),E=D=>p(K=>({...K,events:K.events.includes(D)?K.events.filter(P=>P!==D):[...K.events,D]})),C=new Set(["name","source.accept","target.agent_id","target.input","target.max_cost_usd"]),T=(U=(g??[]).find(D=>D.agent_id===f.agentId))==null?void 0:U.definition.max_cost_usd,A=typeof T=="number"&&T>0?T:void 0,F=async D=>{D.preventDefault();const{body:K,issues:P}=cz(f,A!==void 0);if(w([]),!K){m(P??{});return}m({}),N(!0);try{const G=await e.createTrigger(K,R.keyFor("createTrigger",K));$.current&&t(uo(G.id))}catch(G){const I=tx(G);m(Object.fromEntries(Object.entries(I.fields).filter(([Y])=>C.has(Y)))),w([...I.rest,...Object.entries(I.fields).filter(([Y])=>!C.has(Y)).map(([,Y])=>Y)]),N(!1)}},L=n.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(qs,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),z=n.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[n.jsx(Wh,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(a)return n.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[L,z,n.jsx(Mn,{problem:a,onRetry:()=>u(D=>D+1),className:"mt-4"})]});if(s===null)return n.jsx(Os,{label:"Reading GitHub's connection",rows:3});if(!s)return n.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[L,z,n.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",n.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const W=tf((g??[]).filter(D=>!D.archived_at));return n.jsxs("form",{onSubmit:D=>void F(D),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[L,z,n.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event it takes from this server's GitHub App starts a capped run of the agent."}),b.length>0&&n.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:b.map((D,K)=>n.jsx("p",{children:D},K))}),n.jsxs("div",{className:"mt-5 space-y-5",children:[n.jsx(dn,{label:"Name",field:"name",issue:h.name,children:n.jsx(Ue,{name:"name",value:f.name,onChange:D=>S("name")(D.target.value),placeholder:"review PRs"})}),n.jsxs("fieldset",{className:"min-w-0",children:[n.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Events"}),n.jsx("div",{className:"mt-1 space-y-1",children:QN.map(({event:D,action:K,label:P})=>{const G=`${D}:${K}`;return n.jsxs("label",{className:"flex items-center gap-2 text-body",children:[n.jsx("input",{type:"checkbox",name:"event",value:G,checked:f.events.includes(G),onChange:()=>E(G),className:"accent-primary"}),P," ",n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[D," ",K]})]},G)})}),h["source.accept"]&&n.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.accept",children:h["source.accept"]})]}),n.jsx(dn,{label:"Agent",field:"target.agent_id",issue:h["target.agent_id"],children:n.jsx(Lt,{name:"agent",label:"Agent",className:"w-full",value:f.agentId,onChange:D=>S("agentId")(D),options:[{value:"",label:g?"Pick an agent":"Loading the agents"},...W.map(D=>({value:D.agent_id,label:`${D.definition.name||D.agent_id}${D.kind==="workflow"?" (workflow)":""}`}))]})}),n.jsx(dn,{label:"Each run is asked",field:"target.input",issue:h["target.input"],hint:"The event's payload comes with it.",children:n.jsx(As,{name:"content",rows:4,className:"p-3 font-sans",value:f.content,onChange:D=>S("content")(D.target.value)})}),n.jsx(dn,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:h["target.max_cost_usd"],hint:A!==void 0?`Uses the agent's default (${Ei(A)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:n.jsx(Ue,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:f.maxCost,onChange:D=>S("maxCost")(D.target.value),placeholder:nx(A)})})]}),n.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[n.jsx(V,{type:"submit",size:"lg",variant:"solid",disabled:j,children:j?"Creating":"Create GitHub trigger"}),n.jsx(V,{type:"button",size:"lg",variant:"ghost",onClick:()=>t("#/triggers"),children:"Cancel"})]})]})}const Ad=(e,t={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(t,r)?t[r].trim():"")||"…"),Cz=e=>`#/templates/${encodeURIComponent(e)}`,m0=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function dS(e,{secrets:t=!0,mcp:s=!0}={}){var a,l,c;const r=[];return t&&e.secrets.length&&r.push(["Keys",e.secrets.join(", ")]),s&&e.mcp.length&&r.push(["MCP",e.mcp.map(u=>`${u.server}${u.required?"":" (optional)"}`).join(", ")]),e.triggers.length&&r.push(["Triggers",m0(e.triggers.length,"trigger")]),(a=e.budget)!=null&&a.per_run_usd&&r.push(["Budget",`${fo(e.budget.per_run_usd)} a run`]),(l=e.budget)!=null&&l.tool_calls&&r.push(["Tool calls",`${m0(e.budget.tool_calls,"call")} a conversation`]),(c=e.harness)!=null&&c.length&&r.push(["Harness",e.harness.join(", ")]),e.model&&r.push(["Model",`${e.model.tier}${e.model.prefer?`, ${e.model.prefer} first`:""}`]),r}function wf(e){var s;if(e.type==="boolean")return null;if((s=e.enum)!=null&&s.length)return e.enum.map(String);const t=e.pattern?/^\^\(([A-Za-z0-9_-]+(?:\|[A-Za-z0-9_-]+)+)\)\$$/.exec(e.pattern):null;return t?t[1].split("|"):null}function Tz(e,t){const s={};for(const[r,a]of Object.entries(e.parameters)){const l=t[r];if(a.type==="boolean"){s[r]=l==="true";continue}l===void 0||l===""||(a.type==="number"||a.type==="integer"?s[r]=Number.isFinite(Number(l))?Number(l):l:s[r]=l)}return s}function Rz(e){return Object.fromEntries(Object.entries(e.parameters).flatMap(([t,s])=>s.type==="boolean"?typeof s.default=="boolean"?[[t,String(s.default)]]:[]:wf(s)?[]:s.format==="timezone"?[[t,$i()]]:s.format==="cron"?typeof s.default=="string"?[[t,s.default]]:[]:[]))}const Az=(e,t)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>t.has(s)),Oz=(e,t)=>e.filter(s=>s.field===t),_l=(e,t)=>(t==null?void 0:t.type)==="string"&&t.format==="cron"?"Schedule":(t==null?void 0:t.type)==="string"&&t.format==="timezone"?"Time zone":e;function Mz(e){if(e.type!=="string"||e.format!=="cron"&&e.format!=="timezone"||!e.description)return e.description;if(e.format==="timezone")return;const t=e.description.indexOf(": ");return t<0?void 0:e.description.slice(t+2).trim()||void 0}function p0(e){const t=wf(e);if(!t)return null;const s=e.default===void 0?void 0:String(e.default),r=!e.required&&s!==void 0&&t.includes(s);return[...r?[]:[{value:"",label:e.required?"Choose one":s!==void 0?`${s} (default)`:"None chosen"}],...t.map(l=>r&&l===s?{value:"",label:`${l} (default)`}:{value:l,label:l})]}function Pz(e,t,s){const r=_l(t,s);if(!s)return e.message;switch(e.reason){case"missing":return`${r} is required.`;case"wrong_type":return`${r} takes ${s.type==="integer"?"a whole number":s.type==="number"?"a number":s.type==="boolean"?"yes or no":"text"}.`;case"not_an_option":return`${r} takes one of: ${fS(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const fS=e=>{var t;return(t=e.enum)!=null&&t.length?e.enum.map(String):wf(e)??[]};function Lz(e,t){var r;if(t==="")return!e.required;const s=wf(e);if(s)return s.includes(t);if(e.type==="integer")return t.trim()!==""&&Number.isSafeInteger(Number(t));if(e.type==="number")return t.trim()!==""&&Number.isFinite(Number(t));if(e.type==="boolean")return(t==="true"||t==="false")&&(!((r=e.enum)!=null&&r.length)||fS(e).includes(t));if(e.pattern)try{return new RegExp(e.pattern,"u").test(t)}catch{return!0}return!0}function Iz({v2:e,name:t,go:s}){const[r,a]=x.useState(null),[l,c]=x.useState(null),[u,f]=x.useState(0);x.useEffect(()=>{let g=!0;return c(null),e.listTemplates().then(v=>{g&&a(v.templates)},v=>{g&&c(fn(v,"the templates"))}),()=>{g=!1}},[e,u]);const p=t===void 0||r==null?void 0:r.find(g=>g.name===t);return n.jsx("div",{className:"p-5 md:p-8",children:l&&!r?n.jsx(Mn,{problem:l,onRetry:()=>f(g=>g+1),className:""}):r?t===void 0?n.jsx(zz,{templates:r,go:s}):p?n.jsx(Uz,{v2:e,template:p,go:s},p.name):n.jsxs("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",role:"alert",children:["This server offers no template named ",t,". ",n.jsx("a",{href:"#/templates",className:"underline",children:"See its templates"}),"."]}):n.jsx(Os,{label:"Loading the templates",rows:3})})}function zz({templates:e,go:t}){return n.jsxs(n.Fragment,{children:[n.jsx("h1",{className:"mb-5 font-mono text-2xl font-semibold",children:"Templates"}),e.length?n.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:e.map(s=>n.jsx("li",{children:n.jsxs("article",{"aria-label":Ad(s),className:"flex h-full flex-col border bg-card px-5 py-4",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx(I0,{className:"size-4 shrink-0 self-center text-muted-foreground","aria-hidden":!0}),n.jsx("h2",{className:"min-w-0 break-words text-prose font-semibold",children:Ad(s)}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:s.version})]}),n.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:s.description}),n.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:dS(s).map(([r,a])=>n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"shrink-0",children:r}),n.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:a})]},r))}),n.jsx("div",{className:"mt-auto pt-4",children:n.jsx(V,{size:"sm",variant:"solid",onClick:()=>t(Cz(s.name)),children:"Apply"})})]})},s.name))}):n.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:"This server offers no templates yet."})]})}const Dz=3e3;function Fz(e,t){let s;const r=new Promise(a=>s=setTimeout(()=>a(void 0),t));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function Uz({v2:e,template:t,go:s}){var K;const[r,a]=x.useState(()=>Rz(t)),[l,c]=x.useState(new Set),[u,f]=x.useState(t.approvals_default??"ask"),[p,g]=x.useState(null),[v,h]=x.useState(!1),[m,b]=x.useState([]),[w,j]=x.useState(null),[N,R]=x.useState(null),[$,S]=x.useState([]),[E,C]=x.useState({}),T=x.useRef(Ks()).current,A=x.useRef(!0);x.useEffect(()=>(A.current=!0,()=>{A.current=!1}),[]),x.useEffect(()=>{let P=!0;return e.listMcpServers().then(G=>{P&&g(new Set(G.servers.map(I=>I.name)))},()=>{}),()=>{P=!1}},[e]);const F=Az(t,l),L=P=>Oz(m,P),z=(P,G)=>{a(Y=>({...Y,[P]:G}));const I=t.parameters[P];I&&Lz(I,G)&&b(Y=>Y.filter(q=>q.field!==`parameters.${P}`))},W=async()=>{var I,Y;h(!0),b([]),j(null);const P=r,G={parameters:Tz(t,P),...F.length?{grants:F}:{},overrides:{approvals:u}};try{const q=await e.applyTemplate(t.name,G,T.keyFor(t.name,G));T.done();const O=async()=>(await Promise.all(q.trigger_ids.map(le=>Fz(e.getTrigger(le),Dz).catch(()=>null)))).filter(le=>le!=null&&Jg(le));if(q.warnings.length||(I=q.webhook_secrets)!=null&&I.length){C(P),R(q),O().then(S,()=>{});return}const B=q.trigger_ids.length?await O():[];if(!A.current)return;if(!B.length){s(`#/agents/${encodeURIComponent(q.agent_id)}`);return}C(P),S(B),R(q)}catch(q){q instanceof Ee&&((Y=q.fields)!=null&&Y.length)?(b(q.fields),j({text:q.message,withIssues:!0})):j({text:q instanceof Error?q.message:String(q),withIssues:!1})}finally{h(!1)}},U=Object.entries(t.parameters),D=P=>/^(parameters|secrets|mcp)\./.test(P.field)||/^grants\.\d+$/.test(P.field);return N?n.jsxs("section",{"aria-label":"Applied",className:"max-w-3xl",children:[n.jsxs("h1",{className:"mb-4 flex items-center gap-2 font-mono text-2xl font-semibold",children:[n.jsx(Ld,{className:"size-5 text-success-text","aria-hidden":!0})," ",Ad(t,E)," applied"]}),N.warnings.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"mb-3 text-lead",children:"The agent is made. The server says:"}),n.jsx("ul",{className:"mb-5 space-y-2 border bg-card px-4 py-3 text-body",role:"status","aria-label":"Warnings",children:N.warnings.map((P,G)=>{var O,B;const I=/^triggers\.(\d+)\.secret$/.exec(P.field),Y=I?N.trigger_ids[Number(I[1])]:void 0,q=I?(O=t.triggers[Number(I[1])])==null?void 0:O.name:void 0;return Y&&((B=N.webhook_secrets)!=null&&B.some(ee=>ee.trigger_id===Y))?n.jsxs("li",{children:[n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:P.field})," ",P.message]},`${P.field}:${G}`):n.jsxs("li",{children:[n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:P.field})," ",P.message,P.fix?n.jsx("span",{className:"block text-muted-foreground",children:P.fix}):null,Y&&n.jsxs("a",{href:`#/triggers/${encodeURIComponent(Y)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof q=="string"&&q?q:Y," to get its signing secret (Rotate)"]})]},`${P.field}:${G}`)})})]}),(K=N.webhook_secrets)==null?void 0:K.map(P=>{var q;const G=N.trigger_ids.indexOf(P.trigger_id),I=G>=0?(q=t.triggers[G])==null?void 0:q.name:void 0,Y=typeof I=="string"&&I?I:P.trigger_id;return P.signing_secret?n.jsx(rx,{label:`The webhook's URL and secret (${Y})`,url:Vl({id:P.trigger_id}),secret:P.signing_secret},P.trigger_id):n.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[P.note&&n.jsx("p",{className:"text-muted-foreground",role:"note",children:P.note}),n.jsxs("a",{href:`#/triggers/${encodeURIComponent(P.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",Y," to get its signing secret (Rotate)"]})]},P.trigger_id)}),$.length>0&&n.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:$.map(P=>n.jsxs("li",{"data-trigger":P.id,className:"px-4 py-3",children:[n.jsx("a",{href:`#/triggers/${encodeURIComponent(P.id)}`,className:"break-words text-prose font-semibold hover:underline",children:P.name}),n.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:Qg(P.source,P.next_at)})]},P.id))}),n.jsx("div",{className:"mt-5"}),n.jsx("a",{href:`#/agents/${encodeURIComponent(N.agent_id)}`,className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):n.jsxs("div",{className:"max-w-3xl",children:[n.jsxs("a",{href:"#/templates",className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[n.jsx(qs,{className:"size-3.5","aria-hidden":!0})," Templates"]}),n.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[Ad(t,r)," ",n.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:t.version})]}),n.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:t.description}),U.length>0&&n.jsx(Fu,{title:"Parameters",children:U.map(([P,G])=>n.jsxs("div",{"data-field":`parameters.${P}`,className:"px-4 py-3",children:[n.jsxs("label",{className:"block",children:[n.jsxs("span",{className:"caps text-small font-semibold",children:[_l(P,G),G.required&&n.jsx("span",{className:"text-destructive-text",children:" *"})]}),n.jsx("span",{className:"mb-1.5 block text-small text-muted-foreground",children:Mz(G)}),p0(G)?n.jsx(Lt,{label:_l(P,G),className:"w-full",value:r[P]??"",onChange:I=>z(P,I),options:p0(G)}):G.format==="cron"&&G.type==="string"?n.jsx(nS,{label:_l(P,G),value:r[P]??"",onChange:I=>z(P,I)}):G.format==="timezone"&&G.type==="string"?n.jsx(sS,{label:_l(P,G),className:"w-full",value:r[P]??"",onChange:I=>z(P,I)}):G.type==="boolean"?n.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r[P]==="true",onChange:I=>z(P,I.target.checked?"true":"false")}):n.jsx(Ue,{type:G.type==="string"?"text":"number",step:G.type==="integer"?1:"any",value:r[P]??"",required:G.required,placeholder:G.default===void 0?void 0:String(G.default),onChange:I=>z(P,I.target.value)})]}),n.jsx(vl,{issues:L(`parameters.${P}`),words:I=>Pz(I,P,G)})]},P))}),t.mcp.length>0&&n.jsx(Fu,{title:"Tools you allow",note:"Nothing is granted until you tick it. A tool you leave unticked stays at your own setting for it.",children:t.mcp.map(P=>n.jsxs("div",{"data-mcp":P.server,className:"px-4 py-3",children:[n.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[n.jsx("span",{className:"font-semibold",children:P.server}),n.jsx(Ce,{tone:P.required?"plain":"muted",children:P.required?"Required":"Optional"}),p&&n.jsx("span",{className:"text-small text-muted-foreground",children:p.has(P.server)?"Set up here":"Not set up here"})]}),p&&!p.has(P.server)&&n.jsxs("p",{role:"status","data-missing-mcp":P.server,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[P.required?`${P.server} is required and not set up here: Apply is refused until it is.`:`${P.server} is not set up here: Apply makes the agent without its tools (${P.tools.map(G=>G.name).join(", ")}).`," ",n.jsx("a",{href:`#/settings/mcp?add=${encodeURIComponent(P.server)}${P.server==="github"?"&auth=github_app":""}`,className:"font-mono text-primary-text underline-offset-2 hover:underline",children:P.server==="github"?"Set up GitHub App access":`Set up ${P.server}`})]}),n.jsx(vl,{issues:L(`mcp.${P.server}`)}),n.jsx("ul",{className:"mt-2 space-y-2",children:P.tools.map(G=>{const I=F.indexOf(G.tool);return n.jsxs("li",{"data-tool":G.tool,children:[n.jsxs("label",{className:"flex items-start gap-2.5",children:[n.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:l.has(G.tool),onChange:()=>c(Y=>{const q=new Set(Y);return q.has(G.tool)?q.delete(G.tool):q.add(G.tool),q})}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"font-mono text-body",children:G.name})," ",n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:G.tool}),n.jsx("span",{className:"block text-small",children:"Allow: the agent may call this without asking you."}),n.jsx("span",{className:"block text-small text-muted-foreground",children:G.asks==="allow"?"The template asks you to allow this.":"The template does not ask for this; unticked, it stays at your setting."})]})]}),I>=0&&n.jsx(vl,{issues:L(`grants.${I}`)})]},G.tool)})})]},P.server))}),t.secrets.length>0&&n.jsx(Fu,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:t.secrets.map(P=>n.jsxs("div",{"data-secret":P,className:"px-4 py-3 font-mono text-body",children:[P,n.jsx(vl,{issues:L(`secrets.${P}`)})]},P))}),n.jsxs("fieldset",{"aria-label":"Approvals",className:"mt-6",children:[n.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),n.jsx("div",{className:"mt-2 divide-y border",children:[["ask","Ask me","A call whose permission is ask waits for your answer."],["never","Never ask (run unattended)","For an agent that runs on its triggers, with no one there to answer."]].map(([P,G,I])=>n.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[n.jsx("input",{type:"radio",name:"approvals",value:P,className:"mt-1 accent-primary",checked:u===P,onChange:()=>f(P)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-mono text-body",children:G}),n.jsx("span",{className:"block text-small text-muted-foreground",children:I})]})]},P))}),u==="never"&&n.jsx("p",{className:"mt-2 text-small text-warning-text",children:LN})]}),n.jsx(Fu,{title:"What it makes",children:n.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:dS(t,{secrets:!1,mcp:!1}).map(([P,G])=>n.jsxs("div",{className:"flex gap-2",children:[n.jsx("dt",{className:"shrink-0 text-muted-foreground",children:P}),n.jsx("dd",{className:"min-w-0 break-words",children:G})]},P))})}),n.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[n.jsx(V,{size:"sm",variant:"solid",onClick:()=>void W(),disabled:v,children:v?"Applying…":"Apply"}),w&&(!w.withIssues||m.length>0)&&n.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:w.text})]}),m.filter(P=>!D(P)).length>0&&n.jsx("div",{className:"mt-2",children:n.jsx(vl,{issues:m.filter(P=>!D(P)),named:!0})})]})}function Fu({title:e,note:t,children:s}){return n.jsxs("section",{"aria-label":e,className:"mt-6",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:e}),t&&n.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:t}),n.jsx("div",{className:"mt-2 divide-y border",children:s})]})}function vl({issues:e,named:t=!1,words:s=r=>r.message}){return e.length?n.jsx("ul",{className:"mt-1.5 space-y-1 text-small text-destructive-text",role:"alert",children:e.map((r,a)=>n.jsxs("li",{children:[t&&n.jsxs("span",{className:"font-mono",children:[r.field," "]}),s(r),r.fix&&n.jsx("span",{className:"block text-foreground/80",children:r.fix})]},`${r.field}:${a}`))}):null}const mS="tool_approval_requested";function Wz(e){var t;return e.status!=="input_required"||e.state!=="waiting"?null:((t=e.pending)==null?void 0:t.kind)==="approval"?e.pending:null}function Hz(e){return e==="not metered"?"Not metered":e===0?"Costs nothing per call":typeof e=="number"?`Costs ${fo(e)} per call`:null}function Bz(e){let t;try{t=JSON.parse(e)}catch{return e}return!t||typeof t!="object"||Array.isArray(t)?JSON.stringify(t,null,2):Object.entries(t).map(([s,r])=>`${s}: ${typeof r=="string"?r:JSON.stringify(r)}`).join(`
546
+ `)}const Gz={allow:"This call was already allowed, in another tab or by another answer. The run shows what happened next.",deny:"This call was already declined. The run shows what happened next.",withdrawn:"The run was stopped before this call ran, so it was withdrawn and never ran.",canceled:"The run was cancelled before this call ran, so it never ran."};function pS(e){var t;if(e instanceof Ee){const s=((t=e.details)==null?void 0:t.reason)==="already_answered"&&typeof e.details.decision=="string"?Gz[e.details.decision]:void 0;if(e.status===409&&s)return s;if(e.status===403)return"Only the owner, signed in with the password on this page, can answer an approval.";if(e.status===401)return"Your sign-in ended. Sign in again to answer.";if(e.status===404)return"This run no longer waits on that call."}return Jt(e)}const qz=2e3;function hS({pending:e,onAnswer:t,compact:s=!1,heading:r}){const[a,l]=x.useState(""),[c,u]=x.useState(!1),[f,p]=x.useState(null),[g,v]=x.useState(null),h=x.useRef(!1),m=Hz(e.price),b=async w=>{if(h.current)return;h.current=!0,u(!0),p(null);const j=a.trim(),N=await t(w,w==="deny"&&j?j:void 0);h.current=!1,u(!1),N?p(N):v(w)};return n.jsxs("section",{"aria-label":"Approval required",className:oe("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,n.jsxs("p",{className:oe("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[n.jsx(F0,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),n.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",n.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),"."]}),n.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:oe("mt-2 overflow-auto whitespace-pre-wrap break-all border bg-card p-3 font-mono text-small leading-[1.6]",s?"max-h-28":"max-h-64"),children:Bz(e.args_preview)}),m&&n.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:m}),g?n.jsx("p",{className:"mt-3 font-mono text-body text-success-text",role:"status",children:g==="allow"?"Allowed. The run goes on.":"Denied. The agent reads why and goes on."}):n.jsxs("div",{className:"mt-3 space-y-2",children:[n.jsxs("label",{className:"block",children:[n.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),n.jsx(As,{value:a,onChange:w=>l(w.target.value),maxLength:qz,rows:s?1:2,disabled:c,className:"mt-1 block resize-y py-2 font-sans text-lead"})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(V,{type:"button",variant:"solid",size:"sm",disabled:c,onClick:()=>void b("allow"),children:"Allow once"}),n.jsx(V,{type:"button",size:"sm",disabled:c,onClick:()=>void b("deny"),children:"Deny"}),c&&n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),!s&&n.jsx("p",{className:"text-small text-muted-foreground",children:"or type what to do instead; sending it declines this call"}),f&&n.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f})]})]})}const Vz={steer:{label:"Steer the run",placeholder:"Steer the run...",does:"The agent reads it when its current step ends."},answer:{label:"Answer the question",placeholder:"Answer the question...",does:"Answers what the agent asked; the run goes back to work."},follow_up:{label:"Ask a follow-up",placeholder:"Ask a follow-up question...",does:"Continues this run with your message; the same spend cap applies."}};function Kz({mode:e,onSend:t,sending:s,sent:r,purpose:a}){const l=a??Vz[e],[c,u]=x.useState(""),[f,p]=x.useState(!1),g=s||f,v=async()=>{if(!c.trim()||!t||g)return;p(!0);const h=await t(c.trim());p(!1),h!==!1&&u("")};return n.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:h=>{h.preventDefault(),v()},children:[n.jsx(As,{bare:!0,id:"composer",rows:2,value:c,readOnly:g,"aria-busy":g,onChange:h=>u(h.target.value),placeholder:l.placeholder,onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),v())},className:"block w-full resize-none px-4 pt-3"}),n.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[n.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[n.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:l.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":l.does]}),n.jsxs(V,{type:"submit",size:"sm",disabled:!c.trim()||!t||g,children:[g?"Sending":"Send"," ",n.jsx(z_,{"aria-hidden":!0})]})]})]})}let ri=0;const Ah=()=>{var t;const e=(t=history.state)==null?void 0:t.console_at;return typeof e=="number"?e:void 0},h0=e=>{ri=e,history.replaceState({...history.state??{},console_at:e},"")};function Xz(){const e=Ah();e===void 0?h0(0):ri=e;const t=()=>{const s=Ah();s===void 0?h0(ri+1):ri=s};return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function Yz(){const e=Ah();return e===void 0?-1:ri-e}function Qz(e){ri>0?history.back():location.hash=e}const Zz=(e,t)=>{const s=Si(e);return s?R4(s,{ended:t}):e&&e.usd!==null&&Zj(e)?"A local estimate, not a bill":void 0};function Jz({run:e,agentName:t,actions:s={},costText:r}){var w,j;const a=oP(e.place),l=ic(e.status,e.state,e.kind,ac,!0,e.error,e.review),[c,u]=x.useState(!1),f=!!e.archived_at,p=(w=e.cost)==null?void 0:w.cap_usd,g=!!e.pending&&e.pending.kind!=="budget",v=!!s.onRaiseCap&&!l.final&&typeof p=="number"&&!g,[h,m]=x.useState(!1),b=((j=e.pending)==null?void 0:j.kind)==="budget"?e.pending:null;return n.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[n.jsxs("nav",{className:"caps flex min-w-0 items-center gap-2 text-label text-muted-foreground","aria-label":"Breadcrumb",children:[n.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>Qz(Gs(e.agent_id)),className:"-m-1 shrink-0 p-1 hover:text-foreground",children:n.jsx(qs,{className:"size-3.5","aria-hidden":!0})}),n.jsx("a",{href:Gs(e.agent_id),className:"truncate hover:text-foreground hover:underline",children:t}),n.jsx("span",{"aria-hidden":!0,children:"/"}),n.jsxs("span",{className:"truncate",children:["Run ",ua(e.run_id)]})]}),n.jsxs("div",{"data-phone-row":!0,className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 max-sm:mt-2 max-sm:flex-row max-sm:flex-wrap max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-2 sm:flex-row sm:flex-wrap",children:[n.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[n.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:mn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?t:mn(e)}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-small text-muted-foreground max-sm:contents",children:[n.jsx(lc,{run:e}),f&&n.jsx(Ce,{tone:"muted",children:"Archived"}),e.approvals==="never"&&n.jsx(Ce,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),n.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,a&&` · ${a}`]}),n.jsx("span",{className:"font-mono",children:ft(e.created_at)}),r!==void 0?n.jsx("span",{className:"font-mono",title:"The run's decisions and model calls, as the providers priced them",children:Fv(e.cost,p,{text:r})}):n.jsx("span",{className:"font-mono",title:Zz(e.cost,ra(e.status)),children:Fv(e.cost,p,{ended:ra(e.status)})}),n.jsx(lf,{run:e,link:!0}),n.jsx(GN,{run:e})]}),e.status==="completed"&&e.review&&n.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(l.canStop||l.canCancel||s.onArchive||v)&&n.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[v&&n.jsxs(V,{size:"sm",onClick:()=>m(N=>!N),"aria-expanded":h,title:`Raise its ${rr(p)} spend cap.`,children:[n.jsx(Uh,{"aria-hidden":!0})," Raise the cap"]}),l.canStop&&n.jsxs(V,{size:"sm",onClick:s.onStop,disabled:!s.onStop||!!s.busy,title:"End this turn. The run stays open and waits for your next message.",children:[n.jsx(o$,{"aria-hidden":!0})," ",s.busy==="stop"?"Stopping":"Stop"]}),l.canCancel&&!c&&n.jsxs(V,{size:"sm",variant:"destructive",onClick:()=>u(!0),disabled:!s.onCancel||!!s.busy,title:"End the run for good.",children:[n.jsx(R0,{"aria-hidden":!0})," ",s.busy==="cancel"?"Cancelling":"Cancel run"]}),c&&n.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Cancel this run?",children:[n.jsx("span",{children:"Cancel for good?"}),n.jsx(V,{size:"sm",variant:"destructive",onClick:()=>{var N;u(!1),(N=s.onCancel)==null||N.call(s)},children:"Yes, cancel"}),n.jsx(V,{size:"sm",variant:"ghost",onClick:()=>u(!1),children:"Keep"})]}),s.onArchive&&n.jsxs(V,{size:"sm",onClick:s.onArchive,disabled:!!s.busy,title:f?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[f?n.jsx(T0,{"aria-hidden":!0}):n.jsx(Kl,{"aria-hidden":!0})," ",s.busy==="archive"?f?"Unarchiving":"Archiving":f?"Unarchive":"Archive"]})]})]}),v&&h&&n.jsx("div",{className:"mt-3 max-w-xl",children:n.jsx(rN,{cap:p,suggested:nN(b),least:sN(b),paused:!!b,onRaise:s.onRaiseCap},b?`${e.run_id}:${b.at}`:`${e.run_id}:working`)})]})}const e6=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function t6({view:e,onView:t}){return n.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:e6.map(s=>n.jsxs("label",{className:oe("caps -ml-px cursor-pointer border px-3 py-1.5 text-label first:ml-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:outline-offset-2",e===s.id?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[n.jsx("input",{type:"radio",name:"file-view",value:s.id,checked:e===s.id,onChange:()=>t(s.id),className:"sr-only"}),s.label]},s.id))})}const gS=(e,t)=>t?e:e.filter(s=>!m1(s.path));function n6({files:e,onOpen:t,showHidden:s,onShowHidden:r}){const a=e.filter(u=>m1(u.path)).length,l=gS(e,s),c=l.reduce((u,f)=>u+f.size_bytes,0);return n.jsxs("section",{children:[n.jsxs("div",{className:"mb-2 flex items-center gap-3",children:[n.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[n.jsx(U_,{className:"size-3.5","aria-hidden":!0})," Files · ",l.length," ",l.length===1?"file":"files"," (",ui(c),")"]}),a>0&&n.jsxs("button",{type:"button",className:"caps ml-auto text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline","aria-pressed":s,onClick:()=>r(!s),children:[s?"Hide":"Show"," ",a," hidden"]})]}),l.length===0?n.jsx("p",{className:"border px-4 py-8 text-center font-mono text-body text-muted-foreground",children:a?`Only files in hidden folders (${a}).`:"This run wrote no files."}):n.jsx("ul",{className:"border",children:l.map(u=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("button",{type:"button",onClick:()=>t(u),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-accent",children:[n.jsx(gi,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:u.path}),n.jsx("span",{className:"hidden font-mono text-label text-muted-foreground sm:inline",children:ft(u.modified_at)}),n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ui(u.size_bytes)})]})},u.path))})]})}function s6({file:e,text:t,onClose:s,files:r=[],onOpen:a}){const[l,c]=x.useState(!1),u=x.useRef(null);x.useEffect(()=>{var N;const w=document.activeElement,j=u.current;return j&&!j.open&&((N=j.showModal)==null||N.call(j)),()=>{var R;j!=null&&j.open&&j.close(),(R=w==null?void 0:w.focus)==null||R.call(w)}},[]),x.useEffect(()=>c(!1),[e.path]);const f=x.useRef(!1),p=x.useRef(!1),g=uA(e),[v,h]=x.useState(g==="markdown"?"rendered":"raw");x.useEffect(()=>h(g==="markdown"?"rendered":"raw"),[e.path]);const m=kg(w=>{const j=r.find(N=>N.path===w);j&&(a==null||a(j))}),b=()=>{if(t===null)return;const w=URL.createObjectURL(new Blob([t],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:w,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(w)};return n.jsx("dialog",{ref:u,"aria-label":e.path,onCancel:w=>{w.preventDefault(),s()},onMouseDown:w=>{f.current=w.target===w.currentTarget},onMouseUp:w=>{p.current=w.target===w.currentTarget},onClick:w=>{f.current&&p.current&&w.target===w.currentTarget&&s(),f.current=p.current=!1},className:"m-0 h-full max-h-none w-full max-w-none border-0 bg-transparent p-0 text-foreground backdrop:bg-overlay/60 md:p-8",children:n.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[n.jsx(V,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:n.jsx(Yl,{"aria-hidden":!0})}),n.jsx(gi,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:e.path}),g!=="download"&&n.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:n.jsx(t6,{view:v,onView:h})}),n.jsxs(V,{size:"sm",disabled:t===null,onClick:async()=>{var w;t!==null&&(await((w=navigator.clipboard)==null?void 0:w.writeText(t)),c(!0))},children:[n.jsx(Id,{"aria-hidden":!0})," ",l?"Copied":"Copy"]}),n.jsxs(V,{size:"sm",disabled:t===null,onClick:b,children:[n.jsx(D_,{"aria-hidden":!0})," Download"]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:t===null?n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):g==="download"?n.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."}):v==="rendered"?n.jsx("article",{className:"report mx-auto max-w-3xl",onClick:m,dangerouslySetInnerHTML:{__html:mo(t,a&&{paths:r.map(w=>w.path),from:e.path.split("/").slice(0,-1).join("/")})}}):n.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:t})}),n.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",t===null?"...":`${t.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function r6(e){const t=e.replace(/\r\n?/g,`
547
+ `).trim(),s=c=>{try{const u=JSON.parse(c);return u&&typeof u=="object"&&!Array.isArray(u)?u:null}catch{return null}},r=t.split(`
548
+ `);let a;for(let c=0;c<r.length;c++){const u=/^ {0,3}(`{3,}|~{3,})([^`]*)$/.exec(r[c]);if(!u)continue;const f=u[1],p=new RegExp(`^ {0,3}${f[0]==="`"?"`":"~"}{${f.length},}\\s*$`),g=r.findIndex((h,m)=>m>c&&p.test(h));if(g<0)break;const v=u[2].trim().toLowerCase();a=v==="json"||v===""?{open:c,end:g}:void 0,c=g}if(a&&a.end===r.length-1){const c=s(r.slice(a.open+1,a.end).join(`
549
+ `));return c?{words:r.slice(0,a.open).join(`
550
+ `).trim(),record:c}:null}const l=s(t);if(l)return{words:"",record:l};for(let c=t.lastIndexOf(`
551
+ {`);c>=0;c=t.lastIndexOf(`
552
+ {`,c-1)){const u=s(t.slice(c+1));if(u)return{words:t.slice(0,c).trim(),record:u};if(c===0)break}return null}const o6=e=>e.replace(/[_-]+/g," ").trim()||e;function xS({value:e}){return e==null?n.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"—"}):Array.isArray(e)?e.length?n.jsx("ul",{"data-json":"array",className:"list-disc space-y-1 pl-5",children:e.map((t,s)=>n.jsx("li",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:n.jsx(xS,{value:t})},s))}):n.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"none"}):typeof e=="object"?n.jsx(yS,{record:e}):n.jsx("span",{"data-json-value":!0,className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:String(e)})}function yS({record:e}){return n.jsx("dl",{"data-json":"object",className:"min-w-0 space-y-3 border-l pl-4",children:Object.entries(e).map(([t,s])=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("dt",{className:"caps break-words [overflow-wrap:anywhere] text-label text-muted-foreground",children:o6(t)}),n.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:n.jsx(xS,{value:s})})]},t))})}function a6({record:e}){const[t,s]=x.useState(!1);return n.jsxs("section",{className:"min-w-0 space-y-3",children:[n.jsx("div",{className:"flex justify-end",children:n.jsx(V,{type:"button",size:"xs",onClick:()=>s(r=>!r),children:t?"Show fields":"Show raw JSON"})}),t?n.jsx("pre",{"aria-label":"The answer's JSON",className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(e,null,2)}):n.jsx("div",{"aria-label":"The answer's fields",className:"min-w-0 [&>dl]:border-l-0 [&>dl]:pl-0",children:n.jsx(yS,{record:e})})]})}function i6({run:e,rows:t,files:s=[],onOpen:r}){var u,f,p;const a=((u=e.result)==null?void 0:u.final_answer)??((f=t.findLast(g=>g.kind==="final_answer"))==null?void 0:f.text)??null,l=r?{paths:s.map(g=>g.path)}:void 0,c=kg(g=>{const v=s.find(h=>h.path===g);v&&(r==null||r(v))});if(a!=null&&a.trim()){const g=r6(a);return g?n.jsxs("div",{className:"min-w-0 space-y-6",children:[g.words&&n.jsx("article",{className:"report max-w-none",onClick:c,dangerouslySetInnerHTML:{__html:mo(g.words,l)}}),n.jsx(a6,{record:g.record})]}):n.jsx("article",{className:"report max-w-none",onClick:c,dangerouslySetInnerHTML:{__html:mo(a,l)}})}if(((p=e.result)==null?void 0:p.output)!==void 0&&e.result.output!==null){const g=e.result.output,v=g&&typeof g=="object"&&!Array.isArray(g)?Object.entries(g).filter(m=>typeof m[1]=="string"&&m[1].includes(`
553
+ `)&&m[1].length>80):[],h=v.length?Object.fromEntries(Object.entries(g).filter(([m])=>!v.some(([b])=>b===m))):g;return n.jsxs("div",{className:"space-y-8",children:[v.map(([m,b])=>n.jsxs("section",{children:[n.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:m.replace(/_/g," ")}),n.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:c,dangerouslySetInnerHTML:{__html:mo(b,l)}})]},m)),(!v.length||Object.keys(h).length>0)&&n.jsxs("section",{children:[n.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:v.length?"The rest of the output":"Output"}),n.jsx("pre",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(h,null,2)})]})]})}return null}function l6(e,t,s=3e3){const[r,a]=x.useState(null),[l,c]=x.useState(!1),u=x.useRef(e);u.current=e;const f=x.useRef(!1),p=x.useRef(!1),g=!!e;x.useEffect(()=>{if(!g||l)return;if(!t&&f.current&&!p.current){a(w=>w&&g0(w));return}let h=!0,m;const b=async()=>{try{const w=await u.current();if(!h)return;f.current=!0,p.current=w.state==="none"&&w.session==="unopened",w.state==="off"?a(null):a(t?j=>c6(j,w)?j:w:g0(w))}catch(w){if(!h)return;if(w instanceof Ee&&w.status===401){c(!0),a(j=>j?{state:"signed_out"}:null);return}if(w instanceof Ee&&w.status===403){c(!0),a(null);return}}h&&t&&(m=setTimeout(()=>void b(),s))};return b(),()=>{h=!1,clearTimeout(m)}},[g,t,s,l]);const v=x.useCallback(h=>a(m=>m&&m.state==="live"&&m.hold!==h?{...m,hold:h}:m),[]);return{view:r,held:v}}const c6=(e,t)=>{var s,r;return!!e&&e.state!=="signed_out"&&e.state===t.state&&e.kind===t.kind&&e.hold===t.hold&&(e.state!=="live"||t.state==="live"&&e.viewer===t.viewer)&&(e.state!=="none"||t.state==="none"&&e.session===t.session&&((s=e.ended)==null?void 0:s.at)===((r=t.ended)==null?void 0:r.at))},g0=e=>e.state==="off"?null:e.state==="signed_out"?e:{state:"none",kind:e.kind,hold:"agent",session:e.state==="none"&&e.session==="unopened"?"unopened":"closed"},u6={browser:L0,desktop:xi,phone:U0,sandbox:W0},d6={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},f6={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function m6({runId:e,screen:t,machine:s,opens:r,followUp:a,metered:l,onTake:c,onHand:u}){const f=x.useRef({viewer:"",n:0});(t==null?void 0:t.state)==="live"&&t.viewer!==f.current.viewer&&(f.current={viewer:t.viewer,n:f.current.n+1});const p=(t==null?void 0:t.state)==="live"?g6(t.viewer,e):void 0,g=t&&t.state!=="signed_out"?t.kind:(s==null?void 0:s.kind)??"browser",v=u6[g],h=(t==null?void 0:t.state)==="live"?t:null,[m,b]=x.useState(!1),[w,j]=x.useState(null),N=async U=>{if(!(!U||m)){b(!0),j(null);try{j(await U())}finally{b(!1)}}},R=h&&p&&g!=="browser"?h:null,[$,S]=x.useState(!1),E=x.useRef(null),C=x.useRef(null),T=x.useRef(null),A=x.useRef(!1),F=!!(h&&p);x.useEffect(()=>{F||S(!1)},[F]),x.useEffect(()=>{var U,D,K;if($){A.current=!0,(D=(U=C.current)==null?void 0:U.querySelector("button"))==null||D.focus();return}A.current&&(A.current=!1,(K=T.current)==null||K.focus())},[$]),x.useEffect(()=>{if(!$)return;const U=I=>{if(I.key==="Escape"){S(!1);return}if(I.key!=="Tab"||!C.current)return;const Y=[...C.current.querySelectorAll("button:not([disabled]), iframe")];if(!Y.length)return;const q=Y[0],O=Y[Y.length-1],B=document.activeElement;C.current.contains(B)?I.shiftKey&&B===q?(I.preventDefault(),O.focus()):!I.shiftKey&&B===O&&(I.preventDefault(),q.focus()):(I.preventDefault(),q.focus())},D=I=>{I.key==="Escape"&&S(!1)};document.addEventListener("keydown",U);const K=E.current;let P=null;const G=()=>{try{P==null||P.removeEventListener("keydown",D,!0)}catch{}try{P=(K==null?void 0:K.contentWindow)??null,P==null||P.addEventListener("keydown",D,!0)}catch{P=null}};return G(),K==null||K.addEventListener("load",G),()=>{document.removeEventListener("keydown",U),K==null||K.removeEventListener("load",G);try{P==null||P.removeEventListener("keydown",D,!0)}catch{}}},[$,f.current.n]);const L=h?g==="browser"?"browser · take over in the view below":`${f6[h.hold]} · ${g}`:"",z=R&&(R.hold==="person"?n.jsx(V,{size:"sm",variant:"solid",disabled:m,onClick:()=>void N(u),children:"Hand back"}):n.jsx(V,{size:"sm",variant:"solid",disabled:m||R.hold==="pending",onClick:()=>void N(c),children:R.hold==="pending"?"Taking over":"Take over"})),W=F&&n.jsx(V,{ref:$?void 0:T,size:"sm",variant:"ghost",onClick:()=>S(U=>!U),"aria-label":$?"Exit full window (Esc)":"Fill the window",title:$?"Exit full window (Esc)":"Fill the window","aria-pressed":$,children:$?n.jsx(Q_,{className:"size-4","aria-hidden":!0}):n.jsx(K_,{className:"size-4","aria-hidden":!0})});return n.jsxs("section",{"aria-label":"Screen",className:"border",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[n.jsx(v,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"caps text-small font-semibold",children:h?"Live":d6[g]}),n.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:L}),!$&&z,!$&&W]}),l&&g!=="browser"&&n.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:Kg}),!$&&w&&n.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:w}),h&&p?n.jsxs("div",{ref:C,"data-testid":"screen-frame",className:$?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:$?"dialog":void 0,"aria-modal":$?!0:void 0,"aria-label":$?"The run's screen, filling the window":void 0,children:[$&&n.jsxs("div",{className:"flex items-center gap-3 border-b bg-background px-4 py-2 text-foreground",children:[n.jsx("span",{className:"flex-1 font-mono text-small",children:L}),z,W]}),$&&w&&n.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:w}),n.jsx("iframe",{ref:E,src:p,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:$?"block min-h-0 w-full flex-1 bg-background":g==="phone"?"mx-auto block aspect-[9/19] h-[70vh] max-w-full bg-background":"block aspect-[16/10] w-full bg-background"},f.current.n)]}):n.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:p6(g,t,s,r,a)})]})}function p6(e,t,s,r,a){if((t==null?void 0:t.state)==="live")return"The live view can't be shown here.";if((t==null?void 0:t.state)==="signed_out")return"Signed out: sign in to watch.";if(e==="sandbox")return"A sandbox has no screen. What the agent runs in it is on the timeline.";if((s==null?void 0:s.state)==="failed")return`The ${e} didn't start.${s.why?` ${s.why}`:""}`;if(r&&(t==null?void 0:t.state)==="none"&&t.ended)return`${t.ended.why} (${h6(t.ended.at)}). A new browser opens when the run goes on.`;const l=(t==null?void 0:t.state)==="none"?t.session:void 0;return l==="unopened"?r?e==="browser"?"This run hasn't opened its browser. The agent's page shows here if it opens one.":`This run hasn't opened its ${e}. Its screen shows here if the agent opens one.`:`This run didn't open its ${e}.${a?" A follow-up opens one if the agent needs it.":""}`:r&&l==="closed"?e==="browser"?"The run's browser isn't open now. The agent's page shows here if it opens one again.":`The run's ${e} isn't up now. Its screen shows here when it comes up again.`:r?e==="browser"?"Waiting for the browser. The agent's page shows here once it opens one.":`Waiting for the ${e}. Its screen shows here once it is up.`:`The ${e} closed when the run ended.${a?" A follow-up opens a new one if the agent needs it.":""}`}function h6(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`at ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function g6(e,t){let s;try{s=new URL(e,location.origin).href}catch{return}const r=Yo(s);if(!r)return;const a=new URL(r);return a.origin===location.origin&&a.pathname.startsWith(`/v2/runs/${encodeURIComponent(t)}/computer/live/`)?r:void 0}const Va=e=>{var t,s;return e.status==="input_required"&&(((t=e.pending)==null?void 0:t.kind)==="browser"||((s=e.pending)==null?void 0:s.kind)==="computer")?e.pending:null},bS=e=>e.kind==="computer"?e.computer:"browser";function Oh(e,t){var s;if(e instanceof Ee&&e.code==="handoff_answered"){const r=(s=e.details)==null?void 0:s.outcome;return r==="expired"?"The ask expired before your answer: the agent was told.":r==="done"||r==="cancelled"?`It was already answered: ${r}.`:e.message}return e instanceof Ee&&e.code==="computer_not_live"?e.message:e instanceof Ee&&e.status===404?t==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof Ee&&e.status===403?"Sign in with your password to do this from here.":`${t==="hand"?"Not answered":"Not taken"}: ${Jt(e)}`}function vS({ask:e,onAnswer:t,open:s,heading:r,compact:a=!1}){const[l,c]=x.useState(!1),[u,f]=x.useState(null),p=x.useRef(!1),g=async v=>{if(!(!t||p.current)){p.current=!0,c(!0),f(null);try{f(await t(v))}finally{p.current=!1,c(!1)}}};return n.jsxs("section",{"aria-label":"Waiting for you at the computer",className:a?"px-4 py-3":"border border-warning/50 bg-warning/5 p-4",children:[r,n.jsxs("p",{className:oe("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[n.jsx(xi,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",bS(e)]}),n.jsxs("div",{"data-agent-request":!0,className:oe("border-l-2 border-warning/60 pl-3",a?"mt-1":"mt-2"),children:[n.jsxs("p",{className:a?"text-prose leading-snug":"text-prose leading-relaxed",children:["The agent asks you to: ",e.instruction]}),n.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["Done when: ",e.completion_condition]})]}),n.jsx("p",{className:"mt-2 text-small font-semibold",children:"You never need to type your AgentRun password for this."}),n.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:["Expires ",ft(e.expires_at)," unanswered"]}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s,n.jsx("span",{className:"flex-1"}),t&&n.jsxs(n.Fragment,{children:[n.jsx(V,{size:"sm",variant:"solid",disabled:l,onClick:()=>void g("done"),children:"Done"}),n.jsx(V,{size:"sm",variant:"ghost",disabled:l,onClick:()=>void g("cancelled"),children:"Cancel"})]})]}),u&&n.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:u})]})}function x6(e,t){const s=!!t&&Wl(e.learning).length>0,[r,a]=x.useState({state:"reading"}),[l,c]=x.useState(0);return x.useEffect(()=>{if(!s)return;let u=!0;return a({state:"reading"}),Promise.resolve().then(()=>t()).then(f=>{u&&a({state:"read",changes:cO(f,e.learning)})},f=>{u&&a({state:"failed",error:f??new Error("unknown")})}),()=>{u=!1}},[e.run_id,s,l]),s?{got:r,retry:()=>c(u=>u+1)}:null}function y6({got:e,retry:t}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?fn(e.error,"what it changed"):null;return n.jsxs("section",{className:"border","aria-label":"What it changed",children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What it changed"}),e.state==="reading"&&n.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:"Reading what it changed…"}),s&&n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 text-body",role:"alert",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't read what it changed: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)]}),n.jsx(V,{type:"button",onClick:t,size:"sm",children:"Try again"})]}),e.state==="read"&&n.jsx("ul",{className:"divide-y",children:e.changes.map(r=>n.jsx("li",{children:n.jsx(b6,{change:r})},r.file))})]})}function b6({change:e}){const[t,s]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-4 py-3 text-left hover:bg-accent/40","aria-expanded":t,onClick:()=>s(r=>!r),children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block break-words text-lead","data-said":!0,children:e.said}),n.jsx("span",{className:"mt-0.5 block break-all font-mono text-label text-muted-foreground",children:e.file})]}),n.jsx(Rs,{className:oe("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",t&&"rotate-90"),"aria-hidden":!0})]}),t&&(e.withheld?n.jsx("p",{className:"px-4 pb-3 text-body text-muted-foreground",children:e.withheld}):n.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2",children:[n.jsx(x0,{name:"before",lines:e.before,none:"Not there before."}),n.jsx(x0,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function x0({name:e,lines:t,none:s}){return n.jsxs("div",{className:"min-w-0 border","data-side":e,children:[n.jsx("p",{className:"caps border-b px-3 py-2 text-label text-muted-foreground",children:e==="before"?"Before":"After"}),t===null?n.jsx("p",{className:"px-3 py-2 text-body text-muted-foreground",children:s}):n.jsx("pre",{className:"max-h-80 overflow-auto py-2 font-mono text-small leading-[1.7]",children:t.map((r,a)=>n.jsxs("span",{className:oe("flex min-h-[1.7em] px-3",r.mark==="added"&&"bg-primary/10",r.mark==="removed"&&"bg-destructive/10"),children:[n.jsx("span",{"aria-hidden":!0,className:"w-4 shrink-0 select-none text-muted-foreground",children:r.mark==="added"?"+":r.mark==="removed"?"−":""}),r.mark==="added"&&n.jsx("span",{className:"sr-only",children:"Added line: "}),r.mark==="removed"&&n.jsx("span",{className:"sr-only",children:"Taken out: "}),n.jsx("span",{"data-mark":r.mark,className:oe("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},a))})]})}function v6(e,t,s){const r=!!s&&!!e.learning,[a,l]=x.useState(null);return x.useEffect(()=>{if(!r)return;let c=!0;return Promise.resolve().then(()=>s()).then(u=>{c&&l((u==null?void 0:u.used)??null)},()=>{c&&l(null)}),()=>{c=!1}},[e.run_id,r,t]),r?a:null}const w6=e=>e===1?"once":e===2?"twice":`${e} times`;function k6({used:e,agentId:t}){return!e||!e.skills.length&&!e.workflows.length?null:n.jsxs("section",{className:"border","aria-label":"What it used of what it learned",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-3",children:[n.jsx("h2",{className:"caps text-small font-semibold",children:"What it used of what it learned"}),n.jsx("span",{className:"flex-1"}),n.jsx("a",{href:af(t),className:"font-mono text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:"Open the Learning tab"})]}),n.jsxs("ul",{className:"divide-y",children:[e.skills.map(s=>n.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[n.jsx(Zu,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Skill"}),n.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),s.read?n.jsx(Ce,{tone:"success",children:"Read"}):n.jsx(Ce,{tone:"muted",children:"Given, not read"})]},`skill:${s.name}`)),e.workflows.map(s=>n.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[n.jsx(ia,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Workflow"}),n.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),n.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Called ",w6(s.calls)]}),s.failed>0&&n.jsxs(Ce,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const j6={label:"Decline and say what to do instead",placeholder:"Tell the agent what to do instead...",does:"Sending it declines the waiting call; the agent reads your message."},N6={steer:{label:"Steer the run",placeholder:"Steer the run...",does:"A message steers the run; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."},follow_up:{label:"Message the run",placeholder:"Message the run...",does:"A message goes to the run after its turn; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."}};function S6(e,t){var r,a;if(e.status==="input_required"&&((r=e.pending)==null?void 0:r.kind)==="budget"){const{cap_usd:l,spent_usd:c}=e.pending,u=typeof l=="number"&&Number.isFinite(l);return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${rr(c)} of its ${rr(l)} cap.`:u?`Its ${rr(l)} cap is reached.`:"Its spend cap is reached."} Raise the cap above to continue.`,spin:!1}}if(e.status==="input_required"&&((a=e.pending)==null?void 0:a.kind)==="approval")return{title:"Waiting for your approval",note:`The run continues once you answer the approval above${t.canMessage?", or send a message below to decline it":""}.`,spin:!1};const s=Va(e);return s?{title:`Waiting for you at the ${bS(s)}`,note:"The run continues once you answer the ask above, or hand the computer back on the Screen tab.",spin:!1}:e.status==="input_required"&&e.state==="waiting"?{title:"Waiting for your answer",note:t.messageMode==="answer"?"The run continues when you reply below.":"The run continues once the question is answered.",spin:!1}:e.status==="input_required"?{title:"Stopped",note:`Stopped before it wrote an answer.${t.canMessage?" Send a message below to continue it.":""}`,spin:!1}:e.status==="paused"?{title:"Paused",note:"No new step starts until it's resumed. The answer appears here when it finishes.",spin:!1}:{title:"Writing the answer",note:"The answer appears here when the run finishes. Follow it on the timeline.",spin:t.live}}function _6({run:e,agentName:t,messages:s,harnessSteers:r,rows:a,files:l,readFile:c,openFile:u=null,actions:f,onMessage:p,onApprove:g,tab:v,graphView:h,costText:m,readLearningDiff:b,readLearning:w,readComputer:j,computerEvery:N,onTakeOver:R,onHandBack:$,readComputers:S}){var en,Ot,Wt,Et,ct;const E=((en=e.pending)==null?void 0:en.kind)==="budget"?e.pending:null,C=Va(e),T=C?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,A=ic(e.status,e.state,e.kind,s,r,e.error,e.review),F=E?{...A,canMessage:!1,messageMode:null}:C?{...A,canMessage:T!==null,messageMode:T}:A,L=h?"graph":F.final&&e.status==="completed"?"report":"timeline",[z,W]=x.useState(v??L),U=z==="graph"&&!h?L:z,[D,K]=x.useState(!1),[P,G]=x.useState(u?{file:u,text:null}:null),I=Wz(e),Y=I||C?null:cA(e.status,e.state,a),q=I?a.findLast(Ie=>Ie.kind===mS&&Ie.tool_use_id===I.call_id):void 0,[O,B]=x.useState(null),ee=async(Ie,st,gt)=>{const Xe=g?await g(Ie,st,gt):"This page can't answer an approval.";return B(Xe?{id:Ie,text:Xe}:null),Xe},le=x.useRef(md()).current,ie=async Ie=>{const st=le.begin();if(G({file:Ie,text:null}),!c)return;const gt=await c(Ie);le.current(st)&&G({file:Ie,text:gt})},ue=()=>{le.cancel(),G(null)},ae=x6(e,b),ce=v6(e,F.final,w),he=F.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",{view:et,held:se}=l6(j,!F.final,N),ke=e.computer,Se=!!et||!!ke||!!C,Fe=x.useRef(!1);x.useEffect(()=>{if(Se){Fe.current=!0;return}Fe.current&&U==="screen"&&W(L),Fe.current=!1},[Se,U,L]);const[fe,Le]=x.useState(!1);x.useEffect(()=>{if(!ke||!Xg.has(ke.kind)||!S)return;let Ie=!0;return S().then(st=>{var gt,Xe;Ie&&Le(!!((Xe=(gt=st.kinds.find(St=>St.kind===ke.kind))==null?void 0:gt.providers.find(St=>St.id===ke.provider))!=null&&Xe.metered))}).catch(()=>{}),()=>{Ie=!1}},[ke==null?void 0:ke.kind,ke==null?void 0:ke.provider]);const He=C?`${C.kind}:${C.asked_at}`:null,It=x.useRef(null);x.useEffect(()=>{!He||It.current===He||!Se||(It.current=He,W("screen"))},[He,Se]);const We=async()=>{if(!R)return"This page can't take the computer over.";try{return se((await R()).hold),null}catch(Ie){return Oh(Ie,"take")}},we=async Ie=>{if(!$)return"This page can't hand the computer back.";try{return se((await $(Ie)).hold),null}catch(st){return Oh(st,"hand")}},[lt,jt]=x.useState(null),Nt=async Ie=>{const st=(C==null?void 0:C.asked_at)??"",gt=await we(Ie);return jt(gt?{at:st,text:gt}:null),gt};x.useEffect(()=>{u&&c&&ie(u)},[u]);const on=[...h?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],["files",`Files ${gS(l,D).length}`],...Se?[["screen","Screen"]]:[]];return n.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[n.jsx(Jz,{run:e,agentName:t,actions:f,costText:m}),n.jsx(x1,{tabs:on.map(([Ie,st])=>({id:Ie,label:st})),value:U,onChange:W}),U==="graph"?n.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:h}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto short:flex-none short:overflow-visible",children:n.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-5 py-8 md:px-8",children:[e.status==="failed"&&e.error&&n.jsx(fa,{error:e.error,title:P1(e.status,e.error)?"The run escalated":void 0}),e.status==="cancelled"&&n.jsxs("section",{className:"border border-border-strong/60 p-4",children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:"Cancelled"}),n.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"This run was cancelled. It keeps what it did before; it takes no more messages."})]}),e.status==="completed"&&e.review&&n.jsxs("section",{className:"border border-warning/50 bg-warning/10 p-4","aria-label":"Needs review",children:[n.jsx("p",{className:"caps text-label text-warning-text",children:"Needs review"}),n.jsx("p",{className:"mt-2 text-lead",children:e.review.reason}),n.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:[[e.review.node&&`Stopped at ${e.review.node}`,e.review.kind].filter(Boolean).join(" · "),". A person takes it from here."]})]}),O&&O.id!==(I==null?void 0:I.id)&&n.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",O.text]}),lt&&lt.at!==(C==null?void 0:C.asked_at)&&n.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",lt.text]}),I?n.jsx(hS,{pending:I,onAnswer:(Ie,st)=>ee(I.id,Ie,st)},I.id):C?n.jsx(vS,{ask:C,onAnswer:$?Nt:void 0,open:U!=="screen"?n.jsx(V,{size:"sm",variant:"primary",onClick:()=>W("screen"),children:"Open the screen"}):null},He):F.needsYou&&(E?n.jsx(A5,{pending:E}):n.jsx(M5,{waiting:Y})),F.needsYou&&E&&typeof E.cap_usd=="number"&&(f==null?void 0:f.onRaiseCap)&&n.jsx(rN,{cap:E.cap_usd,suggested:nN(E),least:sN(E),paused:!0,onRaise:f.onRaiseCap},`${e.run_id}:${E.at}`),U==="report"&&n.jsx(i6,{run:e,rows:a,files:l,onOpen:ie}),U==="report"&&!e.result&&!F.final&&n.jsx(mh,{...S6(e,F)}),U==="report"&&F.final&&!((Wt=(Ot=e.result)==null?void 0:Ot.final_answer)!=null&&Wt.trim())&&!((Et=e.result)!=null&&Et.output)&&!a.some(Ie=>{var st;return Ie.kind==="final_answer"&&((st=Ie.text)==null?void 0:st.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&n.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[p1,F.canMessage?" Send a follow-up below to ask for one.":""]}),U==="timeline"&&n.jsx(B1,{rows:M1(a,e.learning),live:F.live,ended:ra(e.status),asking:(q==null?void 0:q.id)??(F.needsYou&&!E?Y==null?void 0:Y.id:void 0),waitingOn:e.status==="input_required"?(ct=e.pending)==null?void 0:ct.kind:void 0,files:l,onOpen:ie}),(U==="report"||U==="timeline")&&n.jsx(k6,{used:ce,agentId:e.agent_id}),(U==="report"||U==="timeline")&&ae&&n.jsx(y6,{got:ae.got,retry:ae.retry}),U==="files"&&n.jsx(n6,{files:l,onOpen:ie,showHidden:D,onShowHidden:K}),U==="screen"&&Se&&n.jsx(m6,{runId:e.run_id,screen:et,machine:ke,opens:he,followUp:F.canMessage&&F.messageMode==="follow_up",metered:fe,onTake:R?We:void 0,onHand:$?()=>we():void 0})]})}),F.canMessage&&n.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:n.jsx("div",{className:"mx-auto max-w-4xl",children:n.jsx(Kz,{mode:F.messageMode,onSend:p,purpose:I?j6:C&&T?N6[T]:void 0})})}),P&&n.jsx(s6,{file:P.file,text:P.text,onClose:ue,files:l,onOpen:ie})]})}const wS=new Set(["chain","parallel","route","map","loop","workflow"]),$6={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},E6=e=>e==="review"?"needs review":e.replace("-"," ");function ox({state:e}){const t=fd(e)??"pending";return n.jsx(Ce,{tone:$6[t]??"plain",className:"whitespace-nowrap",children:E6(t)})}function ax({provider:e}){if(!e)return null;const t=e==="parallel"?"--wf-parallel":e==="openrouter"?"--wf-openrouter":"--wf-jev";return n.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${t}))`,borderColor:`hsl(var(${t}) / .6)`,background:`hsl(var(${t}) / .12)`},children:e})}const kS={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},ix=(e,t)=>e&&t?Date.parse(t)-Date.parse(e):void 0;function C6({data:e,selected:t,onSelect:s,onClose:r,fileUrl:a}){var j,N,R,$,S,E;const l=e.graph.nodes.find(C=>C.path===t.path),[c,u]=x.useState(null);if(!l)return null;const f=e.nodes[l.path],p=$g(e.workflow,l.path,l),g=l.kind==="map"?l.path:(j=e.graph.nodes.find(C=>C.kind==="map"&&l.path.startsWith(`${C.path}/body/`)))==null?void 0:j.path,v=t.item!=null&&g?(R=(N=e.nodes[g])==null?void 0:N.items)==null?void 0:R.find(C=>C.index===t.item):void 0,h=e.decisions.filter(C=>C.node===l.path),m=e.effects.filter(C=>C.node===l.path),b=!!g&&l.kind!=="map",w=ix(f==null?void 0:f.startedAt,f==null?void 0:f.endedAt);return n.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[n.jsxs("header",{className:"border-b px-5 py-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[p.decision?l.kind:Lg(l.kind,f),p.tool?` · ${SS(p.tool)}`:l.via?` · ${l.via}`:"",p.tool&&cc(p.tool)&&n.jsx(_S,{}),v&&n.jsxs(n.Fragment,{children:[n.jsx(Rs,{className:"size-3","aria-hidden":!0})," item ",v.index+1]})]}),n.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:v?Ul(e,g,v.index)??`Item ${v.index+1}`:l.label}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n.jsx(ox,{state:v?v.status:f==null?void 0:f.status}),v&&(()=>{const C=Eg(e,g,v);return C.outcome?n.jsxs("span",{className:"font-mono text-label",title:C.pNote,children:["outcome ",n.jsx("b",{className:kS[C.tone??""],children:C.outcome}),C.p!==void 0&&n.jsxs("span",{className:"text-muted-foreground",children:[" · ",$s(C.p)]})]}):null})(),p.decision&&n.jsx(ax,{provider:p.provider}),p.decision&&((f==null?void 0:f.model)??p.model)&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(f==null?void 0:f.model)??p.model}),(f==null?void 0:f.branch)&&n.jsxs("span",{className:"font-mono text-label",children:["took ",n.jsx("b",{children:f.branch})]}),!v&&w!==void 0&&n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ja(w)})]})]}),n.jsx(V,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:n.jsx(Yl,{"aria-hidden":!0})})]}),v&&n.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>s({path:g,item:null}),children:["All ",(S=($=e.nodes[g])==null?void 0:$.items)==null?void 0:S.length," items of ",(E=e.graph.nodes.find(C=>C.path===g))==null?void 0:E.label]})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[v?n.jsx(O6,{data:e,mapPath:g,index:v.index,status:v.status,fileUrl:a,zoom:u}):l.kind==="map"?n.jsx(T6,{data:e,mapPath:l.path,onSelect:s}):b&&(h.length||m.length)?n.jsx(R6,{data:e,path:l.path,mapPath:g,onSelect:s}):n.jsxs(n.Fragment,{children:[l.kind==="parallel"&&n.jsx(A6,{data:e,path:l.path,onSelect:s}),h.map((C,T)=>n.jsx(NS,{d:C,fileUrl:a,zoom:u},C.id??T)),m.map((C,T)=>n.jsx($S,{e:C,fileUrl:a,zoom:u},T)),!h.length&&!m.length&&l.kind!=="parallel"&&n.jsx(jS,{kind:l.kind,status:f==null?void 0:f.status,meta:p})]}),n.jsx(z6,{workflow:e.workflow,path:l.path,kind:l.kind})]}),c&&n.jsx(D6,{src:c,onClose:()=>u(null)})]})}function jS({kind:e,status:t,meta:s}){const r=s.decision?t==="working"?"Asking now. The verdict shows here when the answer comes back.":"Not asked yet.":e==="code"?"A code node: a pure transform of the run's state. It calls nothing, so it leaves no record of its own.":e==="route"?"Routed by a value already in the state: no model was asked.":wS.has(e)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return n.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:r})}function T6({data:e,mapPath:t,onSelect:s}){var l;const r=((l=e.nodes[t])==null?void 0:l.items)??[],a=d1(r);return n.jsxs("section",{children:[n.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",a.total],["Done",a.done],["Working",a.working],["Review",a.review],["Failed",a.failed]].map(([c,u])=>n.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[n.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),n.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:u})]},c))}),n.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),n.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),n.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),n.jsx("tbody",{children:r.map(c=>{const u=e.decisions.filter(g=>{var v;return g.item===c.index&&!!((v=g.node)!=null&&v.startsWith(`${t}/body`))}),f=Eg(e,t,c),p=u.length?u.some(g=>g.cost_usd===null)?null:u.reduce((g,v)=>g+(v.cost_usd??0),0):void 0;return n.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:t,item:c.index}),children:[n.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),n.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Ul(e,t,c.index),children:Ul(e,t,c.index)??"—"}),n.jsx("td",{className:"border-b py-1.5 pr-2",children:n.jsx(ox,{state:c.status})}),n.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[f.pNote,...u.map(g=>di(g))].filter(Boolean).join(", "),children:f.outcome?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:oe("font-semibold",kS[f.tone??""]),children:f.outcome}),f.p!==void 0&&n.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:$s(f.p)})]}):u.map(g=>di(g)).filter(Boolean).join(", ")||n.jsx("span",{className:"text-muted-foreground",children:"—"})}),n.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:p===void 0?n.jsx("span",{className:"text-muted-foreground",children:"—"}):_i(p)})]},c.index)})})]})]})}function R6({data:e,path:t,mapPath:s,onSelect:r}){var g;const a=e.decisions.filter(v=>v.node===t),l=e.effects.filter(v=>v.node===t),c=(((g=e.nodes[s])==null?void 0:g.items)??[]).map(v=>({it:v,d:a.find(h=>h.item===v.index),e:l.find(h=>h.item===v.index)})).filter(v=>v.d||v.e),u=a.filter(v=>v.cost_usd!==null),f=a.filter(v=>v.latency_ms!==null),p=f.length?f.reduce((v,h)=>v+(h.latency_ms??0),0)/f.length:void 0;return n.jsxs("section",{children:[a.length>0&&n.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[a.length," asked · ",_i(u.reduce((v,h)=>v+(h.cost_usd??0),0)),u.length<a.length?` + ${a.length-u.length} unknown`:""," · mean ",Ja(p)]}),n.jsx("table",{className:"w-full border-collapse font-mono text-small",children:n.jsx("tbody",{children:c.map(({it:v,d:h,e:m})=>n.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:v.index}),children:[n.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:v.index+1}),n.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Ul(e,s,v.index)}),n.jsx("td",{className:"border-b py-1.5 pr-2",children:h?di(h):m?n.jsx(ox,{state:m.status}):null}),n.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:h?Ja(h.latency_ms):m?Ja(ix(m.startedAt,m.endedAt)):""})]},v.index))})})]})}function A6({data:e,path:t,onSelect:s}){var h,m;const r=`${t}/branches/`,a=e.decisions.filter(b=>{var w;return((w=b.node)==null?void 0:w.startsWith(r))&&/^\d+$/.test(b.node.slice(r.length))&&b.item===null}),l=new Set(a.flatMap(b=>Object.keys(b.answers??{}))),[c]=[...l],u=a.map(b=>{var w;return{d:b,a:(w=b.answers)==null?void 0:w[c]}}).filter(b=>{var w;return((w=b.a)==null?void 0:w.type)==="noul"});if(l.size!==1||u.length<2)return n.jsx(jS,{kind:"parallel",meta:{decision:!1}});const f=u.map(b=>b.a.noul),p=f.reduce((b,w)=>b+w,0)/f.length,g=Math.max(...f)-Math.min(...f),v=b=>{var w;return((w=e.graph.nodes.find(j=>j.path===b.node))==null?void 0:w.label)??b.node};return n.jsxs("section",{className:"border bg-card",children:[n.jsxs("header",{className:"border-b px-4 py-2.5",children:[n.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",u.length," models · ",c]}),n.jsx("p",{className:"mt-1 text-body leading-snug",children:((m=(h=a[0].questions)==null?void 0:h[c])==null?void 0:m.instructions)??c})]}),n.jsx("ul",{className:"divide-y",children:u.map(({d:b,a:w})=>n.jsx("li",{children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>s({path:b.node,item:null}),children:[n.jsx("span",{className:"w-[92px] shrink-0",children:n.jsx(ax,{provider:b.provider})}),n.jsx("span",{className:"w-[132px] shrink-0 truncate",title:b.model??"",children:b.model??v(b)}),n.jsx(Mh,{p:w.noul,strong:!0,tick:.5,tone:w.noul>=.5?"fg":"muted"}),n.jsx("span",{className:"w-10 text-right tabular-nums",children:$s(w.noul)})]})},b.id??b.executionPath))}),n.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),n.jsx("dd",{className:"font-semibold tabular-nums",children:$s(p)})]}),n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),n.jsx("dd",{className:oe("font-semibold tabular-nums",g>.3&&"text-warning-text"),children:$s(g)})]}),n.jsxs("div",{className:"px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),n.jsx("dd",{className:"tabular-nums",children:_i(u.some(b=>b.d.cost_usd===null)?null:u.reduce((b,w)=>b+(w.d.cost_usd??0),0))})]})]})]})}function O6({data:e,mapPath:t,index:s,status:r,fileUrl:a,zoom:l}){const u=e.graph.nodes.filter(f=>f.path.startsWith(`${t}/body`)).map(f=>({n:f,ds:e.decisions.filter(p=>p.node===f.path&&p.item===s),es:e.effects.filter(p=>p.node===f.path&&p.item===s)})).filter(f=>!wS.has(f.n.kind)||f.ds.length||f.es.length);return r==="pending"?n.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):n.jsxs("div",{className:"space-y-5",children:[u.map(({n:f,ds:p,es:g})=>p.length||g.length?n.jsxs("div",{className:"space-y-3",children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:f.label}),g.map((v,h)=>n.jsx($S,{e:v,fileUrl:a,zoom:l,compact:!0},h)),p.map((v,h)=>n.jsx(NS,{d:v,fileUrl:a,zoom:l},v.id??h))]},f.path):null),r==="working"&&!u.some(f=>f.ds.length)&&n.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"In flight: the verdict shows here when it comes back."})]})}const y0=e=>`${Math.round(e*100)}%`,$s=e=>e.toFixed(2);function Mh({p:e,strong:t,tick:s,tone:r="fg"}){const a={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[r];return n.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[n.jsx("span",{className:oe("absolute inset-y-0 left-0 transition-[width] duration-slow",t?a:"bg-muted-foreground/45"),style:{width:y0(Math.max(0,Math.min(1,e)))}}),s!==void 0&&n.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:y0(s)},title:`threshold ${$s(s)}`})]})}function M6({id:e,q:t,a:s,rule:r}){const a=u=>{var f;return(r==null?void 0:r.kind)==="pick"&&(t==null?void 0:t.type)==="choice"&&typeof((f=t.criteria)==null?void 0:f[u])=="string"?t.criteria[u]:u},l=(t==null?void 0:t.instructions)??e,c=(r==null?void 0:r.kind)==="route"?r.unsure:null;return n.jsxs("div",{className:"py-2.5",children:[n.jsxs("p",{className:"mb-2 text-body leading-snug",children:[n.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:e}),l]}),s?s.type==="refusal"?n.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):s.type==="noul"?n.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[n.jsx("span",{className:oe("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),n.jsx(Mh,{p:s.noul,strong:!0,tick:.5,tone:s.noul>=.5?"fg":"muted"}),n.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",$s(s.noul)]})]}):s.type==="box"?n.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(s.box)]}):n.jsxs("div",{className:"space-y-1.5",children:[Object.entries(s.probabilities).sort((u,f)=>f[1]-u[1]).slice(0,(r==null?void 0:r.kind)==="pick"?5:void 0).map(([u,f])=>{const p=(s.type==="choice"?s.choice:String(s.score))===u;return n.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[n.jsx("span",{className:oe("truncate",(r==null?void 0:r.kind)==="pick"?"w-48":"w-28",p?"font-semibold":"text-muted-foreground"),title:a(u),children:s.type==="score"?`${u} ${s.legend[u]??""}`:a(u)}),n.jsx(Mh,{p:f,strong:p,tick:p&&c?c.gte:void 0}),n.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:$s(f)})]},u)}),(r==null?void 0:r.kind)==="pick"&&Object.keys(s.probabilities).length>5&&n.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(s.probabilities).length-5," more options, each less likely"]})]}):n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function P6(e){if(!e)return"No rule applied: nothing came back to decide on.";switch(e.kind){case"judge":return"Each answer is decoded on its own: a yes/no is yes at P(yes) ≥ 0.50, a choice is its top option.";case"route":return e.unsure?`Take the chosen branch; below ${$s(e.unsure.gte)} confidence take "${e.unsure.branch}".`:"Take the chosen branch.";case"pick":return`Pick one of ${e.options.length} options${e.none?`, or "${e.none}"`:""}.`;case"ask":return`Holds when P(yes) ≥ ${$s(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${$s(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function L6(e){var s,r,a,l;const t=e.action;if(t==null)return e.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((s=e.rule)==null?void 0:s.kind)==="route"){const c=((a=(r=e.answers)==null?void 0:r.branch)==null?void 0:a.type)==="choice"?e.answers.branch.confidence:void 0;return t.unsure?`Took "${String(t.taken)}": "${String(t.branch)}" at ${c!==void 0?$s(c):"?"} is below the threshold.`:`Took "${String(t.taken??t.branch)}".`}if(((l=e.rule)==null?void 0:l.kind)==="pick"&&typeof t.index=="number"){const c=e.rule.options[t.index];return t.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${c!==void 0?`"${c1(e,Object.keys(e.questions??{})[0]??"pick",c)}"`:`option ${t.index}`}.`}return typeof t=="object"?Object.entries(t).map(([c,u])=>`${c} = ${typeof u=="object"?JSON.stringify(u):String(u)}`).join(" · "):String(t)}function NS({d:e,fileUrl:t,zoom:s}){var l,c,u;const r=Array.from(new Set([...Object.keys(e.questions??{}),...Object.keys(e.answers??{})])),a=e.status==="answered"?"success":e.status==="cancelled"?"warning":"error";return n.jsxs("section",{className:"border bg-card",children:[n.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[n.jsx(ax,{provider:e.provider}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),n.jsx(Ce,{tone:a,children:e.status==="cancelled"?"outcome unknown":e.status})]}),n.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((l=e.rule)==null?void 0:l.kind)!=="route"?"Least sure answer":"Verdict"}),n.jsx("dd",{className:"break-words font-semibold",children:di(e)??"—"})]}),n.jsxs("div",{className:"border-r px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),n.jsx("dd",{className:"tabular-nums",title:e.cost_basis??void 0,children:_i(e.cost_usd)})]}),n.jsxs("div",{className:"px-4 py-2",children:[n.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),n.jsx("dd",{className:"tabular-nums",children:Ja(e.latency_ms)})]})]}),e.error&&n.jsx("p",{className:oe("border-b px-4 py-2.5 font-mono text-small",e.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:e.error}),!!((c=e.images)!=null&&c.length)&&n.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:e.images.map(f=>({img:f,src:f.ref&&t(f.ref)||Yo(f.url)})).filter(({src:f})=>f).map(({img:f,src:p})=>n.jsxs("figure",{className:"flex gap-3",children:[n.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>s(p),"aria-label":`Open ${f.ref}`,children:n.jsx("img",{src:p,alt:`The page the model saw as ${f.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),n.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[n.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),n.jsxs("p",{children:[n.jsx("span",{className:"text-muted-foreground",children:"token "}),f.token]}),n.jsxs("p",{className:"break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:"page "}),f.ref]}),f.sha256&&n.jsxs("p",{className:"break-all",title:f.sha256,children:[n.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),f.sha256.slice(0,16),"…"]}),(f.mime||f.bytes)&&n.jsx("p",{className:"text-muted-foreground",children:[f.mime,f.bytes?`${Math.round(f.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},f.token))}),n.jsx("div",{className:"divide-y px-4",children:r.map(f=>{var p,g;return n.jsx(M6,{id:f,q:(p=e.questions)==null?void 0:p[f],a:(g=e.answers)==null?void 0:g[f],rule:e.rule},f)})}),n.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[n.jsxs("div",{className:"flex gap-3",children:[n.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),n.jsx("dd",{children:P6(e.rule)})]}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),n.jsx("dd",{className:"font-mono text-small",children:L6(e)})]})]}),!!((u=e.evidence)!=null&&u.length)&&n.jsx(I6,{evidence:e.evidence}),e.state!=null&&n.jsxs("details",{className:"group border-t",children:[n.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(Rs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",e.state_truncated?" (cut at 64 KB)":""]}),n.jsx(Od,{value:e.state})]})]})}function I6({evidence:e}){return n.jsxs("section",{className:"border-t px-4 py-3",children:[n.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",e.length]}),n.jsx("ol",{className:"space-y-3",children:e.map((t,s)=>{let r=t.url;try{r=new URL(t.url).host}catch{}const a=Yo(t.url);return n.jsxs("li",{className:"flex gap-3",children:[n.jsx("span",{className:"font-mono text-label text-muted-foreground",children:s+1}),n.jsxs("div",{className:"min-w-0 flex-1",children:[a?n.jsxs("a",{href:a,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[t.title??r,n.jsx(F_,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):n.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:t.title??r}),n.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[r,t.scope&&n.jsx("span",{className:"border px-1",children:t.scope})]}),t.excerpts.slice(0,2).map((l,c)=>n.jsx("blockquote",{className:"mt-1.5 line-clamp-3 border-l-2 border-wf-parallel/[.6] pl-2.5 text-body leading-snug text-muted-foreground",children:l},c))]})]},s)})})]})}const SS=e=>{const t=cc(e);return t?`${t.tool} on ${t.server}`:e},_S=()=>n.jsx(Ce,{tone:"muted",title:"An MCP server's tool",children:n.jsx("span",{"data-mcp":!0,children:"MCP"})});function $S({e,fileUrl:t,zoom:s,compact:r=!1}){var g;const a=e.output,l=a!=null,c=a&&typeof a=="object"?a:null,u=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),f=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),p=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return n.jsxs("section",{className:"border bg-card",children:[n.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[n.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:SS(e.tool)}),cc(e.tool)&&n.jsx(_S,{}),n.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?Ja(ix(e.startedAt,e.endedAt)):""}),n.jsx(Ce,{tone:p,children:e.status})]}),n.jsxs("div",{className:"space-y-3 px-4 py-3",children:[r?n.jsxs("p",{className:"break-all font-mono text-label",children:[n.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(e.input)]}):n.jsxs("div",{children:[n.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),n.jsx(Od,{value:e.input,small:!0})]}),f&&n.jsx("p",{className:"font-mono text-small text-destructive-text",children:f}),!!((g=c==null?void 0:c.pages)!=null&&g.length)&&n.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(v=>n.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(t(v.image)),"aria-label":`Open page ${v.page}`,children:n.jsx("img",{src:t(v.image),alt:`Page ${v.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},v.page))}),l&&!f&&n.jsxs("details",{className:"group",children:[n.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[n.jsx(Rs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),n.jsx(Od,{value:a,small:!0})]}),!l&&!f&&n.jsx("p",{className:"font-mono text-small text-muted-foreground",children:e.status==="stopped"?"Stopped before it answered.":u?"Running…":"Finished with no output."})]})]})}function z6({workflow:e,path:t,kind:s}){const r=i1(e,t);if(!r)return null;const a=Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(l==="steps"||l==="branches"&&s==="parallel")&&Array.isArray(c)?`… ${mf(c.length)}`:l==="body"?"… its body":l==="branches"&&s==="route"&&c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([u,f])=>[u,(f==null?void 0:f.criteria)??"…"])):c]));return n.jsxs("details",{className:"group border",children:[n.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[n.jsx(Rs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",n.jsx("span",{className:"normal-case tracking-normal",children:t})]}),n.jsx(Od,{value:a})]})}function Od({value:e,small:t}){return n.jsx("pre",{className:oe("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",t?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(e,null,2)})}function D6({src:e,onClose:t}){return n.jsx(Cg,{open:!0,onClose:t,title:"Page image",size:"full",children:n.jsx("img",{src:e,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const ES=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function F6(e,{everyMs:t=1e3,key:s="",enabled:r=!0}={}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState(0),[g,v]=x.useState(0),h=x.useRef(e);return h.current=e,x.useEffect(()=>{if(!r)return;const m=new AbortController;let b;const w=async()=>{try{const j=Date.now(),N=await h.current(m.signal);if(m.signal.aborted||(l(N),u(null),p(j),sc(N.run.status)))return}catch(j){if(m.signal.aborted)return;u(j);const N=j;if(N.retryable){b=setTimeout(w,Math.min(t,N.retryAfterMs??500));return}if(ES(j))return}b=setTimeout(w,t)};return w(),()=>{m.abort(),clearTimeout(b)}},[s,t,g,r]),{data:a,error:c,readAt:f,reload:()=>v(m=>m+1)}}function U6({data:e,actions:t={},fileUrl:s,initial:r=null,lastRead:a}){const[l,c]=x.useState(r),u=x.useMemo(()=>oA(e,l),[e,l]),f=sc(e.run.status),[p,g]=x.useState(()=>Date.now()),v=x.useMemo(()=>Date.now(),[e]);return x.useEffect(()=>{if(f||e.run.paused)return;const h=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(h)},[f,e.run.paused]),n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsx(W6,{data:e,readAt:v,now:p,actions:t,stale:!f&&a&&p-a>5e3?Math.max(1e3,p-a):0}),e.run.paused&&n.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[n.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:n.jsx("div",{className:"px-5 py-6 md:px-8",children:n.jsx(dc,{graph:e.graph,marks:u,onSelect:h=>c(m=>m&&m.path===h.path&&(m.item??null)===h.item?null:h),label:"The run's workflow graph"})})}),l&&n.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:n.jsx(C6,{data:e,selected:l,onSelect:c,onClose:()=>c(null),fileUrl:s})})]}),n.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:n.jsx(fc,{run:!0})})]})}function W6({data:e,readAt:t,now:s,actions:r,stale:a}){const l=sc(e.run.status),c=e.graph.nodes.find(v=>{var h,m;return v.kind==="map"&&((m=(h=e.nodes[v.path])==null?void 0:h.items)==null?void 0:m.length)}),u=c?d1(e.nodes[c.path].items):null,{usd:f,unknown:p}=f1(e),g=[["Elapsed",fi(lA(e,t,s))],["Cost",n.jsxs(n.Fragment,{children:[_i(f),p>0&&n.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",p," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",e.totals.decisions],["Tool calls",e.totals.effects],["Agents",B6(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return u&&g.push(["Items",n.jsxs(n.Fragment,{children:[n.jsx("span",{children:u.done}),n.jsxs("span",{className:"text-muted-foreground",children:["/",u.total]}),u.failed>0&&n.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[u.failed," failed"]}),u.review>0&&n.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[u.review," review"]})]})]),n.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&n.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:n.jsxs(Ce,{tone:"warning",children:[n.jsx(ii,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([v,h,m],b)=>n.jsxs("div",{className:oe("px-4 py-2",b?"border-l":"pl-5 md:pl-8"),title:m,children:[n.jsx("p",{className:"caps text-micro text-muted-foreground",children:v}),n.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:h})]},v)),n.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[a>0&&n.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",fi(a)," ago, reading again"]}),!l&&(e.run.paused?n.jsxs(V,{size:"sm",variant:"solid",onClick:r.onResume,disabled:!r.onResume||!!r.busy,children:[n.jsx(yi,{"aria-hidden":!0})," ",r.busy==="resume"?"Resuming":"Resume"]}):n.jsxs(V,{size:"sm",onClick:r.onPause,disabled:!r.onPause||!!r.busy,title:"Calls in flight finish; no new node starts.",children:[n.jsx(ii,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const H6=new Set(["agent","decide","extract","report","artifact"]),B6=e=>e.graph.nodes.filter(t=>{var s;return H6.has(t.kind)&&!["pending","not_run"].includes(((s=e.nodes[t.path])==null?void 0:s.status)??"pending")}).length;function G6({error:e}){const t=e==null?void 0:e.status;return n.jsx("p",{className:oe("m-8 border p-4 font-mono text-body",t===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:e==null?"Reading the run's graph...":t===404?"This server does not give run graphs: GET /v2/runs/{id}/graph is not there.":`The run's graph could not be read: ${e.message??String(e)}`})}function q6(e,t){return!t||e.state==="loading"?{messages:ac,steers:!1}:e.state==="failed"?{messages:t.features.messages,steers:!1}:{messages:t.features.messages,steers:pO(e.id,t.harnesses)}}async function V6(e,t){try{let s=null;do{const r=await e.listRevisions(t.agent_id,s),a=r.revisions.find(l=>l.revision===t.revision);if(a)return{state:"read",id:a.definition.harness};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const b0=new Set(["completed","failed","cancelled"]),K6=e=>{const t=f1(e);return`${_i(t.usd)}${t.unknown?` + ${t.unknown} unknown`:""}`},X6=e=>e instanceof Ee?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},Ha=e=>({api:X6(e),title:GP(e),cause:e});function v0({v2:e,runId:t,caps:s,agentName:r}){const[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState([]),[g,v]=x.useState([]),[h,m]=x.useState(null),[b,w]=x.useState(null),[j,N]=x.useState(0),R=x.useRef(""),$=x.useRef(md()).current,S=x.useRef(md()).current,E=x.useRef(Ks()).current,C=x.useRef(0),T=x.useRef(""),[A,F]=x.useState({state:"loading"});x.useEffect(()=>{a&&A.state==="loading"&&V6(e,a).then(F)},[a==null?void 0:a.revision]);const L=q6(A,s);G1(a,()=>z(),()=>N(O=>O+1));const z=async()=>{const O=$.begin();try{const[B,ee]=await Promise.all([e.getRun(t),e.listFiles(t)]);$.current(O)&&(l(B),v(ee.files))}catch(B){$.current(O)&&m(Ha(B))}};x.useEffect(()=>{z()},[t]),WN(()=>{z()}),x.useEffect(()=>{const O=new AbortController;return u(null),_g(e,t,{signal:O.signal,onRows:B=>{p(B);const ee=B.filter(ie=>ie.kind===mS).map(ie=>`${ie.id}\0${ie.summary}`).join("");ee!==T.current&&(T.current=ee,z());const le=B.filter(ie=>ie.kind==="tool_result").length;if(le>C.current){C.current=le;const ie=S.begin();e.listFiles(t).then(ue=>{S.current(ie)&&v(ue.files)}).catch(()=>{})}},onPage:B=>{B.cost&&u(B.cost);const ee=`${B.status}/${B.state}`;(ee!==R.current||B.status==="input_required"&&!B.unchanged)&&(R.current=ee,z())}}).catch(B=>{O.signal.aborted||m(Ha(B))}),()=>O.abort()},[t,j]);const W=async O=>{w(O);try{await e[O](t),m(null)}catch(B){m(Ha(B))}w(null),await z(),N(B=>B+1)},U=async()=>{if(a){w("archive");try{const O=await(a.archived_at?e.unarchiveRun(t):e.archiveRun(t));l(B=>B?{...B,archived_at:O.archived_at}:O),m(null)}catch(O){m(Ha(O))}w(null),z()}},D=async O=>{const B=await e.raiseCap(t,O);return await z(),N(ee=>ee+1),B},K=async O=>{let B=!0;try{await oN(E,t,O,e.sendMessage),m(null)}catch(ee){m(Ha(ee)),B=!1}return await z(),N(ee=>ee+1),B},P=async(O,B,ee)=>{let le=null;try{await e.answerApproval(t,O,B,ee)}catch(ie){le=pS(ie)}return await z(),N(ie=>ie+1),le},G=async O=>{try{return await O()}finally{await z(),N(B=>B+1)}},I=F6(O=>e.getRunGraph(t,O),{key:t,enabled:(a==null?void 0:a.kind)==="workflow"}),Y=!I.data&&ES(I.error);if(!a)return h?h.cause instanceof Ee&&h.cause.status===404?n.jsx(q1,{what:"run",id:t,list:{href:"#/runs",label:"Open the runs list"}}):n.jsx(Mn,{problem:fn(h.cause,"the run"),onRetry:()=>{m(null),z(),N(O=>O+1)}}):n.jsx(U5,{});const q=c&&!b0.has(a.status)?{...a,cost:c}:a;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[h&&n.jsx("div",{className:"border-b p-3",children:n.jsx(fa,{title:h.title,error:h.api})}),n.jsx(_6,{run:q,agentName:r(a.agent_id),messages:L.messages,harnessSteers:L.steers,graphView:a.kind==="workflow"&&!Y?n.jsx(Y6,{v2:e,runId:t,graph:I,onMoved:()=>{z()}}):void 0,costText:a.kind==="workflow"&&!b0.has(a.status)&&I.data?K6(I.data):void 0,rows:f,files:g,readFile:O=>e.readFile(t,O.path),readLearningDiff:()=>e.runLearningDiff(t),readLearning:()=>e.runLearning(t),readComputer:()=>e.runComputer(t),onTakeOver:()=>G(()=>e.takeOverComputer(t)),onHandBack:O=>G(()=>e.handBackComputer(t,O)),readComputers:()=>e.computers(),onMessage:K,onApprove:P,actions:{onStop:()=>void W("stop"),onCancel:()=>void W("cancel"),onArchive:()=>void U(),onRaiseCap:D,busy:b}},a.run_id)]})}function Y6({v2:e,runId:t,graph:s,onMoved:r}){const{data:a,error:l,readAt:c,reload:u}=s,[f,p]=x.useState(null),[g,v]=x.useState(null),[h,m]=x.useState(null),b=async j=>{p(j);try{const N=await(j==="pause"?e.pauseRun(t):e.resumeRun(t));m({paused:N.paused,status:N.status,at:Date.now()}),v(null)}catch(N){v(Ha(N))}p(null),u(),r()},w=a&&h&&c<h.at?{...a,run:{...a.run,paused:h.paused,...h.status?{status:h.status}:{}}}:a;return w?n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[g&&n.jsx("div",{className:"border-b p-3",children:n.jsx(fa,{title:g.title,error:g.api})}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(U6,{data:w,lastRead:c,fileUrl:j=>e.fileUrl(t,j),actions:{onPause:()=>void b("pause"),onResume:()=>void b("resume"),busy:f}})})]}):n.jsx(G6,{error:l})}function Q6({view:e,error:t,onRetry:s,scope:r,needsYou:a,asking:l,failed:c,live:u,startHere:f}){if(t)return n.jsx(Mn,{problem:t,onRetry:s});if(!e)return n.jsx(F5,{});if(f)return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1600px] space-y-6 px-6 py-8",children:[n.jsx("h1",{className:"text-2xl font-semibold",children:"Mission Control"}),f]})});const p=h=>{var m;return((m=e.perAgent.find(b=>b.agentId===h))==null?void 0:m.name)??h},g=r!=null&&r.agent?e.perAgent.filter(h=>h.agentId===r.agent):e.perAgent,v=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,[typeof u=="number"&&u!==e.runs.active?`${u} running now`:"",e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:""].filter(Boolean).join(" · ")||void 0],["Needs input",l===null?"–":String(l??e.runs.needsInput),"#/runs?status=input_required",l??e.runs.needsInput?"text-warning-text":void 0],c===void 0?["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,w0(e.runs.needsReview)]:["Failed · last 24 h",c===null?"–":String(c),"#/runs?status=failed",c?"text-destructive-text":void 0,[`See all ${e.runs.failed}`,w0(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return n.jsx("div",{className:"h-full overflow-auto",children:n.jsxs("div",{className:"mx-auto max-w-[1600px] space-y-8 px-6 py-8",children:[n.jsx("h1",{className:"text-2xl font-semibold",children:"Mission Control"}),a,n.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:v.map(([h,m,b,w,j])=>{const N=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"caps text-label text-muted-foreground",children:h}),n.jsx("p",{className:oe("mt-2 font-mono text-xl font-semibold",w),children:m}),j&&n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:j})]});return n.jsx("li",{children:b?n.jsx("a",{href:b,className:"block h-full border p-4 hover:border-border-strong hover:bg-accent",children:N}):n.jsx("div",{className:"h-full border p-4",children:N})},h)})}),n.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-3",children:[n.jsx("h2",{className:"text-lg font-semibold",children:Z6(e)}),r&&n.jsx(t1,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),n.jsx(n1,{a:e.analytics,basis:e.cost.basis,refreshing:r==null?void 0:r.refreshing})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[n.jsxs("section",{className:"border",children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"Runs per agent"}),g.length?n.jsx("ul",{children:g.map(h=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:Gs(h.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[n.jsx("span",{className:"min-w-0 truncate",children:h.name}),n.jsx("span",{className:"font-mono text-body text-muted-foreground",children:h.runs})]})},h.agentId))}):n.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),n.jsxs("section",{className:"border",children:[n.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"Recent runs"}),e.recent.length?n.jsx("ul",{children:e.recent.map(h=>n.jsx("li",{className:"border-b last:border-b-0",children:n.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[n.jsx(lc,{run:h}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"min-w-0 truncate text-lead",children:mn(h)}),n.jsx(lf,{run:h,className:"hidden sm:inline-flex"}),LL(h)&&n.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),n.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:p(h.agent_id)}),h.ended_at&&n.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:fi(Date.parse(h.ended_at)-Date.parse(h.created_at))}),h.cost&&(h.cost.usd!==null||Si(h.cost))&&n.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:go(h.cost,{ended:ra(h.status)})}),n.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ft(h.created_at)})]})},h.run_id))}):n.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const w0=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function Z6(e,t=Date.now()){var l;const s=e.analytics.filter,r=s.from?Math.round((Math.floor(t/864e5)*864e5-Date.parse(s.from))/864e5)+1:null,a=s.from?jg.some(c=>c.days===r)?`Runs started in the last ${r} days`:`Runs started since ${s.from.slice(0,10)}`:"All runs";return s.agent?`${a}, of ${((l=e.perAgent.find(c=>c.agentId===s.agent))==null?void 0:l.name)??s.agent}`:a}const Vs=e=>`#/runs/${encodeURIComponent(e)}`;function J6({asking:e,failed:t,failedAll:s,live:r,learning:a=[],agentName:l,onAnswer:c,onApprove:u,onHandBack:f,onRunAgain:p,onStop:g,problem:v,now:h=Date.now}){const m=TL(t),[,b]=x.useState(0);x.useEffect(()=>{if(!r.length)return;const L=setInterval(()=>b(z=>z+1),1e3);return()=>clearInterval(L)},[r.length]);const[w,j]=x.useState([]),N=(L,z,W)=>{const U=e.find(K=>K.run_id===L),D=U?mn(U):L;j(K=>[...K.filter(P=>P.runId!==L),...W?[{runId:L,what:z,title:D,text:W}]:[]])},R=u&&(async(L,z,W,U)=>{const D=await u(L,z,W,U);return N(L,z,D),D}),$=f&&(async(L,z,W)=>{const U=await f(L,W);return N(L,`ask:${z.asked_at}`,U),U}),S=L=>{var W;const z=Va(L);return((W=L.pending)==null?void 0:W.kind)==="approval"?L.pending.id:z?`ask:${z.asked_at}`:null},E=IN(t),C=a.filter(L=>L.pending>0),T=C.reduce((L,z)=>L+z.pending,0),A=e.length+E+T;if(!A&&!r.length&&!v&&!w.length)return null;const F=h();return n.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[A>0&&n.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",n.jsxs("span",{className:"text-warning-text",children:["· ",A]})]}),v&&n.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:v}),w.filter(L=>!e.some(z=>z.run_id===L.runId&&S(z)===L.what)).map(L=>n.jsxs("p",{className:"flex items-start gap-3 border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("a",{href:Vs(L.runId),className:"underline-offset-4 hover:underline",children:L.title}),": your answer wasn't taken. ",L.text]}),n.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>j(z=>z.filter(W=>W.runId!==L.runId)),children:"Dismiss"})]},L.runId)),e.length>0&&n.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(L=>{var z,W,U;return((z=L.pending)==null?void 0:z.kind)==="approval"?n.jsx(eD,{run:L,pending:L.pending,agentName:l(L.agent_id),at:F,onApprove:R},`${L.run_id}:${L.pending.id}`):Va(L)?n.jsx(tD,{run:L,ask:Va(L),agentName:l(L.agent_id),at:F,onHandBack:$},`${L.run_id}:${Va(L).asked_at}`):n.jsx(nD,{run:L,agentName:l(L.agent_id),at:F,onAnswer:c},`${L.run_id}:${((W=L.pending)==null?void 0:W.kind)==="question"?L.pending.asked_at:((U=L.pending)==null?void 0:U.kind)==="budget"?L.pending.at??"":""}`)})}),m.length>0&&n.jsxs("div",{className:"border",children:[n.jsxs("p",{className:"caps flex items-center justify-between border-b px-4 py-2.5 text-label text-muted-foreground",children:[n.jsxs("span",{children:["Failed in the last 24 h · ",E]}),n.jsx("a",{href:"#/runs?status=failed",className:"normal-case tracking-normal hover:text-foreground",children:s===void 0?"All failed runs →":`All ${s} failed ${s===1?"run":"runs"} →`})]}),n.jsx("ul",{children:m.map(L=>n.jsx(oD,{message:L.message,runs:L.runs,agentName:l,at:F,onRunAgain:p},L.message))})]}),C.length>0&&n.jsxs("div",{className:"border",children:[n.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Learned, waiting for your OK · ",T]}),n.jsx("ul",{children:C.map(L=>n.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[n.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:L.name}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:Ag(L.pending)}),n.jsx("a",{href:`#/agents/${encodeURIComponent(L.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},L.agent_id))})]}),r.length>0&&n.jsxs("div",{className:"border",children:[n.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",r.length]}),n.jsx("ul",{children:r.map(L=>n.jsx(aD,{run:L,agentName:l(L.agent_id),at:F,onStop:g},L.run_id))})]})]})}function eD({run:e,pending:t,agentName:s,at:r,onApprove:a}){return n.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:n.jsx(hS,{compact:!0,pending:t,heading:n.jsx(lx,{run:e,agentName:s,since:`asked ${mc(t.requested_at,r)} ago`}),onAnswer:(l,c)=>a?a(e.run_id,t.id,l,c):Promise.resolve("Open the run to answer it.")})})}function tD({run:e,ask:t,agentName:s,at:r,onHandBack:a}){return n.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:n.jsx(vS,{compact:!0,ask:t,heading:n.jsx(lx,{run:e,agentName:s,since:`asked ${mc(t.asked_at,r)} ago`}),open:n.jsx("a",{href:Vs(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:a&&(l=>a(e.run_id,t,l))})})}function nD(e){var t;return((t=e.run.pending)==null?void 0:t.kind)==="budget"?n.jsx(sD,{run:e.run,pending:e.run.pending,agentName:e.agentName}):n.jsx(rD,{...e})}function sD({run:e,pending:t,agentName:s}){return n.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[n.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[n.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:s}),n.jsx("a",{href:Vs(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:mn(e)})]}),n.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:tN(t)}),typeof t.said=="string"&&n.jsx("p",{className:"mt-1 text-prose leading-snug",children:t.said}),n.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:n.jsx("a",{href:Vs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function lx({run:e,agentName:t,since:s}){return n.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[n.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:t}),n.jsx("a",{href:Vs(e.run_id),className:"min-w-0 truncate text-muted-foreground hover:text-foreground",children:mn(e)}),s&&n.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function rD({run:e,agentName:t,at:s,onAnswer:r}){var j;const a=((j=e.pending)==null?void 0:j.kind)==="question"?e.pending:null,l=(a==null?void 0:a.question)??"",c=CL(l),[u,f]=x.useState(""),[p,g]=x.useState(!1),[v,h]=x.useState(null),[m,b]=x.useState(null),w=async N=>{N.preventDefault();const R=u.trim();if(!R||p)return;g(!0),h(null);const $=await r(e.run_id,R);g(!1),$?h($):b(R)};return n.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[n.jsx(lx,{run:e,agentName:t,since:a!=null&&a.asked_at?`asked ${mc(a.asked_at,s)} ago`:void 0}),n.jsx("p",{className:"mt-2 text-base leading-snug",children:l}),m?n.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",m," · ",n.jsx("a",{href:Vs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):n.jsxs("form",{onSubmit:N=>void w(N),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(N=>n.jsx("button",{type:"button",onClick:()=>f(N),className:oe("border px-3 py-1.5 text-body hover:border-border-strong",u===N?"border-warning text-warning-text":"border-border"),children:N},N)),n.jsx(Ue,{value:u,onChange:N=>f(N.target.value),"aria-label":`Answer ${t}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),n.jsx(V,{type:"submit",variant:"solid",size:"sm",disabled:p||!u.trim(),children:p?"Sending…":"Send"}),v&&n.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:v})]})]})}function oD({message:e,runs:t,agentName:s,at:r,onRunAgain:a}){const[l,c]=x.useState(!1),[u,f]=x.useState(null),[p,g]=x.useState(new Set),v=t.filter(N=>!p.has(N.run_id)),h=t.length-v.length,m=async()=>{c(!0),f(null);const{started:N,problem:R}=await a(v);c(!1),f(R),g($=>new Set([...$,...N]))},b=h>0&&n.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",h===1?"1 run":`${h} runs`]});if(!v.length)return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[n.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),n.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),b]});const w=v[0],j=v.length===1;return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[n.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[j?n.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[n.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(w.agent_id)}),n.jsx("a",{href:Vs(w.run_id),className:"min-w-0 truncate hover:underline",children:mn(w)})]}):n.jsxs("p",{className:"text-lead",children:[v.length," runs failed ",n.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(v.map(N=>s(N.agent_id)))].join(", ")]})]}),n.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&n.jsxs("details",{className:"mt-1 text-body",children:[n.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),n.jsx("ul",{className:"mt-1 space-y-1",children:v.map(N=>n.jsxs("li",{children:[n.jsx("a",{href:Vs(N.run_id),className:"hover:underline",children:mn(N)})," ",n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["· ",s(N.agent_id)]})]},N.run_id))})]}),u&&n.jsx("p",{className:"mt-1 font-mono text-small text-destructive-text",role:"alert",children:u})]}),n.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:[mc(w.ended_at??w.created_at,r)," ago"]}),b,n.jsx(V,{type:"button",size:"sm",disabled:l,onClick:()=>void m(),children:j?"Run again":"Run all again"})]})}function aD({run:e,agentName:t,at:s,onStop:r}){var g;const[a,l]=x.useState(!1),[c,u]=x.useState(null),f=(g=e.cost)==null?void 0:g.usd,p=f===0?"nothing spent yet":typeof f=="number"?`${go(e.cost)} so far`:Si(e.cost)?go(e.cost):"cost not known yet";return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[n.jsx("span",{className:"size-2 shrink-0 bg-run-active ring-4 ring-run-active/[0.18]","aria-hidden":!0}),n.jsx("span",{className:"shrink-0 font-mono text-small",children:t}),n.jsx("a",{href:Vs(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:mn(e)}),n.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",fi(s-Date.parse(e.created_at))]}),n.jsx("span",{className:"font-mono text-small text-muted-foreground",children:p}),n.jsx("a",{href:Vs(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),ic(e.status,e.state,e.kind,ac,!0,e.error,e.review).canStop?n.jsx(V,{type:"button",size:"sm",disabled:a,onClick:async()=>{l(!0),u(await r(e.run_id)),l(!1)},children:"Stop"}):n.jsx("a",{href:Vs(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Open to cancel"}),c&&n.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:c})]})}function iD({keyCard:e=!1}){const t="font-mono text-small text-foreground";return n.jsxs("div",{className:"border bg-background p-5",children:[n.jsxs("p",{className:"flex items-center gap-2 text-base font-semibold",children:[n.jsx(Qo,{className:"size-4 text-primary-text","aria-hidden":!0}),"Add a model key"]}),n.jsx("p",{className:"mt-2 max-w-prose text-lead leading-relaxed text-muted-foreground",children:e?"Add a model key in the card above, and the templates here run in one click.":n.jsxs(n.Fragment,{children:["This server has no model to run an agent on yet. Start agentrun-serve with the model to run in its environment, ",n.jsx("span",{className:t,children:"AGENT_MODEL"}),"=provider/model-id, and that provider's key (",n.jsx("span",{className:t,children:"ANTHROPIC_API_KEY"}),", ",n.jsx("span",{className:t,children:"OPENAI_API_KEY"})," or ",n.jsx("span",{className:t,children:"OPENROUTER_API_KEY"}),"). Or name a gateway: ",n.jsx("span",{className:t,children:"AGENT_MODEL_BASE_URL"})," and ",n.jsx("span",{className:t,children:"AGENT_MODEL_API_KEY"}),", with the gateway's model in ",n.jsx("span",{className:t,children:"AGENT_MODEL"}),". Then reload this page, and the templates here run in one click."]})})]})}const lD=[{id:"hello",name:"Hello, AgentRun",shows:"Writes a file, then answers",description:"A first agent: writes hello.md and answers in one line.",instructions:"You are a friendly first agent on this machine. Do what the person asks, briefly and plainly.",tools:["write"],input:"Write hello.md listing three things you could help me with on this machine, then answer in one line."},{id:"web",name:"Summarize a web page",shows:"Reads the web, then sums it up",description:"Reads a public web page and sums it up in three bullets.",instructions:"Read the page you are given and summarize it in three short bullets, then name the one thing worth remembering.",tools:["web_fetch"],input:"Summarize https://en.wikipedia.org/wiki/Hacker_News in three bullets."},{id:"plan",name:"Plan a task",shows:"Thinks it through, no tools",description:"Turns a goal into steps, risks and a first move.",instructions:"Turn the goal you are given into a short plan: the steps in order, the main risks, and what to do first. Keep it to one screen.",tools:[],input:"Plan a weekend launch of a small side project: the steps, the risks, and what to do first."}];function CS(e){var r;const t=["pi","claude-agent","codex"],s=e.filter(a=>a.available&&a.default_model);return s.sort((a,l)=>(t.indexOf(a.id)+1||99)-(t.indexOf(l.id)+1||99)),((r=s[0])==null?void 0:r.id)??null}function cD(e,t,s){const r=hf(t,[...s]).filter(l=>l.available).map(l=>l.name),a=e.tools.find(l=>!r.includes(l));return a?{ok:!1,reason:`${a} can't run on this server yet`}:{ok:!0}}async function uD(e,t,s,r=Ks()){const l=(await ao(p=>e.listAgents({cursor:p}),p=>p.agents)).find(p=>p.definition.name===t.name&&!p.archived_at),c=(l==null?void 0:l.agent_id)??(await e.createAgent({definition:{version:1,name:t.name,description:t.description,instructions:t.instructions,harness:s,tools:t.tools,skills:[]}})).agent_id,u={input:{content:t.input}},{run:f}=await e.startRun(c,u,r.keyFor(t.name,u));return r.done(),f.run_id}const dD={hello:gi,web:L0,plan:G_};function fD({harnesses:e,tools:t,onTry:s,imported:r=0,keyCard:a=!1}){const[l,c]=x.useState(null),[u,f]=x.useState(null),p=CS(e),g=async v=>{c(v.id),f(null);const h=await s(v);c(null),f(h)};return n.jsxs("section",{"aria-label":"Start here",className:"space-y-4",children:[n.jsxs("div",{className:"border border-primary/50 bg-primary/5 p-6",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"Start here"}),n.jsx("h2",{className:"mt-2 text-xl font-semibold",children:"Watch an agent work in about ten seconds"}),n.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:p?"Pick one: it makes the agent, runs it, and opens the run as it happens.":"First a model to run on; then one click makes an agent, runs it, and opens the run as it happens."}),n.jsxs("div",{className:"mt-5",children:[p?n.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:lD.map(v=>{const h=cD(v,p,t),m=dD[v.id]??gi;return n.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[n.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[n.jsx(m,{className:"size-4 text-primary-text","aria-hidden":!0}),v.name]}),n.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:v.shows}),n.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:v.description}),h.ok?n.jsx(V,{type:"button",variant:v.id==="hello"?"solid":"outline",size:"sm",className:"mt-4 self-start",disabled:l!==null,onClick:()=>void g(v),children:l===v.id?"Starting…":"Try it"}):n.jsx("p",{className:"mt-4 font-mono text-small text-muted-foreground",children:h.reason})]},v.id)})}):n.jsx(iD,{keyCard:a}),u&&n.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:u})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border px-5 py-4",children:[n.jsxs("p",{className:"text-lead",children:["Or ",n.jsx("a",{href:"#/agents/new",className:"text-primary-text underline-offset-4 hover:underline",children:"Create your own"}),": name it, say what it does, pick its tools."]}),r>0&&n.jsxs("p",{className:"text-lead text-muted-foreground",children:[r," imported sessions to read · ",n.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse them"})]})]})]})}const mD=(e,t)=>e instanceof Ee?{status:e.status,ms:t,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:t,body:{error:{code:"network",message:String(e)}}};function pD({agents:e,revisions:t=[],efforts:s,origin:r,agentId:a,onAgent:l,onSend:c,onOpenRun:u,result:f=null,live:p,limits:g,upload:v=V1,removeUpload:h}){var Fe;const[m,b]=x.useState(a??((Fe=e[0])==null?void 0:Fe.agent_id)??"");x.useEffect(()=>{var fe;a&&a!==m&&e.some(Le=>Le.agent_id===a)?b(a):e.some(Le=>Le.agent_id===m)||b(((fe=e[0])==null?void 0:fe.agent_id)??"")},[e,a]);const w=e.find(fe=>fe.agent_id===m),j=(w==null?void 0:w.kind)??"agentic",[N,R]=x.useState(""),$=j==="workflow"?cN(w==null?void 0:w.definition.workflow):null,S=x.useRef("");x.useEffect(()=>{if(N.trim()&&N!==S.current)return;const fe=($==null?void 0:$.text)??"";S.current=fe,R(fe)},[m,$==null?void 0:$.text]);const[E,C]=x.useState(""),[T,A]=x.useState(""),[F,L]=x.useState(""),[z,W]=x.useState(""),[U,D]=x.useState("form"),[K,P]=x.useState(f?"response":"code"),[G,I]=x.useState("curl"),[Y,q]=x.useState(!1),[O,B]=x.useState(f),ee=x.useMemo(()=>{var He,It;const fe=O&&O.status>=400?(He=O.body)==null?void 0:He.error:void 0;if(!fe||typeof fe.message!="string")return;const Le=Array.isArray(fe.fields)?fe.fields.filter(We=>!!We&&typeof We.field=="string"&&typeof We.message=="string"&&We.message!==fe.message):[];return{message:fe.message,more:Le,box:typeof((It=fe.details)==null?void 0:It.box)=="string"?fe.details.box:void 0,details:fe.code==="agent_not_runnable"?fe.details:void 0}},[O]),[le,ie]=x.useState(!1),ue=x.useMemo(()=>Ks(),[]),ae=K1({upload:v,remove:h,limits:g,frozen:le}),ce=iN(j,{text:N,revision:E,effort:T,maxCostUsd:F,fileIds:ae.fileIds,repo:z}),he=ce.ok?ce.body:{input:j==="agentic"?{content:N}:N,...ae.fileIds.length?{file_ids:ae.fileIds}:{}},et=m?ue.keyFor(m,he):"",se=G==="curl"?I5(r,m,he,et):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${m||"{agent_id}"}/runs`)}, {
554
+ method: "POST",
555
+ headers: {
556
+ Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
557
+ "Content-Type": "application/json",
558
+ "Idempotency-Key": ${JSON.stringify(et)},
559
+ },
560
+ body: JSON.stringify(${JSON.stringify(he,null,2).replace(/\n/g,`
561
+ `)}),
562
+ });
563
+ console.log(res.status, await res.json());`,ke=async()=>{if(!ce.ok||!c||ae.busy)return;ie(!0);const fe=await uN(ue,m,ce.body,c);ie(!1),B(fe),P("response"),q(!0),fe.status>=200&&fe.status<300&&ae.clear()},Se=j==="agentic"?"The run's first message, e.g. Summarize the standup: we ship Friday.":'{ "subject": "...", "body": "..." }';return n.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{"aria-label":"Playground agent",className:"flex shrink-0 flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[e.length>0&&n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[n.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),n.jsx(Lt,{id:"playground-agent",label:"Agent",placeholder:"Pick an agent",value:m,onChange:fe=>{b(fe),C(""),l==null||l(fe)},options:tf(e).map(fe=>({value:fe.agent_id,label:fe.definition.name})),className:"w-56 max-w-[60vw]"})]}),n.jsxs("span",{className:"font-mono text-small",children:[n.jsx("span",{className:"text-primary-text",children:"POST"})," ",n.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",m||"{agent_id}","/runs"]})]}),n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"caps text-label text-muted-foreground",children:"Live API"}),n.jsx(V,{type:"button",size:"xs",onClick:()=>q(fe=>!fe),"aria-expanded":Y,className:"hidden text-muted-foreground hover:text-foreground short:inline-flex",children:Y?"Hide code":"Show code"})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:[@media(min-height:501px)]:grid-cols-2",children:[n.jsx("section",{"aria-label":"Request",className:oe("flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",Y&&"short:hidden"),children:e.length===0?n.jsxs(n.Fragment,{children:[n.jsx("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:n.jsx("span",{className:"pb-1 text-lead font-semibold",children:"Request"})}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[n.jsxs("div",{className:"border border-primary/50 bg-primary/5 p-5",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"No agents yet"}),n.jsx("h2",{className:"mt-2 text-xl font-semibold",children:"Start a run"}),n.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Runs start from an agent. Make one, then send its first request here."}),n.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[n.jsx("a",{href:"#/agents/new",className:mi({variant:"solid",size:"lg"}),children:"Create an agent"}),n.jsx("a",{href:"#/templates",className:mi({variant:"outline",size:"lg"}),children:"Browse templates"})]})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"caps text-label text-muted-foreground",children:"What a request takes"}),n.jsx("dl",{className:"mt-3 divide-y border-y",children:Object.entries(Wo).map(([fe,Le])=>n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 py-3",children:[n.jsx("dt",{className:"w-40 font-mono text-body",children:fe}),n.jsx("dd",{className:"text-small text-muted-foreground",children:Le})]},fe))})]})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[n.jsx("span",{className:"text-lead font-semibold",children:"Request"}),n.jsx("span",{className:"flex gap-4 text-small",children:["form","json"].map(fe=>n.jsx("button",{type:"button",onClick:()=>D(fe),className:oe("border-b pb-1 capitalize",U===fe?"border-foreground":"border-transparent text-muted-foreground"),children:fe==="json"?"JSON":"Form"},fe))})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),n.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[w?`${w.definition.name}: ${j==="agentic"?"an":"a"} ${j} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),U==="json"?n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.7]",children:JSON.stringify(he,null,2)}),n.jsx(Ho,{name:"file_ids",note:Wo.file_ids,children:n.jsx(ph,{attachments:ae,limits:g})})]}):n.jsxs(n.Fragment,{children:[n.jsxs(Ho,{name:j==="agentic"?"input.content":"input",required:!0,error:!ce.ok&&ce.field==="input"&&N?ce.message:void 0,children:[n.jsx(As,{value:N,onChange:fe=>R(fe.target.value),rows:j==="agentic"?4:7,placeholder:Se}),$&&n.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[lN($,"start"),$.fields.length>0&&n.jsxs(n.Fragment,{children:[" Fields: ",$.fields.map((fe,Le)=>n.jsxs("span",{title:fe.note,children:[Le?", ":"",n.jsx("span",{className:"text-foreground",children:fe.name})]},fe.name)),"."]})]})]}),n.jsx(Ho,{name:"file_ids",note:Wo.file_ids,children:n.jsx(ph,{attachments:ae,limits:g})}),n.jsx(Ho,{name:"revision",note:Wo.revision,children:n.jsx(Lt,{label:"Revision",value:E,onChange:C,className:"w-full",options:[{value:"",label:"The current revision"},...t.map(fe=>({value:fe.revision,label:`rev ${fe.version}${fe.current?" (current)":""}${fe.note?`: ${fe.note}`:""}`}))]})}),n.jsx(Ho,{name:"effort",note:Wo.effort,children:n.jsx("div",{className:"flex gap-2",children:["",...s].map(fe=>n.jsx(V,{type:"button",size:"sm","aria-pressed":T===fe,onClick:()=>A(fe),className:T===fe?"border-foreground hover:border-foreground":"text-muted-foreground",children:fe||"default"},fe||"default"))})}),j==="agentic"&&n.jsx(Ho,{name:"repo",note:Wo.repo,error:!ce.ok&&ce.field==="repo"?ce.message:void 0,children:n.jsx(Ue,{value:z,onChange:fe=>W(fe.target.value),placeholder:"owner/name"})}),j==="agentic"&&n.jsxs(Ho,{name:"max_cost_usd",note:Wo.max_cost_usd,error:!ce.ok&&ce.field==="max_cost_usd"?ce.message:void 0,children:[n.jsx(Ue,{value:F,onChange:fe=>L(fe.target.value),inputMode:"decimal",placeholder:"e.g. 0.50"}),n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:n.jsx(PN,{})})]})]})]}),n.jsxs("footer",{className:"flex shrink-0 items-center justify-between gap-3 border-t px-5 py-3 md:px-6",children:[n.jsx("span",{className:"text-small text-muted-foreground",children:"Sends a real request to this server."}),n.jsxs(V,{variant:"primary",size:"lg",onClick:ke,disabled:!ce.ok||!c||le||!m||ae.busy,title:ae.busy?"Waiting for the files to be sent":void 0,children:[n.jsx(yi,{"aria-hidden":!0})," ",le?"Sending":"Send request"]})]})]})}),n.jsxs("section",{"aria-label":"Code and response",className:oe("flex min-h-0 flex-col",!Y&&"short:hidden"),children:[n.jsxs("header",{className:"flex items-center justify-between border-b px-5 py-3 md:px-6",children:[n.jsxs("span",{className:"flex gap-4 text-body",children:[n.jsx("button",{type:"button",onClick:()=>P("code"),className:oe("border-b pb-1",K==="code"?"border-foreground":"border-transparent text-muted-foreground"),children:"Code"}),n.jsxs("button",{type:"button",onClick:()=>P("response"),disabled:!O,className:oe("border-b pb-1 disabled:opacity-45",K==="response"?"border-foreground":"border-transparent text-muted-foreground"),children:["Response",O&&n.jsx("span",{className:oe("ml-2 font-mono",O.status<300?"text-success-text":"text-destructive-text"),children:O.status})]})]}),K==="code"&&n.jsx(V,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var fe;return void((fe=navigator.clipboard)==null?void 0:fe.writeText(se))},children:n.jsx(Id,{"aria-hidden":!0})})]}),K==="code"?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex gap-5 border-b px-5 text-small md:px-6",children:["curl","fetch"].map(fe=>n.jsx("button",{type:"button",onClick:()=>I(fe),className:oe("-mb-px border-b-2 py-2.5",G===fe?"border-primary":"border-transparent text-muted-foreground"),children:fe==="curl"?"cURL":"JavaScript"},fe))}),n.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:se}),n.jsx("footer",{className:"border-t px-5 py-3 text-small text-muted-foreground md:px-6",children:"The same request from your code: set AGENTRUN_API_KEY in your environment."})]}):O&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small md:px-6",children:[n.jsx("span",{className:O.status<300?"text-success-text":"text-destructive-text",children:O.status})," ",n.jsxs("span",{className:"text-muted-foreground",children:[O.ms," ms"]})]}),ee&&n.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small text-destructive-text md:px-6",role:"alert",children:["The run did not start: ",ee.message,ee.box?n.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",ee.box,")"]}):null,n.jsx(eN,{agentId:m,details:ee.details}),ee.more.length>0&&n.jsx("span",{className:"mt-1 block",children:ee.more.map(fe=>n.jsxs("span",{className:"block",children:[fe.field,": ",fe.message]},`${fe.field}:${fe.message}`))})]}),O.runId&&p?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden border-b short:overflow-auto",children:p(O.runId)}),n.jsxs("details",{className:"border-b px-5 py-2.5 md:px-6",children:[n.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Response body"}),n.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words py-3 font-mono text-small leading-[1.8]",children:JSON.stringify(O.body,null,2)})]})]}):n.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:JSON.stringify(O.body,null,2)}),O.runId&&n.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(O.runId),className:"caps flex items-center justify-between border-t px-5 py-4 text-small text-primary-text hover:bg-accent md:px-6",children:["Open this run ",n.jsx(Dh,{className:"size-4","aria-hidden":!0})]})]})]})]})]})}const Wo={"input.content":"Required. The run's first message.",file_ids:"Empty names none.",revision:"Empty runs the current revision.",effort:"How hard the model thinks. Empty uses the agent's own.",max_cost_usd:"A spend cap in dollars; empty means none.",repo:"The GitHub repository the run reaches, owner/name. It must be one the agent is bound to; empty takes the agent's one repository."};function Ho({name:e,required:t,note:s,error:r,children:a}){return n.jsxs("div",{children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[n.jsx("span",{className:"font-mono text-body",children:e}),t&&n.jsx("span",{className:"text-label text-muted-foreground",children:"required"})]}),a,s&&n.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:s}),r&&n.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:r})]})}const TS=["queued","working","paused","input_required","completed","failed","cancelled"],hD={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function gD({runs:e,agentName:t,onOpen:s,error:r,onRetry:a,onMore:l,loadingMore:c,filter:u={},onFilter:f}){const p=!!u.archived;return n.jsxs("div",{className:"p-5 md:p-8",children:[n.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[n.jsx("h1",{className:"mr-auto font-mono text-2xl font-semibold",children:p?"Archived runs":"Runs"}),f&&n.jsxs(n.Fragment,{children:[n.jsx(Lt,{label:"Runs in one state",value:u.status??"",onChange:g=>f({...u,status:g||void 0}),className:"h-11 w-48",options:[{value:"",label:"Any state"},...TS.map(g=>({value:g,label:hD[g]}))]}),n.jsxs(V,{size:"lg",variant:p?"primary":"outline","aria-pressed":p,onClick:()=>f({...u,archived:!p}),children:[n.jsx(Kl,{"aria-hidden":!0})," Archived"]})]})]}),r&&!e?n.jsx(Mn,{problem:r,onRetry:a,className:""}):e?e.length?n.jsx(yD,{runs:e,agentName:t,onOpen:s}):u.status||p?n.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:u.status?"No run matches.":"No archived runs."}):n.jsx(xD,{}):n.jsx(Os,{label:"Loading the runs"}),e&&r&&n.jsx(Mn,{problem:r,className:"mt-4"}),e&&l&&n.jsx("div",{className:"mt-4 flex justify-center",children:n.jsx(V,{type:"button",onClick:l,disabled:c,size:"sm",children:c?"Loading":"Load more"})})]})}function xD(){return n.jsxs("section",{"aria-labelledby":"first-run",className:"border border-primary/50 bg-primary/5 p-5",children:[n.jsx("p",{className:"caps text-label text-primary-text",children:"No runs yet"}),n.jsx("h2",{id:"first-run",className:"mt-2 text-xl font-semibold",children:"Start your first run"}),n.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A run is one piece of work an agent does: a question answered, a page researched, a file written. Each one is listed here with its state, when it started and what it cost."}),n.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[n.jsxs("a",{href:"#/playground",className:mi({variant:"solid",size:"lg"}),children:[n.jsx(yi,{"aria-hidden":!0})," Start a run"]}),n.jsx("a",{href:"#/templates",className:mi({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function yD({runs:e,agentName:t,onOpen:s}){return n.jsxs("table",{className:"w-full border-collapse border text-body",children:[n.jsx("thead",{className:"hidden md:table-header-group",children:n.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Status","Run","Agent","Kind","Started","Cost"].map(r=>n.jsx("th",{className:"border-b px-3 py-2 text-left font-normal",children:r},r))})}),n.jsx("tbody",{children:e.map(r=>n.jsxs("tr",{className:"cursor-pointer border-b hover:bg-accent",onClick:()=>s(r.run_id),children:[n.jsx("td",{className:"px-3 py-2.5 align-top",children:n.jsx(lc,{run:r})}),n.jsxs("td",{className:"px-3 py-2.5 align-top",children:[n.jsxs("button",{type:"button",className:"flex items-start gap-1 text-left",onClick:a=>{a.stopPropagation(),s(r.run_id)},children:[n.jsx("span",{className:"line-clamp-2",children:mn(r)}),n.jsx(O_,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),r.status==="completed"&&r.review&&n.jsx("span",{className:"mt-1 block text-small text-warning-text",children:r.review.reason}),r.trigger&&n.jsx("span",{className:"mt-1 flex",children:n.jsx(GN,{run:r})}),n.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[t(r.agent_id)," · ",ft(r.created_at)]})]}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top md:table-cell",children:t(r.agent_id)}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:r.kind}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:ft(r.created_at)}),n.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:go(r.cost,{ended:ra(r.status)})})]},r.run_id))})]})}const bD=["system","light","dark"],Ph="agentrun.theme",vD="(prefers-color-scheme: dark)",kf=()=>{try{return globalThis.localStorage??null}catch{return null}},RS=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(vD):null;let Lh=null;function wD(e=kf()){try{const t=e==null?void 0:e.getItem(Ph);return t==="light"||t==="dark"?t:"system"}catch{return"system"}}const Ih=(e=kf())=>Lh??wD(e);function kD(e,t=kf()){Lh=null;try{e==="system"?t==null||t.removeItem(Ph):t==null||t.setItem(Ph,e)}catch{Lh=e}}function zh(e,t=document.documentElement,s=RS()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);t.classList.toggle("dark",r),t.classList.toggle("light",!r)}function jD(e=document.documentElement,t=RS(),s=kf()){zh(Ih(s),e,t);const r=()=>{Ih(s)==="system"&&zh("system",e,t)};return t==null||t.addEventListener("change",r),()=>t==null?void 0:t.removeEventListener("change",r)}const ND=[{id:"mission",label:"Mission Control",Icon:B_},{id:"playground",label:"Playground",Icon:W0},{id:"agents",label:"Agents",Icon:Fh},{id:"templates",label:"Templates",Icon:I0},{id:"runs",label:"Runs",Icon:Hh},{id:"triggers",label:"Triggers",Icon:Pd},{id:"settings",label:"Settings",Icon:D0}],SD={system:["System",xi],light:["Light",a$],dark:["Dark",Z_]};function _D(){const[e,t]=x.useState(()=>Ih()),s=r=>{kD(r),zh(r),t(r)};return n.jsx("div",{role:"group","aria-label":"Theme",className:"flex border",children:bD.map(r=>{const[a,l]=SD[r];return n.jsx("button",{type:"button","aria-label":a,title:a,"aria-pressed":e===r,onClick:()=>s(r),className:oe("flex flex-1 items-center justify-center py-2 hover:bg-accent",e===r&&"bg-primary/[0.06] text-primary-text"),children:n.jsx(l,{className:"size-4","aria-hidden":!0})},r)})})}function k0(){return n.jsxs("span",{className:"whitespace-nowrap font-mono text-figure font-semibold","aria-label":"AgentRun",children:["agent",n.jsx("span",{className:"text-primary-text",children:".run()"})]})}function $D({active:e,settings:t=!1,triggers:s=!1,onNavigate:r,onSignOut:a,onSignOutEverywhere:l,banners:c,children:u}){const[f,p]=x.useState(!1),[g,v]=x.useState(!1),h=x.useRef(null),m=x.useRef(null),b=x.useRef(!1);x.useEffect(()=>{var j,N;g?(j=m.current)==null||j.focus():b.current&&((N=h.current)==null||N.focus())},[g]);const w=()=>{b.current=!0,v(!1)};return n.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[n.jsxs("header",{className:"flex shrink-0 items-center justify-between border-b px-4 py-3 roomy:hidden",children:[n.jsx(k0,{}),n.jsx(V,{size:"icon",className:"size-9 [&_svg]:size-[18px]","aria-label":"Navigation","aria-expanded":f,onClick:()=>p(j=>!j),children:n.jsx(X_,{"aria-hidden":!0})})]}),n.jsxs("aside",{className:oe("shrink-0 flex-col border-r bg-background px-3 pb-4 pt-6 roomy:flex roomy:h-dvh roomy:w-sidebar roomy:overflow-y-auto",f?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[n.jsx("div",{className:"hidden px-3 pb-[30px] roomy:block",children:n.jsx(k0,{})}),n.jsx("nav",{"aria-label":"Navigation",className:"flex flex-col gap-1",children:ND.filter(j=>(j.id!=="settings"||t)&&(j.id!=="triggers"||s)).map(({id:j,label:N,Icon:R})=>n.jsx(xA,{icon:R,active:e===j,onClick:()=>{r==null||r(j),p(!1)},children:N},j))}),n.jsx("div",{className:"mt-4 roomy:mt-auto",children:n.jsx(_D,{})}),n.jsxs(V,{type:"button",onClick:a,className:"mt-2 justify-start gap-2.5 px-3",children:[n.jsx(V_,{"aria-hidden":!0})," Sign out"]}),l&&(g?n.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:j=>{j.key==="Escape"&&w()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[n.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(V,{type:"button",variant:"destructive",size:"xs",onClick:()=>{v(!1),l()},children:"Sign out everywhere"}),n.jsx(V,{type:"button",ref:m,onClick:w,size:"xs",children:"Cancel"})]})]}):n.jsx("button",{type:"button",ref:h,onClick:()=>v(!0),className:"mt-1 px-3 py-1.5 text-left text-small text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]}),n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[n.jsx(eI,{}),c,n.jsx("main",{className:"relative min-h-0 min-w-0 flex-1 overflow-auto",children:u})]})]})}const zp={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},j0={sign_in:{title:"Sign in",body:"Sign in to make agents, start runs and follow them on this server."},setup:{title:"Start building",body:"This is the server's first visit: set the owner's password. You sign in with it from now on."},token_link:{title:"Open the server's link",body:"This server has no accounts. Open the link it printed when it started: it signs this browser in, and its code leaves the address."}};function ED({mode:e,code:t=null,codeNeeded:s=!1,onSubmit:r,problem:a=null,offer:l=null}){const[c,u]=x.useState(""),[f,p]=x.useState(!1),[g,v]=x.useState(""),[h,m]=x.useState(t??"");x.useEffect(()=>{t!==null&&m(t)},[t]);const[b,w]=x.useState(a),[j,N]=x.useState(!1),R=e==="setup",$=R&&l!==null&&!("sessions"in l&&l.sessions===0),S=R&&(s||t!==null),E=e!=="token_link"&&c.length>0&&(!R||c===g&&c.length>=12)&&(!S||h.trim()!==""),C=async()=>{if(!E||!r)return;N(!0);const T=await r(c,S&&h.trim()?h.trim():void 0,R&&$&&f);N(!1),w(T)};return n.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:n.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[n.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[n.jsx(Rs,{className:"size-5 text-primary-text","aria-hidden":!0}),n.jsxs("span",{children:["agent",n.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),n.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:j0[e].title}),n.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:j0[e].body}),e!=="token_link"&&n.jsxs("form",{className:"space-y-5",onSubmit:T=>{T.preventDefault(),C()},children:[S&&n.jsx(Bs,{label:"Setup code",id:"setup-code",hint:"On Render: paste the server's AGENTRUN_TOKEN from the service's Environment tab. Elsewhere: paste the setup code the server printed in its log, or open the link it prints.",children:n.jsx(Ue,{name:"setup-code",value:h,onChange:T=>m(T.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),n.jsx(Bs,{label:zp[e].label,hint:R?"12 characters or more.":void 0,children:n.jsxs("span",{className:oe("flex items-center gap-3 px-3",Oj),children:[n.jsx(Qo,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.jsx(Ue,{bare:!0,type:"password",value:c,onChange:T=>u(T.target.value),autoComplete:zp[e].autocomplete,autoFocus:!0,"aria-label":zp[e].label,className:"h-control-md flex-1 text-lead"})]})}),R&&n.jsx(Bs,{label:"Again",hint:g&&g!==c?"The two passwords differ.":void 0,children:n.jsx(Ue,{type:"password",value:g,onChange:T=>v(T.target.value),autoComplete:"new-password","aria-label":"Password again",className:"text-lead"})}),$&&n.jsxs("label",{className:"flex items-start gap-3 text-lead",children:[n.jsx("input",{type:"checkbox",name:"import",checked:f,onChange:T=>p(T.target.checked),className:"mt-1 size-4 accent-primary"}),n.jsxs("span",{children:[n.jsx("span",{className:"block",children:"Import this machine's Claude Code, Codex and pi sessions"}),n.jsx("span",{className:"mt-1 block text-small text-muted-foreground","aria-live":"polite",children:CD(l)})]})]}),n.jsx(V,{type:"submit",variant:"solid",disabled:!E||j,"aria-busy":j||void 0,className:"w-full text-body",children:j?"Signing in":R?"Set password and continue":"Continue"}),b&&n.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:b}),!R&&n.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",n.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",n.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",n.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",n.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const N0=(e,t)=>`${e.toLocaleString("en-US")} ${t}${e===1?"":"s"}`,Dp="Each project becomes an agent, each session a run you can read.";function CD(e){return"counting"in e?`Counting sessions… ${Dp}`:e.sessions===null||e.projects===null?`The count isn't known. ${Dp}`:`${N0(e.sessions,"session")} in ${N0(e.projects,"project")}. ${Dp}`}function TD({problem:e,starting:t=!1,onRetry:s}){return n.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:n.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[n.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[n.jsx(Rs,{className:"size-5 text-primary-text","aria-hidden":!0}),n.jsxs("span",{children:["agent",n.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),n.jsx("h1",{className:"mb-3 mt-8 text-2xl",children:t?"This server is starting":"Can't read this server's sign-in"}),n.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:t?"Its address answers for it until it is up (a first start, a redeploy or a wake can take a minute or two). Trying again…":"The page asked the server whether it has its owner yet, and got no answer it could read, so it can't show setup or sign-in. It asks again on its own."}),n.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),n.jsx(V,{type:"button",variant:"solid",onClick:s,className:"w-full text-body",children:"Retry now"})]})})}const AS=e=>{var t;return e.status===200&&((t=e.body)==null?void 0:t.accounts)===!1};function RD(e,t){if(AS(e))return t===200?"signed_in":"token_link";const s=e.body??{};return s.signed_in?"signed_in":s.password_set?"sign_in":"setup"}const AD=e=>{var t;return e.status===200&&((t=e.body)==null?void 0:t.setup_code)===!0};function OD(e){var t,s;if(e.status===401)return"That is not the password.";if(e.status===429){const r=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Too many sign-ins. Try again in ${r===1?"a second":r>=60?"a minute":`${r} seconds`}.`}return e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.status===403&&/a new one is in the server's log/.test(e.message)?"That setup code expired or was voided after too many wrong tries: a new one is in the server's log (on Render, the Logs tab).":e.status===403&&/takes the setup code/.test(e.message)?"Enter the setup code from the server's log.":e.status===403&&/setup code/.test(e.message)?"That setup code was refused: open the newest setup link in the server's log, or paste the server's token (AGENTRUN_TOKEN) here.":((s=(t=e.fields)==null?void 0:t[0])==null?void 0:s.message)??e.message}function OS(e){const t=new URLSearchParams(e.startsWith("#")?e.slice(1):e),s=t.get("code");if(s===null)return{code:null,rest:e};t.delete("code");const r=t.toString();return{code:/^[A-Za-z0-9_-]*/.exec(s)[0],rest:r?`#${r}`:""}}const MD=1e4;function S0(e=location.hash){let t=e.match(/^#\/runs\/([^/?]+)$/);if(t)return{section:"runs",run:decodeURIComponent(t[1])};if(e==="#/agents/new")return{section:"agents",agent:null};if(t=e.match(/^#\/agents\/([^/?]+)\/learning\?(.*)$/),t)return{section:"agents",agent:decodeURIComponent(t[1]),tab:"learning",notes:new URLSearchParams(t[2]).getAll("note")};if(t=e.match(/^#\/agents\/([^/?]+)\/edit\?(.*)$/),t){const l=new URLSearchParams(t[2]).get("tool");return{section:"agents",agent:decodeURIComponent(t[1]),edit:!0,...l?{tool:l}:{}}}if(t=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),t)return{section:"agents",agent:decodeURIComponent(t[1]),...t[2]==="edit"?{edit:!0}:t[2]?{tab:t[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground"))return{section:"playground"};if(t=e.match(/^#\/templates\/([^/?]+)$/),t)return{section:"templates",template:decodeURIComponent(t[1])};if(e.startsWith("#/templates"))return{section:"templates"};if(e==="#/triggers/new")return{section:"triggers",trigger:null,kind:"schedule"};if(e==="#/triggers/new-webhook")return{section:"triggers",trigger:null,kind:"webhook"};if(e==="#/triggers/new-github")return{section:"triggers",trigger:null,kind:"github"};if(t=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),t)return{section:"triggers",trigger:decodeURIComponent(t[1]),...t[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(t=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),t){const l=KO(t[1]);return{section:"settings",settings:"mcp",signIn:s5(t[1]),...l?{add:l}:{}}}if(t=e.match(/^#\/settings\/github(?:\?(.*))?$/),t){const l=oI(t[1]);return{section:"settings",settings:"github",...l?{github:l}:{}}}if(t=e.match(/^#\/settings(?:\/(keys|tools|computers|workspace|webhook))?$/),t)return{section:"settings",settings:t[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const s=new URLSearchParams(e.slice(7)),r=s.get("agent"),a=s.get("status");return{section:"runs",...r?{runsOf:r}:{},...a&&TS.includes(a)?{status:a}:{},...s.get("archived")==="true"?{archived:!0}:{}}}function PD({runsOf:e,status:t,archived:s}){const r=new URLSearchParams;return e&&r.set("agent",e),t&&r.set("status",t),s&&r.set("archived","true"),`#/runs${r.size?`?${r}`:""}`}let Fp;function LD(){if(!Fp){const{code:e,rest:t}=OS(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${t}`),Fp={code:e}}return Fp.code}const ID=e=>Math.min(1e3*2**e,3e4),MS=1e3,zD=30;function DD(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function FD(){const[e]=x.useState(HP),[t,s]=x.useState(null),[r,a]=x.useState(!1),l=x.useRef(null);l.current=t;const c=x.useRef(!1),u=x.useRef(async()=>{}),f=x.useMemo(()=>Y4({fetch:e.fetch,onSignedOut:()=>void u.current()}),[e]),[p,g]=x.useState(LD);x.useEffect(()=>{if(t!=="setup")return;const C=()=>{const{code:T,rest:A}=OS(location.hash);T!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${A}`),g(T))};return window.addEventListener("hashchange",C),C(),()=>window.removeEventListener("hashchange",C)},[t]);const[v,h]=x.useState(!1),m=async()=>{const C=await f.session(),T=AS(C)?await f.listAgents().then(()=>200,A=>A instanceof Ee?A.status:0):void 0;return{mode:RD(C,T),codeNeeded:AD(C)}},b=async()=>{const C=await m();return h(C.codeNeeded),C.mode},w=async()=>s(await b());u.current=async()=>{if(!(l.current!=="signed_in"||c.current)){c.current=!0;try{const C=await b();C!=="signed_in"&&l.current==="signed_in"&&(a(!0),s(C))}catch{}finally{c.current=!1}}};const[j,N]=x.useState(null),[R,$]=x.useState(0);x.useEffect(()=>{let C=!0,T;return m().then(A=>{!C||l.current!==null||(h(A.codeNeeded),s(A.mode),N(null))},A=>{if(!C||l.current!==null)return;const F=ID(R),L=A instanceof Ee?A:null,z=(L==null?void 0:L.code)==="http_error",W=z&&[502,503,504].includes(L.status);N({problem:L===null?Jt(A):W?`Its address answered ${L.status}, not the server.`:`GET /v2/auth/session answered ${L.status}${z?", not as this server answers":`: ${L.message}`}`,starting:W}),T=setTimeout(()=>$(U=>U+1),F)}),()=>{C=!1,clearTimeout(T)}},[f,R]);const[S,E]=x.useState(null);return x.useEffect(()=>{if(t!=="setup")return;let C=!0;return(async()=>{for(let T=!1;C;){const A=await f.setupImport().then(F=>F,()=>{});if(!C)return;if(A===void 0&&T)return void E({projects:null,sessions:null});if(A!==void 0&&(!A||!("counting"in A||"sessions"in A)||(E(A),T=!0,!("counting"in A))))return;await new Promise(F=>setTimeout(F,MS))}})(),()=>{C=!1}},[f,t]),t===null&&j!==null?n.jsx(TD,{problem:j.problem,starting:j.starting,onRetry:()=>$(C=>C+1)}):t===null?n.jsx(Qw,{connection:e,children:n.jsx(UD,{})}):t!=="signed_in"?n.jsx(ED,{mode:t,code:p,codeNeeded:v,offer:S,problem:r&&t==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async(C,T,A)=>{try{return await(t==="setup"?f.setup(C,T,A):f.signIn(C)),a(!1),s("signed_in"),null}catch(F){return F instanceof Ee&&F.status===403&&t==="setup"&&await w().catch(()=>{}),F instanceof Ee?OD(F):F instanceof Error?F.message:String(F)}}},t):n.jsx(Qw,{connection:e,children:n.jsx(WD,{v2:f,onSignedOut:()=>{a(!1),s("sign_in")}})})}function UD(){return Yg().state==="offline"?n.jsx(tI,{}):n.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function WD({v2:e,onSignedOut:t}){var ge,_e,pt,zt,Ve,Xt,ln,Ms,Ct,ko,Ar,jo,es,gc,Dn,xc,yc,bc,No,So,Or,_o;const{writable:s,whyNot:r}=GL(e),[a,l]=x.useState(null),[c,u]=x.useState(()=>S0()),[f,p]=x.useState(null),g=((_e=(ge=f==null?void 0:f.features)==null?void 0:ge.triggers)==null?void 0:_e.routes)===!0,[v,h]=x.useState(new Map);x.useEffect(()=>{if(!g)return;let xe=!0;return e.listTriggers().then(be=>{xe&&h(new Map(be.triggers.map(Te=>[Te.id,{name:Te.name,kind:Te.source.kind}])))},()=>{}),()=>{xe=!1}},[e,g,c.section,c.trigger]);const[m,b]=x.useState(null),[w,j]=x.useState(null),[N,R]=x.useState(0),[$,S]=x.useState("30d"),[E,C]=x.useState(null),[T,A]=x.useState(!1),[F,L]=x.useState(null),[z,W]=x.useState(null),[U,D]=x.useState(null),[K,P]=x.useState(0),G=x.useRef(null),[I,Y]=x.useState(!1),[q,O]=x.useState(!1),[B,ee]=x.useState(!1),[le,ie]=x.useState(null),[ue,ae]=x.useState(null),[ce,he]=x.useState(!1),[et,se]=x.useState({}),[ke,Se]=x.useState(!1),Fe=x.useRef(0),[fe,Le]=x.useState([]),He=x.useRef(-1),[It,We]=x.useState(null),[we,lt]=x.useState(0),jt=x.useRef(0),Nt=xe=>{Lu(xe)||(location.hash=xe)},[on,en]=x.useState(null),[Ot,Wt]=x.useState(0);x.useEffect(()=>{let xe=!0;return(async()=>{let be=!1;for(let Te=0;xe&&Te<zD;){const tt=await e.setupImport().then(Ye=>Ye,()=>{});if(!xe)return;if(tt===void 0)Te+=1;else{if(Te=0,!tt||!("state"in tt))return;if(en(tt),tt.state!=="running")return void(be&&Wt(Ye=>Ye+1));be=!0}await new Promise(Ye=>setTimeout(Ye,MS))}})(),()=>{xe=!1}},[e]),x.useEffect(()=>{const xe=()=>{const be=Yz();Lu(location.hash,()=>{be&&history.go(-be)})?be&&history.go(be):u(S0())};return window.addEventListener("hashchange",xe),()=>window.removeEventListener("hashchange",xe)},[]),x.useEffect(()=>Xz(),[]);const Et=x.useRef(0),ct=x.useRef(!1),Ie=()=>{const xe=++Et.current;return e.capabilities().then(be=>(xe===Et.current&&p(be),!0),()=>!1)};x.useEffect(()=>{Ie()},[e]),x.useEffect(()=>{if(Fe.current&&c.section!=="runs"&&c.section!=="mission"&&He.current===Ot)return;He.current=Ot;const xe=++Fe.current;Se(!1),Promise.allSettled([!1,!0].map(be=>ao(Te=>e.listAgents({archived:be,cursor:Te}),Te=>Te.agents))).then(be=>{if(xe!==Fe.current)return;const Te=Object.fromEntries(be.flatMap(Ye=>Ye.status==="fulfilled"?Ye.value:[]).map(Ye=>[Ye.agent_id,Ye.definition.name??Ye.agent_id])),tt=be.every(Ye=>Ye.status==="fulfilled");se(Ye=>tt?Te:{...Ye,...Te}),Se(tt)})},[e,c,Ot]);const st={status:c.status,archived:c.archived};x.useEffect(()=>{if(c.section!=="runs"||c.run)return;const xe=++jt.current;ie(null),We(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,st):e.listRuns(50,null,st)).then(be=>{xe===jt.current&&(ie(be.runs),ae(be.next_cursor))}).catch(be=>{xe===jt.current&&We(fn(be,"the runs"))})},[e,c,Ot,we]);const gt=xe=>{var be;return et[xe]??((be=Zn==null?void 0:Zn.find(Te=>Te.agent_id===xe))==null?void 0:be.definition.name)??(ke?xe:"")},Xe=f,St=(f==null?void 0:f.models.ready)===!1&&f.models.needs!=="model"&&!f.models.default&&f.models.source!=="gateway"&&!!((zt=(pt=f.features)==null?void 0:pt.tool_keys)!=null&&zt.routes),qt={harnesses:(Xe==null?void 0:Xe.harnesses)??[],tools:pP(Xe==null?void 0:Xe.tools),thinking:((Ve=Xe==null?void 0:Xe.features)==null?void 0:Ve.thinking)??[]},Ln=v5(Xe==null?void 0:Xe.tools),Kn=k5(Xe==null?void 0:Xe.tools),fs=[...(ln=(Xt=f==null?void 0:f.features)==null?void 0:Xt.tool_keys)!=null&&ln.routes?["keys"]:[],...Ln.length||Kn.length?["tools"]:[],"mcp","github","computers","workspace",...(Ct=(Ms=f==null?void 0:f.features)==null?void 0:Ms.webhooks)!=null&&Ct.routes?["webhook"]:[]],Xn=xe=>Nt({runs:"#/runs",agents:"#/agents",playground:"#/playground",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${fs[0]??"keys"}`}[xe]),Yn=x.useRef(Ks()).current,Qn=async xe=>{const be=CS(qt.harnesses);if(!be)return"This server has no model to run it on yet.";try{const Te=await uD(e,xe,be,Yn);return Nt(`#/runs/${encodeURIComponent(Te)}`),null}catch(Te){return Jt(Te)}},an=((m==null?void 0:m.analytics.by_source)??[]).filter(xe=>xe.source!=="live").reduce((xe,be)=>xe+be.runs,0),[Zn,dr]=x.useState(null),[yt,Q]=x.useState([]),[Ae,qe]=x.useState(null),[ut,xt]=x.useState(null),[Vt,Kt]=x.useState(0),mt=x.useRef(0);x.useEffect(()=>{if(c.section!=="playground")return;xt(null);const xe=++mt.current;ao(be=>e.listAgents({cursor:be}),be=>be.agents).then(be=>{if(xe!==mt.current)return;dr(be);const Te=be.filter(tt=>!tt.archived_at);qe(tt=>{var Ye;return tt&&Te.some(pn=>pn.agent_id===tt)?tt:((Ye=Te[0])==null?void 0:Ye.agent_id)??null})}).catch(be=>{if(xe===mt.current){const Te=fn(be,"the agents");xt(`${Te.why} ${Te.next}${Te.said?` (${Te.said})`:""}`)}})},[e,c.section,Vt,Ot]),x.useEffect(()=>{if(c.section!=="mission")return;let xe=!0;j(null),A(!0);const be=Ng($);return Promise.all([e.statsOver({...be?{from:be}:{},...E?{agent:E}:{}}),E?e.listAgentRuns(E,10):e.listRuns(10)]).then(([Te,tt])=>{xe&&(b(U4(Te,tt.runs)),E||D(Ye=>Ye||AL(tt.runs,Te.analytics.by_source)))}).catch(Te=>{xe&&j(fn(Te,"Mission Control"))}).finally(()=>{xe&&A(!1)}),()=>{xe=!1}},[e,c.section,N,$,E,Ot]),WN(()=>R(xe=>xe+1)),x.useEffect(()=>{if(c.section!=="mission"){G.current=null;return}let xe=!0;const be=G,Te=ts=>ao(hn=>e.listRuns(50,hn,{status:ts}),hn=>hn.runs,2),tt=()=>ao(ts=>e.listAgents({archived:!1,cursor:ts}),ts=>ts.agents).then(ts=>{xe&&Le(ts.filter(hn=>gd(hn)>0).map(hn=>({agent_id:hn.agent_id,name:hn.definition.name??hn.agent_id,pending:gd(hn)})))},()=>{}),pn=PL(()=>Promise.allSettled([Te("input_required"),Te("failed"),Te("working"),tt()]).then(([ts,hn,at])=>{var ga,Ci,Ti;if(!xe)return;const fr=[ts,hn,at],vc=Date.now()-RL;if(W(qw(null,fr).problem),((ga=fr[0])==null?void 0:ga.status)==="fulfilled"&&Y(!0),((Ci=fr[1])==null?void 0:Ci.status)==="fulfilled"){O(!0);const $o=fr[1].value.map(ns=>ns.run_id),Xs=be.current;Xs&&$o.some(ns=>!Xs.has(ns))&&R(ns=>ns+1),be.current=new Set($o)}((Ti=fr[2])==null?void 0:Ti.status)==="fulfilled"&&ee(!0),L($o=>{const{needs:Xs}=qw($o,fr);return{asking:Xs.asking.filter(zN),failed:Xs.failed.filter(ns=>Date.parse(ns.ended_at??ns.created_at)>vc),live:Xs.live}})}),1e4);return()=>{xe=!1,pn()}},[e,c.section,K]);const In=x.useRef(P5()).current,jn=()=>setTimeout(()=>P(xe=>xe+1),2500),ms=async(xe,be)=>{try{return await oN(In(xe),xe,be,e.sendMessage),jn(),null}catch(Te){return Jt(Te)}},zn=x.useRef(new Map).current,ma=async xe=>{const be=[];try{for(const Te of xe){const tt=Te.kind==="workflow"?void 0:(await e.getTimeline(Te.run_id)).rows.find(ts=>ts.kind==="user_message"),Ye=ML(Te,tt==null?void 0:tt.text);if("refusal"in Ye)throw new Error(Ye.refusal);const pn=zn.get(Te.run_id)??cf();zn.set(Te.run_id,pn),await e.startRun(Te.agent_id,Ye.body,pn),be.push(Te.run_id)}return jn(),{started:be,problem:null}}catch(Te){return be.length&&jn(),{started:be,problem:Jt(Te)}}},Jn=async xe=>{try{return await e.stop(xe),jn(),null}catch(be){return Jt(be)}},pa=async(xe,be,Te,tt)=>{let Ye=null;try{await e.answerApproval(xe,be,Te,tt)}catch(pn){Ye=pS(pn)}return P(pn=>pn+1),Ye},ps=async(xe,be)=>{let Te=null;try{await e.handBackComputer(xe,be)}catch(tt){Te=Oh(tt,"hand")}return P(tt=>tt+1),Te},Rr=x.useRef(0);x.useEffect(()=>{const xe=++Rr.current;Q([]),Ae&&ao(be=>e.listRevisions(Ae,be),be=>be.revisions).then(be=>{xe===Rr.current&&Q(be)}).catch(()=>{})},[e,Ae]);const wo=async(xe,be,Te)=>{const tt=performance.now();try{const Ye=await e.startRun(xe,be,Te);return{status:Ye.status,ms:Math.round(performance.now()-tt),body:Ye.run,runId:Ye.run.run_id}}catch(Ye){return mD(Ye,Math.round(performance.now()-tt))}},ha=((ko=f==null?void 0:f.features)==null?void 0:ko.efforts)??[],Pe=f?((Ar=f.features)==null?void 0:Ar.learning)??null:void 0;qt.learning=Pe??void 0;const Z=f==null?void 0:f.models.ready;return x.useEffect(()=>{if(Z!==!1)return;const xe=()=>{ct.current||(ct.current=!0,Ie().finally(()=>{ct.current=!1}))},be=()=>Ie(),Te=setInterval(xe,MD);return window.addEventListener("focus",be),()=>{clearInterval(Te),window.removeEventListener("focus",be)}},[e,Z]),n.jsx(BN.Provider,{value:v,children:n.jsx($D,{active:c.section,settings:fs.length>0,triggers:g,onNavigate:Xn,onSignOut:()=>{const xe=()=>void e.signOut().then(t,be=>l(be instanceof Ee?be.message:"The sign-out did not reach the server. Try again."));Lu(null,xe)||xe()},onSignOutEverywhere:()=>{const xe=()=>void e.signOutEverywhere().then(t,be=>l(be instanceof Ee?be.message:"The sign-out did not reach the server. Try again."));Lu(null,xe)||xe()},banners:n.jsxs(n.Fragment,{children:[a&&n.jsxs("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-destructive-text md:px-8",role:"alert",children:["Not signed out: ",a]}),on&&n.jsxs("p",{className:"flex items-center gap-3 border-b bg-card px-5 py-3 font-mono text-body md:px-8",role:"status",children:[n.jsx("span",{className:"flex-1",children:DD(on)}),on.state!=="running"&&n.jsx(V,{type:"button",size:"xs",onClick:()=>en(null),children:"Dismiss"})]}),(f==null?void 0:f.models.ready)===!1&&c.section!=="mission"&&n.jsx(vI,{needs:f.models.needs,source:f.models.source,model:f.models.default,settings:((es=(jo=f.features)==null?void 0:jo.tool_keys)==null?void 0:es.routes)===!0})]}),children:c.section==="playground"&&ut?n.jsx(On,{tone:"error",className:"m-8",actions:n.jsx(V,{type:"button",size:"xs",onClick:()=>Kt(xe=>xe+1),children:"Try again"}),children:n.jsxs("p",{className:"font-mono",children:["The agents could not be read: ",ut]})}):c.section==="settings"?n.jsx(sI,{active:c.settings??"keys",offered:fs,children:c.settings==="tools"?n.jsx(rI,{v2:e,choices:Ln,gates:Kn,harnesses:qt.harnesses,onSaved:Ie,onOpen:Ie}):c.settings==="mcp"?n.jsx(fI,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r}):c.settings==="github"?n.jsx(cI,{v2:e,returned:c.github}):c.settings==="computers"?n.jsx(_I,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?n.jsx(II,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?n.jsx(kI,{v2:e}):n.jsx(YL,{v2:e,onChange:Ie,writable:s,whyNot:r})}):c.section==="mission"?n.jsxs("div",{className:"flex h-full flex-col",children:[(f==null?void 0:f.models.ready)===!1&&n.jsx(bI,{v2:e,needs:f.models.needs,model:f.models.default,onSaved:Ie,writable:s,whyNot:r}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Q6,{view:m,error:w,onRetry:()=>R(xe=>xe+1),scope:{range:$,onRange:S,agent:E,onAgent:C,refreshing:T&&m!==null},asking:F&&I?F.asking.length:null,failed:F&&q?IN(F.failed):null,live:F&&B?F.live.length:null,needsYou:F&&n.jsx(J6,{asking:F.asking,failed:F.failed,failedAll:m==null?void 0:m.runs.failed,live:F.live,learning:fe,problem:z,agentName:gt,onAnswer:ms,onApprove:pa,onHandBack:ps,onRunAgain:ma,onStop:Jn}),startHere:U===!1?n.jsx(fD,{harnesses:qt.harnesses,tools:qt.tools,onTry:Qn,imported:an,keyCard:St}):void 0})})]}):c.section==="templates"?n.jsx(Iz,{v2:e,name:c.template,go:Nt},c.template??""):c.section==="triggers"?n.jsx(xz,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Nt,agentName:gt,minEvery:(Dn=(gc=f==null?void 0:f.features)==null?void 0:gc.triggers)==null?void 0:Dn.min_every_s,failuresToPause:(yc=(xc=f==null?void 0:f.features)==null?void 0:xc.triggers)==null?void 0:yc.failures_to_pause}):c.section==="playground"?Zn&&n.jsx(pD,{agents:Zn.filter(xe=>!xe.archived_at),revisions:yt,efforts:ha,origin:location.origin,agentId:Ae??void 0,onAgent:qe,onSend:wo,limits:f==null?void 0:f.limits,removeUpload:e.deleteUpload,onOpenRun:xe=>Nt(`#/runs/${encodeURIComponent(xe)}`),live:xe=>n.jsx(v0,{v2:e,runId:xe,caps:f,agentName:gt},xe)}):c.section==="agents"?c.agent===void 0?n.jsx(wL,{v2:e,archived:!!c.archived,go:Nt},Ot):c.agent!==null&&!c.edit?n.jsx(VP,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:Pe,routePrefix:(bc=Xe==null?void 0:Xe.models)==null?void 0:bc.route_prefix,harnesses:qt.harnesses,efforts:ha,limits:f==null?void 0:f.limits,places:Ow(f),go:Nt},c.agent):n.jsx(kL,{v2:e,choices:Ln,gates:Kn,focusTool:c.tool,caps:{...qt,routePrefix:(No=Xe==null?void 0:Xe.models)==null?void 0:No.route_prefix,decisionProvider:dP(f==null?void 0:f.workflows),places:Ow(f),mcp:!!((So=f==null?void 0:f.features)!=null&&So.mcp_client),mcpHarnesses:(_o=(Or=f==null?void 0:f.features)==null?void 0:Or.mcp_client)==null?void 0:_o.harnesses},agentId:c.agent,go:Nt},`${c.agent??"new"}:${c.tool??""}`):c.run?n.jsx(v0,{v2:e,runId:c.run,caps:f,agentName:gt},c.run):n.jsx(gD,{runs:le,agentName:gt,error:It,onRetry:()=>lt(xe=>xe+1),onOpen:xe=>Nt(`#/runs/${encodeURIComponent(xe)}`),loadingMore:ce,filter:st,onFilter:xe=>Nt(PD({runsOf:c.runsOf,...xe})),onMore:ue?()=>{const xe=jt.current;he(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,ue,st):e.listRuns(50,ue,st)).then(be=>{xe===jt.current&&(ie(Te=>aN(Te??[],be.runs)),ae(be.next_cursor),We(null))}).catch(be=>We(fn(be,"more runs"))).finally(()=>he(!1))}:void 0})})})}jD();j_.createRoot(document.getElementById("root")).render(n.jsx(x.StrictMode,{children:n.jsx($A,{children:n.jsx(FD,{})})}));