@withbuddi/buddi 0.1.0-pre.21 → 0.1.0-pre.22
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.
- package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/commands.js +5 -2
- package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
- package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/core/dist/actions/permissions.d.ts +14 -0
- package/node_modules/@buddi/core/dist/actions/permissions.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/actions/permissions.js +15 -0
- package/node_modules/@buddi/core/dist/actions/permissions.js.map +1 -1
- package/node_modules/@buddi/core/dist/agents/catalog.d.ts +12 -1
- package/node_modules/@buddi/core/dist/agents/catalog.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/agents/catalog.js +57 -6
- package/node_modules/@buddi/core/dist/agents/catalog.js.map +1 -1
- package/node_modules/@buddi/core/dist/agents/delegates.d.ts +54 -0
- package/node_modules/@buddi/core/dist/agents/delegates.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/agents/delegates.js +51 -0
- package/node_modules/@buddi/core/dist/agents/delegates.js.map +1 -0
- package/node_modules/@buddi/core/dist/agents/index.d.ts +1 -0
- package/node_modules/@buddi/core/dist/agents/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/agents/index.js +1 -0
- package/node_modules/@buddi/core/dist/agents/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/host/build.d.ts +26 -5
- package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/host/build.js +72 -0
- package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
- package/node_modules/@buddi/core/dist/host/types.d.ts +67 -5
- package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/index.d.ts +1 -0
- package/node_modules/@buddi/core/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/index.js +1 -0
- package/node_modules/@buddi/core/dist/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/json-schema.d.ts +32 -0
- package/node_modules/@buddi/core/dist/json-schema.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/json-schema.js +147 -0
- package/node_modules/@buddi/core/dist/json-schema.js.map +1 -0
- package/node_modules/@buddi/core/dist/learning/sources.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/learning/sources.js +3 -0
- package/node_modules/@buddi/core/dist/learning/sources.js.map +1 -1
- package/node_modules/@buddi/core/dist/learning/types.d.ts +4 -3
- package/node_modules/@buddi/core/dist/learning/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/learning/types.js +1 -1
- package/node_modules/@buddi/core/dist/learning/types.js.map +1 -1
- package/node_modules/@buddi/core/dist/notifications/index.d.ts +1 -0
- package/node_modules/@buddi/core/dist/notifications/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/notifications/index.js +1 -0
- package/node_modules/@buddi/core/dist/notifications/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/notifications/notify.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/notifications/notify.js +47 -5
- package/node_modules/@buddi/core/dist/notifications/notify.js.map +1 -1
- package/node_modules/@buddi/core/dist/notifications/store.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/notifications/store.js +3 -1
- package/node_modules/@buddi/core/dist/notifications/store.js.map +1 -1
- package/node_modules/@buddi/core/dist/notifications/topic.d.ts +25 -0
- package/node_modules/@buddi/core/dist/notifications/topic.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/notifications/topic.js +116 -0
- package/node_modules/@buddi/core/dist/notifications/topic.js.map +1 -0
- package/node_modules/@buddi/core/dist/notifications/types.d.ts +4 -0
- package/node_modules/@buddi/core/dist/notifications/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/onboarding/language-tag.d.ts +12 -0
- package/node_modules/@buddi/core/dist/onboarding/language-tag.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/onboarding/language-tag.js +64 -0
- package/node_modules/@buddi/core/dist/onboarding/language-tag.js.map +1 -0
- package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts +11 -0
- package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js +23 -1
- package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js.map +1 -1
- package/node_modules/@buddi/core/dist/pages.d.ts +19 -0
- package/node_modules/@buddi/core/dist/pages.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/pages.js +13 -0
- package/node_modules/@buddi/core/dist/pages.js.map +1 -1
- package/node_modules/@buddi/core/dist/plugin/index.d.ts +4 -3
- package/node_modules/@buddi/core/dist/plugin/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/plugin/version.d.ts +1 -1
- package/node_modules/@buddi/core/dist/plugin/version.js +1 -1
- package/node_modules/@buddi/core/dist/provider-accounts.d.ts +31 -0
- package/node_modules/@buddi/core/dist/provider-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/registry.d.ts +37 -1
- package/node_modules/@buddi/core/dist/registry.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/registry.js +187 -32
- package/node_modules/@buddi/core/dist/registry.js.map +1 -1
- package/node_modules/@buddi/core/dist/secrets/scrub.d.ts +2 -0
- package/node_modules/@buddi/core/dist/secrets/scrub.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/secrets/scrub.js +29 -0
- package/node_modules/@buddi/core/dist/secrets/scrub.js.map +1 -1
- package/node_modules/@buddi/core/dist/tools.d.ts +36 -1
- package/node_modules/@buddi/core/dist/tools.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/tools.js.map +1 -1
- package/node_modules/@buddi/core/dist/views.d.ts +12 -12
- package/node_modules/@buddi/core/migrations/050_notification_topic.sql +8 -0
- package/node_modules/@buddi/core/package.json +2 -0
- package/node_modules/@buddi/gateway/assets/mascot/core-idle.tgs +0 -0
- package/node_modules/@buddi/gateway/assets/mascot/core-working.tgs +0 -0
- package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/gateway/dist/agents/canvas.d.ts +2 -2
- package/node_modules/@buddi/gateway/dist/agents/canvas.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/canvas.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/catalog.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/catalog.js +15 -6
- package/node_modules/@buddi/gateway/dist/agents/catalog.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/delegation.d.ts +20 -3
- package/node_modules/@buddi/gateway/dist/agents/delegation.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/delegation.js +38 -12
- package/node_modules/@buddi/gateway/dist/agents/delegation.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/platform.d.ts +43 -13
- package/node_modules/@buddi/gateway/dist/agents/platform.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/platform.js +97 -3
- package/node_modules/@buddi/gateway/dist/agents/platform.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/starter-team.d.ts +57 -0
- package/node_modules/@buddi/gateway/dist/agents/starter-team.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/agents/starter-team.js +151 -0
- package/node_modules/@buddi/gateway/dist/agents/starter-team.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/anthropic-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/anthropic-accounts.js +9 -20
- package/node_modules/@buddi/gateway/dist/anthropic-accounts.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/bootstrap.d.ts +3 -0
- package/node_modules/@buddi/gateway/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/bootstrap.js +58 -2
- package/node_modules/@buddi/gateway/dist/bootstrap.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts +7 -1
- package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/codex-accounts.js +25 -26
- package/node_modules/@buddi/gateway/dist/codex-accounts.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/mcp/requests.d.ts +8 -1
- package/node_modules/@buddi/gateway/dist/mcp/requests.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/mcp/requests.js +8 -1
- package/node_modules/@buddi/gateway/dist/mcp/requests.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/goals-page.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/goals-page.js +57 -0
- package/node_modules/@buddi/gateway/dist/missions/goals-page.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/approve.js +45 -9
- package/node_modules/@buddi/gateway/dist/plugins/approve.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/load.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/load.js +4 -0
- package/node_modules/@buddi/gateway/dist/plugins/load.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/npm.d.ts +5 -1
- package/node_modules/@buddi/gateway/dist/plugins/npm.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/npm.js +6 -0
- package/node_modules/@buddi/gateway/dist/plugins/npm.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/scaffold.d.ts +15 -4
- package/node_modules/@buddi/gateway/dist/plugins/scaffold.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/scaffold.js +86 -16
- package/node_modules/@buddi/gateway/dist/plugins/scaffold.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts +35 -1
- package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/stage.js +134 -8
- package/node_modules/@buddi/gateway/dist/plugins/stage.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts +5 -1
- package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins-cli.js +26 -4
- package/node_modules/@buddi/gateway/dist/plugins-cli.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-accounts.js +31 -3
- package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-diagnostics.d.ts +14 -2
- package/node_modules/@buddi/gateway/dist/provider-diagnostics.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-diagnostics.js +25 -9
- package/node_modules/@buddi/gateway/dist/provider-diagnostics.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/api.d.ts +49 -0
- package/node_modules/@buddi/gateway/dist/telegram/api.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/api.js +99 -0
- package/node_modules/@buddi/gateway/dist/telegram/api.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/main.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/main.js +17 -0
- package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts +5 -0
- package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/outbound.js +10 -0
- package/node_modules/@buddi/gateway/dist/telegram/outbound.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/stickers.d.ts +30 -0
- package/node_modules/@buddi/gateway/dist/telegram/stickers.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/telegram/stickers.js +146 -0
- package/node_modules/@buddi/gateway/dist/telegram/stickers.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +6 -0
- package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/surface.js +36 -3
- package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/engine.d.ts +75 -0
- package/node_modules/@buddi/gateway/dist/tips/engine.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/tips/engine.js +135 -0
- package/node_modules/@buddi/gateway/dist/tips/engine.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/tips/facts.d.ts +69 -0
- package/node_modules/@buddi/gateway/dist/tips/facts.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/tips/facts.js +104 -0
- package/node_modules/@buddi/gateway/dist/tips/facts.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/tips/route.d.ts +25 -0
- package/node_modules/@buddi/gateway/dist/tips/route.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/tips/route.js +96 -0
- package/node_modules/@buddi/gateway/dist/tips/route.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/tips/rules.d.ts +33 -0
- package/node_modules/@buddi/gateway/dist/tips/rules.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/tips/rules.js +54 -0
- package/node_modules/@buddi/gateway/dist/tips/rules.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/agent-offers.d.ts +30 -0
- package/node_modules/@buddi/gateway/dist/web/agent-offers.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/agent-offers.js +64 -1
- package/node_modules/@buddi/gateway/dist/web/agent-offers.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/connections.d.ts +83 -0
- package/node_modules/@buddi/gateway/dist/web/connections.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/connections.js +270 -0
- package/node_modules/@buddi/gateway/dist/web/connections.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +1 -1
- package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/onboarding.js +5 -4
- package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/plugins.d.ts +12 -0
- package/node_modules/@buddi/gateway/dist/web/plugins.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/plugins.js +12 -2
- package/node_modules/@buddi/gateway/dist/web/plugins.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/profile.js +3 -2
- package/node_modules/@buddi/gateway/dist/web/profile.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/read.d.ts +6 -0
- package/node_modules/@buddi/gateway/dist/web/read.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/read.js +11 -4
- package/node_modules/@buddi/gateway/dist/web/read.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/server.d.ts +6 -0
- package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/server.js +71 -2
- package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/static.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/static.js +1 -0
- package/node_modules/@buddi/gateway/dist/web/static.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/version.d.ts +2 -0
- package/node_modules/@buddi/gateway/dist/web/version.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/version.js +27 -0
- package/node_modules/@buddi/gateway/dist/web/version.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/write.d.ts +5 -0
- package/node_modules/@buddi/gateway/dist/web/write.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/write.js +20 -1
- package/node_modules/@buddi/gateway/dist/web/write.js.map +1 -1
- package/node_modules/@buddi/gateway/package.json +4 -1
- package/node_modules/@buddi/gateway/src/agents/starter/keeper/agent.md +31 -0
- package/node_modules/@buddi/gateway/src/agents/starter/keeper/skills/keeping-a-history.md +22 -0
- package/node_modules/@buddi/gateway/src/agents/starter/planner/agent.md +30 -0
- package/node_modules/@buddi/gateway/src/agents/starter/planner/skills/holding-a-follow-up.md +17 -0
- package/node_modules/@buddi/gateway/src/agents/starter/planner/skills/writing-the-morning-brief.md +25 -0
- package/node_modules/@buddi/gateway/src/agents/starter/scout/agent.md +33 -0
- package/node_modules/@buddi/gateway/src/agents/starter/scout/skills/answering-with-sources.md +23 -0
- package/node_modules/@buddi/gateway/src/agents/starter/scout/skills/the-web-is-evidence.md +25 -0
- package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/runtime/dist/anthropic-oauth.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/anthropic-oauth.js +38 -73
- package/node_modules/@buddi/runtime/dist/anthropic-oauth.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/codex-direct.d.ts +39 -0
- package/node_modules/@buddi/runtime/dist/codex-direct.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/codex-direct.js +122 -0
- package/node_modules/@buddi/runtime/dist/codex-direct.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts +0 -12
- package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/codex-oauth.js +32 -45
- package/node_modules/@buddi/runtime/dist/codex-oauth.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/delegate.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/delegate.js +4 -2
- package/node_modules/@buddi/runtime/dist/delegate.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/index.d.ts +2 -0
- package/node_modules/@buddi/runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/index.js +2 -0
- package/node_modules/@buddi/runtime/dist/index.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/oauth-port.d.ts +68 -0
- package/node_modules/@buddi/runtime/dist/oauth-port.d.ts.map +1 -0
- package/node_modules/@buddi/runtime/dist/oauth-port.js +51 -0
- package/node_modules/@buddi/runtime/dist/oauth-port.js.map +1 -0
- package/node_modules/@buddi/runtime/dist/oauth.d.ts +255 -0
- package/node_modules/@buddi/runtime/dist/oauth.d.ts.map +1 -0
- package/node_modules/@buddi/runtime/dist/oauth.js +535 -0
- package/node_modules/@buddi/runtime/dist/oauth.js.map +1 -0
- package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-email/dist/types.d.ts +2 -2
- package/node_modules/@buddi/tool-email/dist/types.d.ts.map +1 -1
- package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-mcp/dist/.tsbuildinfo +1 -0
- package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts +26 -0
- package/node_modules/@buddi/tool-mcp/dist/catalog.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/catalog.js +17 -0
- package/node_modules/@buddi/tool-mcp/dist/catalog.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts +44 -0
- package/node_modules/@buddi/tool-mcp/dist/fetch.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/fetch.js +88 -0
- package/node_modules/@buddi/tool-mcp/dist/fetch.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/index.d.ts +27 -0
- package/node_modules/@buddi/tool-mcp/dist/index.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/index.js +74 -0
- package/node_modules/@buddi/tool-mcp/dist/index.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/output.d.ts +38 -0
- package/node_modules/@buddi/tool-mcp/dist/output.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/output.js +90 -0
- package/node_modules/@buddi/tool-mcp/dist/output.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/ports.d.ts +105 -0
- package/node_modules/@buddi/tool-mcp/dist/ports.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/ports.js +9 -0
- package/node_modules/@buddi/tool-mcp/dist/ports.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/service.d.ts +220 -0
- package/node_modules/@buddi/tool-mcp/dist/service.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/service.js +742 -0
- package/node_modules/@buddi/tool-mcp/dist/service.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/session.d.ts +50 -0
- package/node_modules/@buddi/tool-mcp/dist/session.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/session.js +108 -0
- package/node_modules/@buddi/tool-mcp/dist/session.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/store.d.ts +70 -0
- package/node_modules/@buddi/tool-mcp/dist/store.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/store.js +78 -0
- package/node_modules/@buddi/tool-mcp/dist/store.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts +51 -0
- package/node_modules/@buddi/tool-mcp/dist/testing/fake.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/testing/fake.js +147 -0
- package/node_modules/@buddi/tool-mcp/dist/testing/fake.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/tiers.d.ts +51 -0
- package/node_modules/@buddi/tool-mcp/dist/tiers.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/tiers.js +106 -0
- package/node_modules/@buddi/tool-mcp/dist/tiers.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/tokens.d.ts +35 -0
- package/node_modules/@buddi/tool-mcp/dist/tokens.d.ts.map +1 -0
- package/node_modules/@buddi/tool-mcp/dist/tokens.js +75 -0
- package/node_modules/@buddi/tool-mcp/dist/tokens.js.map +1 -0
- package/node_modules/@buddi/tool-mcp/migrations/001_connections.sql +49 -0
- package/node_modules/@buddi/tool-mcp/migrations/002_review_again.sql +15 -0
- package/node_modules/@buddi/tool-mcp/package.json +34 -0
- package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
- package/node_modules/@zone-eu/mailsplit/lib/flowed-decoder.js +1 -5
- package/node_modules/@zone-eu/mailsplit/lib/headers.js +35 -25
- package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +126 -79
- package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +27 -5
- package/node_modules/@zone-eu/mailsplit/lib/node-rewriter.js +3 -2
- package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +0 -3
- package/node_modules/@zone-eu/mailsplit/package.json +5 -5
- package/node_modules/hono/dist/_virtual/_rolldown/runtime.js +13 -0
- package/node_modules/hono/dist/adapter/aws-lambda/conninfo.js +42 -23
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +318 -344
- package/node_modules/hono/dist/adapter/aws-lambda/index.js +2 -8
- package/node_modules/hono/dist/adapter/aws-lambda/types.js +1 -0
- package/node_modules/hono/dist/adapter/bun/conninfo.js +20 -25
- package/node_modules/hono/dist/adapter/bun/index.js +3 -13
- package/node_modules/hono/dist/adapter/bun/serve-static.js +27 -27
- package/node_modules/hono/dist/adapter/bun/server.js +11 -5
- package/node_modules/hono/dist/adapter/bun/ssg.js +25 -15
- package/node_modules/hono/dist/adapter/bun/websocket.js +61 -68
- package/node_modules/hono/dist/adapter/cloudflare-pages/conninfo.js +24 -9
- package/node_modules/hono/dist/adapter/cloudflare-pages/handler.js +59 -62
- package/node_modules/hono/dist/adapter/cloudflare-pages/index.js +2 -8
- package/node_modules/hono/dist/adapter/cloudflare-workers/conninfo.js +7 -9
- package/node_modules/hono/dist/adapter/cloudflare-workers/index.js +3 -8
- package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static-module.js +5 -6
- package/node_modules/hono/dist/adapter/cloudflare-workers/serve-static.js +26 -20
- package/node_modules/hono/dist/adapter/cloudflare-workers/utils.js +21 -34
- package/node_modules/hono/dist/adapter/cloudflare-workers/websocket.js +31 -39
- package/node_modules/hono/dist/adapter/deno/conninfo.js +16 -13
- package/node_modules/hono/dist/adapter/deno/deno.d.js +1 -0
- package/node_modules/hono/dist/adapter/deno/index.js +3 -10
- package/node_modules/hono/dist/adapter/deno/serve-static.js +33 -38
- package/node_modules/hono/dist/adapter/deno/ssg.js +27 -16
- package/node_modules/hono/dist/adapter/deno/websocket.js +30 -30
- package/node_modules/hono/dist/adapter/lambda-edge/conninfo.js +7 -9
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +102 -101
- package/node_modules/hono/dist/adapter/lambda-edge/index.js +2 -6
- package/node_modules/hono/dist/adapter/netlify/conninfo.js +24 -9
- package/node_modules/hono/dist/adapter/netlify/handler.js +10 -8
- package/node_modules/hono/dist/adapter/netlify/index.js +3 -2
- package/node_modules/hono/dist/adapter/netlify/mod.js +2 -6
- package/node_modules/hono/dist/adapter/service-worker/handler.js +15 -19
- package/node_modules/hono/dist/adapter/service-worker/index.js +23 -7
- package/node_modules/hono/dist/adapter/service-worker/types.js +1 -0
- package/node_modules/hono/dist/adapter/vercel/conninfo.js +7 -10
- package/node_modules/hono/dist/adapter/vercel/handler.js +8 -6
- package/node_modules/hono/dist/adapter/vercel/index.js +2 -6
- package/node_modules/hono/dist/cjs/_virtual/_rolldown/runtime.js +33 -0
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/conninfo.js +42 -44
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +326 -373
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/index.js +7 -34
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/types.js +0 -15
- package/node_modules/hono/dist/cjs/adapter/bun/conninfo.js +21 -47
- package/node_modules/hono/dist/cjs/adapter/bun/index.js +14 -45
- package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +29 -50
- package/node_modules/hono/dist/cjs/adapter/bun/server.js +11 -26
- package/node_modules/hono/dist/cjs/adapter/bun/ssg.js +24 -35
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +63 -91
- package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/conninfo.js +25 -31
- package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/handler.js +61 -85
- package/node_modules/hono/dist/cjs/adapter/cloudflare-pages/index.js +7 -34
- package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/conninfo.js +8 -31
- package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/index.js +7 -33
- package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +7 -29
- package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/serve-static.js +27 -42
- package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/utils.js +21 -55
- package/node_modules/hono/dist/cjs/adapter/cloudflare-workers/websocket.js +33 -62
- package/node_modules/hono/dist/cjs/adapter/deno/conninfo.js +16 -34
- package/node_modules/hono/dist/cjs/adapter/deno/index.js +10 -38
- package/node_modules/hono/dist/cjs/adapter/deno/serve-static.js +33 -59
- package/node_modules/hono/dist/cjs/adapter/deno/ssg.js +27 -37
- package/node_modules/hono/dist/cjs/adapter/deno/websocket.js +32 -53
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/conninfo.js +8 -31
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +102 -130
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/index.js +5 -30
- package/node_modules/hono/dist/cjs/adapter/netlify/conninfo.js +25 -31
- package/node_modules/hono/dist/cjs/adapter/netlify/handler.js +10 -29
- package/node_modules/hono/dist/cjs/adapter/netlify/index.js +5 -21
- package/node_modules/hono/dist/cjs/adapter/netlify/mod.js +5 -30
- package/node_modules/hono/dist/cjs/adapter/service-worker/handler.js +16 -41
- package/node_modules/hono/dist/cjs/adapter/service-worker/index.js +25 -30
- package/node_modules/hono/dist/cjs/adapter/service-worker/types.js +0 -15
- package/node_modules/hono/dist/cjs/adapter/vercel/conninfo.js +8 -32
- package/node_modules/hono/dist/cjs/adapter/vercel/handler.js +8 -27
- package/node_modules/hono/dist/cjs/adapter/vercel/index.js +5 -30
- package/node_modules/hono/dist/cjs/client/client.js +139 -212
- package/node_modules/hono/dist/cjs/client/fetch-result-please.js +62 -80
- package/node_modules/hono/dist/cjs/client/index.js +7 -32
- package/node_modules/hono/dist/cjs/client/types.js +0 -15
- package/node_modules/hono/dist/cjs/client/utils.js +54 -92
- package/node_modules/hono/dist/cjs/compose.js +49 -66
- package/node_modules/hono/dist/cjs/context.js +379 -450
- package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +47 -72
- package/node_modules/hono/dist/cjs/helper/accepts/index.js +3 -27
- package/node_modules/hono/dist/cjs/helper/adapter/index.js +33 -73
- package/node_modules/hono/dist/cjs/helper/conninfo/index.js +0 -15
- package/node_modules/hono/dist/cjs/helper/conninfo/types.js +0 -15
- package/node_modules/hono/dist/cjs/helper/cookie/index.js +75 -116
- package/node_modules/hono/dist/cjs/helper/css/common.js +165 -244
- package/node_modules/hono/dist/cjs/helper/css/index.js +136 -151
- package/node_modules/hono/dist/cjs/helper/dev/index.js +45 -71
- package/node_modules/hono/dist/cjs/helper/factory/index.js +30 -51
- package/node_modules/hono/dist/cjs/helper/html/index.js +32 -62
- package/node_modules/hono/dist/cjs/helper/proxy/index.js +113 -106
- package/node_modules/hono/dist/cjs/helper/route/index.js +123 -66
- package/node_modules/hono/dist/cjs/helper/ssg/index.js +19 -43
- package/node_modules/hono/dist/cjs/helper/ssg/middleware.js +56 -64
- package/node_modules/hono/dist/cjs/helper/ssg/plugins.js +55 -57
- package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +196 -296
- package/node_modules/hono/dist/cjs/helper/ssg/utils.js +47 -90
- package/node_modules/hono/dist/cjs/helper/streaming/index.js +8 -35
- package/node_modules/hono/dist/cjs/helper/streaming/sse.js +53 -85
- package/node_modules/hono/dist/cjs/helper/streaming/stream.js +23 -53
- package/node_modules/hono/dist/cjs/helper/streaming/text.js +10 -32
- package/node_modules/hono/dist/cjs/helper/streaming/utils.js +13 -32
- package/node_modules/hono/dist/cjs/helper/testing/index.js +16 -31
- package/node_modules/hono/dist/cjs/helper/websocket/index.js +51 -76
- package/node_modules/hono/dist/cjs/hono-base.js +345 -403
- package/node_modules/hono/dist/cjs/hono.js +28 -42
- package/node_modules/hono/dist/cjs/http-exception.js +55 -56
- package/node_modules/hono/dist/cjs/index.js +22 -30
- package/node_modules/hono/dist/cjs/jsx/base.js +237 -366
- package/node_modules/hono/dist/cjs/jsx/children.js +16 -41
- package/node_modules/hono/dist/cjs/jsx/components.js +119 -192
- package/node_modules/hono/dist/cjs/jsx/constants.js +15 -42
- package/node_modules/hono/dist/cjs/jsx/context.js +144 -162
- package/node_modules/hono/dist/cjs/jsx/dom/client.js +49 -69
- package/node_modules/hono/dist/cjs/jsx/dom/components.js +23 -52
- package/node_modules/hono/dist/cjs/jsx/dom/context.js +39 -67
- package/node_modules/hono/dist/cjs/jsx/dom/css.js +143 -158
- package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +55 -64
- package/node_modules/hono/dist/cjs/jsx/dom/index.js +114 -173
- package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +282 -375
- package/node_modules/hono/dist/cjs/jsx/dom/jsx-dev-runtime.js +14 -49
- package/node_modules/hono/dist/cjs/jsx/dom/jsx-runtime.js +5 -32
- package/node_modules/hono/dist/cjs/jsx/dom/render.js +469 -623
- package/node_modules/hono/dist/cjs/jsx/dom/server.js +37 -64
- package/node_modules/hono/dist/cjs/jsx/dom/utils.js +7 -30
- package/node_modules/hono/dist/cjs/jsx/hooks/index.js +225 -318
- package/node_modules/hono/dist/cjs/jsx/index.js +86 -135
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/common.js +20 -43
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +117 -168
- package/node_modules/hono/dist/cjs/jsx/intrinsic-elements.js +0 -15
- package/node_modules/hono/dist/cjs/jsx/jsx-dev-runtime.js +14 -39
- package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +34 -68
- package/node_modules/hono/dist/cjs/jsx/streaming.js +123 -166
- package/node_modules/hono/dist/cjs/jsx/types.js +0 -15
- package/node_modules/hono/dist/cjs/jsx/utils.js +91 -175
- package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +98 -86
- package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +92 -109
- package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +66 -72
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +153 -199
- package/node_modules/hono/dist/cjs/middleware/combine/index.js +133 -95
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +73 -88
- package/node_modules/hono/dist/cjs/middleware/context-storage/index.js +49 -41
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +107 -107
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +101 -72
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +58 -97
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +71 -91
- package/node_modules/hono/dist/cjs/middleware/ip-restriction/index.js +161 -169
- package/node_modules/hono/dist/cjs/middleware/jsx-renderer/index.js +99 -77
- package/node_modules/hono/dist/cjs/middleware/jwk/index.js +3 -27
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +118 -135
- package/node_modules/hono/dist/cjs/middleware/jwt/index.js +9 -38
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +120 -141
- package/node_modules/hono/dist/cjs/middleware/language/index.js +7 -35
- package/node_modules/hono/dist/cjs/middleware/language/language.js +184 -182
- package/node_modules/hono/dist/cjs/middleware/logger/index.js +41 -62
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +82 -88
- package/node_modules/hono/dist/cjs/middleware/method-override/index.js +101 -102
- package/node_modules/hono/dist/cjs/middleware/powered-by/index.js +23 -30
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +38 -42
- package/node_modules/hono/dist/cjs/middleware/request-id/index.js +3 -27
- package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +34 -42
- package/node_modules/hono/dist/cjs/middleware/secure-headers/index.js +4 -29
- package/node_modules/hono/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -15
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +142 -174
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +55 -93
- package/node_modules/hono/dist/cjs/middleware/serve-static/path.js +15 -38
- package/node_modules/hono/dist/cjs/middleware/timeout/index.js +40 -45
- package/node_modules/hono/dist/cjs/middleware/timing/index.js +7 -35
- package/node_modules/hono/dist/cjs/middleware/timing/timing.js +177 -118
- package/node_modules/hono/dist/cjs/middleware/trailing-slash/index.js +85 -58
- package/node_modules/hono/dist/cjs/preset/quick.js +18 -37
- package/node_modules/hono/dist/cjs/preset/tiny.js +15 -33
- package/node_modules/hono/dist/cjs/request/constants.js +5 -27
- package/node_modules/hono/dist/cjs/request.js +334 -346
- package/node_modules/hono/dist/cjs/router/linear-router/index.js +3 -27
- package/node_modules/hono/dist/cjs/router/linear-router/router.js +95 -143
- package/node_modules/hono/dist/cjs/router/pattern-router/index.js +3 -27
- package/node_modules/hono/dist/cjs/router/pattern-router/router.js +41 -63
- package/node_modules/hono/dist/cjs/router/reg-exp-router/index.js +7 -34
- package/node_modules/hono/dist/cjs/router/reg-exp-router/matcher.js +18 -45
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +91 -135
- package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +92 -161
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +98 -147
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +73 -89
- package/node_modules/hono/dist/cjs/router/smart-router/index.js +3 -27
- package/node_modules/hono/dist/cjs/router/smart-router/router.js +49 -79
- package/node_modules/hono/dist/cjs/router/trie-router/index.js +3 -27
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +134 -186
- package/node_modules/hono/dist/cjs/router/trie-router/router.js +15 -39
- package/node_modules/hono/dist/cjs/router/utils.js +5 -27
- package/node_modules/hono/dist/cjs/router.js +37 -37
- package/node_modules/hono/dist/cjs/types.js +5 -28
- package/node_modules/hono/dist/cjs/utils/accept.js +177 -225
- package/node_modules/hono/dist/cjs/utils/basic-auth.js +16 -40
- package/node_modules/hono/dist/cjs/utils/body.js +84 -110
- package/node_modules/hono/dist/cjs/utils/buffer.js +43 -91
- package/node_modules/hono/dist/cjs/utils/color.js +35 -44
- package/node_modules/hono/dist/cjs/utils/compress.js +11 -26
- package/node_modules/hono/dist/cjs/utils/concurrent.js +29 -59
- package/node_modules/hono/dist/cjs/utils/constants.js +7 -26
- package/node_modules/hono/dist/cjs/utils/cookie.js +107 -177
- package/node_modules/hono/dist/cjs/utils/crypto.js +30 -61
- package/node_modules/hono/dist/cjs/utils/encode.js +31 -48
- package/node_modules/hono/dist/cjs/utils/filepath.js +23 -54
- package/node_modules/hono/dist/cjs/utils/handler.js +11 -33
- package/node_modules/hono/dist/cjs/utils/headers.js +0 -15
- package/node_modules/hono/dist/cjs/utils/html.js +96 -137
- package/node_modules/hono/dist/cjs/utils/http-status.js +0 -15
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +213 -286
- package/node_modules/hono/dist/cjs/utils/jwt/index.js +14 -27
- package/node_modules/hono/dist/cjs/utils/jwt/jwa.js +25 -42
- package/node_modules/hono/dist/cjs/utils/jwt/jws.js +119 -199
- package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +122 -206
- package/node_modules/hono/dist/cjs/utils/jwt/types.js +122 -159
- package/node_modules/hono/dist/cjs/utils/jwt/utf8.js +9 -28
- package/node_modules/hono/dist/cjs/utils/mime.js +75 -101
- package/node_modules/hono/dist/cjs/utils/stream.js +88 -111
- package/node_modules/hono/dist/cjs/utils/types.js +0 -15
- package/node_modules/hono/dist/cjs/utils/url.js +185 -234
- package/node_modules/hono/dist/cjs/validator/index.js +3 -27
- package/node_modules/hono/dist/cjs/validator/utils.js +0 -15
- package/node_modules/hono/dist/cjs/validator/validator.js +60 -103
- package/node_modules/hono/dist/client/client.js +138 -197
- package/node_modules/hono/dist/client/fetch-result-please.js +59 -56
- package/node_modules/hono/dist/client/index.js +3 -7
- package/node_modules/hono/dist/client/types.js +1 -0
- package/node_modules/hono/dist/client/utils.js +51 -68
- package/node_modules/hono/dist/compose.js +49 -45
- package/node_modules/hono/dist/context.js +376 -426
- package/node_modules/hono/dist/helper/accepts/accepts.js +47 -51
- package/node_modules/hono/dist/helper/accepts/index.js +1 -4
- package/node_modules/hono/dist/helper/adapter/index.js +33 -52
- package/node_modules/hono/dist/helper/conninfo/index.js +1 -0
- package/node_modules/hono/dist/helper/conninfo/types.js +1 -0
- package/node_modules/hono/dist/helper/cookie/index.js +74 -94
- package/node_modules/hono/dist/helper/css/common.js +167 -225
- package/node_modules/hono/dist/helper/css/index.js +132 -137
- package/node_modules/hono/dist/helper/dev/index.js +44 -49
- package/node_modules/hono/dist/helper/factory/index.js +27 -27
- package/node_modules/hono/dist/helper/html/index.js +30 -39
- package/node_modules/hono/dist/helper/proxy/index.js +116 -88
- package/node_modules/hono/dist/helper/route/index.js +121 -43
- package/node_modules/hono/dist/helper/ssg/index.js +3 -18
- package/node_modules/hono/dist/helper/ssg/middleware.js +53 -40
- package/node_modules/hono/dist/helper/ssg/plugins.js +55 -36
- package/node_modules/hono/dist/helper/ssg/ssg.js +198 -283
- package/node_modules/hono/dist/helper/ssg/utils.js +53 -75
- package/node_modules/hono/dist/helper/streaming/index.js +2 -8
- package/node_modules/hono/dist/helper/streaming/sse.js +50 -61
- package/node_modules/hono/dist/helper/streaming/stream.js +22 -31
- package/node_modules/hono/dist/helper/streaming/text.js +9 -10
- package/node_modules/hono/dist/helper/streaming/utils.js +9 -12
- package/node_modules/hono/dist/helper/testing/index.js +16 -10
- package/node_modules/hono/dist/helper/websocket/index.js +49 -53
- package/node_modules/hono/dist/hono-base.js +342 -379
- package/node_modules/hono/dist/hono.js +27 -20
- package/node_modules/hono/dist/http-exception.js +53 -33
- package/node_modules/hono/dist/index.js +19 -6
- package/node_modules/hono/dist/jsx/base.js +231 -340
- package/node_modules/hono/dist/jsx/children.js +16 -20
- package/node_modules/hono/dist/jsx/components.js +118 -170
- package/node_modules/hono/dist/jsx/constants.js +9 -15
- package/node_modules/hono/dist/jsx/context.js +153 -150
- package/node_modules/hono/dist/jsx/dom/client.js +45 -48
- package/node_modules/hono/dist/jsx/dom/components.js +21 -29
- package/node_modules/hono/dist/jsx/dom/context.js +37 -44
- package/node_modules/hono/dist/jsx/dom/css.js +142 -147
- package/node_modules/hono/dist/jsx/dom/hooks/index.js +52 -40
- package/node_modules/hono/dist/jsx/dom/index.js +71 -134
- package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +275 -359
- package/node_modules/hono/dist/jsx/dom/jsx-dev-runtime.js +14 -18
- package/node_modules/hono/dist/jsx/dom/jsx-runtime.js +2 -8
- package/node_modules/hono/dist/jsx/dom/render.js +492 -631
- package/node_modules/hono/dist/jsx/dom/server.js +32 -32
- package/node_modules/hono/dist/jsx/dom/utils.js +6 -8
- package/node_modules/hono/dist/jsx/hooks/index.js +236 -308
- package/node_modules/hono/dist/jsx/index.js +45 -98
- package/node_modules/hono/dist/jsx/intrinsic-element/common.js +20 -22
- package/node_modules/hono/dist/jsx/intrinsic-element/components.js +113 -154
- package/node_modules/hono/dist/jsx/intrinsic-elements.js +1 -0
- package/node_modules/hono/dist/jsx/jsx-dev-runtime.js +12 -16
- package/node_modules/hono/dist/jsx/jsx-runtime.js +29 -42
- package/node_modules/hono/dist/jsx/streaming.js +120 -142
- package/node_modules/hono/dist/jsx/types.js +1 -0
- package/node_modules/hono/dist/jsx/utils.js +105 -168
- package/node_modules/hono/dist/middleware/basic-auth/index.js +96 -63
- package/node_modules/hono/dist/middleware/bearer-auth/index.js +93 -89
- package/node_modules/hono/dist/middleware/body-limit/index.js +66 -51
- package/node_modules/hono/dist/middleware/cache/index.js +165 -190
- package/node_modules/hono/dist/middleware/combine/index.js +132 -73
- package/node_modules/hono/dist/middleware/compress/index.js +75 -69
- package/node_modules/hono/dist/middleware/context-storage/index.js +49 -19
- package/node_modules/hono/dist/middleware/cors/index.js +107 -86
- package/node_modules/hono/dist/middleware/csrf/index.js +103 -53
- package/node_modules/hono/dist/middleware/etag/digest.js +59 -77
- package/node_modules/hono/dist/middleware/etag/index.js +71 -70
- package/node_modules/hono/dist/middleware/ip-restriction/index.js +163 -158
- package/node_modules/hono/dist/middleware/jsx-renderer/index.js +97 -54
- package/node_modules/hono/dist/middleware/jwk/index.js +1 -4
- package/node_modules/hono/dist/middleware/jwk/jwk.js +116 -112
- package/node_modules/hono/dist/middleware/jwt/index.js +2 -10
- package/node_modules/hono/dist/middleware/jwt/jwt.js +114 -114
- package/node_modules/hono/dist/middleware/language/index.js +2 -15
- package/node_modules/hono/dist/middleware/language/language.js +180 -157
- package/node_modules/hono/dist/middleware/logger/index.js +43 -37
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +81 -66
- package/node_modules/hono/dist/middleware/method-override/index.js +101 -81
- package/node_modules/hono/dist/middleware/powered-by/index.js +23 -9
- package/node_modules/hono/dist/middleware/pretty-json/index.js +39 -22
- package/node_modules/hono/dist/middleware/request-id/index.js +1 -4
- package/node_modules/hono/dist/middleware/request-id/request-id.js +33 -20
- package/node_modules/hono/dist/middleware/secure-headers/index.js +1 -5
- package/node_modules/hono/dist/middleware/secure-headers/permissions-policy.js +1 -0
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +144 -155
- package/node_modules/hono/dist/middleware/serve-static/index.js +55 -72
- package/node_modules/hono/dist/middleware/serve-static/path.js +15 -17
- package/node_modules/hono/dist/middleware/timeout/index.js +40 -23
- package/node_modules/hono/dist/middleware/timing/index.js +2 -9
- package/node_modules/hono/dist/middleware/timing/timing.js +177 -97
- package/node_modules/hono/dist/middleware/trailing-slash/index.js +85 -37
- package/node_modules/hono/dist/preset/quick.js +17 -15
- package/node_modules/hono/dist/preset/tiny.js +14 -11
- package/node_modules/hono/dist/request/constants.js +4 -5
- package/node_modules/hono/dist/request.js +328 -319
- package/node_modules/hono/dist/router/linear-router/index.js +1 -4
- package/node_modules/hono/dist/router/linear-router/router.js +93 -120
- package/node_modules/hono/dist/router/pattern-router/index.js +1 -4
- package/node_modules/hono/dist/router/pattern-router/router.js +39 -40
- package/node_modules/hono/dist/router/reg-exp-router/index.js +1 -7
- package/node_modules/hono/dist/router/reg-exp-router/matcher.js +17 -23
- package/node_modules/hono/dist/router/reg-exp-router/node.js +87 -110
- package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +89 -137
- package/node_modules/hono/dist/router/reg-exp-router/router.js +92 -129
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +69 -64
- package/node_modules/hono/dist/router/smart-router/index.js +1 -4
- package/node_modules/hono/dist/router/smart-router/router.js +46 -55
- package/node_modules/hono/dist/router/trie-router/index.js +1 -4
- package/node_modules/hono/dist/router/trie-router/node.js +131 -162
- package/node_modules/hono/dist/router/trie-router/router.js +11 -14
- package/node_modules/hono/dist/router/utils.js +4 -5
- package/node_modules/hono/dist/router.js +35 -14
- package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +4 -1
- package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +150 -105
- package/node_modules/hono/dist/types/adapter/aws-lambda/index.d.ts +4 -8
- package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +152 -123
- package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +4 -1
- package/node_modules/hono/dist/types/adapter/bun/index.d.ts +6 -10
- package/node_modules/hono/dist/types/adapter/bun/serve-static.d.ts +7 -2
- package/node_modules/hono/dist/types/adapter/bun/server.d.ts +4 -5
- package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +5 -1
- package/node_modules/hono/dist/types/adapter/bun/websocket.d.ts +31 -17
- package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +4 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-pages/handler.d.ts +29 -18
- package/node_modules/hono/dist/types/adapter/cloudflare-pages/index.d.ts +3 -7
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +6 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/index.d.ts +4 -7
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +5 -3
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/serve-static.d.ts +10 -5
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/utils.d.ts +10 -2
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/websocket.d.ts +6 -1
- package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +4 -1
- package/node_modules/hono/dist/types/adapter/deno/deno.d.ts +1 -0
- package/node_modules/hono/dist/types/adapter/deno/index.d.ts +5 -8
- package/node_modules/hono/dist/types/adapter/deno/serve-static.d.ts +7 -2
- package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +5 -1
- package/node_modules/hono/dist/types/adapter/deno/websocket.d.ts +6 -1
- package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +6 -1
- package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +83 -58
- package/node_modules/hono/dist/types/adapter/lambda-edge/index.d.ts +3 -7
- package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +4 -1
- package/node_modules/hono/dist/types/adapter/netlify/handler.d.ts +6 -1
- package/node_modules/hono/dist/types/adapter/netlify/index.d.ts +3 -5
- package/node_modules/hono/dist/types/adapter/netlify/mod.d.ts +3 -2
- package/node_modules/hono/dist/types/adapter/service-worker/handler.d.ts +9 -8
- package/node_modules/hono/dist/types/adapter/service-worker/index.d.ts +6 -9
- package/node_modules/hono/dist/types/adapter/service-worker/types.d.ts +12 -8
- package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +6 -1
- package/node_modules/hono/dist/types/adapter/vercel/handler.d.ts +6 -1
- package/node_modules/hono/dist/types/adapter/vercel/index.d.ts +3 -6
- package/node_modules/hono/dist/types/client/client.d.ts +5 -3
- package/node_modules/hono/dist/types/client/fetch-result-please.d.ts +21 -19
- package/node_modules/hono/dist/types/client/index.d.ts +5 -7
- package/node_modules/hono/dist/types/client/types.d.ts +134 -160
- package/node_modules/hono/dist/types/client/utils.d.ts +6 -4
- package/node_modules/hono/dist/types/compose.d.ts +4 -2
- package/node_modules/hono/dist/types/context.d.ts +335 -336
- package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +11 -9
- package/node_modules/hono/dist/types/helper/accepts/index.d.ts +2 -5
- package/node_modules/hono/dist/types/helper/adapter/index.d.ts +4 -6
- package/node_modules/hono/dist/types/helper/conninfo/index.d.ts +2 -5
- package/node_modules/hono/dist/types/helper/conninfo/types.d.ts +25 -23
- package/node_modules/hono/dist/types/helper/cookie/index.d.ts +10 -13
- package/node_modules/hono/dist/types/helper/css/common.d.ts +11 -10
- package/node_modules/hono/dist/types/helper/css/index.d.ts +25 -28
- package/node_modules/hono/dist/types/helper/dev/index.d.ts +10 -13
- package/node_modules/hono/dist/types/helper/factory/index.d.ts +26 -74
- package/node_modules/hono/dist/types/helper/html/index.d.ts +4 -7
- package/node_modules/hono/dist/types/helper/proxy/index.d.ts +19 -22
- package/node_modules/hono/dist/types/helper/route/index.d.ts +4 -2
- package/node_modules/hono/dist/types/helper/ssg/index.d.ts +4 -7
- package/node_modules/hono/dist/types/helper/ssg/middleware.d.ts +8 -7
- package/node_modules/hono/dist/types/helper/ssg/plugins.d.ts +3 -1
- package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +38 -36
- package/node_modules/hono/dist/types/helper/ssg/utils.d.ts +5 -4
- package/node_modules/hono/dist/types/helper/streaming/index.d.ts +4 -8
- package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +10 -8
- package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +4 -2
- package/node_modules/hono/dist/types/helper/streaming/text.d.ts +4 -2
- package/node_modules/hono/dist/types/helper/streaming/utils.d.ts +2 -0
- package/node_modules/hono/dist/types/helper/testing/index.d.ts +7 -10
- package/node_modules/hono/dist/types/helper/websocket/index.d.ts +30 -33
- package/node_modules/hono/dist/types/hono-base.d.ts +208 -211
- package/node_modules/hono/dist/types/hono.d.ts +11 -10
- package/node_modules/hono/dist/types/http-exception.d.ts +20 -23
- package/node_modules/hono/dist/types/index.d.ts +6 -37
- package/node_modules/hono/dist/types/jsx/base.d.ts +36 -35
- package/node_modules/hono/dist/types/jsx/children.d.ts +8 -6
- package/node_modules/hono/dist/types/jsx/components.d.ts +8 -5
- package/node_modules/hono/dist/types/jsx/constants.d.ts +2 -0
- package/node_modules/hono/dist/types/jsx/context.d.ts +9 -7
- package/node_modules/hono/dist/types/jsx/dom/client.d.ts +8 -10
- package/node_modules/hono/dist/types/jsx/dom/components.d.ts +9 -6
- package/node_modules/hono/dist/types/jsx/dom/context.d.ts +3 -1
- package/node_modules/hono/dist/types/jsx/dom/css.d.ts +26 -30
- package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +11 -13
- package/node_modules/hono/dist/types/jsx/dom/index.d.ts +78 -83
- package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +9 -5
- package/node_modules/hono/dist/types/jsx/dom/jsx-dev-runtime.d.ts +4 -6
- package/node_modules/hono/dist/types/jsx/dom/jsx-runtime.d.ts +3 -7
- package/node_modules/hono/dist/types/jsx/dom/render.d.ts +32 -51
- package/node_modules/hono/dist/types/jsx/dom/server.d.ts +86 -85
- package/node_modules/hono/dist/types/jsx/dom/utils.d.ts +2 -0
- package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +16 -17
- package/node_modules/hono/dist/types/jsx/index.d.ts +70 -73
- package/node_modules/hono/dist/types/jsx/intrinsic-element/common.d.ts +3 -1
- package/node_modules/hono/dist/types/jsx/intrinsic-element/components.d.ts +7 -4
- package/node_modules/hono/dist/types/jsx/intrinsic-elements.d.ts +708 -708
- package/node_modules/hono/dist/types/jsx/jsx-dev-runtime.d.ts +4 -7
- package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +7 -10
- package/node_modules/hono/dist/types/jsx/streaming.d.ts +9 -10
- package/node_modules/hono/dist/types/jsx/types.d.ts +11 -13
- package/node_modules/hono/dist/types/jsx/utils.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +17 -20
- package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +46 -49
- package/node_modules/hono/dist/types/middleware/body-limit/index.d.ts +6 -9
- package/node_modules/hono/dist/types/middleware/cache/index.d.ts +13 -15
- package/node_modules/hono/dist/types/middleware/combine/index.d.ts +4 -7
- package/node_modules/hono/dist/types/middleware/compress/index.d.ts +8 -10
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +4 -6
- package/node_modules/hono/dist/types/middleware/cors/index.d.ts +10 -13
- package/node_modules/hono/dist/types/middleware/csrf/index.d.ts +6 -9
- package/node_modules/hono/dist/types/middleware/etag/digest.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/etag/index.d.ts +6 -9
- package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +11 -13
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +11 -12
- package/node_modules/hono/dist/types/middleware/jwk/index.d.ts +2 -1
- package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +20 -23
- package/node_modules/hono/dist/types/middleware/jwt/index.d.ts +6 -6
- package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +28 -30
- package/node_modules/hono/dist/types/middleware/language/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/language/language.d.ts +42 -44
- package/node_modules/hono/dist/types/middleware/logger/index.d.ts +3 -6
- package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +7 -10
- package/node_modules/hono/dist/types/middleware/method-override/index.d.ts +14 -17
- package/node_modules/hono/dist/types/middleware/powered-by/index.d.ts +8 -11
- package/node_modules/hono/dist/types/middleware/pretty-json/index.d.ts +18 -21
- package/node_modules/hono/dist/types/middleware/request-id/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +9 -11
- package/node_modules/hono/dist/types/middleware/secure-headers/index.d.ts +5 -6
- package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +2 -1
- package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +55 -58
- package/node_modules/hono/dist/types/middleware/serve-static/index.d.ts +22 -24
- package/node_modules/hono/dist/types/middleware/serve-static/path.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/timeout/index.d.ts +5 -7
- package/node_modules/hono/dist/types/middleware/timing/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/timing/timing.d.ts +17 -21
- package/node_modules/hono/dist/types/middleware/trailing-slash/index.d.ts +35 -38
- package/node_modules/hono/dist/types/preset/quick.d.ts +6 -9
- package/node_modules/hono/dist/types/preset/tiny.d.ts +6 -9
- package/node_modules/hono/dist/types/request/constants.d.ts +2 -0
- package/node_modules/hono/dist/types/request.d.ts +288 -287
- package/node_modules/hono/dist/types/router/linear-router/index.d.ts +2 -5
- package/node_modules/hono/dist/types/router/linear-router/router.d.ts +7 -5
- package/node_modules/hono/dist/types/router/pattern-router/index.d.ts +2 -5
- package/node_modules/hono/dist/types/router/pattern-router/router.d.ts +7 -5
- package/node_modules/hono/dist/types/router/reg-exp-router/index.d.ts +3 -6
- package/node_modules/hono/dist/types/router/reg-exp-router/matcher.d.ts +3 -1
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +6 -4
- package/node_modules/hono/dist/types/router/reg-exp-router/prepared-router.d.ts +11 -11
- package/node_modules/hono/dist/types/router/reg-exp-router/router.d.ts +10 -9
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +7 -5
- package/node_modules/hono/dist/types/router/smart-router/index.d.ts +2 -5
- package/node_modules/hono/dist/types/router/smart-router/router.d.ts +11 -9
- package/node_modules/hono/dist/types/router/trie-router/index.d.ts +2 -5
- package/node_modules/hono/dist/types/router/trie-router/node.d.ts +6 -4
- package/node_modules/hono/dist/types/router/trie-router/router.d.ts +7 -5
- package/node_modules/hono/dist/types/router/utils.d.ts +2 -0
- package/node_modules/hono/dist/types/router.d.ts +23 -22
- package/node_modules/hono/dist/types/types.d.ts +146 -506
- package/node_modules/hono/dist/types/utils/accept.d.ts +5 -3
- package/node_modules/hono/dist/types/utils/basic-auth.d.ts +4 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +46 -51
- package/node_modules/hono/dist/types/utils/buffer.d.ts +7 -6
- package/node_modules/hono/dist/types/utils/color.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/compress.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/concurrent.d.ts +6 -4
- package/node_modules/hono/dist/types/utils/constants.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/cookie.d.ts +20 -19
- package/node_modules/hono/dist/types/utils/crypto.d.ts +5 -8
- package/node_modules/hono/dist/types/utils/encode.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/filepath.d.ts +5 -4
- package/node_modules/hono/dist/types/utils/handler.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/headers.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/html.d.ts +11 -10
- package/node_modules/hono/dist/types/utils/http-status.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/ipaddr.d.ts +4 -6
- package/node_modules/hono/dist/types/utils/jwt/index.d.ts +18 -12
- package/node_modules/hono/dist/types/utils/jwt/jwa.d.ts +15 -13
- package/node_modules/hono/dist/types/utils/jwt/jws.d.ts +4 -7
- package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +26 -29
- package/node_modules/hono/dist/types/utils/jwt/types.d.ts +48 -45
- package/node_modules/hono/dist/types/utils/jwt/utf8.d.ts +2 -0
- package/node_modules/hono/dist/types/utils/mime.d.ts +59 -57
- package/node_modules/hono/dist/types/utils/stream.d.ts +27 -25
- package/node_modules/hono/dist/types/utils/types.d.ts +14 -27
- package/node_modules/hono/dist/types/utils/url.d.ts +2 -1
- package/node_modules/hono/dist/types/validator/index.d.ts +3 -7
- package/node_modules/hono/dist/types/validator/utils.d.ts +6 -9
- package/node_modules/hono/dist/types/validator/validator.d.ts +11 -10
- package/node_modules/hono/dist/types.js +4 -6
- package/node_modules/hono/dist/utils/accept.js +185 -212
- package/node_modules/hono/dist/utils/basic-auth.js +18 -21
- package/node_modules/hono/dist/utils/body.js +87 -92
- package/node_modules/hono/dist/utils/buffer.js +44 -71
- package/node_modules/hono/dist/utils/color.js +33 -21
- package/node_modules/hono/dist/utils/compress.js +11 -5
- package/node_modules/hono/dist/utils/concurrent.js +29 -38
- package/node_modules/hono/dist/utils/constants.js +7 -5
- package/node_modules/hono/dist/utils/cookie.js +114 -163
- package/node_modules/hono/dist/utils/crypto.js +30 -40
- package/node_modules/hono/dist/utils/encode.js +30 -26
- package/node_modules/hono/dist/utils/filepath.js +23 -33
- package/node_modules/hono/dist/utils/handler.js +10 -11
- package/node_modules/hono/dist/utils/headers.js +1 -0
- package/node_modules/hono/dist/utils/html.js +97 -117
- package/node_modules/hono/dist/utils/http-status.js +1 -0
- package/node_modules/hono/dist/utils/ipaddr.js +227 -279
- package/node_modules/hono/dist/utils/jwt/index.js +12 -4
- package/node_modules/hono/dist/utils/jwt/jwa.js +24 -20
- package/node_modules/hono/dist/utils/jwt/jws.js +115 -174
- package/node_modules/hono/dist/utils/jwt/jwt.js +120 -198
- package/node_modules/hono/dist/utils/jwt/types.js +79 -95
- package/node_modules/hono/dist/utils/jwt/utf8.js +9 -7
- package/node_modules/hono/dist/utils/mime.js +74 -79
- package/node_modules/hono/dist/utils/stream.js +86 -88
- package/node_modules/hono/dist/utils/types.js +1 -0
- package/node_modules/hono/dist/utils/url.js +187 -215
- package/node_modules/hono/dist/validator/index.js +1 -4
- package/node_modules/hono/dist/validator/utils.js +1 -0
- package/node_modules/hono/dist/validator/validator.js +61 -83
- package/node_modules/hono/package.json +27 -27
- package/node_modules/imapflow/CHANGELOG.md +14 -0
- package/node_modules/imapflow/README.md +2 -0
- package/node_modules/imapflow/dist/cjs/commands/list.js +20 -8
- package/node_modules/imapflow/dist/cjs/errors.d.ts +2 -0
- package/node_modules/imapflow/dist/cjs/errors.js +4 -1
- package/node_modules/imapflow/dist/cjs/handler/imap-stream.js +7 -11
- package/node_modules/imapflow/dist/cjs/imap-flow.js +54 -27
- package/node_modules/imapflow/dist/cjs/logger.d.ts +21 -3
- package/node_modules/imapflow/dist/cjs/logger.js +35 -5
- package/node_modules/imapflow/dist/cjs/package-info.d.ts +1 -1
- package/node_modules/imapflow/dist/cjs/package-info.js +1 -1
- package/node_modules/imapflow/dist/cjs/search-compiler.d.ts +1 -1
- package/node_modules/imapflow/dist/cjs/search-compiler.js +48 -35
- package/node_modules/imapflow/dist/cjs/tools.js +9 -2
- package/node_modules/imapflow/dist/esm/commands/list.js +20 -8
- package/node_modules/imapflow/dist/esm/errors.d.ts +2 -0
- package/node_modules/imapflow/dist/esm/errors.js +4 -1
- package/node_modules/imapflow/dist/esm/handler/imap-stream.js +7 -8
- package/node_modules/imapflow/dist/esm/imap-flow.js +54 -27
- package/node_modules/imapflow/dist/esm/logger.d.ts +21 -3
- package/node_modules/imapflow/dist/esm/logger.js +33 -3
- package/node_modules/imapflow/dist/esm/package-info.d.ts +1 -1
- package/node_modules/imapflow/dist/esm/package-info.js +1 -1
- package/node_modules/imapflow/dist/esm/search-compiler.d.ts +1 -1
- package/node_modules/imapflow/dist/esm/search-compiler.js +49 -36
- package/node_modules/imapflow/dist/esm/tools.js +9 -2
- package/node_modules/imapflow/package.json +5 -5
- package/node_modules/libbase64/.github/workflows/release.yaml +12 -10
- package/node_modules/libbase64/.ncurc.js +7 -1
- package/node_modules/libbase64/CHANGELOG.md +7 -0
- package/node_modules/libbase64/lib/libbase64.js +27 -0
- package/node_modules/libbase64/package.json +4 -4
- package/node_modules/libmime/CHANGELOG.md +14 -0
- package/node_modules/libmime/lib/libmime.js +41 -21
- package/node_modules/libmime/package.json +3 -3
- package/node_modules/libqp/.github/workflows/release.yaml +12 -10
- package/node_modules/libqp/CHANGELOG.md +7 -0
- package/node_modules/libqp/lib/libqp.js +6 -4
- package/node_modules/libqp/package.json +2 -2
- package/node_modules/libqp/test/libqp-test.js +71 -14
- package/package.json +4 -2
- package/packages/cli/dist/.tsbuildinfo +1 -1
- package/packages/cli/dist/commands.d.ts.map +1 -1
- package/packages/cli/dist/commands.js +5 -2
- package/packages/cli/dist/commands.js.map +1 -1
- package/packages/core/dist/.tsbuildinfo +1 -1
- package/packages/core/dist/actions/permissions.d.ts +14 -0
- package/packages/core/dist/actions/permissions.d.ts.map +1 -1
- package/packages/core/dist/actions/permissions.js +15 -0
- package/packages/core/dist/actions/permissions.js.map +1 -1
- package/packages/core/dist/agents/catalog.d.ts +12 -1
- package/packages/core/dist/agents/catalog.d.ts.map +1 -1
- package/packages/core/dist/agents/catalog.js +57 -6
- package/packages/core/dist/agents/catalog.js.map +1 -1
- package/packages/core/dist/agents/delegates.d.ts +54 -0
- package/packages/core/dist/agents/delegates.d.ts.map +1 -0
- package/packages/core/dist/agents/delegates.js +51 -0
- package/packages/core/dist/agents/delegates.js.map +1 -0
- package/packages/core/dist/agents/index.d.ts +1 -0
- package/packages/core/dist/agents/index.d.ts.map +1 -1
- package/packages/core/dist/agents/index.js +1 -0
- package/packages/core/dist/agents/index.js.map +1 -1
- package/packages/core/dist/host/build.d.ts +26 -5
- package/packages/core/dist/host/build.d.ts.map +1 -1
- package/packages/core/dist/host/build.js +72 -0
- package/packages/core/dist/host/build.js.map +1 -1
- package/packages/core/dist/host/types.d.ts +67 -5
- package/packages/core/dist/host/types.d.ts.map +1 -1
- package/packages/core/dist/index.d.ts +1 -0
- package/packages/core/dist/index.d.ts.map +1 -1
- package/packages/core/dist/index.js +1 -0
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/json-schema.d.ts +32 -0
- package/packages/core/dist/json-schema.d.ts.map +1 -0
- package/packages/core/dist/json-schema.js +147 -0
- package/packages/core/dist/json-schema.js.map +1 -0
- package/packages/core/dist/learning/sources.d.ts.map +1 -1
- package/packages/core/dist/learning/sources.js +3 -0
- package/packages/core/dist/learning/sources.js.map +1 -1
- package/packages/core/dist/learning/types.d.ts +4 -3
- package/packages/core/dist/learning/types.d.ts.map +1 -1
- package/packages/core/dist/learning/types.js +1 -1
- package/packages/core/dist/learning/types.js.map +1 -1
- package/packages/core/dist/notifications/index.d.ts +1 -0
- package/packages/core/dist/notifications/index.d.ts.map +1 -1
- package/packages/core/dist/notifications/index.js +1 -0
- package/packages/core/dist/notifications/index.js.map +1 -1
- package/packages/core/dist/notifications/notify.d.ts.map +1 -1
- package/packages/core/dist/notifications/notify.js +47 -5
- package/packages/core/dist/notifications/notify.js.map +1 -1
- package/packages/core/dist/notifications/store.d.ts.map +1 -1
- package/packages/core/dist/notifications/store.js +3 -1
- package/packages/core/dist/notifications/store.js.map +1 -1
- package/packages/core/dist/notifications/topic.d.ts +25 -0
- package/packages/core/dist/notifications/topic.d.ts.map +1 -0
- package/packages/core/dist/notifications/topic.js +116 -0
- package/packages/core/dist/notifications/topic.js.map +1 -0
- package/packages/core/dist/notifications/types.d.ts +4 -0
- package/packages/core/dist/notifications/types.d.ts.map +1 -1
- package/packages/core/dist/onboarding/language-tag.d.ts +12 -0
- package/packages/core/dist/onboarding/language-tag.d.ts.map +1 -0
- package/packages/core/dist/onboarding/language-tag.js +64 -0
- package/packages/core/dist/onboarding/language-tag.js.map +1 -0
- package/packages/core/dist/pages/__fixtures__/demo.d.ts +11 -0
- package/packages/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
- package/packages/core/dist/pages/__fixtures__/demo.js +23 -1
- package/packages/core/dist/pages/__fixtures__/demo.js.map +1 -1
- package/packages/core/dist/pages.d.ts +19 -0
- package/packages/core/dist/pages.d.ts.map +1 -1
- package/packages/core/dist/pages.js +13 -0
- package/packages/core/dist/pages.js.map +1 -1
- package/packages/core/dist/plugin/index.d.ts +4 -3
- package/packages/core/dist/plugin/index.d.ts.map +1 -1
- package/packages/core/dist/plugin/version.d.ts +1 -1
- package/packages/core/dist/plugin/version.js +1 -1
- package/packages/core/dist/provider-accounts.d.ts +31 -0
- package/packages/core/dist/provider-accounts.d.ts.map +1 -1
- package/packages/core/dist/registry.d.ts +37 -1
- package/packages/core/dist/registry.d.ts.map +1 -1
- package/packages/core/dist/registry.js +187 -32
- package/packages/core/dist/registry.js.map +1 -1
- package/packages/core/dist/secrets/scrub.d.ts +2 -0
- package/packages/core/dist/secrets/scrub.d.ts.map +1 -1
- package/packages/core/dist/secrets/scrub.js +29 -0
- package/packages/core/dist/secrets/scrub.js.map +1 -1
- package/packages/core/dist/tools.d.ts +36 -1
- package/packages/core/dist/tools.d.ts.map +1 -1
- package/packages/core/dist/tools.js.map +1 -1
- package/packages/core/dist/views.d.ts +12 -12
- package/packages/core/migrations/050_notification_topic.sql +8 -0
- package/packages/core/package.json +2 -0
- package/packages/gateway/assets/mascot/core-idle.tgs +0 -0
- package/packages/gateway/assets/mascot/core-working.tgs +0 -0
- package/packages/gateway/dist/.tsbuildinfo +1 -1
- package/packages/gateway/dist/agents/canvas.d.ts +2 -2
- package/packages/gateway/dist/agents/canvas.d.ts.map +1 -1
- package/packages/gateway/dist/agents/canvas.js.map +1 -1
- package/packages/gateway/dist/agents/catalog.d.ts.map +1 -1
- package/packages/gateway/dist/agents/catalog.js +15 -6
- package/packages/gateway/dist/agents/catalog.js.map +1 -1
- package/packages/gateway/dist/agents/delegation.d.ts +20 -3
- package/packages/gateway/dist/agents/delegation.d.ts.map +1 -1
- package/packages/gateway/dist/agents/delegation.js +38 -12
- package/packages/gateway/dist/agents/delegation.js.map +1 -1
- package/packages/gateway/dist/agents/platform.d.ts +43 -13
- package/packages/gateway/dist/agents/platform.d.ts.map +1 -1
- package/packages/gateway/dist/agents/platform.js +97 -3
- package/packages/gateway/dist/agents/platform.js.map +1 -1
- package/packages/gateway/dist/agents/starter-team.d.ts +57 -0
- package/packages/gateway/dist/agents/starter-team.d.ts.map +1 -0
- package/packages/gateway/dist/agents/starter-team.js +151 -0
- package/packages/gateway/dist/agents/starter-team.js.map +1 -0
- package/packages/gateway/dist/anthropic-accounts.d.ts.map +1 -1
- package/packages/gateway/dist/anthropic-accounts.js +9 -20
- package/packages/gateway/dist/anthropic-accounts.js.map +1 -1
- package/packages/gateway/dist/bootstrap.d.ts +3 -0
- package/packages/gateway/dist/bootstrap.d.ts.map +1 -1
- package/packages/gateway/dist/bootstrap.js +58 -2
- package/packages/gateway/dist/bootstrap.js.map +1 -1
- package/packages/gateway/dist/codex-accounts.d.ts +7 -1
- package/packages/gateway/dist/codex-accounts.d.ts.map +1 -1
- package/packages/gateway/dist/codex-accounts.js +25 -26
- package/packages/gateway/dist/codex-accounts.js.map +1 -1
- package/packages/gateway/dist/mcp/requests.d.ts +8 -1
- package/packages/gateway/dist/mcp/requests.d.ts.map +1 -1
- package/packages/gateway/dist/mcp/requests.js +8 -1
- package/packages/gateway/dist/mcp/requests.js.map +1 -1
- package/packages/gateway/dist/missions/goals-page.d.ts.map +1 -1
- package/packages/gateway/dist/missions/goals-page.js +57 -0
- package/packages/gateway/dist/missions/goals-page.js.map +1 -1
- package/packages/gateway/dist/plugins/approve.js +45 -9
- package/packages/gateway/dist/plugins/approve.js.map +1 -1
- package/packages/gateway/dist/plugins/load.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/load.js +4 -0
- package/packages/gateway/dist/plugins/load.js.map +1 -1
- package/packages/gateway/dist/plugins/npm.d.ts +5 -1
- package/packages/gateway/dist/plugins/npm.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/npm.js +6 -0
- package/packages/gateway/dist/plugins/npm.js.map +1 -1
- package/packages/gateway/dist/plugins/scaffold.d.ts +15 -4
- package/packages/gateway/dist/plugins/scaffold.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/scaffold.js +86 -16
- package/packages/gateway/dist/plugins/scaffold.js.map +1 -1
- package/packages/gateway/dist/plugins/stage.d.ts +35 -1
- package/packages/gateway/dist/plugins/stage.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/stage.js +134 -8
- package/packages/gateway/dist/plugins/stage.js.map +1 -1
- package/packages/gateway/dist/plugins-cli.d.ts +5 -1
- package/packages/gateway/dist/plugins-cli.d.ts.map +1 -1
- package/packages/gateway/dist/plugins-cli.js +26 -4
- package/packages/gateway/dist/plugins-cli.js.map +1 -1
- package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
- package/packages/gateway/dist/provider-accounts.js +31 -3
- package/packages/gateway/dist/provider-accounts.js.map +1 -1
- package/packages/gateway/dist/provider-diagnostics.d.ts +14 -2
- package/packages/gateway/dist/provider-diagnostics.d.ts.map +1 -1
- package/packages/gateway/dist/provider-diagnostics.js +25 -9
- package/packages/gateway/dist/provider-diagnostics.js.map +1 -1
- package/packages/gateway/dist/telegram/api.d.ts +49 -0
- package/packages/gateway/dist/telegram/api.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/api.js +99 -0
- package/packages/gateway/dist/telegram/api.js.map +1 -1
- package/packages/gateway/dist/telegram/main.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/main.js +17 -0
- package/packages/gateway/dist/telegram/main.js.map +1 -1
- package/packages/gateway/dist/telegram/outbound.d.ts +5 -0
- package/packages/gateway/dist/telegram/outbound.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/outbound.js +10 -0
- package/packages/gateway/dist/telegram/outbound.js.map +1 -1
- package/packages/gateway/dist/telegram/stickers.d.ts +30 -0
- package/packages/gateway/dist/telegram/stickers.d.ts.map +1 -0
- package/packages/gateway/dist/telegram/stickers.js +146 -0
- package/packages/gateway/dist/telegram/stickers.js.map +1 -0
- package/packages/gateway/dist/telegram/surface.d.ts +6 -0
- package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/surface.js +36 -3
- package/packages/gateway/dist/telegram/surface.js.map +1 -1
- package/packages/gateway/dist/tips/engine.d.ts +75 -0
- package/packages/gateway/dist/tips/engine.d.ts.map +1 -0
- package/packages/gateway/dist/tips/engine.js +135 -0
- package/packages/gateway/dist/tips/engine.js.map +1 -0
- package/packages/gateway/dist/tips/facts.d.ts +69 -0
- package/packages/gateway/dist/tips/facts.d.ts.map +1 -0
- package/packages/gateway/dist/tips/facts.js +104 -0
- package/packages/gateway/dist/tips/facts.js.map +1 -0
- package/packages/gateway/dist/tips/route.d.ts +25 -0
- package/packages/gateway/dist/tips/route.d.ts.map +1 -0
- package/packages/gateway/dist/tips/route.js +96 -0
- package/packages/gateway/dist/tips/route.js.map +1 -0
- package/packages/gateway/dist/tips/rules.d.ts +33 -0
- package/packages/gateway/dist/tips/rules.d.ts.map +1 -0
- package/packages/gateway/dist/tips/rules.js +54 -0
- package/packages/gateway/dist/tips/rules.js.map +1 -0
- package/packages/gateway/dist/web/agent-offers.d.ts +30 -0
- package/packages/gateway/dist/web/agent-offers.d.ts.map +1 -1
- package/packages/gateway/dist/web/agent-offers.js +64 -1
- package/packages/gateway/dist/web/agent-offers.js.map +1 -1
- package/packages/gateway/dist/web/connections.d.ts +83 -0
- package/packages/gateway/dist/web/connections.d.ts.map +1 -0
- package/packages/gateway/dist/web/connections.js +270 -0
- package/packages/gateway/dist/web/connections.js.map +1 -0
- package/packages/gateway/dist/web/onboarding.d.ts +1 -1
- package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
- package/packages/gateway/dist/web/onboarding.js +5 -4
- package/packages/gateway/dist/web/onboarding.js.map +1 -1
- package/packages/gateway/dist/web/plugins.d.ts +12 -0
- package/packages/gateway/dist/web/plugins.d.ts.map +1 -1
- package/packages/gateway/dist/web/plugins.js +12 -2
- package/packages/gateway/dist/web/plugins.js.map +1 -1
- package/packages/gateway/dist/web/profile.js +3 -2
- package/packages/gateway/dist/web/profile.js.map +1 -1
- package/packages/gateway/dist/web/read.d.ts +6 -0
- package/packages/gateway/dist/web/read.d.ts.map +1 -1
- package/packages/gateway/dist/web/read.js +11 -4
- package/packages/gateway/dist/web/read.js.map +1 -1
- package/packages/gateway/dist/web/server.d.ts +6 -0
- package/packages/gateway/dist/web/server.d.ts.map +1 -1
- package/packages/gateway/dist/web/server.js +71 -2
- package/packages/gateway/dist/web/server.js.map +1 -1
- package/packages/gateway/dist/web/static.d.ts.map +1 -1
- package/packages/gateway/dist/web/static.js +1 -0
- package/packages/gateway/dist/web/static.js.map +1 -1
- package/packages/gateway/dist/web/version.d.ts +2 -0
- package/packages/gateway/dist/web/version.d.ts.map +1 -1
- package/packages/gateway/dist/web/version.js +27 -0
- package/packages/gateway/dist/web/version.js.map +1 -1
- package/packages/gateway/dist/web/write.d.ts +5 -0
- package/packages/gateway/dist/web/write.d.ts.map +1 -1
- package/packages/gateway/dist/web/write.js +20 -1
- package/packages/gateway/dist/web/write.js.map +1 -1
- package/packages/gateway/package.json +4 -1
- package/packages/gateway/src/agents/starter/keeper/agent.md +31 -0
- package/packages/gateway/src/agents/starter/keeper/skills/keeping-a-history.md +22 -0
- package/packages/gateway/src/agents/starter/planner/agent.md +30 -0
- package/packages/gateway/src/agents/starter/planner/skills/holding-a-follow-up.md +17 -0
- package/packages/gateway/src/agents/starter/planner/skills/writing-the-morning-brief.md +25 -0
- package/packages/gateway/src/agents/starter/scout/agent.md +33 -0
- package/packages/gateway/src/agents/starter/scout/skills/answering-with-sources.md +23 -0
- package/packages/gateway/src/agents/starter/scout/skills/the-web-is-evidence.md +25 -0
- package/packages/install/dist/.tsbuildinfo +1 -1
- package/packages/runtime/dist/.tsbuildinfo +1 -1
- package/packages/runtime/dist/anthropic-oauth.d.ts.map +1 -1
- package/packages/runtime/dist/anthropic-oauth.js +38 -73
- package/packages/runtime/dist/anthropic-oauth.js.map +1 -1
- package/packages/runtime/dist/codex-direct.d.ts +39 -0
- package/packages/runtime/dist/codex-direct.d.ts.map +1 -1
- package/packages/runtime/dist/codex-direct.js +122 -0
- package/packages/runtime/dist/codex-direct.js.map +1 -1
- package/packages/runtime/dist/codex-oauth.d.ts +0 -12
- package/packages/runtime/dist/codex-oauth.d.ts.map +1 -1
- package/packages/runtime/dist/codex-oauth.js +32 -45
- package/packages/runtime/dist/codex-oauth.js.map +1 -1
- package/packages/runtime/dist/delegate.d.ts.map +1 -1
- package/packages/runtime/dist/delegate.js +4 -2
- package/packages/runtime/dist/delegate.js.map +1 -1
- package/packages/runtime/dist/index.d.ts +2 -0
- package/packages/runtime/dist/index.d.ts.map +1 -1
- package/packages/runtime/dist/index.js +2 -0
- package/packages/runtime/dist/index.js.map +1 -1
- package/packages/runtime/dist/oauth-port.d.ts +68 -0
- package/packages/runtime/dist/oauth-port.d.ts.map +1 -0
- package/packages/runtime/dist/oauth-port.js +51 -0
- package/packages/runtime/dist/oauth-port.js.map +1 -0
- package/packages/runtime/dist/oauth.d.ts +255 -0
- package/packages/runtime/dist/oauth.d.ts.map +1 -0
- package/packages/runtime/dist/oauth.js +535 -0
- package/packages/runtime/dist/oauth.js.map +1 -0
- package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
- package/packages/tools/browser/dist/.tsbuildinfo +1 -1
- package/packages/tools/email/dist/.tsbuildinfo +1 -1
- package/packages/tools/email/dist/types.d.ts +2 -2
- package/packages/tools/email/dist/types.d.ts.map +1 -1
- package/packages/tools/host/dist/.tsbuildinfo +1 -1
- package/packages/tools/mcp/dist/.tsbuildinfo +1 -0
- package/packages/tools/mcp/dist/catalog.d.ts +26 -0
- package/packages/tools/mcp/dist/catalog.d.ts.map +1 -0
- package/packages/tools/mcp/dist/catalog.js +17 -0
- package/packages/tools/mcp/dist/catalog.js.map +1 -0
- package/packages/tools/mcp/dist/fetch.d.ts +44 -0
- package/packages/tools/mcp/dist/fetch.d.ts.map +1 -0
- package/packages/tools/mcp/dist/fetch.js +88 -0
- package/packages/tools/mcp/dist/fetch.js.map +1 -0
- package/packages/tools/mcp/dist/index.d.ts +27 -0
- package/packages/tools/mcp/dist/index.d.ts.map +1 -0
- package/packages/tools/mcp/dist/index.js +74 -0
- package/packages/tools/mcp/dist/index.js.map +1 -0
- package/packages/tools/mcp/dist/output.d.ts +38 -0
- package/packages/tools/mcp/dist/output.d.ts.map +1 -0
- package/packages/tools/mcp/dist/output.js +90 -0
- package/packages/tools/mcp/dist/output.js.map +1 -0
- package/packages/tools/mcp/dist/ports.d.ts +105 -0
- package/packages/tools/mcp/dist/ports.d.ts.map +1 -0
- package/packages/tools/mcp/dist/ports.js +9 -0
- package/packages/tools/mcp/dist/ports.js.map +1 -0
- package/packages/tools/mcp/dist/service.d.ts +220 -0
- package/packages/tools/mcp/dist/service.d.ts.map +1 -0
- package/packages/tools/mcp/dist/service.js +742 -0
- package/packages/tools/mcp/dist/service.js.map +1 -0
- package/packages/tools/mcp/dist/session.d.ts +50 -0
- package/packages/tools/mcp/dist/session.d.ts.map +1 -0
- package/packages/tools/mcp/dist/session.js +108 -0
- package/packages/tools/mcp/dist/session.js.map +1 -0
- package/packages/tools/mcp/dist/store.d.ts +70 -0
- package/packages/tools/mcp/dist/store.d.ts.map +1 -0
- package/packages/tools/mcp/dist/store.js +78 -0
- package/packages/tools/mcp/dist/store.js.map +1 -0
- package/packages/tools/mcp/dist/testing/fake.d.ts +51 -0
- package/packages/tools/mcp/dist/testing/fake.d.ts.map +1 -0
- package/packages/tools/mcp/dist/testing/fake.js +147 -0
- package/packages/tools/mcp/dist/testing/fake.js.map +1 -0
- package/packages/tools/mcp/dist/tiers.d.ts +51 -0
- package/packages/tools/mcp/dist/tiers.d.ts.map +1 -0
- package/packages/tools/mcp/dist/tiers.js +106 -0
- package/packages/tools/mcp/dist/tiers.js.map +1 -0
- package/packages/tools/mcp/dist/tokens.d.ts +35 -0
- package/packages/tools/mcp/dist/tokens.d.ts.map +1 -0
- package/packages/tools/mcp/dist/tokens.js +75 -0
- package/packages/tools/mcp/dist/tokens.js.map +1 -0
- package/packages/tools/mcp/migrations/001_connections.sql +49 -0
- package/packages/tools/mcp/migrations/002_review_again.sql +15 -0
- package/packages/tools/mcp/package.json +34 -0
- package/packages/tools/memory/dist/.tsbuildinfo +1 -1
- package/packages/tools/web/dist/.tsbuildinfo +1 -1
- package/packages/web/dist/apple-touch-icon.png +0 -0
- package/packages/web/dist/assets/index-CBEdA2dN.js +125 -0
- package/packages/web/dist/assets/index-Ddp9egOQ.css +1 -0
- package/packages/web/dist/assets/lottie_light-BCNsQpt8.js +9 -0
- package/packages/web/dist/build.json +1 -0
- package/packages/web/dist/icon-192.png +0 -0
- package/packages/web/dist/icon-512.png +0 -0
- package/packages/web/dist/icon-maskable-512.png +0 -0
- package/packages/web/dist/index.html +6 -3
- package/packages/web/dist/manifest.webmanifest +16 -0
- package/packages/web/dist/mascot/README.md +5 -0
- package/packages/web/dist/mascot/anim/core-idle.json +1 -0
- package/packages/web/dist/mascot/anim/core-working.json +1 -0
- package/packages/web/dist/precache.json +28 -0
- package/packages/web/dist/sw.js +99 -0
- package/packages/web/dist/assets/index-D5cRFcgm.css +0 -1
- package/packages/web/dist/assets/index-GCFB1vBV.js +0 -125
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
var Yg=e=>{throw TypeError(e)};var qg=(e,t,n)=>t.has(e)||Yg("Cannot "+n);var $t=(e,t,n)=>(qg(e,t,"read from private field"),n?n.call(e):t.get(e)),Qg=(e,t,n)=>t.has(e)?Yg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xu=(e,t,n,r)=>(qg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function EN(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function AN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ej={exports:{}},iu={},tj={exports:{}},Te={};/**
|
|
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 $a=Symbol.for("react.element"),RN=Symbol.for("react.portal"),TN=Symbol.for("react.fragment"),PN=Symbol.for("react.strict_mode"),IN=Symbol.for("react.profiler"),MN=Symbol.for("react.provider"),$N=Symbol.for("react.context"),_N=Symbol.for("react.forward_ref"),ON=Symbol.for("react.suspense"),DN=Symbol.for("react.memo"),LN=Symbol.for("react.lazy"),Xg=Symbol.iterator;function FN(e){return e===null||typeof e!="object"?null:(e=Xg&&e[Xg]||e["@@iterator"],typeof e=="function"?e:null)}var nj={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},sj=Object.assign,rj={};function oo(e,t,n){this.props=e,this.context=t,this.refs=rj,this.updater=n||nj}oo.prototype.isReactComponent={};oo.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};oo.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ij(){}ij.prototype=oo.prototype;function hp(e,t,n){this.props=e,this.context=t,this.refs=rj,this.updater=n||nj}var pp=hp.prototype=new ij;pp.constructor=hp;sj(pp,oo.prototype);pp.isPureReactComponent=!0;var Jg=Array.isArray,oj=Object.prototype.hasOwnProperty,mp={current:null},aj={key:!0,ref:!0,__self:!0,__source:!0};function lj(e,t,n){var r,i={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)oj.call(t,r)&&!aj.hasOwnProperty(r)&&(i[r]=t[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)i[r]===void 0&&(i[r]=l[r]);return{$$typeof:$a,type:e,key:o,ref:a,props:i,_owner:mp.current}}function UN(e,t){return{$$typeof:$a,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function gp(e){return typeof e=="object"&&e!==null&&e.$$typeof===$a}function BN(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Zg=/\/+/g;function Ju(e,t){return typeof e=="object"&&e!==null&&e.key!=null?BN(""+e.key):t.toString(36)}function Hl(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case $a:case RN:a=!0}}if(a)return a=e,i=i(a),e=r===""?"."+Ju(a,0):r,Jg(i)?(n="",e!=null&&(n=e.replace(Zg,"$&/")+"/"),Hl(i,t,n,"",function(u){return u})):i!=null&&(gp(i)&&(i=UN(i,n+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(Zg,"$&/")+"/")+e)),t.push(i)),1;if(a=0,r=r===""?".":r+":",Jg(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+Ju(o,l);a+=Hl(o,t,n,c,i)}else if(c=FN(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+Ju(o,l++),a+=Hl(o,t,n,c,i);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function rl(e,t,n){if(e==null)return e;var r=[],i=0;return Hl(e,r,"","",function(o){return t.call(n,o,i++)}),r}function zN(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Yt={current:null},Vl={transition:null},WN={ReactCurrentDispatcher:Yt,ReactCurrentBatchConfig:Vl,ReactCurrentOwner:mp};function cj(){throw Error("act(...) is not supported in production builds of React.")}Te.Children={map:rl,forEach:function(e,t,n){rl(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return rl(e,function(){t++}),t},toArray:function(e){return rl(e,function(t){return t})||[]},only:function(e){if(!gp(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Te.Component=oo;Te.Fragment=TN;Te.Profiler=IN;Te.PureComponent=hp;Te.StrictMode=PN;Te.Suspense=ON;Te.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=WN;Te.act=cj;Te.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=sj({},e.props),i=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=mp.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)oj.call(t,c)&&!aj.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:$a,type:e.type,key:i,ref:o,props:r,_owner:a}};Te.createContext=function(e){return e={$$typeof:$N,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:MN,_context:e},e.Consumer=e};Te.createElement=lj;Te.createFactory=function(e){var t=lj.bind(null,e);return t.type=e,t};Te.createRef=function(){return{current:null}};Te.forwardRef=function(e){return{$$typeof:_N,render:e}};Te.isValidElement=gp;Te.lazy=function(e){return{$$typeof:LN,_payload:{_status:-1,_result:e},_init:zN}};Te.memo=function(e,t){return{$$typeof:DN,type:e,compare:t===void 0?null:t}};Te.startTransition=function(e){var t=Vl.transition;Vl.transition={};try{e()}finally{Vl.transition=t}};Te.unstable_act=cj;Te.useCallback=function(e,t){return Yt.current.useCallback(e,t)};Te.useContext=function(e){return Yt.current.useContext(e)};Te.useDebugValue=function(){};Te.useDeferredValue=function(e){return Yt.current.useDeferredValue(e)};Te.useEffect=function(e,t){return Yt.current.useEffect(e,t)};Te.useId=function(){return Yt.current.useId()};Te.useImperativeHandle=function(e,t,n){return Yt.current.useImperativeHandle(e,t,n)};Te.useInsertionEffect=function(e,t){return Yt.current.useInsertionEffect(e,t)};Te.useLayoutEffect=function(e,t){return Yt.current.useLayoutEffect(e,t)};Te.useMemo=function(e,t){return Yt.current.useMemo(e,t)};Te.useReducer=function(e,t,n){return Yt.current.useReducer(e,t,n)};Te.useRef=function(e){return Yt.current.useRef(e)};Te.useState=function(e){return Yt.current.useState(e)};Te.useSyncExternalStore=function(e,t,n){return Yt.current.useSyncExternalStore(e,t,n)};Te.useTransition=function(){return Yt.current.useTransition()};Te.version="18.3.1";tj.exports=Te;var d=tj.exports;const HN=AN(d),ao=EN({__proto__:null,default:HN},[d]);/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var VN=d,KN=Symbol.for("react.element"),GN=Symbol.for("react.fragment"),YN=Object.prototype.hasOwnProperty,qN=VN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,QN={key:!0,ref:!0,__self:!0,__source:!0};function uj(e,t,n){var r,i={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)YN.call(t,r)&&!QN.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:KN,type:e,key:o,ref:a,props:i,_owner:qN.current}}iu.Fragment=GN;iu.jsx=uj;iu.jsxs=uj;ej.exports=iu;var s=ej.exports,dj={exports:{}},wn={},fj={exports:{}},hj={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(e){function t(M,W){var $=M.length;M.push(W);e:for(;0<$;){var ee=$-1>>>1,ce=M[ee];if(0<i(ce,W))M[ee]=W,M[$]=ce,$=ee;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var W=M[0],$=M.pop();if($!==W){M[0]=$;e:for(var ee=0,ce=M.length,Ce=ce>>>1;ee<Ce;){var J=2*(ee+1)-1,ge=M[J],xe=J+1,je=M[xe];if(0>i(ge,$))xe<ce&&0>i(je,ge)?(M[ee]=je,M[xe]=$,ee=xe):(M[ee]=ge,M[J]=$,ee=J);else if(xe<ce&&0>i(je,$))M[ee]=je,M[xe]=$,ee=xe;else break e}}return W}function i(M,W){var $=M.sortIndex-W.sortIndex;return $!==0?$:M.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],u=[],h=1,f=null,p=3,x=!1,y=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(M){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=M)r(u),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(u)}}function g(M){if(w=!1,j(M),!y)if(n(c)!==null)y=!0,Y(S);else{var W=n(u);W!==null&&G(g,W.startTime-M)}}function S(M,W){y=!1,w&&(w=!1,v(C),C=-1),x=!0;var $=p;try{for(j(W),f=n(c);f!==null&&(!(f.expirationTime>W)||M&&!_());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,p=f.priorityLevel;var ce=ee(f.expirationTime<=W);W=e.unstable_now(),typeof ce=="function"?f.callback=ce:f===n(c)&&r(c),j(W)}else r(c);f=n(c)}if(f!==null)var Ce=!0;else{var J=n(u);J!==null&&G(g,J.startTime-W),Ce=!1}return Ce}finally{f=null,p=$,x=!1}}var k=!1,N=null,C=-1,A=5,E=-1;function _(){return!(e.unstable_now()-E<A)}function L(){if(N!==null){var M=e.unstable_now();E=M;var W=!0;try{W=N(!0,M)}finally{W?B():(k=!1,N=null)}}else k=!1}var B;if(typeof m=="function")B=function(){m(L)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,O=R.port2;R.port1.onmessage=L,B=function(){O.postMessage(null)}}else B=function(){b(L,0)};function Y(M){N=M,k||(k=!0,B())}function G(M,W){C=b(function(){M(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){y||x||(y=!0,Y(S))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(M){switch(p){case 1:case 2:case 3:var W=3;break;default:W=p}var $=p;p=W;try{return M()}finally{p=$}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,W){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var $=p;p=M;try{return W()}finally{p=$}},e.unstable_scheduleCallback=function(M,W,$){var ee=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?ee+$:ee):$=ee,M){case 1:var ce=-1;break;case 2:ce=250;break;case 5:ce=1073741823;break;case 4:ce=1e4;break;default:ce=5e3}return ce=$+ce,M={id:h++,callback:W,priorityLevel:M,startTime:$,expirationTime:ce,sortIndex:-1},$>ee?(M.sortIndex=$,t(u,M),n(c)===null&&M===n(u)&&(w?(v(C),C=-1):w=!0,G(g,$-ee))):(M.sortIndex=ce,t(c,M),y||x||(y=!0,Y(S))),M},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(M){var W=p;return function(){var $=p;p=W;try{return M.apply(this,arguments)}finally{p=$}}}})(hj);fj.exports=hj;var XN=fj.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 JN=d,jn=XN;function Q(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var pj=new Set,sa={};function Jr(e,t){Wi(e,t),Wi(e+"Capture",t)}function Wi(e,t){for(sa[e]=t,e=0;e<t.length;e++)pj.add(t[e])}var _s=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gf=Object.prototype.hasOwnProperty,ZN=/^[: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]*$/,ex={},tx={};function eC(e){return gf.call(tx,e)?!0:gf.call(ex,e)?!1:ZN.test(e)?tx[e]=!0:(ex[e]=!0,!1)}function tC(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function nC(e,t,n,r){if(t===null||typeof t>"u"||tC(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function qt(e,t,n,r,i,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var It={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){It[e]=new qt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];It[t]=new qt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){It[e]=new qt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){It[e]=new qt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){It[e]=new qt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){It[e]=new qt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){It[e]=new qt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){It[e]=new qt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){It[e]=new qt(e,5,!1,e.toLowerCase(),null,!1,!1)});var xp=/[\-:]([a-z])/g;function vp(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(xp,vp);It[t]=new qt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(xp,vp);It[t]=new qt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(xp,vp);It[t]=new qt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){It[e]=new qt(e,1,!1,e.toLowerCase(),null,!1,!1)});It.xlinkHref=new qt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){It[e]=new qt(e,1,!1,e.toLowerCase(),null,!0,!0)});function yp(e,t,n,r){var i=It.hasOwnProperty(t)?It[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(nC(t,n,i,r)&&(n=null),r||i===null?eC(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Ws=JN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,il=Symbol.for("react.element"),ji=Symbol.for("react.portal"),wi=Symbol.for("react.fragment"),jp=Symbol.for("react.strict_mode"),xf=Symbol.for("react.profiler"),mj=Symbol.for("react.provider"),gj=Symbol.for("react.context"),wp=Symbol.for("react.forward_ref"),vf=Symbol.for("react.suspense"),yf=Symbol.for("react.suspense_list"),bp=Symbol.for("react.memo"),Qs=Symbol.for("react.lazy"),xj=Symbol.for("react.offscreen"),nx=Symbol.iterator;function No(e){return e===null||typeof e!="object"?null:(e=nx&&e[nx]||e["@@iterator"],typeof e=="function"?e:null)}var et=Object.assign,Zu;function Lo(e){if(Zu===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Zu=t&&t[1]||""}return`
|
|
34
|
-
`+Zu+e}var ed=!1;function td(e,t){if(!e||ed)return"";ed=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(`
|
|
35
|
-
`),o=r.stack.split(`
|
|
36
|
-
`),a=i.length-1,l=o.length-1;1<=a&&0<=l&&i[a]!==o[l];)l--;for(;1<=a&&0<=l;a--,l--)if(i[a]!==o[l]){if(a!==1||l!==1)do if(a--,l--,0>l||i[a]!==o[l]){var c=`
|
|
37
|
-
`+i[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{ed=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Lo(e):""}function sC(e){switch(e.tag){case 5:return Lo(e.type);case 16:return Lo("Lazy");case 13:return Lo("Suspense");case 19:return Lo("SuspenseList");case 0:case 2:case 15:return e=td(e.type,!1),e;case 11:return e=td(e.type.render,!1),e;case 1:return e=td(e.type,!0),e;default:return""}}function jf(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case wi:return"Fragment";case ji:return"Portal";case xf:return"Profiler";case jp:return"StrictMode";case vf:return"Suspense";case yf:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case gj:return(e.displayName||"Context")+".Consumer";case mj:return(e._context.displayName||"Context")+".Provider";case wp:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case bp:return t=e.displayName||null,t!==null?t:jf(e.type)||"Memo";case Qs:t=e._payload,e=e._init;try{return jf(e(t))}catch{}}return null}function rC(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return jf(t);case 8:return t===jp?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function hr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vj(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function iC(e){var t=vj(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ol(e){e._valueTracker||(e._valueTracker=iC(e))}function yj(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vj(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function mc(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function wf(e,t){var n=t.checked;return et({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function sx(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=hr(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function jj(e,t){t=t.checked,t!=null&&yp(e,"checked",t,!1)}function bf(e,t){jj(e,t);var n=hr(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?kf(e,t.type,n):t.hasOwnProperty("defaultValue")&&kf(e,t.type,hr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function rx(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function kf(e,t,n){(t!=="number"||mc(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Fo=Array.isArray;function Mi(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+hr(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Sf(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Q(91));return et({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ix(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Q(92));if(Fo(n)){if(1<n.length)throw Error(Q(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:hr(n)}}function wj(e,t){var n=hr(t.value),r=hr(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function ox(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function bj(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Nf(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?bj(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var al,kj=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(al=al||document.createElement("div"),al.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=al.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ra(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Wo={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},oC=["Webkit","ms","Moz","O"];Object.keys(Wo).forEach(function(e){oC.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Wo[t]=Wo[e]})});function Sj(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Wo.hasOwnProperty(e)&&Wo[e]?(""+t).trim():t+"px"}function Nj(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Sj(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var aC=et({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Cf(e,t){if(t){if(aC[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Q(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Q(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Q(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Q(62))}}function Ef(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Af=null;function kp(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rf=null,$i=null,_i=null;function ax(e){if(e=Da(e)){if(typeof Rf!="function")throw Error(Q(280));var t=e.stateNode;t&&(t=uu(t),Rf(e.stateNode,e.type,t))}}function Cj(e){$i?_i?_i.push(e):_i=[e]:$i=e}function Ej(){if($i){var e=$i,t=_i;if(_i=$i=null,ax(e),t)for(e=0;e<t.length;e++)ax(t[e])}}function Aj(e,t){return e(t)}function Rj(){}var nd=!1;function Tj(e,t,n){if(nd)return e(t,n);nd=!0;try{return Aj(e,t,n)}finally{nd=!1,($i!==null||_i!==null)&&(Rj(),Ej())}}function ia(e,t){var n=e.stateNode;if(n===null)return null;var r=uu(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Q(231,t,typeof n));return n}var Tf=!1;if(_s)try{var Co={};Object.defineProperty(Co,"passive",{get:function(){Tf=!0}}),window.addEventListener("test",Co,Co),window.removeEventListener("test",Co,Co)}catch{Tf=!1}function lC(e,t,n,r,i,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(h){this.onError(h)}}var Ho=!1,gc=null,xc=!1,Pf=null,cC={onError:function(e){Ho=!0,gc=e}};function uC(e,t,n,r,i,o,a,l,c){Ho=!1,gc=null,lC.apply(cC,arguments)}function dC(e,t,n,r,i,o,a,l,c){if(uC.apply(this,arguments),Ho){if(Ho){var u=gc;Ho=!1,gc=null}else throw Error(Q(198));xc||(xc=!0,Pf=u)}}function Zr(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Pj(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function lx(e){if(Zr(e)!==e)throw Error(Q(188))}function fC(e){var t=e.alternate;if(!t){if(t=Zr(e),t===null)throw Error(Q(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return lx(i),e;if(o===r)return lx(i),t;o=o.sibling}throw Error(Q(188))}if(n.return!==r.return)n=i,r=o;else{for(var a=!1,l=i.child;l;){if(l===n){a=!0,n=i,r=o;break}if(l===r){a=!0,r=i,n=o;break}l=l.sibling}if(!a){for(l=o.child;l;){if(l===n){a=!0,n=o,r=i;break}if(l===r){a=!0,r=o,n=i;break}l=l.sibling}if(!a)throw Error(Q(189))}}if(n.alternate!==r)throw Error(Q(190))}if(n.tag!==3)throw Error(Q(188));return n.stateNode.current===n?e:t}function Ij(e){return e=fC(e),e!==null?Mj(e):null}function Mj(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Mj(e);if(t!==null)return t;e=e.sibling}return null}var $j=jn.unstable_scheduleCallback,cx=jn.unstable_cancelCallback,hC=jn.unstable_shouldYield,pC=jn.unstable_requestPaint,at=jn.unstable_now,mC=jn.unstable_getCurrentPriorityLevel,Sp=jn.unstable_ImmediatePriority,_j=jn.unstable_UserBlockingPriority,vc=jn.unstable_NormalPriority,gC=jn.unstable_LowPriority,Oj=jn.unstable_IdlePriority,ou=null,cs=null;function xC(e){if(cs&&typeof cs.onCommitFiberRoot=="function")try{cs.onCommitFiberRoot(ou,e,void 0,(e.current.flags&128)===128)}catch{}}var zn=Math.clz32?Math.clz32:jC,vC=Math.log,yC=Math.LN2;function jC(e){return e>>>=0,e===0?32:31-(vC(e)/yC|0)|0}var ll=64,cl=4194304;function Uo(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function yc(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~i;l!==0?r=Uo(l):(o&=a,o!==0&&(r=Uo(o)))}else a=n&~i,a!==0?r=Uo(a):o!==0&&(r=Uo(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-zn(t),i=1<<n,r|=e[n],t&=~i;return r}function wC(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function bC(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-zn(o),l=1<<a,c=i[a];c===-1?(!(l&n)||l&r)&&(i[a]=wC(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function If(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Dj(){var e=ll;return ll<<=1,!(ll&4194240)&&(ll=64),e}function sd(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function _a(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-zn(t),e[t]=n}function kC(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-zn(n),o=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~o}}function Np(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-zn(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var Be=0;function Lj(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Fj,Cp,Uj,Bj,zj,Mf=!1,ul=[],sr=null,rr=null,ir=null,oa=new Map,aa=new Map,Js=[],SC="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 ux(e,t){switch(e){case"focusin":case"focusout":sr=null;break;case"dragenter":case"dragleave":rr=null;break;case"mouseover":case"mouseout":ir=null;break;case"pointerover":case"pointerout":oa.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":aa.delete(t.pointerId)}}function Eo(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=Da(t),t!==null&&Cp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function NC(e,t,n,r,i){switch(t){case"focusin":return sr=Eo(sr,e,t,n,r,i),!0;case"dragenter":return rr=Eo(rr,e,t,n,r,i),!0;case"mouseover":return ir=Eo(ir,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return oa.set(o,Eo(oa.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,aa.set(o,Eo(aa.get(o)||null,e,t,n,r,i)),!0}return!1}function Wj(e){var t=Mr(e.target);if(t!==null){var n=Zr(t);if(n!==null){if(t=n.tag,t===13){if(t=Pj(n),t!==null){e.blockedOn=t,zj(e.priority,function(){Uj(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Kl(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=$f(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Af=r,n.target.dispatchEvent(r),Af=null}else return t=Da(n),t!==null&&Cp(t),e.blockedOn=n,!1;t.shift()}return!0}function dx(e,t,n){Kl(e)&&n.delete(t)}function CC(){Mf=!1,sr!==null&&Kl(sr)&&(sr=null),rr!==null&&Kl(rr)&&(rr=null),ir!==null&&Kl(ir)&&(ir=null),oa.forEach(dx),aa.forEach(dx)}function Ao(e,t){e.blockedOn===t&&(e.blockedOn=null,Mf||(Mf=!0,jn.unstable_scheduleCallback(jn.unstable_NormalPriority,CC)))}function la(e){function t(i){return Ao(i,e)}if(0<ul.length){Ao(ul[0],e);for(var n=1;n<ul.length;n++){var r=ul[n];r.blockedOn===e&&(r.blockedOn=null)}}for(sr!==null&&Ao(sr,e),rr!==null&&Ao(rr,e),ir!==null&&Ao(ir,e),oa.forEach(t),aa.forEach(t),n=0;n<Js.length;n++)r=Js[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Js.length&&(n=Js[0],n.blockedOn===null);)Wj(n),n.blockedOn===null&&Js.shift()}var Oi=Ws.ReactCurrentBatchConfig,jc=!0;function EC(e,t,n,r){var i=Be,o=Oi.transition;Oi.transition=null;try{Be=1,Ep(e,t,n,r)}finally{Be=i,Oi.transition=o}}function AC(e,t,n,r){var i=Be,o=Oi.transition;Oi.transition=null;try{Be=4,Ep(e,t,n,r)}finally{Be=i,Oi.transition=o}}function Ep(e,t,n,r){if(jc){var i=$f(e,t,n,r);if(i===null)hd(e,t,r,wc,n),ux(e,r);else if(NC(i,e,t,n,r))r.stopPropagation();else if(ux(e,r),t&4&&-1<SC.indexOf(e)){for(;i!==null;){var o=Da(i);if(o!==null&&Fj(o),o=$f(e,t,n,r),o===null&&hd(e,t,r,wc,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else hd(e,t,r,null,n)}}var wc=null;function $f(e,t,n,r){if(wc=null,e=kp(r),e=Mr(e),e!==null)if(t=Zr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Pj(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return wc=e,null}function Hj(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(mC()){case Sp:return 1;case _j:return 4;case vc:case gC:return 16;case Oj:return 536870912;default:return 16}default:return 16}}var er=null,Ap=null,Gl=null;function Vj(){if(Gl)return Gl;var e,t=Ap,n=t.length,r,i="value"in er?er.value:er.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===i[o-r];r++);return Gl=i.slice(e,1<r?1-r:void 0)}function Yl(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function dl(){return!0}function fx(){return!1}function bn(e){function t(n,r,i,o,a){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?dl:fx,this.isPropagationStopped=fx,this}return et(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=dl)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=dl)},persist:function(){},isPersistent:dl}),t}var lo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Rp=bn(lo),Oa=et({},lo,{view:0,detail:0}),RC=bn(Oa),rd,id,Ro,au=et({},Oa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tp,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Ro&&(Ro&&e.type==="mousemove"?(rd=e.screenX-Ro.screenX,id=e.screenY-Ro.screenY):id=rd=0,Ro=e),rd)},movementY:function(e){return"movementY"in e?e.movementY:id}}),hx=bn(au),TC=et({},au,{dataTransfer:0}),PC=bn(TC),IC=et({},Oa,{relatedTarget:0}),od=bn(IC),MC=et({},lo,{animationName:0,elapsedTime:0,pseudoElement:0}),$C=bn(MC),_C=et({},lo,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),OC=bn(_C),DC=et({},lo,{data:0}),px=bn(DC),LC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},FC={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"},UC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function BC(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=UC[e])?!!t[e]:!1}function Tp(){return BC}var zC=et({},Oa,{key:function(e){if(e.key){var t=LC[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Yl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?FC[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tp,charCode:function(e){return e.type==="keypress"?Yl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Yl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),WC=bn(zC),HC=et({},au,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),mx=bn(HC),VC=et({},Oa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tp}),KC=bn(VC),GC=et({},lo,{propertyName:0,elapsedTime:0,pseudoElement:0}),YC=bn(GC),qC=et({},au,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),QC=bn(qC),XC=[9,13,27,32],Pp=_s&&"CompositionEvent"in window,Vo=null;_s&&"documentMode"in document&&(Vo=document.documentMode);var JC=_s&&"TextEvent"in window&&!Vo,Kj=_s&&(!Pp||Vo&&8<Vo&&11>=Vo),gx=" ",xx=!1;function Gj(e,t){switch(e){case"keyup":return XC.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yj(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function ZC(e,t){switch(e){case"compositionend":return Yj(t);case"keypress":return t.which!==32?null:(xx=!0,gx);case"textInput":return e=t.data,e===gx&&xx?null:e;default:return null}}function eE(e,t){if(bi)return e==="compositionend"||!Pp&&Gj(e,t)?(e=Vj(),Gl=Ap=er=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Kj&&t.locale!=="ko"?null:t.data;default:return null}}var tE={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 vx(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!tE[e.type]:t==="textarea"}function qj(e,t,n,r){Cj(r),t=bc(t,"onChange"),0<t.length&&(n=new Rp("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Ko=null,ca=null;function nE(e){ow(e,0)}function lu(e){var t=Ni(e);if(yj(t))return e}function sE(e,t){if(e==="change")return t}var Qj=!1;if(_s){var ad;if(_s){var ld="oninput"in document;if(!ld){var yx=document.createElement("div");yx.setAttribute("oninput","return;"),ld=typeof yx.oninput=="function"}ad=ld}else ad=!1;Qj=ad&&(!document.documentMode||9<document.documentMode)}function jx(){Ko&&(Ko.detachEvent("onpropertychange",Xj),ca=Ko=null)}function Xj(e){if(e.propertyName==="value"&&lu(ca)){var t=[];qj(t,ca,e,kp(e)),Tj(nE,t)}}function rE(e,t,n){e==="focusin"?(jx(),Ko=t,ca=n,Ko.attachEvent("onpropertychange",Xj)):e==="focusout"&&jx()}function iE(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return lu(ca)}function oE(e,t){if(e==="click")return lu(t)}function aE(e,t){if(e==="input"||e==="change")return lu(t)}function lE(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Vn=typeof Object.is=="function"?Object.is:lE;function ua(e,t){if(Vn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!gf.call(t,i)||!Vn(e[i],t[i]))return!1}return!0}function wx(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function bx(e,t){var n=wx(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=wx(n)}}function Jj(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Jj(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zj(){for(var e=window,t=mc();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=mc(e.document)}return t}function Ip(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function cE(e){var t=Zj(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Jj(n.ownerDocument.documentElement,n)){if(r!==null&&Ip(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=bx(n,o);var a=bx(n,r);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var uE=_s&&"documentMode"in document&&11>=document.documentMode,ki=null,_f=null,Go=null,Of=!1;function kx(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Of||ki==null||ki!==mc(r)||(r=ki,"selectionStart"in r&&Ip(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Go&&ua(Go,r)||(Go=r,r=bc(_f,"onSelect"),0<r.length&&(t=new Rp("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ki)))}function fl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Si={animationend:fl("Animation","AnimationEnd"),animationiteration:fl("Animation","AnimationIteration"),animationstart:fl("Animation","AnimationStart"),transitionend:fl("Transition","TransitionEnd")},cd={},ew={};_s&&(ew=document.createElement("div").style,"AnimationEvent"in window||(delete Si.animationend.animation,delete Si.animationiteration.animation,delete Si.animationstart.animation),"TransitionEvent"in window||delete Si.transitionend.transition);function cu(e){if(cd[e])return cd[e];if(!Si[e])return e;var t=Si[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ew)return cd[e]=t[n];return e}var tw=cu("animationend"),nw=cu("animationiteration"),sw=cu("animationstart"),rw=cu("transitionend"),iw=new Map,Sx="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 jr(e,t){iw.set(e,t),Jr(t,[e])}for(var ud=0;ud<Sx.length;ud++){var dd=Sx[ud],dE=dd.toLowerCase(),fE=dd[0].toUpperCase()+dd.slice(1);jr(dE,"on"+fE)}jr(tw,"onAnimationEnd");jr(nw,"onAnimationIteration");jr(sw,"onAnimationStart");jr("dblclick","onDoubleClick");jr("focusin","onFocus");jr("focusout","onBlur");jr(rw,"onTransitionEnd");Wi("onMouseEnter",["mouseout","mouseover"]);Wi("onMouseLeave",["mouseout","mouseover"]);Wi("onPointerEnter",["pointerout","pointerover"]);Wi("onPointerLeave",["pointerout","pointerover"]);Jr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Jr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Jr("onBeforeInput",["compositionend","keypress","textInput","paste"]);Jr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Jr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Jr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bo="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(" "),hE=new Set("cancel close invalid load scroll toggle".split(" ").concat(Bo));function Nx(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,dC(r,t,void 0,e),e.currentTarget=null}function ow(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==o&&i.isPropagationStopped())break e;Nx(i,l,u),o=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==o&&i.isPropagationStopped())break e;Nx(i,l,u),o=c}}}if(xc)throw e=Pf,xc=!1,Pf=null,e}function Ge(e,t){var n=t[Bf];n===void 0&&(n=t[Bf]=new Set);var r=e+"__bubble";n.has(r)||(aw(t,e,2,!1),n.add(r))}function fd(e,t,n){var r=0;t&&(r|=4),aw(n,e,r,t)}var hl="_reactListening"+Math.random().toString(36).slice(2);function da(e){if(!e[hl]){e[hl]=!0,pj.forEach(function(n){n!=="selectionchange"&&(hE.has(n)||fd(n,!1,e),fd(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[hl]||(t[hl]=!0,fd("selectionchange",!1,t))}}function aw(e,t,n,r){switch(Hj(t)){case 1:var i=EC;break;case 4:i=AC;break;default:i=Ep}n=i.bind(null,t,n,e),i=void 0,!Tf||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function hd(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===i||l.nodeType===8&&l.parentNode===i)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;a=a.return}for(;l!==null;){if(a=Mr(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}Tj(function(){var u=o,h=kp(n),f=[];e:{var p=iw.get(e);if(p!==void 0){var x=Rp,y=e;switch(e){case"keypress":if(Yl(n)===0)break e;case"keydown":case"keyup":x=WC;break;case"focusin":y="focus",x=od;break;case"focusout":y="blur",x=od;break;case"beforeblur":case"afterblur":x=od;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":x=hx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=PC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=KC;break;case tw:case nw:case sw:x=$C;break;case rw:x=YC;break;case"scroll":x=RC;break;case"wheel":x=QC;break;case"copy":case"cut":case"paste":x=OC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=mx}var w=(t&4)!==0,b=!w&&e==="scroll",v=w?p!==null?p+"Capture":null:p;w=[];for(var m=u,j;m!==null;){j=m;var g=j.stateNode;if(j.tag===5&&g!==null&&(j=g,v!==null&&(g=ia(m,v),g!=null&&w.push(fa(m,g,j)))),b)break;m=m.return}0<w.length&&(p=new x(p,y,null,n,h),f.push({event:p,listeners:w}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",p&&n!==Af&&(y=n.relatedTarget||n.fromElement)&&(Mr(y)||y[Os]))break e;if((x||p)&&(p=h.window===h?h:(p=h.ownerDocument)?p.defaultView||p.parentWindow:window,x?(y=n.relatedTarget||n.toElement,x=u,y=y?Mr(y):null,y!==null&&(b=Zr(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(x=null,y=u),x!==y)){if(w=hx,g="onMouseLeave",v="onMouseEnter",m="mouse",(e==="pointerout"||e==="pointerover")&&(w=mx,g="onPointerLeave",v="onPointerEnter",m="pointer"),b=x==null?p:Ni(x),j=y==null?p:Ni(y),p=new w(g,m+"leave",x,n,h),p.target=b,p.relatedTarget=j,g=null,Mr(h)===u&&(w=new w(v,m+"enter",y,n,h),w.target=j,w.relatedTarget=b,g=w),b=g,x&&y)t:{for(w=x,v=y,m=0,j=w;j;j=hi(j))m++;for(j=0,g=v;g;g=hi(g))j++;for(;0<m-j;)w=hi(w),m--;for(;0<j-m;)v=hi(v),j--;for(;m--;){if(w===v||v!==null&&w===v.alternate)break t;w=hi(w),v=hi(v)}w=null}else w=null;x!==null&&Cx(f,p,x,w,!1),y!==null&&b!==null&&Cx(f,b,y,w,!0)}}e:{if(p=u?Ni(u):window,x=p.nodeName&&p.nodeName.toLowerCase(),x==="select"||x==="input"&&p.type==="file")var S=sE;else if(vx(p))if(Qj)S=aE;else{S=iE;var k=rE}else(x=p.nodeName)&&x.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(S=oE);if(S&&(S=S(e,u))){qj(f,S,n,h);break e}k&&k(e,p,u),e==="focusout"&&(k=p._wrapperState)&&k.controlled&&p.type==="number"&&kf(p,"number",p.value)}switch(k=u?Ni(u):window,e){case"focusin":(vx(k)||k.contentEditable==="true")&&(ki=k,_f=u,Go=null);break;case"focusout":Go=_f=ki=null;break;case"mousedown":Of=!0;break;case"contextmenu":case"mouseup":case"dragend":Of=!1,kx(f,n,h);break;case"selectionchange":if(uE)break;case"keydown":case"keyup":kx(f,n,h)}var N;if(Pp)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else bi?Gj(e,n)&&(C="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(Kj&&n.locale!=="ko"&&(bi||C!=="onCompositionStart"?C==="onCompositionEnd"&&bi&&(N=Vj()):(er=h,Ap="value"in er?er.value:er.textContent,bi=!0)),k=bc(u,C),0<k.length&&(C=new px(C,e,null,n,h),f.push({event:C,listeners:k}),N?C.data=N:(N=Yj(n),N!==null&&(C.data=N)))),(N=JC?ZC(e,n):eE(e,n))&&(u=bc(u,"onBeforeInput"),0<u.length&&(h=new px("onBeforeInput","beforeinput",null,n,h),f.push({event:h,listeners:u}),h.data=N))}ow(f,t)})}function fa(e,t,n){return{instance:e,listener:t,currentTarget:n}}function bc(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=ia(e,n),o!=null&&r.unshift(fa(e,o,i)),o=ia(e,t),o!=null&&r.push(fa(e,o,i))),e=e.return}return r}function hi(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Cx(e,t,n,r,i){for(var o=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,i?(c=ia(n,o),c!=null&&a.unshift(fa(n,c,l))):i||(c=ia(n,o),c!=null&&a.push(fa(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var pE=/\r\n?/g,mE=/\u0000|\uFFFD/g;function Ex(e){return(typeof e=="string"?e:""+e).replace(pE,`
|
|
38
|
-
`).replace(mE,"")}function pl(e,t,n){if(t=Ex(t),Ex(e)!==t&&n)throw Error(Q(425))}function kc(){}var Df=null,Lf=null;function Ff(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Uf=typeof setTimeout=="function"?setTimeout:void 0,gE=typeof clearTimeout=="function"?clearTimeout:void 0,Ax=typeof Promise=="function"?Promise:void 0,xE=typeof queueMicrotask=="function"?queueMicrotask:typeof Ax<"u"?function(e){return Ax.resolve(null).then(e).catch(vE)}:Uf;function vE(e){setTimeout(function(){throw e})}function pd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),la(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);la(t)}function or(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Rx(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var co=Math.random().toString(36).slice(2),is="__reactFiber$"+co,ha="__reactProps$"+co,Os="__reactContainer$"+co,Bf="__reactEvents$"+co,yE="__reactListeners$"+co,jE="__reactHandles$"+co;function Mr(e){var t=e[is];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Os]||n[is]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Rx(e);e!==null;){if(n=e[is])return n;e=Rx(e)}return t}e=n,n=e.parentNode}return null}function Da(e){return e=e[is]||e[Os],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ni(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Q(33))}function uu(e){return e[ha]||null}var zf=[],Ci=-1;function wr(e){return{current:e}}function Ye(e){0>Ci||(e.current=zf[Ci],zf[Ci]=null,Ci--)}function Ve(e,t){Ci++,zf[Ci]=e.current,e.current=t}var pr={},Bt=wr(pr),nn=wr(!1),Ur=pr;function Hi(e,t){var n=e.type.contextTypes;if(!n)return pr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function sn(e){return e=e.childContextTypes,e!=null}function Sc(){Ye(nn),Ye(Bt)}function Tx(e,t,n){if(Bt.current!==pr)throw Error(Q(168));Ve(Bt,t),Ve(nn,n)}function lw(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(Q(108,rC(e)||"Unknown",i));return et({},n,r)}function Nc(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pr,Ur=Bt.current,Ve(Bt,e),Ve(nn,nn.current),!0}function Px(e,t,n){var r=e.stateNode;if(!r)throw Error(Q(169));n?(e=lw(e,t,Ur),r.__reactInternalMemoizedMergedChildContext=e,Ye(nn),Ye(Bt),Ve(Bt,e)):Ye(nn),Ve(nn,n)}var Es=null,du=!1,md=!1;function cw(e){Es===null?Es=[e]:Es.push(e)}function wE(e){du=!0,cw(e)}function br(){if(!md&&Es!==null){md=!0;var e=0,t=Be;try{var n=Es;for(Be=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Es=null,du=!1}catch(i){throw Es!==null&&(Es=Es.slice(e+1)),$j(Sp,br),i}finally{Be=t,md=!1}}return null}var Ei=[],Ai=0,Cc=null,Ec=0,Rn=[],Tn=0,Br=null,Rs=1,Ts="";function Pr(e,t){Ei[Ai++]=Ec,Ei[Ai++]=Cc,Cc=e,Ec=t}function uw(e,t,n){Rn[Tn++]=Rs,Rn[Tn++]=Ts,Rn[Tn++]=Br,Br=e;var r=Rs;e=Ts;var i=32-zn(r)-1;r&=~(1<<i),n+=1;var o=32-zn(t)+i;if(30<o){var a=i-i%5;o=(r&(1<<a)-1).toString(32),r>>=a,i-=a,Rs=1<<32-zn(t)+i|n<<i|r,Ts=o+e}else Rs=1<<o|n<<i|r,Ts=e}function Mp(e){e.return!==null&&(Pr(e,1),uw(e,1,0))}function $p(e){for(;e===Cc;)Cc=Ei[--Ai],Ei[Ai]=null,Ec=Ei[--Ai],Ei[Ai]=null;for(;e===Br;)Br=Rn[--Tn],Rn[Tn]=null,Ts=Rn[--Tn],Rn[Tn]=null,Rs=Rn[--Tn],Rn[Tn]=null}var yn=null,xn=null,Qe=!1,Un=null;function dw(e,t){var n=In(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Ix(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,yn=e,xn=or(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,yn=e,xn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Br!==null?{id:Rs,overflow:Ts}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=In(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,yn=e,xn=null,!0):!1;default:return!1}}function Wf(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Hf(e){if(Qe){var t=xn;if(t){var n=t;if(!Ix(e,t)){if(Wf(e))throw Error(Q(418));t=or(n.nextSibling);var r=yn;t&&Ix(e,t)?dw(r,n):(e.flags=e.flags&-4097|2,Qe=!1,yn=e)}}else{if(Wf(e))throw Error(Q(418));e.flags=e.flags&-4097|2,Qe=!1,yn=e}}}function Mx(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;yn=e}function ml(e){if(e!==yn)return!1;if(!Qe)return Mx(e),Qe=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ff(e.type,e.memoizedProps)),t&&(t=xn)){if(Wf(e))throw fw(),Error(Q(418));for(;t;)dw(e,t),t=or(t.nextSibling)}if(Mx(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Q(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){xn=or(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}xn=null}}else xn=yn?or(e.stateNode.nextSibling):null;return!0}function fw(){for(var e=xn;e;)e=or(e.nextSibling)}function Vi(){xn=yn=null,Qe=!1}function _p(e){Un===null?Un=[e]:Un.push(e)}var bE=Ws.ReactCurrentBatchConfig;function To(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Q(309));var r=n.stateNode}if(!r)throw Error(Q(147,e));var i=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(a){var l=i.refs;a===null?delete l[o]:l[o]=a},t._stringRef=o,t)}if(typeof e!="string")throw Error(Q(284));if(!n._owner)throw Error(Q(290,e))}return e}function gl(e,t){throw e=Object.prototype.toString.call(t),Error(Q(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function $x(e){var t=e._init;return t(e._payload)}function hw(e){function t(v,m){if(e){var j=v.deletions;j===null?(v.deletions=[m],v.flags|=16):j.push(m)}}function n(v,m){if(!e)return null;for(;m!==null;)t(v,m),m=m.sibling;return null}function r(v,m){for(v=new Map;m!==null;)m.key!==null?v.set(m.key,m):v.set(m.index,m),m=m.sibling;return v}function i(v,m){return v=ur(v,m),v.index=0,v.sibling=null,v}function o(v,m,j){return v.index=j,e?(j=v.alternate,j!==null?(j=j.index,j<m?(v.flags|=2,m):j):(v.flags|=2,m)):(v.flags|=1048576,m)}function a(v){return e&&v.alternate===null&&(v.flags|=2),v}function l(v,m,j,g){return m===null||m.tag!==6?(m=bd(j,v.mode,g),m.return=v,m):(m=i(m,j),m.return=v,m)}function c(v,m,j,g){var S=j.type;return S===wi?h(v,m,j.props.children,g,j.key):m!==null&&(m.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Qs&&$x(S)===m.type)?(g=i(m,j.props),g.ref=To(v,m,j),g.return=v,g):(g=tc(j.type,j.key,j.props,null,v.mode,g),g.ref=To(v,m,j),g.return=v,g)}function u(v,m,j,g){return m===null||m.tag!==4||m.stateNode.containerInfo!==j.containerInfo||m.stateNode.implementation!==j.implementation?(m=kd(j,v.mode,g),m.return=v,m):(m=i(m,j.children||[]),m.return=v,m)}function h(v,m,j,g,S){return m===null||m.tag!==7?(m=Dr(j,v.mode,g,S),m.return=v,m):(m=i(m,j),m.return=v,m)}function f(v,m,j){if(typeof m=="string"&&m!==""||typeof m=="number")return m=bd(""+m,v.mode,j),m.return=v,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case il:return j=tc(m.type,m.key,m.props,null,v.mode,j),j.ref=To(v,null,m),j.return=v,j;case ji:return m=kd(m,v.mode,j),m.return=v,m;case Qs:var g=m._init;return f(v,g(m._payload),j)}if(Fo(m)||No(m))return m=Dr(m,v.mode,j,null),m.return=v,m;gl(v,m)}return null}function p(v,m,j,g){var S=m!==null?m.key:null;if(typeof j=="string"&&j!==""||typeof j=="number")return S!==null?null:l(v,m,""+j,g);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case il:return j.key===S?c(v,m,j,g):null;case ji:return j.key===S?u(v,m,j,g):null;case Qs:return S=j._init,p(v,m,S(j._payload),g)}if(Fo(j)||No(j))return S!==null?null:h(v,m,j,g,null);gl(v,j)}return null}function x(v,m,j,g,S){if(typeof g=="string"&&g!==""||typeof g=="number")return v=v.get(j)||null,l(m,v,""+g,S);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case il:return v=v.get(g.key===null?j:g.key)||null,c(m,v,g,S);case ji:return v=v.get(g.key===null?j:g.key)||null,u(m,v,g,S);case Qs:var k=g._init;return x(v,m,j,k(g._payload),S)}if(Fo(g)||No(g))return v=v.get(j)||null,h(m,v,g,S,null);gl(m,g)}return null}function y(v,m,j,g){for(var S=null,k=null,N=m,C=m=0,A=null;N!==null&&C<j.length;C++){N.index>C?(A=N,N=null):A=N.sibling;var E=p(v,N,j[C],g);if(E===null){N===null&&(N=A);break}e&&N&&E.alternate===null&&t(v,N),m=o(E,m,C),k===null?S=E:k.sibling=E,k=E,N=A}if(C===j.length)return n(v,N),Qe&&Pr(v,C),S;if(N===null){for(;C<j.length;C++)N=f(v,j[C],g),N!==null&&(m=o(N,m,C),k===null?S=N:k.sibling=N,k=N);return Qe&&Pr(v,C),S}for(N=r(v,N);C<j.length;C++)A=x(N,v,C,j[C],g),A!==null&&(e&&A.alternate!==null&&N.delete(A.key===null?C:A.key),m=o(A,m,C),k===null?S=A:k.sibling=A,k=A);return e&&N.forEach(function(_){return t(v,_)}),Qe&&Pr(v,C),S}function w(v,m,j,g){var S=No(j);if(typeof S!="function")throw Error(Q(150));if(j=S.call(j),j==null)throw Error(Q(151));for(var k=S=null,N=m,C=m=0,A=null,E=j.next();N!==null&&!E.done;C++,E=j.next()){N.index>C?(A=N,N=null):A=N.sibling;var _=p(v,N,E.value,g);if(_===null){N===null&&(N=A);break}e&&N&&_.alternate===null&&t(v,N),m=o(_,m,C),k===null?S=_:k.sibling=_,k=_,N=A}if(E.done)return n(v,N),Qe&&Pr(v,C),S;if(N===null){for(;!E.done;C++,E=j.next())E=f(v,E.value,g),E!==null&&(m=o(E,m,C),k===null?S=E:k.sibling=E,k=E);return Qe&&Pr(v,C),S}for(N=r(v,N);!E.done;C++,E=j.next())E=x(N,v,C,E.value,g),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?C:E.key),m=o(E,m,C),k===null?S=E:k.sibling=E,k=E);return e&&N.forEach(function(L){return t(v,L)}),Qe&&Pr(v,C),S}function b(v,m,j,g){if(typeof j=="object"&&j!==null&&j.type===wi&&j.key===null&&(j=j.props.children),typeof j=="object"&&j!==null){switch(j.$$typeof){case il:e:{for(var S=j.key,k=m;k!==null;){if(k.key===S){if(S=j.type,S===wi){if(k.tag===7){n(v,k.sibling),m=i(k,j.props.children),m.return=v,v=m;break e}}else if(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Qs&&$x(S)===k.type){n(v,k.sibling),m=i(k,j.props),m.ref=To(v,k,j),m.return=v,v=m;break e}n(v,k);break}else t(v,k);k=k.sibling}j.type===wi?(m=Dr(j.props.children,v.mode,g,j.key),m.return=v,v=m):(g=tc(j.type,j.key,j.props,null,v.mode,g),g.ref=To(v,m,j),g.return=v,v=g)}return a(v);case ji:e:{for(k=j.key;m!==null;){if(m.key===k)if(m.tag===4&&m.stateNode.containerInfo===j.containerInfo&&m.stateNode.implementation===j.implementation){n(v,m.sibling),m=i(m,j.children||[]),m.return=v,v=m;break e}else{n(v,m);break}else t(v,m);m=m.sibling}m=kd(j,v.mode,g),m.return=v,v=m}return a(v);case Qs:return k=j._init,b(v,m,k(j._payload),g)}if(Fo(j))return y(v,m,j,g);if(No(j))return w(v,m,j,g);gl(v,j)}return typeof j=="string"&&j!==""||typeof j=="number"?(j=""+j,m!==null&&m.tag===6?(n(v,m.sibling),m=i(m,j),m.return=v,v=m):(n(v,m),m=bd(j,v.mode,g),m.return=v,v=m),a(v)):n(v,m)}return b}var Ki=hw(!0),pw=hw(!1),Ac=wr(null),Rc=null,Ri=null,Op=null;function Dp(){Op=Ri=Rc=null}function Lp(e){var t=Ac.current;Ye(Ac),e._currentValue=t}function Vf(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Di(e,t){Rc=e,Op=Ri=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(en=!0),e.firstContext=null)}function $n(e){var t=e._currentValue;if(Op!==e)if(e={context:e,memoizedValue:t,next:null},Ri===null){if(Rc===null)throw Error(Q(308));Ri=e,Rc.dependencies={lanes:0,firstContext:e}}else Ri=Ri.next=e;return t}var $r=null;function Fp(e){$r===null?$r=[e]:$r.push(e)}function mw(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Fp(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ds(e,r)}function Ds(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Xs=!1;function Up(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function gw(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ps(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ar(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Oe&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ds(e,n)}return i=r.interleaved,i===null?(t.next=t,Fp(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ds(e,n)}function ql(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Np(e,n)}}function _x(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Tc(e,t,n,r){var i=e.updateQueue;Xs=!1;var o=i.firstBaseUpdate,a=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?o=u:a.next=u,a=c;var h=e.alternate;h!==null&&(h=h.updateQueue,l=h.lastBaseUpdate,l!==a&&(l===null?h.firstBaseUpdate=u:l.next=u,h.lastBaseUpdate=c))}if(o!==null){var f=i.baseState;a=0,h=u=c=null,l=o;do{var p=l.lane,x=l.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:x,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,w=l;switch(p=t,x=n,w.tag){case 1:if(y=w.payload,typeof y=="function"){f=y.call(x,f,p);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=w.payload,p=typeof y=="function"?y.call(x,f,p):y,p==null)break e;f=et({},f,p);break e;case 2:Xs=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=i.effects,p===null?i.effects=[l]:p.push(l))}else x={eventTime:x,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},h===null?(u=h=x,c=f):h=h.next=x,a|=p;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;p=l,l=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(!0);if(h===null&&(c=f),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=h,t=i.shared.interleaved,t!==null){i=t;do a|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);Wr|=a,e.lanes=a,e.memoizedState=f}}function Ox(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(Q(191,i));i.call(r)}}}var La={},us=wr(La),pa=wr(La),ma=wr(La);function _r(e){if(e===La)throw Error(Q(174));return e}function Bp(e,t){switch(Ve(ma,t),Ve(pa,e),Ve(us,La),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Nf(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Nf(t,e)}Ye(us),Ve(us,t)}function Gi(){Ye(us),Ye(pa),Ye(ma)}function xw(e){_r(ma.current);var t=_r(us.current),n=Nf(t,e.type);t!==n&&(Ve(pa,e),Ve(us,n))}function zp(e){pa.current===e&&(Ye(us),Ye(pa))}var Xe=wr(0);function Pc(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var gd=[];function Wp(){for(var e=0;e<gd.length;e++)gd[e]._workInProgressVersionPrimary=null;gd.length=0}var Ql=Ws.ReactCurrentDispatcher,xd=Ws.ReactCurrentBatchConfig,zr=0,Je=null,mt=null,wt=null,Ic=!1,Yo=!1,ga=0,kE=0;function _t(){throw Error(Q(321))}function Hp(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Vn(e[n],t[n]))return!1;return!0}function Vp(e,t,n,r,i,o){if(zr=o,Je=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ql.current=e===null||e.memoizedState===null?EE:AE,e=n(r,i),Yo){o=0;do{if(Yo=!1,ga=0,25<=o)throw Error(Q(301));o+=1,wt=mt=null,t.updateQueue=null,Ql.current=RE,e=n(r,i)}while(Yo)}if(Ql.current=Mc,t=mt!==null&&mt.next!==null,zr=0,wt=mt=Je=null,Ic=!1,t)throw Error(Q(300));return e}function Kp(){var e=ga!==0;return ga=0,e}function ss(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wt===null?Je.memoizedState=wt=e:wt=wt.next=e,wt}function _n(){if(mt===null){var e=Je.alternate;e=e!==null?e.memoizedState:null}else e=mt.next;var t=wt===null?Je.memoizedState:wt.next;if(t!==null)wt=t,mt=e;else{if(e===null)throw Error(Q(310));mt=e,e={memoizedState:mt.memoizedState,baseState:mt.baseState,baseQueue:mt.baseQueue,queue:mt.queue,next:null},wt===null?Je.memoizedState=wt=e:wt=wt.next=e}return wt}function xa(e,t){return typeof t=="function"?t(e):t}function vd(e){var t=_n(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=mt,i=r.baseQueue,o=n.pending;if(o!==null){if(i!==null){var a=i.next;i.next=o.next,o.next=a}r.baseQueue=i=o,n.pending=null}if(i!==null){o=i.next,r=r.baseState;var l=a=null,c=null,u=o;do{var h=u.lane;if((zr&h)===h)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:h,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,Je.lanes|=h,Wr|=h}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,Vn(r,t.memoizedState)||(en=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do o=i.lane,Je.lanes|=o,Wr|=o,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function yd(e){var t=_n(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var a=i=i.next;do o=e(o,a.action),a=a.next;while(a!==i);Vn(o,t.memoizedState)||(en=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function vw(){}function yw(e,t){var n=Je,r=_n(),i=t(),o=!Vn(r.memoizedState,i);if(o&&(r.memoizedState=i,en=!0),r=r.queue,Gp(bw.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||wt!==null&&wt.memoizedState.tag&1){if(n.flags|=2048,va(9,ww.bind(null,n,r,i,t),void 0,null),St===null)throw Error(Q(349));zr&30||jw(n,t,i)}return i}function jw(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Je.updateQueue,t===null?(t={lastEffect:null,stores:null},Je.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ww(e,t,n,r){t.value=n,t.getSnapshot=r,kw(t)&&Sw(e)}function bw(e,t,n){return n(function(){kw(t)&&Sw(e)})}function kw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Vn(e,n)}catch{return!0}}function Sw(e){var t=Ds(e,1);t!==null&&Wn(t,e,1,-1)}function Dx(e){var t=ss();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:xa,lastRenderedState:e},t.queue=e,e=e.dispatch=CE.bind(null,Je,e),[t.memoizedState,e]}function va(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Je.updateQueue,t===null?(t={lastEffect:null,stores:null},Je.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Nw(){return _n().memoizedState}function Xl(e,t,n,r){var i=ss();Je.flags|=e,i.memoizedState=va(1|t,n,void 0,r===void 0?null:r)}function fu(e,t,n,r){var i=_n();r=r===void 0?null:r;var o=void 0;if(mt!==null){var a=mt.memoizedState;if(o=a.destroy,r!==null&&Hp(r,a.deps)){i.memoizedState=va(t,n,o,r);return}}Je.flags|=e,i.memoizedState=va(1|t,n,o,r)}function Lx(e,t){return Xl(8390656,8,e,t)}function Gp(e,t){return fu(2048,8,e,t)}function Cw(e,t){return fu(4,2,e,t)}function Ew(e,t){return fu(4,4,e,t)}function Aw(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Rw(e,t,n){return n=n!=null?n.concat([e]):null,fu(4,4,Aw.bind(null,t,e),n)}function Yp(){}function Tw(e,t){var n=_n();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Hp(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Pw(e,t){var n=_n();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Hp(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Iw(e,t,n){return zr&21?(Vn(n,t)||(n=Dj(),Je.lanes|=n,Wr|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,en=!0),e.memoizedState=n)}function SE(e,t){var n=Be;Be=n!==0&&4>n?n:4,e(!0);var r=xd.transition;xd.transition={};try{e(!1),t()}finally{Be=n,xd.transition=r}}function Mw(){return _n().memoizedState}function NE(e,t,n){var r=cr(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},$w(e))_w(t,n);else if(n=mw(e,t,n,r),n!==null){var i=Kt();Wn(n,e,r,i),Ow(n,t,r)}}function CE(e,t,n){var r=cr(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if($w(e))_w(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,l=o(a,n);if(i.hasEagerState=!0,i.eagerState=l,Vn(l,a)){var c=t.interleaved;c===null?(i.next=i,Fp(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=mw(e,t,i,r),n!==null&&(i=Kt(),Wn(n,e,r,i),Ow(n,t,r))}}function $w(e){var t=e.alternate;return e===Je||t!==null&&t===Je}function _w(e,t){Yo=Ic=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ow(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Np(e,n)}}var Mc={readContext:$n,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},EE={readContext:$n,useCallback:function(e,t){return ss().memoizedState=[e,t===void 0?null:t],e},useContext:$n,useEffect:Lx,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Xl(4194308,4,Aw.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Xl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Xl(4,2,e,t)},useMemo:function(e,t){var n=ss();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ss();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=NE.bind(null,Je,e),[r.memoizedState,e]},useRef:function(e){var t=ss();return e={current:e},t.memoizedState=e},useState:Dx,useDebugValue:Yp,useDeferredValue:function(e){return ss().memoizedState=e},useTransition:function(){var e=Dx(!1),t=e[0];return e=SE.bind(null,e[1]),ss().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Je,i=ss();if(Qe){if(n===void 0)throw Error(Q(407));n=n()}else{if(n=t(),St===null)throw Error(Q(349));zr&30||jw(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Lx(bw.bind(null,r,o,e),[e]),r.flags|=2048,va(9,ww.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=ss(),t=St.identifierPrefix;if(Qe){var n=Ts,r=Rs;n=(r&~(1<<32-zn(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ga++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=kE++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},AE={readContext:$n,useCallback:Tw,useContext:$n,useEffect:Gp,useImperativeHandle:Rw,useInsertionEffect:Cw,useLayoutEffect:Ew,useMemo:Pw,useReducer:vd,useRef:Nw,useState:function(){return vd(xa)},useDebugValue:Yp,useDeferredValue:function(e){var t=_n();return Iw(t,mt.memoizedState,e)},useTransition:function(){var e=vd(xa)[0],t=_n().memoizedState;return[e,t]},useMutableSource:vw,useSyncExternalStore:yw,useId:Mw,unstable_isNewReconciler:!1},RE={readContext:$n,useCallback:Tw,useContext:$n,useEffect:Gp,useImperativeHandle:Rw,useInsertionEffect:Cw,useLayoutEffect:Ew,useMemo:Pw,useReducer:yd,useRef:Nw,useState:function(){return yd(xa)},useDebugValue:Yp,useDeferredValue:function(e){var t=_n();return mt===null?t.memoizedState=e:Iw(t,mt.memoizedState,e)},useTransition:function(){var e=yd(xa)[0],t=_n().memoizedState;return[e,t]},useMutableSource:vw,useSyncExternalStore:yw,useId:Mw,unstable_isNewReconciler:!1};function Ln(e,t){if(e&&e.defaultProps){t=et({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Kf(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:et({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var hu={isMounted:function(e){return(e=e._reactInternals)?Zr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Kt(),i=cr(e),o=Ps(r,i);o.payload=t,n!=null&&(o.callback=n),t=ar(e,o,i),t!==null&&(Wn(t,e,i,r),ql(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Kt(),i=cr(e),o=Ps(r,i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=ar(e,o,i),t!==null&&(Wn(t,e,i,r),ql(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Kt(),r=cr(e),i=Ps(n,r);i.tag=2,t!=null&&(i.callback=t),t=ar(e,i,r),t!==null&&(Wn(t,e,r,n),ql(t,e,r))}};function Fx(e,t,n,r,i,o,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,a):t.prototype&&t.prototype.isPureReactComponent?!ua(n,r)||!ua(i,o):!0}function Dw(e,t,n){var r=!1,i=pr,o=t.contextType;return typeof o=="object"&&o!==null?o=$n(o):(i=sn(t)?Ur:Bt.current,r=t.contextTypes,o=(r=r!=null)?Hi(e,i):pr),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=hu,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function Ux(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&hu.enqueueReplaceState(t,t.state,null)}function Gf(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},Up(e);var o=t.contextType;typeof o=="object"&&o!==null?i.context=$n(o):(o=sn(t)?Ur:Bt.current,i.context=Hi(e,o)),i.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Kf(e,t,o,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&hu.enqueueReplaceState(i,i.state,null),Tc(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Yi(e,t){try{var n="",r=t;do n+=sC(r),r=r.return;while(r);var i=n}catch(o){i=`
|
|
39
|
-
Error generating stack: `+o.message+`
|
|
40
|
-
`+o.stack}return{value:e,source:t,stack:i,digest:null}}function jd(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Yf(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var TE=typeof WeakMap=="function"?WeakMap:Map;function Lw(e,t,n){n=Ps(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){_c||(_c=!0,rh=r),Yf(e,t)},n}function Fw(e,t,n){n=Ps(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Yf(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Yf(e,t),typeof r!="function"&&(lr===null?lr=new Set([this]):lr.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Bx(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new TE;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=HE.bind(null,e,t,n),t.then(e,e))}function zx(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Wx(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ps(-1,1),t.tag=2,ar(n,t,1))),n.lanes|=1),e)}var PE=Ws.ReactCurrentOwner,en=!1;function Wt(e,t,n,r){t.child=e===null?pw(t,null,n,r):Ki(t,e.child,n,r)}function Hx(e,t,n,r,i){n=n.render;var o=t.ref;return Di(t,i),r=Vp(e,t,n,r,o,i),n=Kp(),e!==null&&!en?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ls(e,t,i)):(Qe&&n&&Mp(t),t.flags|=1,Wt(e,t,r,i),t.child)}function Vx(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!nm(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,Uw(e,t,o,r,i)):(e=tc(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var a=o.memoizedProps;if(n=n.compare,n=n!==null?n:ua,n(a,r)&&e.ref===t.ref)return Ls(e,t,i)}return t.flags|=1,e=ur(o,r),e.ref=t.ref,e.return=t,t.child=e}function Uw(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(ua(o,r)&&e.ref===t.ref)if(en=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(en=!0);else return t.lanes=e.lanes,Ls(e,t,i)}return qf(e,t,n,r,i)}function Bw(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ve(Pi,mn),mn|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ve(Pi,mn),mn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,Ve(Pi,mn),mn|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,Ve(Pi,mn),mn|=r;return Wt(e,t,i,n),t.child}function zw(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function qf(e,t,n,r,i){var o=sn(n)?Ur:Bt.current;return o=Hi(t,o),Di(t,i),n=Vp(e,t,n,r,o,i),r=Kp(),e!==null&&!en?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ls(e,t,i)):(Qe&&r&&Mp(t),t.flags|=1,Wt(e,t,n,i),t.child)}function Kx(e,t,n,r,i){if(sn(n)){var o=!0;Nc(t)}else o=!1;if(Di(t,i),t.stateNode===null)Jl(e,t),Dw(t,n,r),Gf(t,n,r,i),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,u=n.contextType;typeof u=="object"&&u!==null?u=$n(u):(u=sn(n)?Ur:Bt.current,u=Hi(t,u));var h=n.getDerivedStateFromProps,f=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&Ux(t,a,r,u),Xs=!1;var p=t.memoizedState;a.state=p,Tc(t,r,a,i),c=t.memoizedState,l!==r||p!==c||nn.current||Xs?(typeof h=="function"&&(Kf(t,n,h,r),c=t.memoizedState),(l=Xs||Fx(t,n,l,r,p,c,u))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=u,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,gw(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Ln(t.type,l),a.props=u,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=$n(c):(c=sn(n)?Ur:Bt.current,c=Hi(t,c));var x=n.getDerivedStateFromProps;(h=typeof x=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&Ux(t,a,r,c),Xs=!1,p=t.memoizedState,a.state=p,Tc(t,r,a,i);var y=t.memoizedState;l!==f||p!==y||nn.current||Xs?(typeof x=="function"&&(Kf(t,n,x,r),y=t.memoizedState),(u=Xs||Fx(t,n,u,r,p,y,c)||!1)?(h||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,y,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,y,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),a.props=r,a.state=y,a.context=c,r=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return Qf(e,t,n,r,o,i)}function Qf(e,t,n,r,i,o){zw(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return i&&Px(t,n,!1),Ls(e,t,o);r=t.stateNode,PE.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Ki(t,e.child,null,o),t.child=Ki(t,null,l,o)):Wt(e,t,l,o),t.memoizedState=r.state,i&&Px(t,n,!0),t.child}function Ww(e){var t=e.stateNode;t.pendingContext?Tx(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Tx(e,t.context,!1),Bp(e,t.containerInfo)}function Gx(e,t,n,r,i){return Vi(),_p(i),t.flags|=256,Wt(e,t,n,r),t.child}var Xf={dehydrated:null,treeContext:null,retryLane:0};function Jf(e){return{baseLanes:e,cachePool:null,transitions:null}}function Hw(e,t,n){var r=t.pendingProps,i=Xe.current,o=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(i&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Ve(Xe,i&1),e===null)return Hf(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,o?(r=t.mode,o=t.child,a={mode:"hidden",children:a},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=gu(a,r,0,null),e=Dr(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Jf(n),t.memoizedState=Xf,e):qp(t,a));if(i=e.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return IE(e,t,a,r,l,i,n);if(o){o=r.fallback,a=t.mode,i=e.child,l=i.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=ur(i,c),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?o=ur(l,o):(o=Dr(o,a,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,a=e.child.memoizedState,a=a===null?Jf(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=Xf,r}return o=e.child,e=o.sibling,r=ur(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function qp(e,t){return t=gu({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function xl(e,t,n,r){return r!==null&&_p(r),Ki(t,e.child,null,n),e=qp(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function IE(e,t,n,r,i,o,a){if(n)return t.flags&256?(t.flags&=-257,r=jd(Error(Q(422))),xl(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=gu({mode:"visible",children:r.children},i,0,null),o=Dr(o,i,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Ki(t,e.child,null,a),t.child.memoizedState=Jf(a),t.memoizedState=Xf,o);if(!(t.mode&1))return xl(e,t,a,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Q(419)),r=jd(o,r,void 0),xl(e,t,a,r)}if(l=(a&e.childLanes)!==0,en||l){if(r=St,r!==null){switch(a&-a){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|a)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,Ds(e,i),Wn(r,e,i,-1))}return tm(),r=jd(Error(Q(421))),xl(e,t,a,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=VE.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,xn=or(i.nextSibling),yn=t,Qe=!0,Un=null,e!==null&&(Rn[Tn++]=Rs,Rn[Tn++]=Ts,Rn[Tn++]=Br,Rs=e.id,Ts=e.overflow,Br=t),t=qp(t,r.children),t.flags|=4096,t)}function Yx(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Vf(e.return,t,n)}function wd(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function Vw(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(Wt(e,t,r.children,n),r=Xe.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Yx(e,n,t);else if(e.tag===19)Yx(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ve(Xe,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Pc(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),wd(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Pc(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}wd(t,!0,n,null,o);break;case"together":wd(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Jl(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ls(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Wr|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Q(153));if(t.child!==null){for(e=t.child,n=ur(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ur(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function ME(e,t,n){switch(t.tag){case 3:Ww(t),Vi();break;case 5:xw(t);break;case 1:sn(t.type)&&Nc(t);break;case 4:Bp(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Ve(Ac,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Ve(Xe,Xe.current&1),t.flags|=128,null):n&t.child.childLanes?Hw(e,t,n):(Ve(Xe,Xe.current&1),e=Ls(e,t,n),e!==null?e.sibling:null);Ve(Xe,Xe.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Vw(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ve(Xe,Xe.current),r)break;return null;case 22:case 23:return t.lanes=0,Bw(e,t,n)}return Ls(e,t,n)}var Kw,Zf,Gw,Yw;Kw=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Zf=function(){};Gw=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,_r(us.current);var o=null;switch(n){case"input":i=wf(e,i),r=wf(e,r),o=[];break;case"select":i=et({},i,{value:void 0}),r=et({},r,{value:void 0}),o=[];break;case"textarea":i=Sf(e,i),r=Sf(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=kc)}Cf(n,r);var a;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(sa.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var c=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(o||(o=[]),o.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(sa.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Ge("scroll",e),o||l===c||(o=[])):(o=o||[]).push(u,c))}n&&(o=o||[]).push("style",n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}};Yw=function(e,t,n,r){n!==r&&(t.flags|=4)};function Po(e,t){if(!Qe)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ot(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function $E(e,t,n){var r=t.pendingProps;switch($p(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ot(t),null;case 1:return sn(t.type)&&Sc(),Ot(t),null;case 3:return r=t.stateNode,Gi(),Ye(nn),Ye(Bt),Wp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ml(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Un!==null&&(ah(Un),Un=null))),Zf(e,t),Ot(t),null;case 5:zp(t);var i=_r(ma.current);if(n=t.type,e!==null&&t.stateNode!=null)Gw(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Q(166));return Ot(t),null}if(e=_r(us.current),ml(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[is]=t,r[ha]=o,e=(t.mode&1)!==0,n){case"dialog":Ge("cancel",r),Ge("close",r);break;case"iframe":case"object":case"embed":Ge("load",r);break;case"video":case"audio":for(i=0;i<Bo.length;i++)Ge(Bo[i],r);break;case"source":Ge("error",r);break;case"img":case"image":case"link":Ge("error",r),Ge("load",r);break;case"details":Ge("toggle",r);break;case"input":sx(r,o),Ge("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},Ge("invalid",r);break;case"textarea":ix(r,o),Ge("invalid",r)}Cf(n,o),i=null;for(var a in o)if(o.hasOwnProperty(a)){var l=o[a];a==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&pl(r.textContent,l,e),i=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&pl(r.textContent,l,e),i=["children",""+l]):sa.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Ge("scroll",r)}switch(n){case"input":ol(r),rx(r,o,!0);break;case"textarea":ol(r),ox(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=kc)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=bj(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[is]=t,e[ha]=r,Kw(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ef(n,r),n){case"dialog":Ge("cancel",e),Ge("close",e),i=r;break;case"iframe":case"object":case"embed":Ge("load",e),i=r;break;case"video":case"audio":for(i=0;i<Bo.length;i++)Ge(Bo[i],e);i=r;break;case"source":Ge("error",e),i=r;break;case"img":case"image":case"link":Ge("error",e),Ge("load",e),i=r;break;case"details":Ge("toggle",e),i=r;break;case"input":sx(e,r),i=wf(e,r),Ge("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=et({},r,{value:void 0}),Ge("invalid",e);break;case"textarea":ix(e,r),i=Sf(e,r),Ge("invalid",e);break;default:i=r}Cf(n,i),l=i;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?Nj(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&kj(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&ra(e,c):typeof c=="number"&&ra(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(sa.hasOwnProperty(o)?c!=null&&o==="onScroll"&&Ge("scroll",e):c!=null&&yp(e,o,c,a))}switch(n){case"input":ol(e),rx(e,r,!1);break;case"textarea":ol(e),ox(e);break;case"option":r.value!=null&&e.setAttribute("value",""+hr(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?Mi(e,!!r.multiple,o,!1):r.defaultValue!=null&&Mi(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=kc)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Ot(t),null;case 6:if(e&&t.stateNode!=null)Yw(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Q(166));if(n=_r(ma.current),_r(us.current),ml(t)){if(r=t.stateNode,n=t.memoizedProps,r[is]=t,(o=r.nodeValue!==n)&&(e=yn,e!==null))switch(e.tag){case 3:pl(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&pl(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[is]=t,t.stateNode=r}return Ot(t),null;case 13:if(Ye(Xe),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Qe&&xn!==null&&t.mode&1&&!(t.flags&128))fw(),Vi(),t.flags|=98560,o=!1;else if(o=ml(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Q(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Q(317));o[is]=t}else Vi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ot(t),o=!1}else Un!==null&&(ah(Un),Un=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Xe.current&1?yt===0&&(yt=3):tm())),t.updateQueue!==null&&(t.flags|=4),Ot(t),null);case 4:return Gi(),Zf(e,t),e===null&&da(t.stateNode.containerInfo),Ot(t),null;case 10:return Lp(t.type._context),Ot(t),null;case 17:return sn(t.type)&&Sc(),Ot(t),null;case 19:if(Ye(Xe),o=t.memoizedState,o===null)return Ot(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Po(o,!1);else{if(yt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Pc(e),a!==null){for(t.flags|=128,Po(o,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,a=o.alternate,a===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=a.childLanes,o.lanes=a.lanes,o.child=a.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=a.memoizedProps,o.memoizedState=a.memoizedState,o.updateQueue=a.updateQueue,o.type=a.type,e=a.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ve(Xe,Xe.current&1|2),t.child}e=e.sibling}o.tail!==null&&at()>qi&&(t.flags|=128,r=!0,Po(o,!1),t.lanes=4194304)}else{if(!r)if(e=Pc(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Po(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!Qe)return Ot(t),null}else 2*at()-o.renderingStartTime>qi&&n!==1073741824&&(t.flags|=128,r=!0,Po(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=at(),t.sibling=null,n=Xe.current,Ve(Xe,r?n&1|2:n&1),t):(Ot(t),null);case 22:case 23:return em(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?mn&1073741824&&(Ot(t),t.subtreeFlags&6&&(t.flags|=8192)):Ot(t),null;case 24:return null;case 25:return null}throw Error(Q(156,t.tag))}function _E(e,t){switch($p(t),t.tag){case 1:return sn(t.type)&&Sc(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gi(),Ye(nn),Ye(Bt),Wp(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return zp(t),null;case 13:if(Ye(Xe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Q(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ye(Xe),null;case 4:return Gi(),null;case 10:return Lp(t.type._context),null;case 22:case 23:return em(),null;case 24:return null;default:return null}}var vl=!1,Lt=!1,OE=typeof WeakSet=="function"?WeakSet:Set,le=null;function Ti(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){st(e,t,r)}else n.current=null}function eh(e,t,n){try{n()}catch(r){st(e,t,r)}}var qx=!1;function DE(e,t){if(Df=jc,e=Zj(),Ip(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,u=0,h=0,f=e,p=null;t:for(;;){for(var x;f!==n||i!==0&&f.nodeType!==3||(l=a+i),f!==o||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(x=f.firstChild)!==null;)p=f,f=x;for(;;){if(f===e)break t;if(p===n&&++u===i&&(l=a),p===o&&++h===r&&(c=a),(x=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=x}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Lf={focusedElem:e,selectionRange:n},jc=!1,le=t;le!==null;)if(t=le,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,le=e;else for(;le!==null;){t=le;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var w=y.memoizedProps,b=y.memoizedState,v=t.stateNode,m=v.getSnapshotBeforeUpdate(t.elementType===t.type?w:Ln(t.type,w),b);v.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var j=t.stateNode.containerInfo;j.nodeType===1?j.textContent="":j.nodeType===9&&j.documentElement&&j.removeChild(j.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Q(163))}}catch(g){st(t,t.return,g)}if(e=t.sibling,e!==null){e.return=t.return,le=e;break}le=t.return}return y=qx,qx=!1,y}function qo(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&eh(t,n,o)}i=i.next}while(i!==r)}}function pu(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function th(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function qw(e){var t=e.alternate;t!==null&&(e.alternate=null,qw(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[is],delete t[ha],delete t[Bf],delete t[yE],delete t[jE])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Qw(e){return e.tag===5||e.tag===3||e.tag===4}function Qx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Qw(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function nh(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=kc));else if(r!==4&&(e=e.child,e!==null))for(nh(e,t,n),e=e.sibling;e!==null;)nh(e,t,n),e=e.sibling}function sh(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(sh(e,t,n),e=e.sibling;e!==null;)sh(e,t,n),e=e.sibling}var Rt=null,Fn=!1;function Ys(e,t,n){for(n=n.child;n!==null;)Xw(e,t,n),n=n.sibling}function Xw(e,t,n){if(cs&&typeof cs.onCommitFiberUnmount=="function")try{cs.onCommitFiberUnmount(ou,n)}catch{}switch(n.tag){case 5:Lt||Ti(n,t);case 6:var r=Rt,i=Fn;Rt=null,Ys(e,t,n),Rt=r,Fn=i,Rt!==null&&(Fn?(e=Rt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Rt.removeChild(n.stateNode));break;case 18:Rt!==null&&(Fn?(e=Rt,n=n.stateNode,e.nodeType===8?pd(e.parentNode,n):e.nodeType===1&&pd(e,n),la(e)):pd(Rt,n.stateNode));break;case 4:r=Rt,i=Fn,Rt=n.stateNode.containerInfo,Fn=!0,Ys(e,t,n),Rt=r,Fn=i;break;case 0:case 11:case 14:case 15:if(!Lt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&eh(n,t,a),i=i.next}while(i!==r)}Ys(e,t,n);break;case 1:if(!Lt&&(Ti(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){st(n,t,l)}Ys(e,t,n);break;case 21:Ys(e,t,n);break;case 22:n.mode&1?(Lt=(r=Lt)||n.memoizedState!==null,Ys(e,t,n),Lt=r):Ys(e,t,n);break;default:Ys(e,t,n)}}function Xx(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new OE),t.forEach(function(r){var i=KE.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function On(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var o=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:Rt=l.stateNode,Fn=!1;break e;case 3:Rt=l.stateNode.containerInfo,Fn=!0;break e;case 4:Rt=l.stateNode.containerInfo,Fn=!0;break e}l=l.return}if(Rt===null)throw Error(Q(160));Xw(o,a,i),Rt=null,Fn=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){st(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Jw(t,e),t=t.sibling}function Jw(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(On(t,e),ts(e),r&4){try{qo(3,e,e.return),pu(3,e)}catch(w){st(e,e.return,w)}try{qo(5,e,e.return)}catch(w){st(e,e.return,w)}}break;case 1:On(t,e),ts(e),r&512&&n!==null&&Ti(n,n.return);break;case 5:if(On(t,e),ts(e),r&512&&n!==null&&Ti(n,n.return),e.flags&32){var i=e.stateNode;try{ra(i,"")}catch(w){st(e,e.return,w)}}if(r&4&&(i=e.stateNode,i!=null)){var o=e.memoizedProps,a=n!==null?n.memoizedProps:o,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&jj(i,o),Ef(l,a);var u=Ef(l,o);for(a=0;a<c.length;a+=2){var h=c[a],f=c[a+1];h==="style"?Nj(i,f):h==="dangerouslySetInnerHTML"?kj(i,f):h==="children"?ra(i,f):yp(i,h,f,u)}switch(l){case"input":bf(i,o);break;case"textarea":wj(i,o);break;case"select":var p=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var x=o.value;x!=null?Mi(i,!!o.multiple,x,!1):p!==!!o.multiple&&(o.defaultValue!=null?Mi(i,!!o.multiple,o.defaultValue,!0):Mi(i,!!o.multiple,o.multiple?[]:"",!1))}i[ha]=o}catch(w){st(e,e.return,w)}}break;case 6:if(On(t,e),ts(e),r&4){if(e.stateNode===null)throw Error(Q(162));i=e.stateNode,o=e.memoizedProps;try{i.nodeValue=o}catch(w){st(e,e.return,w)}}break;case 3:if(On(t,e),ts(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{la(t.containerInfo)}catch(w){st(e,e.return,w)}break;case 4:On(t,e),ts(e);break;case 13:On(t,e),ts(e),i=e.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(Jp=at())),r&4&&Xx(e);break;case 22:if(h=n!==null&&n.memoizedState!==null,e.mode&1?(Lt=(u=Lt)||h,On(t,e),Lt=u):On(t,e),ts(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!h&&e.mode&1)for(le=e,h=e.child;h!==null;){for(f=le=h;le!==null;){switch(p=le,x=p.child,p.tag){case 0:case 11:case 14:case 15:qo(4,p,p.return);break;case 1:Ti(p,p.return);var y=p.stateNode;if(typeof y.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(w){st(r,n,w)}}break;case 5:Ti(p,p.return);break;case 22:if(p.memoizedState!==null){Zx(f);continue}}x!==null?(x.return=p,le=x):Zx(f)}h=h.sibling}e:for(h=null,f=e;;){if(f.tag===5){if(h===null){h=f;try{i=f.stateNode,u?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Sj("display",a))}catch(w){st(e,e.return,w)}}}else if(f.tag===6){if(h===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(w){st(e,e.return,w)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;h===f&&(h=null),f=f.return}h===f&&(h=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:On(t,e),ts(e),r&4&&Xx(e);break;case 21:break;default:On(t,e),ts(e)}}function ts(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Qw(n)){var r=n;break e}n=n.return}throw Error(Q(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(ra(i,""),r.flags&=-33);var o=Qx(e);sh(e,o,i);break;case 3:case 4:var a=r.stateNode.containerInfo,l=Qx(e);nh(e,l,a);break;default:throw Error(Q(161))}}catch(c){st(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function LE(e,t,n){le=e,Zw(e)}function Zw(e,t,n){for(var r=(e.mode&1)!==0;le!==null;){var i=le,o=i.child;if(i.tag===22&&r){var a=i.memoizedState!==null||vl;if(!a){var l=i.alternate,c=l!==null&&l.memoizedState!==null||Lt;l=vl;var u=Lt;if(vl=a,(Lt=c)&&!u)for(le=i;le!==null;)a=le,c=a.child,a.tag===22&&a.memoizedState!==null?ev(i):c!==null?(c.return=a,le=c):ev(i);for(;o!==null;)le=o,Zw(o),o=o.sibling;le=i,vl=l,Lt=u}Jx(e)}else i.subtreeFlags&8772&&o!==null?(o.return=i,le=o):Jx(e)}}function Jx(e){for(;le!==null;){var t=le;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Lt||pu(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Lt)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Ln(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&Ox(t,o,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Ox(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var h=u.memoizedState;if(h!==null){var f=h.dehydrated;f!==null&&la(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Q(163))}Lt||t.flags&512&&th(t)}catch(p){st(t,t.return,p)}}if(t===e){le=null;break}if(n=t.sibling,n!==null){n.return=t.return,le=n;break}le=t.return}}function Zx(e){for(;le!==null;){var t=le;if(t===e){le=null;break}var n=t.sibling;if(n!==null){n.return=t.return,le=n;break}le=t.return}}function ev(e){for(;le!==null;){var t=le;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{pu(4,t)}catch(c){st(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){st(t,i,c)}}var o=t.return;try{th(t)}catch(c){st(t,o,c)}break;case 5:var a=t.return;try{th(t)}catch(c){st(t,a,c)}}}catch(c){st(t,t.return,c)}if(t===e){le=null;break}var l=t.sibling;if(l!==null){l.return=t.return,le=l;break}le=t.return}}var FE=Math.ceil,$c=Ws.ReactCurrentDispatcher,Qp=Ws.ReactCurrentOwner,Mn=Ws.ReactCurrentBatchConfig,Oe=0,St=null,dt=null,Tt=0,mn=0,Pi=wr(0),yt=0,ya=null,Wr=0,mu=0,Xp=0,Qo=null,Jt=null,Jp=0,qi=1/0,Ns=null,_c=!1,rh=null,lr=null,yl=!1,tr=null,Oc=0,Xo=0,ih=null,Zl=-1,ec=0;function Kt(){return Oe&6?at():Zl!==-1?Zl:Zl=at()}function cr(e){return e.mode&1?Oe&2&&Tt!==0?Tt&-Tt:bE.transition!==null?(ec===0&&(ec=Dj()),ec):(e=Be,e!==0||(e=window.event,e=e===void 0?16:Hj(e.type)),e):1}function Wn(e,t,n,r){if(50<Xo)throw Xo=0,ih=null,Error(Q(185));_a(e,n,r),(!(Oe&2)||e!==St)&&(e===St&&(!(Oe&2)&&(mu|=n),yt===4&&Zs(e,Tt)),rn(e,r),n===1&&Oe===0&&!(t.mode&1)&&(qi=at()+500,du&&br()))}function rn(e,t){var n=e.callbackNode;bC(e,t);var r=yc(e,e===St?Tt:0);if(r===0)n!==null&&cx(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&cx(n),t===1)e.tag===0?wE(tv.bind(null,e)):cw(tv.bind(null,e)),xE(function(){!(Oe&6)&&br()}),n=null;else{switch(Lj(r)){case 1:n=Sp;break;case 4:n=_j;break;case 16:n=vc;break;case 536870912:n=Oj;break;default:n=vc}n=ab(n,eb.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function eb(e,t){if(Zl=-1,ec=0,Oe&6)throw Error(Q(327));var n=e.callbackNode;if(Li()&&e.callbackNode!==n)return null;var r=yc(e,e===St?Tt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Dc(e,r);else{t=r;var i=Oe;Oe|=2;var o=nb();(St!==e||Tt!==t)&&(Ns=null,qi=at()+500,Or(e,t));do try{zE();break}catch(l){tb(e,l)}while(!0);Dp(),$c.current=o,Oe=i,dt!==null?t=0:(St=null,Tt=0,t=yt)}if(t!==0){if(t===2&&(i=If(e),i!==0&&(r=i,t=oh(e,i))),t===1)throw n=ya,Or(e,0),Zs(e,r),rn(e,at()),n;if(t===6)Zs(e,r);else{if(i=e.current.alternate,!(r&30)&&!UE(i)&&(t=Dc(e,r),t===2&&(o=If(e),o!==0&&(r=o,t=oh(e,o))),t===1))throw n=ya,Or(e,0),Zs(e,r),rn(e,at()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(Q(345));case 2:Ir(e,Jt,Ns);break;case 3:if(Zs(e,r),(r&130023424)===r&&(t=Jp+500-at(),10<t)){if(yc(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Kt(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=Uf(Ir.bind(null,e,Jt,Ns),t);break}Ir(e,Jt,Ns);break;case 4:if(Zs(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var a=31-zn(r);o=1<<a,a=t[a],a>i&&(i=a),r&=~o}if(r=i,r=at()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*FE(r/1960))-r,10<r){e.timeoutHandle=Uf(Ir.bind(null,e,Jt,Ns),r);break}Ir(e,Jt,Ns);break;case 5:Ir(e,Jt,Ns);break;default:throw Error(Q(329))}}}return rn(e,at()),e.callbackNode===n?eb.bind(null,e):null}function oh(e,t){var n=Qo;return e.current.memoizedState.isDehydrated&&(Or(e,t).flags|=256),e=Dc(e,t),e!==2&&(t=Jt,Jt=n,t!==null&&ah(t)),e}function ah(e){Jt===null?Jt=e:Jt.push.apply(Jt,e)}function UE(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],o=i.getSnapshot;i=i.value;try{if(!Vn(o(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Zs(e,t){for(t&=~Xp,t&=~mu,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-zn(t),r=1<<n;e[n]=-1,t&=~r}}function tv(e){if(Oe&6)throw Error(Q(327));Li();var t=yc(e,0);if(!(t&1))return rn(e,at()),null;var n=Dc(e,t);if(e.tag!==0&&n===2){var r=If(e);r!==0&&(t=r,n=oh(e,r))}if(n===1)throw n=ya,Or(e,0),Zs(e,t),rn(e,at()),n;if(n===6)throw Error(Q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ir(e,Jt,Ns),rn(e,at()),null}function Zp(e,t){var n=Oe;Oe|=1;try{return e(t)}finally{Oe=n,Oe===0&&(qi=at()+500,du&&br())}}function Hr(e){tr!==null&&tr.tag===0&&!(Oe&6)&&Li();var t=Oe;Oe|=1;var n=Mn.transition,r=Be;try{if(Mn.transition=null,Be=1,e)return e()}finally{Be=r,Mn.transition=n,Oe=t,!(Oe&6)&&br()}}function em(){mn=Pi.current,Ye(Pi)}function Or(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,gE(n)),dt!==null)for(n=dt.return;n!==null;){var r=n;switch($p(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Sc();break;case 3:Gi(),Ye(nn),Ye(Bt),Wp();break;case 5:zp(r);break;case 4:Gi();break;case 13:Ye(Xe);break;case 19:Ye(Xe);break;case 10:Lp(r.type._context);break;case 22:case 23:em()}n=n.return}if(St=e,dt=e=ur(e.current,null),Tt=mn=t,yt=0,ya=null,Xp=mu=Wr=0,Jt=Qo=null,$r!==null){for(t=0;t<$r.length;t++)if(n=$r[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,o=n.pending;if(o!==null){var a=o.next;o.next=i,r.next=a}n.pending=r}$r=null}return e}function tb(e,t){do{var n=dt;try{if(Dp(),Ql.current=Mc,Ic){for(var r=Je.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Ic=!1}if(zr=0,wt=mt=Je=null,Yo=!1,ga=0,Qp.current=null,n===null||n.return===null){yt=1,ya=t,dt=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=Tt,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,h=l,f=h.tag;if(!(h.mode&1)&&(f===0||f===11||f===15)){var p=h.alternate;p?(h.updateQueue=p.updateQueue,h.memoizedState=p.memoizedState,h.lanes=p.lanes):(h.updateQueue=null,h.memoizedState=null)}var x=zx(a);if(x!==null){x.flags&=-257,Wx(x,a,l,o,t),x.mode&1&&Bx(o,u,t),t=x,c=u;var y=t.updateQueue;if(y===null){var w=new Set;w.add(c),t.updateQueue=w}else y.add(c);break e}else{if(!(t&1)){Bx(o,u,t),tm();break e}c=Error(Q(426))}}else if(Qe&&l.mode&1){var b=zx(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),Wx(b,a,l,o,t),_p(Yi(c,l));break e}}o=c=Yi(c,l),yt!==4&&(yt=2),Qo===null?Qo=[o]:Qo.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=Lw(o,c,t);_x(o,v);break e;case 1:l=c;var m=o.type,j=o.stateNode;if(!(o.flags&128)&&(typeof m.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(lr===null||!lr.has(j)))){o.flags|=65536,t&=-t,o.lanes|=t;var g=Fw(o,l,t);_x(o,g);break e}}o=o.return}while(o!==null)}rb(n)}catch(S){t=S,dt===n&&n!==null&&(dt=n=n.return);continue}break}while(!0)}function nb(){var e=$c.current;return $c.current=Mc,e===null?Mc:e}function tm(){(yt===0||yt===3||yt===2)&&(yt=4),St===null||!(Wr&268435455)&&!(mu&268435455)||Zs(St,Tt)}function Dc(e,t){var n=Oe;Oe|=2;var r=nb();(St!==e||Tt!==t)&&(Ns=null,Or(e,t));do try{BE();break}catch(i){tb(e,i)}while(!0);if(Dp(),Oe=n,$c.current=r,dt!==null)throw Error(Q(261));return St=null,Tt=0,yt}function BE(){for(;dt!==null;)sb(dt)}function zE(){for(;dt!==null&&!hC();)sb(dt)}function sb(e){var t=ob(e.alternate,e,mn);e.memoizedProps=e.pendingProps,t===null?rb(e):dt=t,Qp.current=null}function rb(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=_E(n,t),n!==null){n.flags&=32767,dt=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{yt=6,dt=null;return}}else if(n=$E(n,t,mn),n!==null){dt=n;return}if(t=t.sibling,t!==null){dt=t;return}dt=t=e}while(t!==null);yt===0&&(yt=5)}function Ir(e,t,n){var r=Be,i=Mn.transition;try{Mn.transition=null,Be=1,WE(e,t,n,r)}finally{Mn.transition=i,Be=r}return null}function WE(e,t,n,r){do Li();while(tr!==null);if(Oe&6)throw Error(Q(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Q(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(kC(e,o),e===St&&(dt=St=null,Tt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||yl||(yl=!0,ab(vc,function(){return Li(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Mn.transition,Mn.transition=null;var a=Be;Be=1;var l=Oe;Oe|=4,Qp.current=null,DE(e,n),Jw(n,e),cE(Lf),jc=!!Df,Lf=Df=null,e.current=n,LE(n),pC(),Oe=l,Be=a,Mn.transition=o}else e.current=n;if(yl&&(yl=!1,tr=e,Oc=i),o=e.pendingLanes,o===0&&(lr=null),xC(n.stateNode),rn(e,at()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(_c)throw _c=!1,e=rh,rh=null,e;return Oc&1&&e.tag!==0&&Li(),o=e.pendingLanes,o&1?e===ih?Xo++:(Xo=0,ih=e):Xo=0,br(),null}function Li(){if(tr!==null){var e=Lj(Oc),t=Mn.transition,n=Be;try{if(Mn.transition=null,Be=16>e?16:e,tr===null)var r=!1;else{if(e=tr,tr=null,Oc=0,Oe&6)throw Error(Q(331));var i=Oe;for(Oe|=4,le=e.current;le!==null;){var o=le,a=o.child;if(le.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(le=u;le!==null;){var h=le;switch(h.tag){case 0:case 11:case 15:qo(8,h,o)}var f=h.child;if(f!==null)f.return=h,le=f;else for(;le!==null;){h=le;var p=h.sibling,x=h.return;if(qw(h),h===u){le=null;break}if(p!==null){p.return=x,le=p;break}le=x}}}var y=o.alternate;if(y!==null){var w=y.child;if(w!==null){y.child=null;do{var b=w.sibling;w.sibling=null,w=b}while(w!==null)}}le=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,le=a;else e:for(;le!==null;){if(o=le,o.flags&2048)switch(o.tag){case 0:case 11:case 15:qo(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,le=v;break e}le=o.return}}var m=e.current;for(le=m;le!==null;){a=le;var j=a.child;if(a.subtreeFlags&2064&&j!==null)j.return=a,le=j;else e:for(a=m;le!==null;){if(l=le,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:pu(9,l)}}catch(S){st(l,l.return,S)}if(l===a){le=null;break e}var g=l.sibling;if(g!==null){g.return=l.return,le=g;break e}le=l.return}}if(Oe=i,br(),cs&&typeof cs.onPostCommitFiberRoot=="function")try{cs.onPostCommitFiberRoot(ou,e)}catch{}r=!0}return r}finally{Be=n,Mn.transition=t}}return!1}function nv(e,t,n){t=Yi(n,t),t=Lw(e,t,1),e=ar(e,t,1),t=Kt(),e!==null&&(_a(e,1,t),rn(e,t))}function st(e,t,n){if(e.tag===3)nv(e,e,n);else for(;t!==null;){if(t.tag===3){nv(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(lr===null||!lr.has(r))){e=Yi(n,e),e=Fw(t,e,1),t=ar(t,e,1),e=Kt(),t!==null&&(_a(t,1,e),rn(t,e));break}}t=t.return}}function HE(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Kt(),e.pingedLanes|=e.suspendedLanes&n,St===e&&(Tt&n)===n&&(yt===4||yt===3&&(Tt&130023424)===Tt&&500>at()-Jp?Or(e,0):Xp|=n),rn(e,t)}function ib(e,t){t===0&&(e.mode&1?(t=cl,cl<<=1,!(cl&130023424)&&(cl=4194304)):t=1);var n=Kt();e=Ds(e,t),e!==null&&(_a(e,t,n),rn(e,n))}function VE(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ib(e,n)}function KE(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Q(314))}r!==null&&r.delete(t),ib(e,n)}var ob;ob=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||nn.current)en=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return en=!1,ME(e,t,n);en=!!(e.flags&131072)}else en=!1,Qe&&t.flags&1048576&&uw(t,Ec,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Jl(e,t),e=t.pendingProps;var i=Hi(t,Bt.current);Di(t,n),i=Vp(null,t,r,e,i,n);var o=Kp();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,sn(r)?(o=!0,Nc(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Up(t),i.updater=hu,t.stateNode=i,i._reactInternals=t,Gf(t,r,e,n),t=Qf(null,t,r,!0,o,n)):(t.tag=0,Qe&&o&&Mp(t),Wt(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Jl(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=YE(r),e=Ln(r,e),i){case 0:t=qf(null,t,r,e,n);break e;case 1:t=Kx(null,t,r,e,n);break e;case 11:t=Hx(null,t,r,e,n);break e;case 14:t=Vx(null,t,r,Ln(r.type,e),n);break e}throw Error(Q(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ln(r,i),qf(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ln(r,i),Kx(e,t,r,i,n);case 3:e:{if(Ww(t),e===null)throw Error(Q(387));r=t.pendingProps,o=t.memoizedState,i=o.element,gw(e,t),Tc(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Yi(Error(Q(423)),t),t=Gx(e,t,r,n,i);break e}else if(r!==i){i=Yi(Error(Q(424)),t),t=Gx(e,t,r,n,i);break e}else for(xn=or(t.stateNode.containerInfo.firstChild),yn=t,Qe=!0,Un=null,n=pw(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Vi(),r===i){t=Ls(e,t,n);break e}Wt(e,t,r,n)}t=t.child}return t;case 5:return xw(t),e===null&&Hf(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,a=i.children,Ff(r,i)?a=null:o!==null&&Ff(r,o)&&(t.flags|=32),zw(e,t),Wt(e,t,a,n),t.child;case 6:return e===null&&Hf(t),null;case 13:return Hw(e,t,n);case 4:return Bp(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ki(t,null,r,n):Wt(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ln(r,i),Hx(e,t,r,i,n);case 7:return Wt(e,t,t.pendingProps,n),t.child;case 8:return Wt(e,t,t.pendingProps.children,n),t.child;case 12:return Wt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value,Ve(Ac,r._currentValue),r._currentValue=a,o!==null)if(Vn(o.value,a)){if(o.children===i.children&&!nn.current){t=Ls(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){a=o.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=Ps(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var h=u.pending;h===null?c.next=c:(c.next=h.next,h.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Vf(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(Q(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),Vf(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}Wt(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Di(t,n),i=$n(i),r=r(i),t.flags|=1,Wt(e,t,r,n),t.child;case 14:return r=t.type,i=Ln(r,t.pendingProps),i=Ln(r.type,i),Vx(e,t,r,i,n);case 15:return Uw(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ln(r,i),Jl(e,t),t.tag=1,sn(r)?(e=!0,Nc(t)):e=!1,Di(t,n),Dw(t,r,i),Gf(t,r,i,n),Qf(null,t,r,!0,e,n);case 19:return Vw(e,t,n);case 22:return Bw(e,t,n)}throw Error(Q(156,t.tag))};function ab(e,t){return $j(e,t)}function GE(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function In(e,t,n,r){return new GE(e,t,n,r)}function nm(e){return e=e.prototype,!(!e||!e.isReactComponent)}function YE(e){if(typeof e=="function")return nm(e)?1:0;if(e!=null){if(e=e.$$typeof,e===wp)return 11;if(e===bp)return 14}return 2}function ur(e,t){var n=e.alternate;return n===null?(n=In(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function tc(e,t,n,r,i,o){var a=2;if(r=e,typeof e=="function")nm(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case wi:return Dr(n.children,i,o,t);case jp:a=8,i|=8;break;case xf:return e=In(12,n,t,i|2),e.elementType=xf,e.lanes=o,e;case vf:return e=In(13,n,t,i),e.elementType=vf,e.lanes=o,e;case yf:return e=In(19,n,t,i),e.elementType=yf,e.lanes=o,e;case xj:return gu(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case mj:a=10;break e;case gj:a=9;break e;case wp:a=11;break e;case bp:a=14;break e;case Qs:a=16,r=null;break e}throw Error(Q(130,e==null?e:typeof e,""))}return t=In(a,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Dr(e,t,n,r){return e=In(7,e,r,t),e.lanes=n,e}function gu(e,t,n,r){return e=In(22,e,r,t),e.elementType=xj,e.lanes=n,e.stateNode={isHidden:!1},e}function bd(e,t,n){return e=In(6,e,null,t),e.lanes=n,e}function kd(e,t,n){return t=In(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function qE(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sd(0),this.expirationTimes=sd(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sd(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function sm(e,t,n,r,i,o,a,l,c){return e=new qE(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=In(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Up(o),e}function QE(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ji,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function lb(e){if(!e)return pr;e=e._reactInternals;e:{if(Zr(e)!==e||e.tag!==1)throw Error(Q(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(sn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Q(171))}if(e.tag===1){var n=e.type;if(sn(n))return lw(e,n,t)}return t}function cb(e,t,n,r,i,o,a,l,c){return e=sm(n,r,!0,e,i,o,a,l,c),e.context=lb(null),n=e.current,r=Kt(),i=cr(n),o=Ps(r,i),o.callback=t??null,ar(n,o,i),e.current.lanes=i,_a(e,i,r),rn(e,r),e}function xu(e,t,n,r){var i=t.current,o=Kt(),a=cr(i);return n=lb(n),t.context===null?t.context=n:t.pendingContext=n,t=Ps(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ar(i,t,a),e!==null&&(Wn(e,i,a,o),ql(e,i,a)),a}function Lc(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function sv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function rm(e,t){sv(e,t),(e=e.alternate)&&sv(e,t)}function XE(){return null}var ub=typeof reportError=="function"?reportError:function(e){console.error(e)};function im(e){this._internalRoot=e}vu.prototype.render=im.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Q(409));xu(e,t,null,null)};vu.prototype.unmount=im.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Hr(function(){xu(null,e,null,null)}),t[Os]=null}};function vu(e){this._internalRoot=e}vu.prototype.unstable_scheduleHydration=function(e){if(e){var t=Bj();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Js.length&&t!==0&&t<Js[n].priority;n++);Js.splice(n,0,e),n===0&&Wj(e)}};function om(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function yu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function rv(){}function JE(e,t,n,r,i){if(i){if(typeof r=="function"){var o=r;r=function(){var u=Lc(a);o.call(u)}}var a=cb(t,r,e,0,null,!1,!1,"",rv);return e._reactRootContainer=a,e[Os]=a.current,da(e.nodeType===8?e.parentNode:e),Hr(),a}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var l=r;r=function(){var u=Lc(c);l.call(u)}}var c=sm(e,0,!1,null,null,!1,!1,"",rv);return e._reactRootContainer=c,e[Os]=c.current,da(e.nodeType===8?e.parentNode:e),Hr(function(){xu(t,c,n,r)}),c}function ju(e,t,n,r,i){var o=n._reactRootContainer;if(o){var a=o;if(typeof i=="function"){var l=i;i=function(){var c=Lc(a);l.call(c)}}xu(t,a,e,i)}else a=JE(n,t,e,i,r);return Lc(a)}Fj=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Uo(t.pendingLanes);n!==0&&(Np(t,n|1),rn(t,at()),!(Oe&6)&&(qi=at()+500,br()))}break;case 13:Hr(function(){var r=Ds(e,1);if(r!==null){var i=Kt();Wn(r,e,1,i)}}),rm(e,1)}};Cp=function(e){if(e.tag===13){var t=Ds(e,134217728);if(t!==null){var n=Kt();Wn(t,e,134217728,n)}rm(e,134217728)}};Uj=function(e){if(e.tag===13){var t=cr(e),n=Ds(e,t);if(n!==null){var r=Kt();Wn(n,e,t,r)}rm(e,t)}};Bj=function(){return Be};zj=function(e,t){var n=Be;try{return Be=e,t()}finally{Be=n}};Rf=function(e,t,n){switch(t){case"input":if(bf(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=uu(r);if(!i)throw Error(Q(90));yj(r),bf(r,i)}}}break;case"textarea":wj(e,n);break;case"select":t=n.value,t!=null&&Mi(e,!!n.multiple,t,!1)}};Aj=Zp;Rj=Hr;var ZE={usingClientEntryPoint:!1,Events:[Da,Ni,uu,Cj,Ej,Zp]},Io={findFiberByHostInstance:Mr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},eA={bundleType:Io.bundleType,version:Io.version,rendererPackageName:Io.rendererPackageName,rendererConfig:Io.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ws.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ij(e),e===null?null:e.stateNode},findFiberByHostInstance:Io.findFiberByHostInstance||XE,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 jl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jl.isDisabled&&jl.supportsFiber)try{ou=jl.inject(eA),cs=jl}catch{}}wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ZE;wn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!om(t))throw Error(Q(200));return QE(e,t,null,n)};wn.createRoot=function(e,t){if(!om(e))throw Error(Q(299));var n=!1,r="",i=ub;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=sm(e,1,!1,null,null,n,!1,r,i),e[Os]=t.current,da(e.nodeType===8?e.parentNode:e),new im(t)};wn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Q(188)):(e=Object.keys(e).join(","),Error(Q(268,e)));return e=Ij(t),e=e===null?null:e.stateNode,e};wn.flushSync=function(e){return Hr(e)};wn.hydrate=function(e,t,n){if(!yu(t))throw Error(Q(200));return ju(null,e,t,!0,n)};wn.hydrateRoot=function(e,t,n){if(!om(e))throw Error(Q(405));var r=n!=null&&n.hydratedSources||null,i=!1,o="",a=ub;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=cb(t,null,e,1,n??null,i,!1,o,a),e[Os]=t.current,da(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new vu(t)};wn.render=function(e,t,n){if(!yu(t))throw Error(Q(200));return ju(null,e,t,!1,n)};wn.unmountComponentAtNode=function(e){if(!yu(e))throw Error(Q(40));return e._reactRootContainer?(Hr(function(){ju(null,null,e,!1,function(){e._reactRootContainer=null,e[Os]=null})}),!0):!1};wn.unstable_batchedUpdates=Zp;wn.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!yu(n))throw Error(Q(200));if(e==null||e._reactInternals===void 0)throw Error(Q(38));return ju(e,t,n,!1,r)};wn.version="18.3.1-next-f1338f8080-20240426";function db(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(db)}catch(e){console.error(e)}}db(),dj.exports=wn;var Qi=dj.exports,fb,iv=Qi;fb=iv.createRoot,iv.hydrateRoot;var tA=Object.defineProperty,uo=(e,t)=>tA(e,"name",{value:t,configurable:!0}),hb=!!(typeof window<"u"&&window.document&&window.document.createElement);function Se(e,t,{checkForDefaultPrevented:n=!0}={}){return uo(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}uo(Se,"composeEventHandlers");function nA(e){var t;if(!hb)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}uo(nA,"getOwnerWindow");function lh(e){if(!hb)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}uo(lh,"getOwnerDocument");function pb(e,t=!1){const{activeElement:n}=lh(e);if(!(n!=null&&n.nodeName))return null;if(mb(n)&&n.contentDocument)return pb(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=lh(n).getElementById(r);if(i)return i}}return n}uo(pb,"getActiveElement");function mb(e){return e.tagName==="IFRAME"}uo(mb,"isFrame");var sA=Object.defineProperty,am=(e,t)=>sA(e,"name",{value:t,configurable:!0});function ch(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}am(ch,"setRef");function gb(...e){return t=>{let n=!1;const r=e.map(i=>{const o=ch(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){const o=r[i];typeof o=="function"?o():ch(e[i],null)}}}}am(gb,"composeRefs");function Ze(...e){return d.useCallback(gb(...e),e)}am(Ze,"useComposedRefs");var rA=Object.defineProperty,Pn=(e,t)=>rA(e,"name",{value:t,configurable:!0});function iA(e,t){const n=d.createContext(t);n.displayName=e+"Context";const r=Pn(o=>{const{children:a,...l}=o,c=d.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:a})},"Provider");r.displayName=e+"Provider";function i(o,a={}){const{optional:l=!1}=a,c=d.useContext(n);if(c)return c;if(t!==void 0)return t;if(!l)throw new Error(`\`${o}\` must be used within \`${e}\``)}return Pn(i,"useContext"),[r,i]}Pn(iA,"createContext");function Yn(e,t=[]){let n=[];function r(o,a){const l=d.createContext(a);l.displayName=o+"Context";const c=n.length;n=[...n,a];const u=Pn(f=>{var v;const{scope:p,children:x,...y}=f,w=((v=p==null?void 0:p[e])==null?void 0:v[c])||l,b=d.useMemo(()=>y,Object.values(y));return s.jsx(w.Provider,{value:b,children:x})},"Provider");u.displayName=o+"Provider";function h(f,p,x={}){var v;const{optional:y=!1}=x,w=((v=p==null?void 0:p[e])==null?void 0:v[c])||l,b=d.useContext(w);if(b)return b;if(a!==void 0)return a;if(!y)throw new Error(`\`${f}\` must be used within \`${o}\``)}return Pn(h,"useContext"),[u,h]}Pn(r,"createContext");const i=Pn(()=>{const o=n.map(a=>d.createContext(a));return Pn(function(l){const c=(l==null?void 0:l[e])||o;return d.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])},"useScope")},"createScope");return i.scopeName=e,[r,xb(i,...t)]}Pn(Yn,"createContextScope");function xb(...e){const t=e[0];if(e.length===1)return t;const n=Pn(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Pn(function(o){const a=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(o)[`__scope${u}`];return{...l,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Pn(xb,"composeContextScopes");var oA=Object.defineProperty,qn=(e,t)=>oA(e,"name",{value:t,configurable:!0});function mr(e){const t=d.forwardRef((n,r)=>{let{children:i,...o}=n,a=null,l=!1;const c=[];uh(i)&&typeof wl=="function"&&(i=wl(i._payload)),d.Children.forEach(i,p=>{var x;if(bb(p)){l=!0;const y=p;let w="child"in y.props?y.props.child:y.props.children;uh(w)&&typeof wl=="function"&&(w=wl(w._payload)),a=aA(y,w),c.push((x=a==null?void 0:a.props)==null?void 0:x.children)}else c.push(p)}),a?a=d.cloneElement(a,void 0,c):!l&&d.Children.count(i)===1&&d.isValidElement(i)&&(a=i);const u=a?wb(a):void 0,h=Ze(r,u);if(!a){if(i||i===0)throw new Error(l?uA(e):cA(e));return i}const f=jb(o,a.props??{});return a.type!==d.Fragment&&(f.ref=r?h:u),d.cloneElement(a,f)});return t.displayName=`${e}.Slot`,t}qn(mr,"createSlot");var vb=Symbol.for("radix.slottable");function yb(e){const t=qn(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=vb,t}qn(yb,"createSlottable");var aA=qn((e,t)=>{if("child"in e.props){const n=e.props.child;return d.isValidElement(n)?d.cloneElement(n,void 0,e.props.children(n.props.children)):null}return d.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function jb(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...l)=>{const c=o(...l);return i(...l),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}qn(jb,"mergeProps");function wb(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}qn(wb,"getElementRef");function bb(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vb}qn(bb,"isSlottable");var lA=Symbol.for("react.lazy");function uh(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===lA&&"_payload"in e&&kb(e._payload)}qn(uh,"isLazyComponent");function kb(e){return typeof e=="object"&&e!==null&&"then"in e}qn(kb,"isPromiseLike");var cA=qn(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),uA=qn(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),wl=ao[" use ".trim().toString()],dA=Object.defineProperty,bt=(e,t)=>dA(e,"name",{value:t,configurable:!0});function wu(e){const t=e+"CollectionProvider",[n,r]=Yn(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=bt(w=>{const{scope:b,children:v}=w,m=d.useRef(null),j=d.useRef(new Map).current;return s.jsx(i,{scope:b,itemMap:j,collectionRef:m,children:v})},"CollectionProvider");a.displayName=t;const l=e+"CollectionSlot",c=mr(l),u=d.forwardRef((w,b)=>{const{scope:v,children:m}=w,j=o(l,v),g=Ze(b,j.collectionRef);return s.jsx(c,{ref:g,children:m})});u.displayName=l;const h=e+"CollectionItemSlot",f="data-radix-collection-item",p=mr(h),x=d.forwardRef((w,b)=>{const{scope:v,children:m,...j}=w,g=d.useRef(null),S=Ze(b,g),k=o(h,v);return d.useEffect(()=>(k.itemMap.set(g,{ref:g,...j}),()=>void k.itemMap.delete(g))),s.jsx(p,{[f]:"",ref:S,children:m})});x.displayName=h;function y(w){const b=o(e+"CollectionConsumer",w);return d.useCallback(()=>{const m=b.collectionRef.current;if(!m)return[];const j=Array.from(m.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((k,N)=>j.indexOf(k.ref.current)-j.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return bt(y,"useCollection"),[{Provider:a,Slot:u,ItemSlot:x},y,r]}bt(wu,"createCollection");var ov=new WeakMap,ut,gn,Sd=(gn=class extends Map{constructor(n){super(n);Qg(this,ut);Xu(this,ut,[...super.keys()]),ov.set(this,!0)}set(n,r){return ov.get(this)&&(this.has(n)?$t(this,ut)[$t(this,ut).indexOf(n)]=n:$t(this,ut).push(n)),super.set(n,r),this}insert(n,r,i){const o=this.has(r),a=$t(this,ut).length,l=lm(n);let c=l>=0?l:a+l;const u=c<0||c>=a?-1:c;if(u===this.size||o&&u===this.size-1||u===-1)return this.set(r,i),this;const h=this.size+(o?0:1);l<0&&c++;const f=[...$t(this,ut)];let p,x=!1;for(let y=c;y<h;y++)if(c===y){let w=f[y];f[y]===r&&(w=f[y+1]),o&&this.delete(r),p=this.get(w),this.set(r,i)}else{!x&&f[y-1]===r&&(x=!0);const w=f[x?y:y-1],b=p;p=this.get(w),this.delete(w),this.set(w,b)}return this}with(n,r,i){const o=new gn(this);return o.insert(n,r,i),o}before(n){const r=$t(this,ut).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,i){const o=$t(this,ut).indexOf(n);return o===-1?this:this.insert(o,r,i)}after(n){let r=$t(this,ut).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,i){const o=$t(this,ut).indexOf(n);return o===-1?this:this.insert(o+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Xu(this,ut,[]),super.clear()}delete(n){const r=super.delete(n);return r&&$t(this,ut).splice($t(this,ut).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=nc($t(this,ut),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=nc($t(this,ut),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return $t(this,ut).indexOf(n)}keyAt(n){return nc($t(this,ut),n)}from(n,r){const i=this.indexOf(n);if(i===-1)return;let o=i+r;return o<0&&(o=0),o>=this.size&&(o=this.size-1),this.at(o)}keyFrom(n,r){const i=this.indexOf(n);if(i===-1)return;let o=i+r;return o<0&&(o=0),o>=this.size&&(o=this.size-1),this.keyAt(o)}find(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return o;i++}}findIndex(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return i;i++}return-1}filter(n,r){const i=[];let o=0;for(const a of this)Reflect.apply(n,r,[a,o,this])&&i.push(a),o++;return new gn(i)}map(n,r){const i=[];let o=0;for(const a of this)i.push([a[0],Reflect.apply(n,r,[a,o,this])]),o++;return new gn(i)}reduce(...n){const[r,i]=n;let o=0,a=i??this.at(0);for(const l of this)o===0&&n.length===1?a=l:a=Reflect.apply(r,this,[a,l,o,this]),o++;return a}reduceRight(...n){const[r,i]=n;let o=i??this.at(-1);for(let a=this.size-1;a>=0;a--){const l=this.at(a);a===this.size-1&&n.length===1?o=l:o=Reflect.apply(r,this,[o,l,a,this])}return o}toSorted(n){const r=[...this.entries()].sort(n);return new gn(r)}toReversed(){const n=new gn;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),o=this.get(i);n.set(i,o)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new gn(r)}slice(n,r){const i=new gn;let o=this.size-1;if(n===void 0)return i;n<0&&(n=n+this.size),r!==void 0&&r>0&&(o=r-1);for(let a=n;a<=o;a++){const l=this.keyAt(a),c=this.get(l);i.set(l,c)}return i}every(n,r){let i=0;for(const o of this){if(!Reflect.apply(n,r,[o,i,this]))return!1;i++}return!0}some(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return!0;i++}return!1}},ut=new WeakMap,bt(gn,"OrderedDict"),gn);function nc(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Sb(e,t);return n===-1?void 0:e[n]}bt(nc,"at");function Sb(e,t){const n=e.length,r=lm(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}bt(Sb,"toSafeIndex");function lm(e){return e!==e||e===0?0:Math.trunc(e)}bt(lm,"toSafeInteger");function fA(e){const t=e+"CollectionProvider",[n,r]=Yn(t),[i,o]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Sd,setItemMap:bt(()=>{},"setItemMap")}),a=bt(({state:j,...g})=>j?s.jsx(c,{...g,state:j}):s.jsx(l,{...g}),"CollectionProvider");a.displayName=t;const l=bt(j=>{const g=b();return s.jsx(c,{...j,state:g})},"CollectionInit");l.displayName=t+"Init";const c=bt(j=>{const{scope:g,children:S,state:k}=j,N=d.useRef(null),[C,A]=d.useState(null),E=Ze(N,A),[_,L]=k;return d.useEffect(()=>{if(!C)return;const B=Eb(()=>{});return B.observe(C,{childList:!0,subtree:!0}),()=>{B.disconnect()}},[C]),s.jsx(i,{scope:g,itemMap:_,setItemMap:L,collectionRef:E,collectionRefObject:N,collectionElement:C,children:S})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",h=mr(u),f=d.forwardRef((j,g)=>{const{scope:S,children:k}=j,N=o(u,S),C=Ze(g,N.collectionRef);return s.jsx(h,{ref:C,children:k})});f.displayName=u;const p=e+"CollectionItemSlot",x="data-radix-collection-item",y=mr(p),w=d.forwardRef((j,g)=>{const{scope:S,children:k,...N}=j,C=d.useRef(null),[A,E]=d.useState(null),_=Ze(g,C,E),L=o(p,S),{setItemMap:B}=L,R=d.useRef(N);Nb(R.current,N)||(R.current=N);const O=R.current;return d.useEffect(()=>{const Y=O;return B(G=>A?G.has(A)?G.set(A,{...Y,element:A}).toSorted(dh):(G.set(A,{...Y,element:A}),G.toSorted(dh)):G),()=>{B(G=>!A||!G.has(A)?G:(G.delete(A),new Sd(G)))}},[A,O,B]),s.jsx(y,{[x]:"",ref:_,children:k})});w.displayName=p;function b(){return d.useState(new Sd)}bt(b,"useInitCollection");function v(j){const{itemMap:g}=o(e+"CollectionConsumer",j);return g}return bt(v,"useCollection"),[{Provider:a,Slot:f,ItemSlot:w},{createCollectionScope:r,useCollection:v,useInitCollection:b}]}bt(fA,"createCollection");function Nb(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}bt(Nb,"shallowEqual");function Cb(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}bt(Cb,"isElementPreceding");function dh(e,t){return!e[1].element||!t[1].element?0:Cb(e[1].element,t[1].element)?-1:1}bt(dh,"sortByDocumentPosition");function Eb(e){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){e();return}})}bt(Eb,"getChildListObserver");var hA=Object.defineProperty,pA=(e,t)=>hA(e,"name",{value:t,configurable:!0}),mA=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],tt=mA.reduce((e,t)=>{const n=mr(`Primitive.${t}`),r=d.forwardRef((i,o)=>{const{asChild:a,...l}=i,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function bu(e,t){e&&Qi.flushSync(()=>e.dispatchEvent(t))}pA(bu,"dispatchDiscreteCustomEvent");var gA=Object.defineProperty,xA=(e,t)=>gA(e,"name",{value:t,configurable:!0});function Kn(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}xA(Kn,"useCallbackRef");var vA=Object.defineProperty,gt=(e,t)=>vA(e,"name",{value:t,configurable:!0}),fh="dismissableLayer.update",yA="dismissableLayer.pointerDownOutside",jA="dismissableLayer.focusOutside",av,cm=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),um=d.forwardRef(gt(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:l,onInteractOutside:c,onDismiss:u,...h}=t,f=d.useContext(cm),[p,x]=d.useState(null),y=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=d.useState({}),b=Ze(n,x),v=Array.from(f.layers),[m]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=m?v.indexOf(m):-1,g=p?v.indexOf(p):-1,S=f.layersWithOutsidePointerEventsDisabled.size>0,k=g>=j,N=d.useRef(!1),C=Rb(L=>{a==null||a(L),c==null||c(L),L.defaultPrevented||u==null||u()},{ownerDocument:y,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:N,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(L=>{if(!(L instanceof Node))return!1;const B=[...f.branches].some(R=>R.contains(L));return k&&!B},[f.branches,k])}),A=Tb(L=>{if(i&&N.current)return;const B=L.target;[...f.branches].some(O=>O.contains(B))||(l==null||l(L),c==null||c(L),L.defaultPrevented||u==null||u())},y),E=p?g===v.length-1:!1,_=Kn(L=>{L.key==="Escape"&&(o==null||o(L),!L.defaultPrevented&&u&&(L.preventDefault(),u()))});return d.useEffect(()=>{if(E)return y.addEventListener("keydown",_,{capture:!0}),()=>y.removeEventListener("keydown",_,{capture:!0})},[y,E,_]),d.useEffect(()=>{if(p)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(av=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),hh(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(y.body.style.pointerEvents=av))}},[p,y,r,f]),d.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),hh())},[p,f]),d.useEffect(()=>{const L=gt(()=>w({}),"handleUpdate");return document.addEventListener(fh,L),()=>document.removeEventListener(fh,L)},[]),s.jsx(tt.div,{...h,ref:b,style:{pointerEvents:S?k?"auto":"none":void 0,...t.style},onFocusCapture:Se(t.onFocusCapture,A.onFocusCapture),onBlurCapture:Se(t.onBlurCapture,A.onBlurCapture),onPointerDownCapture:Se(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),wA=d.forwardRef(gt(function(t,n){const r=d.useContext(cm),i=d.useRef(null),o=Ze(n,i);return d.useEffect(()=>{const a=i.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),s.jsx(tt.div,{...t,ref:o})},"DismissableLayerBranch"));function Ab(){const e=d.useContext(cm),[t,n]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}gt(Ab,"useDismissableLayerSurface");var bA=gt(()=>!0,"IS_TRUE");function Rb(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:o,shouldHandlePointerDownOutside:a=bA}=t,l=Kn(e),c=d.useRef(!1),u=d.useRef(!1),h=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function p(){u.current=!1,i.current=!1,h.current.clear()}gt(p,"resetOutsideInteraction");function x(){return Array.from(h.current.values()).some(Boolean)}gt(x,"isOutsideInteractionIntercepted");function y(j){if(!u.current)return;const g=j.target;g instanceof Node&&[...o].some(k=>k.contains(g))||h.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}gt(y,"handleInteractionCapture");function w(j){u.current&&h.current.set(j.type,!1)}gt(w,"handleInteractionBubble");const b=gt(j=>{if(j.target&&!c.current){let g=function(){n.removeEventListener("click",f.current);const k=x();p(),k||dm(yA,l,S,{discrete:!0})};if(gt(g,"handleAndDispatchPointerDownOutsideEvent"),!a(j.target)){n.removeEventListener("click",f.current),p(),c.current=!1;return}const S={originalEvent:j};u.current=!0,i.current=r&&j.button===0,h.current.clear(),!r||j.button!==0?g():(n.removeEventListener("click",f.current),f.current=g,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),p();c.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of v)n.addEventListener(j,y,!0),n.addEventListener(j,w);const m=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(m),n.removeEventListener("pointerdown",b),n.removeEventListener("click",f.current);for(const j of v)n.removeEventListener(j,y,!0),n.removeEventListener(j,w)}},[n,l,r,i,o,a]),{onPointerDownCapture:gt(()=>c.current=!0,"onPointerDownCapture")}}gt(Rb,"usePointerDownOutside");function Tb(e,t=globalThis==null?void 0:globalThis.document){const n=Kn(e),r=d.useRef(!1);return d.useEffect(()=>{const i=gt(o=>{o.target&&!r.current&&dm(jA,n,{originalEvent:o},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:gt(()=>r.current=!0,"onFocusCapture"),onBlurCapture:gt(()=>r.current=!1,"onBlurCapture")}}gt(Tb,"useFocusOutside");function hh(){const e=new CustomEvent(fh);document.dispatchEvent(e)}gt(hh,"dispatchUpdate");function dm(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?bu(i,o):i.dispatchEvent(o)}gt(dm,"handleAndDispatchCustomEvent");var kA=wA,on=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},SA=Object.defineProperty,NA=(e,t)=>SA(e,"name",{value:t,configurable:!0}),fm=d.forwardRef(NA(function(t,n){var c;const{container:r,...i}=t,[o,a]=d.useState(!1);on(()=>a(!0),[]);const l=r||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?Qi.createPortal(s.jsx(tt.div,{...i,ref:n}),l):null},"Portal")),CA=Object.defineProperty,Fs=(e,t)=>CA(e,"name",{value:t,configurable:!0});function Pb(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}Fs(Pb,"useStateMachine");var kr=Fs(e=>{const{present:t,children:n}=e,r=Ib(t),i=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),o=Mb(r.ref,$b(i));return typeof n=="function"||r.isPresent?d.cloneElement(i,{ref:o}):null},"Presence");function Ib(e){const[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),o=d.useRef("none"),a=d.useRef(void 0),l=e?"mounted":"unmounted",[c,u]=Pb(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{c==="mounted"?(o.current=a.current??yi(r.current),a.current=void 0):o.current="none"},[c]),on(()=>{const h=r.current,f=i.current;if(f!==e){const x=o.current,y=yi(h);e?(a.current=y,u("MOUNT")):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&x!==y?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),on(()=>{if(t){let h;const f=t.ownerDocument.defaultView??window,p=Fs(y=>{const b=yi(r.current).includes(CSS.escape(y.animationName));if(y.target===t&&b&&(u("ANIMATION_END"),!i.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",h=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},"handleAnimationEnd"),x=Fs(y=>{y.target===t&&(o.current=yi(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(h),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:d.useCallback(h=>{if(h){const f=getComputedStyle(h);r.current=f,a.current=yi(f)}else r.current=null;n(h)},[])}}Fs(Ib,"usePresence");function ph(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Fs(ph,"setRef");function Mb(...e){const t=d.useRef(e);return t.current=e,d.useCallback(n=>{const r=t.current;let i=!1;const o=r.map(a=>{const l=ph(a,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let a=0;a<o.length;a++){const l=o[a];typeof l=="function"?l():ph(r[a],null)}}},[])}Fs(Mb,"useStableComposedRefs");function yi(e){return(e==null?void 0:e.animationName)||"none"}Fs(yi,"getAnimationName");function $b(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Fs($b,"getElementRef");var EA=Object.defineProperty,AA=(e,t)=>EA(e,"name",{value:t,configurable:!0}),lv=ao[" useEffectEvent ".trim().toString()],cv=ao[" useInsertionEffect ".trim().toString()];function _b(e){if(typeof lv=="function")return lv(e);const t=d.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof cv=="function"?cv(()=>{t.current=e}):on(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}AA(_b,"useEffectEvent");var RA=Object.defineProperty,Fa=(e,t)=>RA(e,"name",{value:t,configurable:!0}),TA=ao[" useInsertionEffect ".trim().toString()]||on;function fo({prop:e,defaultProp:t,onChange:n=Fa(()=>{},"onChange"),caller:r}){const[i,o,a]=Ob({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:i,u=d.useCallback(h=>{var f;if(l){const p=Db(h)?h(e):h;p!==e&&((f=a.current)==null||f.call(a,p))}else o(h)},[l,e,o,a]);return[c,u]}Fa(fo,"useControllableState");function Ob({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),i=d.useRef(n),o=d.useRef(t);return TA(()=>{o.current=t},[t]),d.useEffect(()=>{var a;i.current!==n&&((a=o.current)==null||a.call(o,n),i.current=n)},[n,i]),[n,r,o]}Fa(Ob,"useUncontrolledState");function Db(e){return typeof e=="function"}Fa(Db,"isFunction");var uv=Symbol("RADIX:SYNC_STATE");function PA(e,t,n,r){const{prop:i,defaultProp:o,onChange:a,caller:l}=t,c=i!==void 0,u=_b(a),h=[{...n,state:o}];r&&h.push(r);const[f,p]=d.useReducer((b,v)=>{if(v.type===uv)return{...b,state:v.state};const m=e(b,v);return c&&!Object.is(m.state,b.state)&&u(m.state),m},...h),x=f.state,y=d.useRef(x);d.useEffect(()=>{y.current!==x&&(y.current=x,c||u(x))},[x,y,c]);const w=d.useMemo(()=>i!==void 0?{...f,state:i}:f,[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&p({type:uv,state:i})},[i,f.state,c]),[w,p]}Fa(PA,"useControllableStateReducer");var IA=Object.defineProperty,MA=(e,t)=>IA(e,"name",{value:t,configurable:!0}),$A=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Lb=d.forwardRef(MA(function(t,n){return s.jsx(tt.span,{...t,ref:n,style:{...$A,...t.style}})},"VisuallyHidden")),_A=Lb,OA=Object.defineProperty,Dt=(e,t)=>OA(e,"name",{value:t,configurable:!0}),Fb="ToastProvider",[Ub,DA,LA]=wu("Toast"),[Bb,YU]=Yn("Toast",[LA]),[FA,zb]=Bb(Fb),UA=Dt(e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:o=50,announcerContainer:a,children:l}=e,[c,u]=d.useState(null),[h,f]=d.useState(0),p=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Fb}\`. Expected non-empty \`string\`.`),s.jsx(Ub.Provider,{scope:t,children:s.jsx(FA,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:o,toastCount:h,viewport:c,onViewportChange:u,onToastAdd:d.useCallback(()=>f(x=>x+1),[]),onToastRemove:d.useCallback(()=>f(x=>x-1),[]),isClosePausedRef:p,announcerContainer:a,children:l})})},"ToastProvider"),BA="ToastViewport",zA=["F8"],WA="toast.viewportPause",HA="toast.viewportResume",VA=d.forwardRef(Dt(function(t,n){const{__scopeToast:r,hotkey:i=zA,label:o="Notifications ({hotkey})",...a}=t,l=zb(BA,r),c=DA(r),u=d.useRef(null),h=d.useRef(null),f=d.useRef(null),p=d.useRef(null),x=Ze(n,p,l.onViewportChange),y=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=l.toastCount>0;d.useEffect(()=>{const v=Dt(m=>{var g;i.length!==0&&i.every(S=>m[S]||m.code===S)&&((g=p.current)==null||g.focus())},"handleKeyDown");return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[i]),d.useEffect(()=>{const v=u.current,m=p.current;if(w&&v&&m){const j=Dt(()=>{if(!l.isClosePausedRef.current){const N=new CustomEvent(WA);m.dispatchEvent(N),l.isClosePausedRef.current=!0}},"handlePause"),g=Dt(()=>{if(l.isClosePausedRef.current){const N=new CustomEvent(HA);m.dispatchEvent(N),l.isClosePausedRef.current=!1}},"handleResume"),S=Dt(N=>{!v.contains(N.relatedTarget)&&g()},"handleFocusOutResume"),k=Dt(()=>{v.contains(document.activeElement)||g()},"handlePointerLeaveResume");return v.addEventListener("focusin",j),v.addEventListener("focusout",S),v.addEventListener("pointermove",j),v.addEventListener("pointerleave",k),window.addEventListener("blur",j),window.addEventListener("focus",g),()=>{v.removeEventListener("focusin",j),v.removeEventListener("focusout",S),v.removeEventListener("pointermove",j),v.removeEventListener("pointerleave",k),window.removeEventListener("blur",j),window.removeEventListener("focus",g)}}},[w,l.isClosePausedRef]);const b=d.useCallback(({tabbingDirection:v})=>{const j=c().map(g=>{const S=g.ref.current,k=[S,...Vb(S)];return v==="forwards"?k:k.reverse()});return(v==="forwards"?j.reverse():j).flat()},[c]);return d.useEffect(()=>{const v=p.current;if(v){const m=Dt(j=>{var k,N,C;const g=j.altKey||j.ctrlKey||j.metaKey;if(j.key==="Tab"&&!g){const A=document.activeElement,E=j.shiftKey;if(j.target===v&&E){(k=h.current)==null||k.focus();return}const B=b({tabbingDirection:E?"backwards":"forwards"}),R=B.findIndex(O=>O===A);sc(B.slice(R+1))?j.preventDefault():E?(N=h.current)==null||N.focus():(C=f.current)==null||C.focus()}},"handleKeyDown");return v.addEventListener("keydown",m),()=>v.removeEventListener("keydown",m)}},[c,b]),s.jsxs(kA,{ref:u,role:"region","aria-label":o.replace("{hotkey}",y),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&s.jsx(dv,{ref:h,onFocusFromOutsideViewport:()=>{const v=b({tabbingDirection:"forwards"});sc(v)}}),s.jsx(Ub.Slot,{scope:r,children:s.jsx(tt.ol,{tabIndex:-1,...a,ref:x})}),w&&s.jsx(dv,{ref:f,onFocusFromOutsideViewport:()=>{const v=b({tabbingDirection:"backwards"});sc(v)}})]})},"ToastViewport")),KA="ToastFocusProxy",dv=d.forwardRef(Dt(function(t,n){const{__scopeToast:r,onFocusFromOutsideViewport:i,...o}=t,a=zb(KA,r);return s.jsx(Lb,{tabIndex:0,...o,ref:n,style:{position:"fixed"},onFocus:l=>{var h;const c=l.relatedTarget;!((h=a.viewport)!=null&&h.contains(c))&&i()}})},"ToastFocusProxy")),GA="Toast",[qU,QU]=Bb(GA,{onClose(){}});function Wb(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Hb(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",o=r.dataset.radixToastAnnounceExclude==="";if(!i)if(o){const a=r.dataset.radixToastAnnounceAlt;a&&t.push(a)}else t.push(...Wb(r))}}),t}Dt(Wb,"getAnnounceTextContent");function YA(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?bu(i,o):i.dispatchEvent(o)}Dt(YA,"handleAndDispatchCustomEvent");function qA(e=()=>{}){const t=Kn(e);on(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}Dt(qA,"useNextFrame");function Hb(e){return e.nodeType===e.ELEMENT_NODE}Dt(Hb,"isHTMLElement");function Vb(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Dt(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Dt(Vb,"getTabbableCandidates");function sc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}Dt(sc,"focusFirst");var fv=UA,hv=VA,QA=Object.defineProperty,XA=(e,t)=>QA(e,"name",{value:t,configurable:!0}),JA=ao[" useId ".trim().toString()]||(()=>{}),ZA=0;function Is(e){const[t,n]=d.useState(JA());return on(()=>{e||n(r=>r??String(ZA++))},[e]),e||(t?`radix-${t}`:"")}XA(Is,"useId");const eR=["top","right","bottom","left"],gr=Math.min,Ms=Math.max,Fc=Math.round,bl=Math.floor,$s=e=>({x:e,y:e}),tR={left:"right",right:"left",bottom:"top",top:"bottom"};function Kb(e,t,n){return Ms(e,gr(t,n))}function Us(e,t){return typeof e=="function"?e(t):e}function xr(e){return e.split("-")[0]}function ho(e){return e.split("-")[1]}function hm(e){return e==="x"?"y":"x"}function pm(e){return e==="y"?"height":"width"}function as(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function mm(e){return hm(as(e))}function nR(e,t,n){n===void 0&&(n=!1);const r=ho(e),i=mm(e),o=pm(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Uc(a)),[a,Uc(a)]}function sR(e){const t=Uc(e);return[mh(e),t,mh(t)]}function mh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const pv=["left","right"],mv=["right","left"],rR=["top","bottom"],iR=["bottom","top"];function oR(e,t,n){switch(e){case"top":case"bottom":return n?t?mv:pv:t?pv:mv;case"left":case"right":return t?rR:iR;default:return[]}}function aR(e,t,n,r){const i=ho(e);let o=oR(xr(e),n==="start",r);return i&&(o=o.map(a=>a+"-"+i),t&&(o=o.concat(o.map(mh)))),o}function Uc(e){const t=xr(e);return tR[t]+e.slice(t.length)}function lR(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function Gb(e){return typeof e!="number"?lR(e):{top:e,right:e,bottom:e,left:e}}function Bc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function gv(e,t,n){let{reference:r,floating:i}=e;const o=as(t),a=mm(t),l=pm(a),c=xr(t),u=o==="y",h=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,p=r[l]/2-i[l]/2;let x;switch(c){case"top":x={x:h,y:r.y-i.height};break;case"bottom":x={x:h,y:r.y+r.height};break;case"right":x={x:r.x+r.width,y:f};break;case"left":x={x:r.x-i.width,y:f};break;default:x={x:r.x,y:r.y}}const y=ho(t);return y&&(x[a]+=p*(y==="end"?1:-1)*(n&&u?-1:1)),x}async function cR(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:x=0}=Us(t,e),y=Gb(x),b=l[p?f==="floating"?"reference":"floating":f],v=Bc(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:h,strategy:c})),m=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,j=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),g=await(o.isElement==null?void 0:o.isElement(j))&&await(o.getScale==null?void 0:o.getScale(j))||{x:1,y:1},S=Bc(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:m,offsetParent:j,strategy:c}):m);return{top:(v.top-S.top+y.top)/g.y,bottom:(S.bottom-v.bottom+y.bottom)/g.y,left:(v.left-S.left+y.left)/g.x,right:(S.right-v.right+y.right)/g.x}}const uR=50,dR=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:cR},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:f}=gv(u,r,c),p=r,x=0;const y={};for(let w=0;w<o.length;w++){const b=o[w];if(!b)continue;const{name:v,fn:m}=b,{x:j,y:g,data:S,reset:k}=await m({x:h,y:f,initialPlacement:r,placement:p,strategy:i,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});h=j??h,f=g??f,y[v]={...y[v],...S},k&&x<uR&&(x++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:h,y:f}=gv(u,p,c)),w=-1)}return{x:h,y:f,placement:p,strategy:i,middlewareData:y}},fR=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:h=0}=Us(e,t)||{};if(u==null)return{};const f=Gb(h),p={x:n,y:r},x=mm(i),y=pm(x),w=await a.getDimensions(u),b=x==="y",v=b?"top":"left",m=b?"bottom":"right",j=b?"clientHeight":"clientWidth",g=o.reference[y]+o.reference[x]-p[x]-o.floating[y],S=p[x]-o.reference[x],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let N=k?k[j]:0;(!N||!await(a.isElement==null?void 0:a.isElement(k)))&&(N=l.floating[j]||o.floating[y]);const C=g/2-S/2,A=N/2-w[y]/2-1,E=gr(f[v],A),_=gr(f[m],A),L=N-w[y]-_,B=N/2-w[y]/2+C,R=Kb(E,B,L),O=!c.arrow&&ho(i)!=null&&B!==R&&o.reference[y]/2-(B<E?E:_)-w[y]/2<0,Y=O?B<E?B-E:B-L:0;return{[x]:p[x]+Y,data:{[x]:R,centerOffset:B-R-Y,...O&&{alignmentOffset:Y}},reset:O}}}),hR=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:w=!0,...b}=Us(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const v=xr(i),m=as(l),j=xr(l)===l,g=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(j||!w?[Uc(l)]:sR(l)),k=y!=="none";!p&&k&&S.push(...aR(l,w,y,g));const N=[l,...S],C=await c.detectOverflow(t,b),A=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(h&&A.push(C[v]),f){const R=nR(i,a,g);A.push(C[R[0]],C[R[1]])}if(E=[...E,{placement:i,overflows:A}],!A.every(R=>R<=0)){var _,L;const R=(((_=o.flip)==null?void 0:_.index)||0)+1,O=N[R];if(O&&(!(f==="alignment"?m!==as(O):!1)||E.every(M=>as(M.placement)===m?M.overflows[0]>0:!0)))return{data:{index:R,overflows:E},reset:{placement:O}};let Y=(L=E.filter(G=>G.overflows[0]<=0).sort((G,M)=>G.overflows[1]-M.overflows[1])[0])==null?void 0:L.placement;if(!Y)switch(x){case"bestFit":{var B;const G=(B=E.filter(M=>{if(k){const W=as(M.placement);return W===m||W==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(W=>W>0).reduce((W,$)=>W+$,0)]).sort((M,W)=>M[1]-W[1])[0])==null?void 0:B[0];G&&(Y=G);break}case"initialPlacement":Y=l;break}if(i!==Y)return{reset:{placement:Y}}}return{}}}};function xv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function vv(e){return eR.some(t=>e[t]>=0)}const pR=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...o}=Us(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...o,elementContext:"reference"}),l=xv(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:vv(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...o,altBoundary:!0}),l=xv(a,n.floating);return{data:{escapedOffsets:l,escaped:vv(l)}}}default:return{}}}}},Yb=new Set(["left","top"]);async function mR(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=xr(n),l=ho(n),c=as(n)==="y",u=Yb.has(a)?-1:1,h=o&&c?-1:1,f=Us(t,e);let{mainAxis:p,crossAxis:x,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(x=l==="end"?y*-1:y),c?{x:x*h,y:p*u}:{x:p*u,y:x*h}}const gR=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:a,middlewareData:l}=t,c=await mR(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:a}}}}},xR=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:o}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:m=>{let{x:j,y:g}=m;return{x:j,y:g}}},...u}=Us(e,t),h={x:n,y:r},f=await o.detectOverflow(t,u),p=as(i),x=hm(p);let y=h[x],w=h[p];const b=(m,j)=>Kb(j+f[m==="y"?"top":"left"],j,j-f[m==="y"?"bottom":"right"]);a&&(y=b(x,y)),l&&(w=b(p,w));const v=c.fn({...t,[x]:y,[p]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[x]:a,[p]:l}}}}}},vR=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:o,placement:a,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:h=!0,crossAxis:f=!0}=Us(e,t),p={x:i,y:o},x=as(a),y=hm(x);let w=p[y],b=p[x];const v=Us(u,t),m=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:(n=v.mainAxis)!=null?n:0,crossAxis:(r=v.crossAxis)!=null?r:0};if(h){const S=y==="y"?"height":"width",k=l.reference[y]-l.floating[S]+m.mainAxis,N=l.reference[y]+l.reference[S]-m.mainAxis;w<k?w=k:w>N&&(w=N)}if(f){var j,g;const S=y==="y"?"width":"height",k=Yb.has(xr(a)),N=l.reference[x]-l.floating[S]+(k&&((j=c.offset)==null?void 0:j[x])||0)+(k?0:m.crossAxis),C=l.reference[x]+l.reference[S]+(k?0:((g=c.offset)==null?void 0:g[x])||0)-(k?m.crossAxis:0);b<N?b=N:b>C&&(b=C)}return{[y]:w,[x]:b}}}},yR=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:o}=t,{apply:a=()=>{},...l}=Us(e,t),c=await i.detectOverflow(t,l),u=xr(n),h=ho(n),f=as(n)==="y",{width:p,height:x}=r.floating;let y,w;u==="top"||u==="bottom"?(y=u,w=h===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(w=u,y=h==="end"?"top":"bottom");const b=x-c.top-c.bottom,v=p-c.left-c.right,m=gr(x-c[y],b),j=gr(p-c[w],v),g=t.middlewareData.shift,S=!g;let k=m,N=j;g!=null&&g.enabled.x&&(N=v),g!=null&&g.enabled.y&&(k=b),S&&!h&&(f?N=p-2*Ms(c.left,c.right):k=x-2*Ms(c.top,c.bottom)),await a({...t,availableWidth:N,availableHeight:k});const C=await i.getDimensions(o.floating);return p!==C.width||x!==C.height?{reset:{rects:!0}}:{}}}};function ku(){return typeof window<"u"}function po(e){return qb(e)?(e.nodeName||"").toLowerCase():"#document"}function an(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Hs(e){var t;return(t=(qb(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function qb(e){return ku()?e instanceof Node||e instanceof an(e).Node:!1}function hs(e){return ku()?e instanceof Element||e instanceof an(e).Element:!1}function Sr(e){return ku()?e instanceof HTMLElement||e instanceof an(e).HTMLElement:!1}function yv(e){return!ku()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof an(e).ShadowRoot}function Su(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=ps(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function jR(e){return/^(table|td|th)$/.test(po(e))}function Nu(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const wR=/transform|translate|scale|rotate|perspective|filter/,bR=/paint|layout|strict|content/,Rr=e=>!!e&&e!=="none";let Nd;function gm(e){const t=hs(e)?ps(e):e;return Rr(t.transform)||Rr(t.translate)||Rr(t.scale)||Rr(t.rotate)||Rr(t.perspective)||!xm()&&(Rr(t.backdropFilter)||Rr(t.filter))||wR.test(t.willChange||"")||bR.test(t.contain||"")}function kR(e){let t=Vr(e);for(;Sr(t)&&!ja(t);){if(gm(t))return t;if(Nu(t))return null;t=Vr(t)}return null}function xm(){return Nd==null&&(Nd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Nd}function ja(e){return/^(html|body|#document)$/.test(po(e))}function ps(e){return an(e).getComputedStyle(e)}function Cu(e){return hs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vr(e){if(po(e)==="html")return e;const t=e.assignedSlot||e.parentNode||yv(e)&&e.host||Hs(e);return yv(t)?t.host:t}function Qb(e){const t=Vr(e);return ja(t)?(e.ownerDocument||e).body:Sr(t)&&Su(t)?t:Qb(t)}function wa(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Qb(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),a=an(i);if(o){const l=gh(a);return t.concat(a,a.visualViewport||[],Su(i)?i:[],l&&n?wa(l):[])}else return t.concat(i,wa(i,[],n))}function gh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Xb(e){const t=ps(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Sr(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=Fc(n)!==o||Fc(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function vm(e){return hs(e)?e:e.contextElement}function Fi(e){const t=vm(e);if(!Sr(t))return $s(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=Xb(t);let a=(o?Fc(n.width):n.width)/r,l=(o?Fc(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const SR=$s(0);function Jb(e){const t=an(e);return!xm()||!t.visualViewport?SR:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function NR(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===an(e)}function Kr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=vm(e);let a=$s(1);t&&(r?hs(r)&&(a=Fi(r)):a=Fi(e));const l=NR(o,n,r)?Jb(o):$s(0);let c=(i.left+l.x)/a.x,u=(i.top+l.y)/a.y,h=i.width/a.x,f=i.height/a.y;if(o&&r){const p=an(o),x=hs(r)?an(r):r;let y=p,w=gh(y);for(;w&&x!==y;){const b=Fi(w),v=w.getBoundingClientRect(),m=ps(w),j=v.left+(w.clientLeft+parseFloat(m.paddingLeft))*b.x,g=v.top+(w.clientTop+parseFloat(m.paddingTop))*b.y;c*=b.x,u*=b.y,h*=b.x,f*=b.y,c+=j,u+=g,y=an(w),w=gh(y)}}return Bc({width:h,height:f,x:c,y:u})}function Eu(e,t){const n=Cu(e).scrollLeft;return t?t.left+n:Kr(Hs(e)).left+n}function Zb(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Eu(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function CR(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",a=Hs(r),l=t?Nu(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=$s(1);const h=$s(0),f=Sr(r);if((f||!o)&&((po(r)!=="body"||Su(a))&&(c=Cu(r)),f)){const x=Kr(r);u=Fi(r),h.x=x.x+r.clientLeft,h.y=x.y+r.clientTop}const p=a&&!f&&!o?Zb(a,c):$s(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+h.x+p.x,y:n.y*u.y-c.scrollTop*u.y+h.y+p.y}}function ER(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function AR(e){const t=Cu(e),n=e.ownerDocument.body,r=Ms(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Ms(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+Eu(e);const a=-t.scrollTop;return ps(n).direction==="rtl"&&(o+=Ms(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:o,y:a}}const RR=25;function TR(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=an(e),o=Hs(e),a=i.visualViewport;let l=o.clientWidth,c=o.clientHeight,u=0,h=0;if(a){const p=!xm()||t==="fixed";r?p||(u=-a.offsetLeft,h=-a.offsetTop):(l=a.width,c=a.height,p&&(u=a.offsetLeft,h=a.offsetTop))}if(Eu(o)<=0){const p=o.ownerDocument,x=p.body,y=getComputedStyle(x),w=p.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,b=Math.abs(o.clientWidth-x.clientWidth-w),v=getComputedStyle(o).scrollbarGutter==="stable both-edges"?b/2:b;v<=RR&&(l-=v)}return{width:l,height:c,x:u,y:h}}function PR(e,t){const n=Kr(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Fi(e),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=i*o.x,u=r*o.y;return{width:a,height:l,x:c,y:u}}function jv(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=TR(e,n,t);else if(t==="document")r=AR(Hs(e));else if(hs(t))r=PR(t,n);else{const i=Jb(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Bc(r)}function IR(e,t){const n=t.get(e);if(n)return n;let r=wa(e,[],!1).filter(l=>hs(l)&&po(l)!=="body"),i=null;const o=ps(e).position==="fixed";let a=o?Vr(e):e;for(;hs(a)&&!ja(a);){const l=ps(a),c=gm(a),u=i?i.position:o?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&l.position==="static")?r=r.filter(f=>f!==a):i=l,a=Vr(a)}return t.set(e,r),r}function MR(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Nu(t)?[]:IR(t,this._c):[].concat(n),r],l=jv(t,a[0],i);let c=l.top,u=l.right,h=l.bottom,f=l.left;for(let p=1;p<a.length;p++){const x=jv(t,a[p],i);c=Ms(x.top,c),u=gr(x.right,u),h=gr(x.bottom,h),f=Ms(x.left,f)}return{width:u-f,height:h-c,x:f,y:c}}function $R(e){const{width:t,height:n}=Xb(e);return{width:t,height:n}}function _R(e,t,n){const r=Sr(t),i=Hs(t),o=n==="fixed",a=Kr(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=$s(0);if((r||!o)&&((po(t)!=="body"||Su(i))&&(l=Cu(t)),r)){const p=Kr(t,!0,o,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}!r&&i&&(c.x=Eu(i));const u=i&&!r&&!o?Zb(i,l):$s(0),h=a.left+l.scrollLeft-c.x-u.x,f=a.top+l.scrollTop-c.y-u.y;return{x:h,y:f,width:a.width,height:a.height}}function Cd(e){return ps(e).position==="static"}function wv(e,t){if(!Sr(e)||ps(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Hs(e)===n&&(n=n.ownerDocument.body),n}function e0(e,t){const n=an(e);if(Nu(e))return n;if(!Sr(e)){let i=Vr(e);for(;i&&!ja(i);){if(hs(i)&&!Cd(i))return i;i=Vr(i)}return n}let r=wv(e,t);for(;r&&jR(r)&&Cd(r);)r=wv(r,t);return r&&ja(r)&&Cd(r)&&!gm(r)?n:r||kR(e)||n}const OR=async function(e){const t=this.getOffsetParent||e0,n=this.getDimensions,r=await n(e.floating);return{reference:_R(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DR(e){return ps(e).direction==="rtl"}const LR={convertOffsetParentRelativeRectToViewportRelativeRect:CR,getDocumentElement:Hs,getClippingRect:MR,getOffsetParent:e0,getElementRects:OR,getClientRects:ER,getDimensions:$R,getScale:Fi,isElement:hs,isRTL:DR};function t0(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function FR(e,t,n){let r=null,i;const o=Hs(e);function a(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function l(h,f){h===void 0&&(h=!1),f===void 0&&(f=1),a();const p=e.getBoundingClientRect(),{left:x,top:y,width:w,height:b}=p;if(h||t(),!w||!b)return;const v=bl(y),m=bl(o.clientWidth-(x+w)),j=bl(o.clientHeight-(y+b)),g=bl(x),k={rootMargin:-v+"px "+-m+"px "+-j+"px "+-g+"px",threshold:Ms(0,gr(1,f))||1};let N=!0;function C(A){const E=A[0].intersectionRatio;if(!t0(p,e.getBoundingClientRect()))return l();if(E!==f){if(!N)return l();E?l(!1,E):i=setTimeout(()=>{l(!1,1e-7)},1e3)}N=!1}try{r=new IntersectionObserver(C,{...k,root:o.ownerDocument})}catch{r=new IntersectionObserver(C,k)}r.observe(e)}const c=an(e),u=()=>l(n);return c.addEventListener("resize",u),l(!0),()=>{c.removeEventListener("resize",u),a()}}function UR(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=vm(e),h=i||o?[...u?wa(u):[],...t?wa(t):[]]:[];h.forEach(v=>{i&&v.addEventListener("scroll",n),o&&v.addEventListener("resize",n)});const f=u&&l?FR(u,n,o):null;let p=-1,x=null;a&&(x=new ResizeObserver(v=>{let[m]=v;m&&m.target===u&&x&&t&&(x.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var j;(j=x)==null||j.observe(t)})),n()}),u&&!c&&x.observe(u),t&&x.observe(t));let y,w=c?Kr(e):null;c&&b();function b(){const v=Kr(e);w&&!t0(w,v)&&n(),w=v,y=requestAnimationFrame(b)}return n(),()=>{var v;h.forEach(m=>{i&&m.removeEventListener("scroll",n),o&&m.removeEventListener("resize",n)}),f==null||f(),(v=x)==null||v.disconnect(),x=null,c&&cancelAnimationFrame(y)}}const BR=gR,zR=xR,WR=hR,HR=yR,VR=pR,bv=fR,KR=vR,GR=(e,t,n)=>{const r=new Map,i=n??{},o={...LR,...i.platform,_c:r};return dR(e,t,{...i,platform:o})};var YR=typeof document<"u",qR=function(){},rc=YR?d.useLayoutEffect:qR;function zc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!zc(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function n0(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kv(e,t){const n=n0(e);return Math.round(t*n)/n}function Ed(e){const t=d.useRef(e);return rc(()=>{t.current=e}),t}function QR(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[h,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,x]=d.useState(r);zc(p,r)||x(r);const[y,w]=d.useState(null),[b,v]=d.useState(null),m=d.useCallback(M=>{M!==k.current&&(k.current=M,w(M))},[]),j=d.useCallback(M=>{M!==N.current&&(N.current=M,v(M))},[]),g=o||y,S=a||b,k=d.useRef(null),N=d.useRef(null),C=d.useRef(h),A=c!=null,E=Ed(c),_=Ed(i),L=Ed(u),B=d.useCallback(()=>{if(!k.current||!N.current)return;const M={placement:t,strategy:n,middleware:p};_.current&&(M.platform=_.current),GR(k.current,N.current,M).then(W=>{const $={...W,isPositioned:L.current!==!1};R.current&&!zc(C.current,$)&&(C.current=$,Qi.flushSync(()=>{f($)}))})},[p,t,n,_,L]);rc(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const R=d.useRef(!1);rc(()=>(R.current=!0,()=>{R.current=!1}),[]),rc(()=>{if(g&&(k.current=g),S&&(N.current=S),g&&S){if(E.current)return E.current(g,S,B);B()}},[g,S,B,E,A]);const O=d.useMemo(()=>({reference:k,floating:N,setReference:m,setFloating:j}),[m,j]),Y=d.useMemo(()=>({reference:g,floating:S}),[g,S]),G=d.useMemo(()=>{const M={position:n,left:0,top:0};if(!Y.floating)return M;const W=kv(Y.floating,h.x),$=kv(Y.floating,h.y);return l?{...M,transform:"translate("+W+"px, "+$+"px)",...n0(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:$}},[n,l,Y.floating,h.x,h.y]);return d.useMemo(()=>({...h,update:B,refs:O,elements:Y,floatingStyles:G}),[h,B,O,Y,G])}const XR=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?bv({element:r.current,padding:i}).fn(n):{}:r?bv({element:r,padding:i}).fn(n):{}}}},JR=(e,t)=>{const n=BR(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZR=(e,t)=>{const n=zR(e);return{name:n.name,fn:n.fn,options:[e,t]}},eT=(e,t)=>({fn:KR(e).fn,options:[e,t]}),tT=(e,t)=>{const n=WR(e);return{name:n.name,fn:n.fn,options:[e,t]}},nT=(e,t)=>{const n=HR(e);return{name:n.name,fn:n.fn,options:[e,t]}},sT=(e,t)=>{const n=VR(e);return{name:n.name,fn:n.fn,options:[e,t]}},rT=(e,t)=>{const n=XR(e);return{name:n.name,fn:n.fn,options:[e,t]}};var iT=Object.defineProperty,oT=(e,t)=>iT(e,"name",{value:t,configurable:!0});function s0(e){const[t,n]=d.useState(void 0);return on(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let a,l;if("borderBoxSize"in o){const c=o.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,l=u.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}oT(s0,"useSize");var aT=Object.defineProperty,dr=(e,t)=>aT(e,"name",{value:t,configurable:!0}),r0="Popper",[i0,Au]=Yn(r0),[lT,o0]=i0(r0),cT=dr(e=>{const{__scopePopper:t,children:n}=e,[r,i]=d.useState(null),[o,a]=d.useState(void 0);return s.jsx(lT,{scope:t,anchor:r,onAnchorChange:i,placementState:o,setPlacementState:a,children:n})},"Popper"),uT="PopperAnchor",dT=d.forwardRef(dr(function(t,n){const{__scopePopper:r,virtualRef:i,...o}=t,a=o0(uT,r),l=d.useRef(null),c=a.onAnchorChange,u=d.useCallback(w=>{l.current=w,w&&c(w)},[c]),h=Ze(n,u),f=d.useRef(null);d.useEffect(()=>{if(!i)return;const w=f.current;f.current=i.current,w!==f.current&&c(f.current)});const p=a.placementState&&Ru(a.placementState),x=p==null?void 0:p[0],y=p==null?void 0:p[1];return i?null:s.jsx(tt.div,{"data-radix-popper-side":x,"data-radix-popper-align":y,...o,ref:h})},"PopperAnchor")),a0="PopperContent",[fT,XU]=i0(a0),hT=d.forwardRef(dr(function(t,n){var ze,te,se,we,be,We,fe;const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:x=!1,updatePositionStrategy:y="optimized",onPlaced:w,...b}=t,v=o0(a0,r),[m,j]=d.useState(null),g=Ze(n,j),[S,k]=d.useState(null),N=s0(S),C=(N==null?void 0:N.width)??0,A=(N==null?void 0:N.height)??0,E=i+(a!=="center"?"-"+a:""),_=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},L=Array.isArray(h)?h:[h],B=L.length>0,R={padding:_,boundary:L.filter(l0),altBoundary:B},{refs:O,floatingStyles:Y,placement:G,isPositioned:M,middlewareData:W}=QR({strategy:"fixed",placement:E,whileElementsMounted:dr((...D)=>UR(...D,{animationFrame:y==="always"}),"whileElementsMounted"),elements:{reference:v.anchor},middleware:[JR({mainAxis:o+A,alignmentAxis:l}),u&&ZR({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?eT():void 0,...R}),u&&tT({...R}),nT({...R,apply:dr(({elements:D,rects:de,availableWidth:Ke,availableHeight:nt})=>{const{width:$e,height:Sn}=de.reference,Nn=D.floating.style;Nn.setProperty("--radix-popper-available-width",`${Ke}px`),Nn.setProperty("--radix-popper-available-height",`${nt}px`),Nn.setProperty("--radix-popper-anchor-width",`${$e}px`),Nn.setProperty("--radix-popper-anchor-height",`${Sn}px`)},"apply")}),S&&rT({element:S,padding:c}),pT({arrowWidth:C,arrowHeight:A}),x&&sT({strategy:"referenceHidden",...R,boundary:B?R.boundary:void 0})]}),$=v.setPlacementState;on(()=>($(G),()=>{$(void 0)}),[G,$]);const[ee,ce]=Ru(G),Ce=Kn(w);on(()=>{M&&(Ce==null||Ce())},[M,Ce]);const J=(ze=W.arrow)==null?void 0:ze.x,ge=(te=W.arrow)==null?void 0:te.y,xe=((se=W.arrow)==null?void 0:se.centerOffset)!==0,[je,Pe]=d.useState();return on(()=>{m&&Pe(window.getComputedStyle(m).zIndex)},[m]),s.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:M?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:je,"--radix-popper-transform-origin":[(we=W.transformOrigin)==null?void 0:we.x,(be=W.transformOrigin)==null?void 0:be.y].join(" "),...((We=W.hide)==null?void 0:We.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(fT,{scope:r,placedSide:ee,placedAlign:ce,onArrowChange:k,arrowX:J,arrowY:ge,shouldHideArrow:xe,children:s.jsx(tt.div,{"data-side":ee,"data-align":ce,...b,ref:g,style:{...b.style,animation:M?(fe=b.style)==null?void 0:fe.animation:"none"}})})})},"PopperContent"));function l0(e){return e!==null}dr(l0,"isNotNull");var pT=dr(e=>({name:"transformOrigin",options:e,fn(t){var b,v,m;const{placement:n,rects:r,middlewareData:i}=t,a=((b=i.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,h]=Ru(n),f={start:"0%",center:"50%",end:"100%"}[h],p=(((v=i.arrow)==null?void 0:v.x)??0)+l/2,x=(((m=i.arrow)==null?void 0:m.y)??0)+c/2;let y="",w="";return u==="bottom"?(y=a?f:`${p}px`,w=`${-c}px`):u==="top"?(y=a?f:`${p}px`,w=`${r.floating.height+c}px`):u==="right"?(y=`${-c}px`,w=a?f:`${x}px`):u==="left"&&(y=`${r.floating.width+c}px`,w=a?f:`${x}px`),{data:{x:y,y:w}}}}),"transformOrigin");function Ru(e){const[t,n="center"]=e.split("-");return[t,n]}dr(Ru,"getSideAndAlignFromPlacement");var c0=cT,u0=dT,d0=hT,mT=Object.defineProperty,kt=(e,t)=>mT(e,"name",{value:t,configurable:!0}),[ym,JU]=Yn("Tooltip",[Au]),jm=Au(),gT="TooltipProvider",xT=700,xh="tooltip.open",[vT,wm]=ym(gT),yT=kt(e=>{const{__scopeTooltip:t,delayDuration:n=xT,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,a=d.useRef(!0),l=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(vT,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),a.current=!1)},[r]),onClose:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r))},[r]),isPointerInTransitRef:l,onPointerInTransitChange:d.useCallback(u=>{l.current=u},[]),disableHoverableContent:i,children:o})},"TooltipProvider"),vh="Tooltip",[jT,Ua]=ym(vh),wT=kt(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:a,delayDuration:l}=e,c=wm(vh,e.__scopeTooltip),u=jm(t),[h,f]=d.useState(null),[p,x]=d.useState(void 0),y=Is(),w=d.useRef(0),b=a??c.disableHoverableContent,v=l??c.delayDuration,m=d.useRef(!1),[j,g]=fo({prop:r,defaultProp:i??!1,onChange:kt(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(xh))):c.onClose(),o==null||o(E)},"onChange"),caller:vh}),S=d.useMemo(()=>j?m.current?"delayed-open":"instant-open":"closed",[j]),k=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,m.current=!1,g(!0)},[g]),N=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,g(!1)},[g]),C=d.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{m.current=!0,g(!0),w.current=0},v)},[v,g]);d.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const A=p??y;return s.jsx(c0,{...u,children:s.jsx(jT,{scope:t,contentId:A,setContentId:x,open:j,stateAttribute:S,trigger:h,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?C():k()},[c.isOpenDelayedRef,C,k]),onTriggerLeave:d.useCallback(()=>{b?N():(window.clearTimeout(w.current),w.current=0)},[N,b]),onOpen:k,onClose:N,disableHoverableContent:b,children:n})})},"Tooltip"),Sv="TooltipTrigger",bT=d.forwardRef(kt(function(t,n){const{__scopeTooltip:r,...i}=t,o=Ua(Sv,r),a=wm(Sv,r),l=jm(r),c=d.useRef(null),u=Ze(n,c,o.onTriggerChange),h=d.useRef(!1),f=d.useRef(!1),p=d.useCallback(()=>h.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),s.jsx(u0,{asChild:!0,...l,children:s.jsx(tt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:u,onPointerMove:Se(t.onPointerMove,x=>{x.pointerType!=="touch"&&!f.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:Se(t.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:Se(t.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:Se(t.onFocus,()=>{h.current||o.onOpen()}),onBlur:Se(t.onBlur,o.onClose),onClick:Se(t.onClick,o.onClose)})})},"TooltipTrigger")),f0="TooltipPortal",[kT,ST]=ym(f0,{forceMount:void 0}),NT=kt(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,o=Ua(f0,t);return s.jsx(kT,{scope:t,forceMount:n,children:s.jsx(kr,{present:n||o.open,children:s.jsx(fm,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),ba="TooltipContent",CT=d.forwardRef(kt(function(t,n){const r=ST(ba,t.__scopeTooltip),{forceMount:i=r.forceMount,side:o="top",...a}=t,l=Ua(ba,t.__scopeTooltip);return s.jsx(kr,{present:i||l.open,children:l.disableHoverableContent?s.jsx(h0,{side:o,...a,ref:n}):s.jsx(ET,{side:o,...a,ref:n})})},"TooltipContent")),ET=d.forwardRef(kt(function(t,n){const r=Ua(ba,t.__scopeTooltip),i=wm(ba,t.__scopeTooltip),o=d.useRef(null),a=Ze(n,o),[l,c]=d.useState(null),{trigger:u,onClose:h}=r,f=o.current,{onPointerInTransitChange:p}=i,x=d.useCallback(()=>{c(null),p(!1)},[p]),y=d.useCallback((w,b)=>{const v=w.currentTarget,m={x:w.clientX,y:w.clientY},j=p0(m,v.getBoundingClientRect()),g=m0(m,j),S=g0(b.getBoundingClientRect()),k=v0([...g,...S]);c(k),p(!0)},[p]);return d.useEffect(()=>()=>x(),[x]),d.useEffect(()=>{if(u&&f){const w=kt(v=>y(v,f),"handleTriggerLeave"),b=kt(v=>y(v,u),"handleContentLeave");return u.addEventListener("pointerleave",w),f.addEventListener("pointerleave",b),()=>{u.removeEventListener("pointerleave",w),f.removeEventListener("pointerleave",b)}}},[u,f,y,x]),d.useEffect(()=>{if(l){const w=kt(b=>{const v=b.target,m={x:b.clientX,y:b.clientY},j=(u==null?void 0:u.contains(v))||(f==null?void 0:f.contains(v)),g=!x0(m,l);j?x():g&&(x(),h())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,f,l,h,x]),s.jsx(h0,{...t,ref:a})},"TooltipContentHoverable")),AT=yb("TooltipContent"),h0=d.forwardRef(kt(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":o,id:a,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=t,h=Ua(ba,r),f=jm(r),{onClose:p}=h;d.useEffect(()=>(document.addEventListener(xh,p),()=>document.removeEventListener(xh,p)),[p]),d.useEffect(()=>{if(h.trigger){const y=kt(w=>{w.target instanceof Node&&w.target.contains(h.trigger)&&p()},"handleScroll");return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[h.trigger,p]);const{setContentId:x}=h;return on(()=>(x(a),()=>{x(void 0)}),[a,x]),s.jsx(um,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:s.jsxs(d0,{"data-state":h.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:h.contentId,...f,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(AT,{children:i}),o?s.jsx(_A,{id:h.contentId,role:"tooltip",children:o}):null]})})},"TooltipContentImpl"));function p0(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}kt(p0,"getExitSideFromRect");function m0(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}kt(m0,"getPaddedExitPoints");function g0(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}kt(g0,"getPointsFromRect");function x0(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){const l=t[o],c=t[a],u=l.x,h=l.y,f=c.x,p=c.y;h>r!=p>r&&n<(f-u)*(r-h)/(p-h)+u&&(i=!i)}return i}kt(x0,"isPointInPolygon");function v0(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),y0(t)}kt(v0,"getHull");function y0(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const o=t[t.length-1],a=t[t.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const o=n[n.length-1],a=n[n.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}kt(y0,"getHullPresorted");var Nv=yT,Wc=wT,Hc=bT,Vc=NT,Kc=CT;const Cv="buddi_csrf",mo="x-buddi-csrf",ka="buddi:agents-changed",RT="This page's sign-in no longer matches its cookies. Reload the page and try again.";class oe extends Error{constructor(t,n,r){super(n),this.status=t,this.detail=r,this.name="ApiError"}}function ei(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${Cv}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const n=[...document.cookie.matchAll(new RegExp(`(?:^|; )${Cv}(?:_\\d+)?=([^;]*)`,"g"))];return n.length===1&&((r=n[0])!=null&&r[1])?decodeURIComponent(n[0][1]):""}async function ti(e,t={}){const n=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}});if(n.status===401)throw new oe(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await n.text(),i=r===""?null:TT(r);if(!n.ok){const o=i&&typeof i=="object"&&"error"in i?String(i.error):void 0,a=(t.method??"GET").toUpperCase(),l=o??(n.status===403&&a!=="GET"&&a!=="HEAD"?RT:`request failed (${n.status})`);throw new oe(n.status,l,i)}return i}function TT(e){try{return JSON.parse(e)}catch{return null}}function ue(e,t={}){const n=new URLSearchParams;for(const[i,o]of Object.entries(t))o!==void 0&&o!==""&&n.set(i,String(o));const r=n.toString();return ti(`/api${e}${r?`?${r}`:""}`)}function j0(e,t){return ti(`/api${e}`,{method:"POST",headers:{[mo]:ei()},body:t})}function Jo(e){return ti(`/api${e}`,{method:"DELETE",headers:{[mo]:ei()}})}function Z(e,t={}){return ti(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[mo]:ei()},body:JSON.stringify(t??{})})}function w0(e,t,n,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||n;return ti(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[mo]:ei(),"X-Filename":i,...r},body:t})}function Ev(e,t,n){return w0(e,t,"backup.tar.gz",{...n.passphrase?{"X-Backup-Passphrase":n.passphrase}:{},...n.confirm?{"X-Backup-Confirm":n.confirm}:{}})}function PT(e,t={}){return ti(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[mo]:ei()},body:JSON.stringify(t??{})})}function Mo(e,t={}){return ti(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[mo]:ei()},body:JSON.stringify(t??{})})}function IT(e){if(e.dismissedAt)return"You said no to this one.";switch(e.lapseReason){case"owner-moved-on":return"The conversation moved on.";case"rolled-over":return"That conversation ended.";case"agent-removed":return"That agent is no longer here.";default:return"It lapsed."}}const ic="gpt-oss:120b",MT=["approval","question","watcher","reminder","failure","recap","plugin"],_e={agents:()=>ue("/chat/agents"),views:()=>ue("/chat/views"),conversations:(e,t)=>ue(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>Z(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>ue(`/chat/conversations/${encodeURIComponent(e)}`),send:(e,t)=>Z(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>Z(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>Z(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),j0("/chat/attachments",t)},transcribe:e=>Z("/speech/transcribe",e),say:e=>Z("/speech/say",e),discardAttachment:e=>Jo(`/artifacts/${encodeURIComponent(e)}`),groups:()=>ue("/groups"),group:e=>ue(`/groups/${encodeURIComponent(e)}`),createGroup:e=>Z("/groups",e),updateGroup:(e,t)=>PT(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>Jo(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>ue(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>Z(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>Z(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`},T={providers:()=>ue("/providers"),providerAccounts:()=>ue("/provider-accounts"),probeModels:e=>Z("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>Z(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>Z("/provider-accounts/save",e),testProviderAccount:e=>Z(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,n)=>Z(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:n}),ollamaConnect:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/connect`,{revision:t}),ollamaPoll:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/poll`,{attemptId:t}),ollamaDisconnect:(e,t)=>Z(`/provider-accounts/${encodeURIComponent(e)}/ollama/disconnect`,{revision:t}),anthropicAccountAction:(e,t,n,r)=>Z(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:n,...r}),assignProviderAccount:(e,t,n)=>Z(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:n}),configureProvider:(e,t)=>Z(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>Z(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>Z(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>Z(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>ue("/host/browser-profiles",{app:e}),installedApps:()=>ue("/host/apps"),browser:e=>ue(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>Z(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>Z("/browser/settings",e),computerPermissions:(e=!1)=>Z("/browser/permissions",{prompt:e}),browserInstall:()=>Z("/browser/install",{}),browserCheck:()=>Z("/browser/check",{}),previewLink:(e,t)=>ue(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>ue(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>ue("/extension"),pairExtension:e=>Z("/extension/pair",{code:e}),forgetExtension:()=>Jo("/extension/pair"),session:()=>ue("/session"),overview:()=>ue("/overview"),events:e=>ue("/events",e),eventKinds:()=>ue("/events/kinds"),conversations:()=>ue("/conversations"),conversation:e=>ue(`/conversations/${encodeURIComponent(e)}`),missions:()=>ue("/missions"),jobs:(e={})=>ue("/jobs",e),approvals:()=>ue("/approvals"),approval:e=>ue(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>ue("/offers"),dismissOffer:e=>Z(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>Z("/offers/dismiss-all",{ids:e}),agentOffers:()=>ue("/agent-offers"),dismissAgentOffer:(e,t)=>Z(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>ue("/proposals"),setDigestSchedule:(e,t)=>Z("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>Z(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),discardProposal:(e,t)=>Z(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>ue("/reminders"),sentinels:()=>ue("/sentinels"),setSentinelEnabled:(e,t)=>Z(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),snoozeAlert:(e,t)=>Z(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>ue("/agents"),library:e=>ue("/artifacts",e),libraryEntry:(e,t=0)=>ue(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>ue("/onboarding"),onboardingStep:(e,t={})=>Z("/onboarding/step",{step:e,...t}),completeOnboarding:()=>Z("/onboarding/complete"),skipOnboarding:()=>Z("/onboarding/skip"),createFirstAgent:e=>Z("/onboarding/agent",e),ollama:()=>ue("/onboarding/ollama"),firstAgentPersona:()=>ue("/onboarding/agent"),updateFirstAgent:e=>Z("/onboarding/agent/update",e),bindBrain:e=>Z("/onboarding/brain",e),pages:()=>ue("/pages"),pageQuery:(e,t,n={})=>ue(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n),pageFileUrl:(e,t,n={})=>{const r=new URLSearchParams(Object.entries(n).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>Z(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>ue("/telegram"),saveTelegramToken:e=>Z("/telegram/token",{token:e}),telegramPairing:()=>Z("/telegram/pairing"),telegramBot:()=>ue("/telegram/bot"),telegramDevices:()=>ue("/telegram/devices"),unpairTelegramDevice:e=>Jo(`/telegram/devices/${encodeURIComponent(e)}`),notifications:(e=20)=>ue("/notifications",{limit:e}),notificationSeen:e=>Z(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>ue("/notifications/settings"),saveNotificationSettings:e=>Mo("/notifications/settings",e),testChannel:e=>Z("/notifications/test",{channel:e}),presence:e=>Z("/presence",{state:e}),owner:()=>ue("/owner"),setOwner:e=>Z("/owner",e),memory:e=>ue(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>Z("/memory/preferences",e),forgetPreference:e=>Z("/memory/preferences/forget",e),updateNote:(e,t)=>Z(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>Z(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>ue(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>ue(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>ue("/host",{agentId:e,conversationId:t}),secrets:()=>ue("/secrets"),secretUses:(e,t)=>ue("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>Z("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>Z("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>Z("/host/revoke",{id:e}),decide:(e,t,n,r)=>Z(`/approvals/${encodeURIComponent(e)}/${t}`,n||r?{...n?{permissionScope:n}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>Z("/pause",{paused:e}),service:()=>ue("/service"),serviceAction:e=>Z(`/service/${e}`),version:()=>ue("/version"),checkVersion:()=>Z("/version/check"),setVersionCheck:e=>Mo("/version/check",{enabled:e}),tailscale:()=>ue("/tailscale"),setTailscale:e=>Mo("/tailscale",e),startUpgrade:e=>Z("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>ue(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>ue("/backups"),startBackup:e=>Z("/backups",{encrypt:e}),verifyArchive:e=>Z("/backups/verify",{name:e}),restoreArchive:e=>Z("/backups/restore",e),restoreUpload:(e,t)=>Ev("/backups/restore",e,t),backupJob:e=>ue(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>ue("/backups/schedule"),setBackupSchedule:e=>Mo("/backups/schedule",e),backupPassphrase:()=>ue("/backups/passphrase"),setBackupPassphrase:e=>Mo("/backups/passphrase",{passphrase:e}),plugins:()=>ue("/plugins"),stagePlugin:e=>Z("/plugins/stage",{spec:e}),uploadPlugin:e=>w0("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>ue(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>Z(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>Z(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),uninstallPlugin:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>Z(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>ue("/recovery"),leaveRecovery:e=>Z("/recovery/leave",e),firstRunRestore:(e,t)=>Ev("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>Z(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,n)=>Z(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...n===void 0?{}:{deadlineMinutes:n}}),retryJob:e=>Z(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>Z(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>Z("/agents/default",{agentId:e}),agentTools:e=>ue(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>ue(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const n=new FormData;return n.append("file",t,t.name),j0(`/agents/${encodeURIComponent(e)}/avatar`,n)},removeAgentPicture:e=>Jo(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>Z(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>Z(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>Z(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};function b0(e){return e==="anthropic"||e==="openai"}function k0(e,t){var i,o;if(!e)return null;const n=e.credentialEnv&&(t!=null&&t.accounts.some(a=>a.id===e.credentialEnv))?e.credentialEnv:(o=(i=t==null?void 0:t.bindings)==null?void 0:i.find(a=>a.agentId===e.id))==null?void 0:o.accountId,r=n?t==null?void 0:t.accounts.find(a=>a.id===n):void 0;return(r==null?void 0:r.kind)??e.provider}const $T="Thinking is up to this model. What it writes while thinking is shown apart and kept out of the answer.";var _T=Object.defineProperty,OT=(e,t)=>_T(e,"name",{value:t,configurable:!0}),DT=d.createContext(void 0);function Tu(e){const t=d.useContext(DT);return e||t||"ltr"}OT(Tu,"useDirection");var LT=Object.defineProperty,bm=(e,t)=>LT(e,"name",{value:t,configurable:!0}),kl=0,ns=null;function FT(e){return Pu(),e.children}bm(FT,"FocusGuards");function Pu(){d.useEffect(()=>{ns||(ns={start:yh(),end:yh()});const{start:e,end:t}=ns;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),kl++,()=>{kl===1&&(ns==null||ns.start.remove(),ns==null||ns.end.remove(),ns=null),kl=Math.max(0,kl-1)}},[])}bm(Pu,"useFocusGuards");function yh(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}bm(yh,"createFocusGuard");var UT=Object.defineProperty,Ht=(e,t)=>UT(e,"name",{value:t,configurable:!0}),Ad="focusScope.autoFocusOnMount",Rd="focusScope.autoFocusOnUnmount",Av={bubbles:!1,cancelable:!0},S0=d.forwardRef(Ht(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=t,[c,u]=d.useState(null),h=Kn(o),f=Kn(a),p=d.useRef(null),x=Ze(n,u),y=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let b=function(g){if(y.paused||!c)return;const S=g.target;c.contains(S)?p.current=S:Cs(p.current,{select:!0})},v=function(g){if(y.paused||!c)return;const S=g.relatedTarget;S!==null&&(c.contains(S)||Cs(p.current,{select:!0}))},m=function(g){if(document.activeElement===document.body)for(const k of g)k.removedNodes.length>0&&Cs(c)};Ht(b,"handleFocusIn"),Ht(v,"handleFocusOut"),Ht(m,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",v);const j=new MutationObserver(m);return c&&j.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",v),j.disconnect()}}},[i,c,y.paused]),d.useEffect(()=>{if(c){Rv.add(y);const b=document.activeElement;if(!c.contains(b)){const m=new CustomEvent(Ad,Av);c.addEventListener(Ad,h),c.dispatchEvent(m),m.defaultPrevented||(N0(T0(km(c)),{select:!0}),document.activeElement===b&&Cs(c))}return()=>{c.removeEventListener(Ad,h),setTimeout(()=>{const m=new CustomEvent(Rd,Av);c.addEventListener(Rd,f),c.dispatchEvent(m),m.defaultPrevented||Cs(b??document.body,{select:!0}),c.removeEventListener(Rd,f),Rv.remove(y)},0)}}},[c,h,f,y]);const w=d.useCallback(b=>{if(!r&&!i||y.paused)return;const v=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,m=document.activeElement;if(v&&m){const j=b.currentTarget,[g,S]=C0(j);g&&S?!b.shiftKey&&m===S?(b.preventDefault(),r&&Cs(g,{select:!0})):b.shiftKey&&m===g&&(b.preventDefault(),r&&Cs(S,{select:!0})):m===j&&b.preventDefault()}},[r,i,y.paused]);return s.jsx(tt.div,{tabIndex:-1,...l,ref:x,onKeyDown:w})},"FocusScope"));function N0(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Cs(r,{select:t}),document.activeElement!==n)return}Ht(N0,"focusFirst");function C0(e){const t=km(e),n=jh(t,e),r=jh(t.reverse(),e);return[n,r]}Ht(C0,"getTabbableEdges");function km(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Ht(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Ht(km,"getTabbableCandidates");function jh(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):E0(r,{upTo:t})))return r}Ht(jh,"findVisible");function E0(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}Ht(E0,"isHidden");function A0(e){return e instanceof HTMLInputElement&&"select"in e}Ht(A0,"isSelectableInput");function Cs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&A0(e)&&t&&e.select()}}Ht(Cs,"focus");var Rv=R0();function R0(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=wh(e,t),e.unshift(t)},remove(t){var n;e=wh(e,t),(n=e[0])==null||n.resume()}}}Ht(R0,"createFocusScopesStack");function wh(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Ht(wh,"arrayRemove");function T0(e){return e.filter(t=>t.tagName!=="A")}Ht(T0,"removeLinks");var BT=Object.defineProperty,Sm=(e,t)=>BT(e,"name",{value:t,configurable:!0}),Td=!1;function P0(){const[e,t]=d.useState(Td);return d.useEffect(()=>{Td||(Td=!0,t(!0))},[]),e}Sm(P0,"useIsHydrated");var I0=ao[" useSyncExternalStore ".trim().toString()];function M0(){return()=>{}}Sm(M0,"subscribe");function $0(){return I0(M0,()=>!0,()=>!1)}Sm($0,"useIsHydratedModern");var zT=typeof I0=="function"?$0:P0,WT=Object.defineProperty,ni=(e,t)=>WT(e,"name",{value:t,configurable:!0}),Pd="rovingFocusGroup.onEntryFocus",HT={bubbles:!1,cancelable:!0},Iu="RovingFocusGroup",[bh,_0,VT]=wu(Iu),[KT,Mu]=Yn(Iu,[VT]),[GT,YT]=KT(Iu),qT=d.forwardRef(ni(function(t,n){return s.jsx(bh.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(bh.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(QT,{...t,ref:n})})})},"RovingFocusGroup")),QT=d.forwardRef(ni(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:o=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...p}=t,x=d.useRef(null),y=Ze(n,x),w=Tu(a),[b,v]=fo({prop:l,defaultProp:c??null,onChange:u,caller:Iu}),[m,j]=d.useState(!1),g=Kn(h),S=_0(r),k=d.useRef(!1),[N,C]=d.useState(0);return d.useEffect(()=>{const A=x.current;if(A)return A.addEventListener(Pd,g),()=>A.removeEventListener(Pd,g)},[g]),s.jsx(GT,{scope:r,orientation:i,dir:w,loop:o,currentTabStopId:b,onItemFocus:d.useCallback(A=>v(A),[v]),onItemShiftTab:d.useCallback(()=>j(!0),[]),onFocusableItemAdd:d.useCallback(()=>C(A=>A+1),[]),onFocusableItemRemove:d.useCallback(()=>C(A=>A-1),[]),children:s.jsx(tt.div,{tabIndex:m||N===0?-1:0,"data-orientation":i,...p,ref:y,style:{outline:"none",...t.style},onMouseDown:Se(t.onMouseDown,()=>{k.current=!0}),onFocus:Se(t.onFocus,A=>{const E=!k.current;if(A.target===A.currentTarget&&E&&!m){const _=new CustomEvent(Pd,HT);if(A.currentTarget.dispatchEvent(_),!_.defaultPrevented){const L=S().filter(G=>G.focusable),B=L.find(G=>G.active),R=L.find(G=>G.id===b),Y=[B,R,...L].filter(Boolean).map(G=>G.ref.current);Nm(Y,f)}}k.current=!1}),onBlur:Se(t.onBlur,()=>j(!1))})})},"RovingFocusGroupImpl")),XT="RovingFocusGroupItem",JT=d.forwardRef(ni(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:o=!1,tabStopId:a,children:l,...c}=t,u=Is(),h=a||u,f=YT(XT,r),p=f.currentTabStopId===h,x=_0(r),{onFocusableItemAdd:y,onFocusableItemRemove:w,currentTabStopId:b}=f,v=zT();return on(()=>{if(!(!v||!i))return y(),()=>w()},[v,i,y,w]),d.useEffect(()=>{if(!(v||!i))return y(),()=>w()},[v,i,y,w]),s.jsx(bh.ItemSlot,{scope:r,id:h,focusable:i,active:o,children:s.jsx(tt.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:Se(t.onMouseDown,m=>{i?f.onItemFocus(h):m.preventDefault()}),onFocus:Se(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:Se(t.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){f.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const j=D0(m,f.orientation,f.dir);if(j!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let S=x().filter(k=>k.focusable).map(k=>k.ref.current);if(j==="last")S.reverse();else if(j==="prev"||j==="next"){j==="prev"&&S.reverse();const k=S.indexOf(m.currentTarget);S=f.loop?L0(S,k+1):S.slice(k+1)}setTimeout(()=>Nm(S))}}),children:typeof l=="function"?l({isCurrentTabStop:p,hasTabStop:b!=null}):l})})},"RovingFocusGroupItem")),ZT={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function O0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}ni(O0,"getDirectionAwareKey");function D0(e,t,n){const r=O0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ZT[r]}ni(D0,"getFocusIntent");function Nm(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}ni(Nm,"focusFirst");function L0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}ni(L0,"wrapArray");var F0=qT,U0=JT,e2=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},pi=new WeakMap,Sl=new WeakMap,Nl={},Id=0,B0=function(e){return e&&(e.host||B0(e.parentNode))},t2=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=B0(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},n2=function(e,t,n,r){var i=t2(t,Array.isArray(e)?e:[e]);Nl[n]||(Nl[n]=new WeakMap);var o=Nl[n],a=[],l=new Set,c=new Set(i),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};i.forEach(u);var h=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(l.has(p))h(p);else try{var x=p.getAttribute(r),y=x!==null&&x!=="false",w=(pi.get(p)||0)+1,b=(o.get(p)||0)+1;pi.set(p,w),o.set(p,b),a.push(p),w===1&&y&&Sl.set(p,!0),b===1&&p.setAttribute(n,"true"),y||p.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",p,v)}})};return h(t),l.clear(),Id++,function(){a.forEach(function(f){var p=pi.get(f)-1,x=o.get(f)-1;pi.set(f,p),o.set(f,x),p||(Sl.has(f)||f.removeAttribute(r),Sl.delete(f)),x||f.removeAttribute(n)}),Id--,Id||(pi=new WeakMap,pi=new WeakMap,Sl=new WeakMap,Nl={})}},z0=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=e2(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),n2(r,i,n,"aria-hidden")):function(){return null}},os=function(){return os=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},os.apply(this,arguments)};function W0(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function s2(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var oc="right-scroll-bar-position",ac="width-before-scroll-bar",r2="with-scroll-bars-hidden",i2="--removed-body-scroll-bar-size";function Md(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function o2(e,t){var n=d.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var a2=typeof window<"u"?d.useLayoutEffect:d.useEffect,Tv=new WeakMap;function l2(e,t){var n=o2(null,function(r){return e.forEach(function(i){return Md(i,r)})});return a2(function(){var r=Tv.get(n);if(r){var i=new Set(r),o=new Set(e),a=n.current;i.forEach(function(l){o.has(l)||Md(l,null)}),o.forEach(function(l){i.has(l)||Md(l,a)})}Tv.set(n,e)},[e]),n}function c2(e){return e}function u2(e,t){t===void 0&&(t=c2);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var a=t(o,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(o){for(r=!0;n.length;){var a=n;n=[],a.forEach(o)}n={push:function(l){return o(l)},filter:function(){return n}}},assignMedium:function(o){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(o),a=n}var c=function(){var h=a;a=[],h.forEach(o)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(h){a.push(h),u()},filter:function(h){return a=a.filter(h),n}}}};return i}function d2(e){e===void 0&&(e={});var t=u2(null);return t.options=os({async:!0,ssr:!1},e),t}var H0=function(e){var t=e.sideCar,n=W0(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,os({},n))};H0.isSideCarExport=!0;function f2(e,t){return e.useMedium(t),H0}var V0=d2(),$d=function(){},$u=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:$d,onWheelCapture:$d,onTouchMoveCapture:$d}),i=r[0],o=r[1],a=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,h=e.enabled,f=e.shards,p=e.sideCar,x=e.noRelative,y=e.noIsolation,w=e.inert,b=e.allowPinchZoom,v=e.as,m=v===void 0?"div":v,j=e.gapMode,g=W0(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=p,k=l2([n,t]),N=os(os({},g),i);return d.createElement(d.Fragment,null,h&&d.createElement(S,{sideCar:V0,removeScrollBar:u,shards:f,noRelative:x,noIsolation:y,inert:w,setCallbacks:o,allowPinchZoom:!!b,lockRef:n,gapMode:j}),a?d.cloneElement(d.Children.only(l),os(os({},N),{ref:k})):d.createElement(m,os({},N,{className:c,ref:k}),l))});$u.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};$u.classNames={fullWidth:ac,zeroRight:oc};var h2=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function p2(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=h2();return t&&e.setAttribute("nonce",t),e}function m2(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function g2(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var x2=function(){var e=0,t=null;return{add:function(n){e==0&&(t=p2())&&(m2(t,n),g2(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},v2=function(){var e=x2();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},K0=function(){var e=v2(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},y2={left:0,top:0,right:0,gap:0},_d=function(e){return parseInt(e||"",10)||0},j2=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[_d(n),_d(r),_d(i)]},w2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return y2;var t=j2(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},b2=K0(),Ui="data-scroll-locked",k2=function(e,t,n,r){var i=e.left,o=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
41
|
-
.`.concat(r2,` {
|
|
42
|
-
overflow: hidden `).concat(r,`;
|
|
43
|
-
padding-right: `).concat(l,"px ").concat(r,`;
|
|
44
|
-
}
|
|
45
|
-
body[`).concat(Ui,`] {
|
|
46
|
-
overflow: hidden `).concat(r,`;
|
|
47
|
-
overscroll-behavior: contain;
|
|
48
|
-
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
49
|
-
padding-left: `.concat(i,`px;
|
|
50
|
-
padding-top: `).concat(o,`px;
|
|
51
|
-
padding-right: `).concat(a,`px;
|
|
52
|
-
margin-left:0;
|
|
53
|
-
margin-top:0;
|
|
54
|
-
margin-right: `).concat(l,"px ").concat(r,`;
|
|
55
|
-
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.`).concat(oc,` {
|
|
59
|
-
right: `).concat(l,"px ").concat(r,`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.`).concat(ac,` {
|
|
63
|
-
margin-right: `).concat(l,"px ").concat(r,`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.`).concat(oc," .").concat(oc,` {
|
|
67
|
-
right: 0 `).concat(r,`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.`).concat(ac," .").concat(ac,` {
|
|
71
|
-
margin-right: 0 `).concat(r,`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
body[`).concat(Ui,`] {
|
|
75
|
-
`).concat(i2,": ").concat(l,`px;
|
|
76
|
-
}
|
|
77
|
-
`)},Pv=function(){var e=parseInt(document.body.getAttribute(Ui)||"0",10);return isFinite(e)?e:0},S2=function(){d.useEffect(function(){return document.body.setAttribute(Ui,(Pv()+1).toString()),function(){var e=Pv()-1;e<=0?document.body.removeAttribute(Ui):document.body.setAttribute(Ui,e.toString())}},[])},N2=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;S2();var o=d.useMemo(function(){return w2(i)},[i]);return d.createElement(b2,{styles:k2(o,!t,i,n?"":"!important")})},kh=!1;if(typeof window<"u")try{var Cl=Object.defineProperty({},"passive",{get:function(){return kh=!0,!0}});window.addEventListener("test",Cl,Cl),window.removeEventListener("test",Cl,Cl)}catch{kh=!1}var mi=kh?{passive:!1}:!1,C2=function(e){return e.tagName==="TEXTAREA"},G0=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!C2(e)&&n[t]==="visible")},E2=function(e){return G0(e,"overflowY")},A2=function(e){return G0(e,"overflowX")},Iv=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=Y0(e,r);if(i){var o=q0(e,r),a=o[1],l=o[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},R2=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},T2=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Y0=function(e,t){return e==="v"?E2(t):A2(t)},q0=function(e,t){return e==="v"?R2(t):T2(t)},P2=function(e,t){return e==="h"&&t==="rtl"?-1:1},I2=function(e,t,n,r,i){var o=P2(e,window.getComputedStyle(t).direction),a=o*r,l=n.target,c=t.contains(l),u=!1,h=a>0,f=0,p=0;do{if(!l)break;var x=q0(e,l),y=x[0],w=x[1],b=x[2],v=w-b-o*y;(y||v)&&Y0(e,l)&&(f+=v,p+=y);var m=l.parentNode;l=m&&m.nodeType===Node.DOCUMENT_FRAGMENT_NODE?m.host:m}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(h&&Math.abs(f)<1||!h&&Math.abs(p)<1)&&(u=!0),u},El=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Mv=function(e){return[e.deltaX,e.deltaY]},$v=function(e){return e&&"current"in e?e.current:e},M2=function(e,t){return e[0]===t[0]&&e[1]===t[1]},$2=function(e){return`
|
|
78
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
79
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
80
|
-
`)},_2=0,gi=[];function O2(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),i=d.useState(_2++)[0],o=d.useState(K0)[0],a=d.useRef(e);d.useEffect(function(){a.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var w=s2([e.lockRef.current],(e.shards||[]).map($v),!0).filter(Boolean);return w.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=d.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!a.current.allowPinchZoom;var v=El(w),m=n.current,j="deltaX"in w?w.deltaX:m[0]-v[0],g="deltaY"in w?w.deltaY:m[1]-v[1],S,k=w.target,N=Math.abs(j)>Math.abs(g)?"h":"v";if("touches"in w&&N==="h"&&k.type==="range")return!1;var C=window.getSelection(),A=C&&C.anchorNode,E=A?A===k||A.contains(k):!1;if(E)return!1;var _=Iv(N,k);if(!_)return!0;if(_?S=N:(S=N==="v"?"h":"v",_=Iv(N,k)),!_)return!1;if(!r.current&&"changedTouches"in w&&(j||g)&&(r.current=S),!S)return!0;var L=r.current||S;return I2(L,b,w,L==="h"?j:g)},[]),c=d.useCallback(function(w){var b=w;if(!(!gi.length||gi[gi.length-1]!==o)){var v="deltaY"in b?Mv(b):El(b),m=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&M2(S.delta,v)})[0];if(m&&m.should){b.cancelable&&b.preventDefault();return}if(!m){var j=(a.current.shards||[]).map($v).filter(Boolean).filter(function(S){return S.contains(b.target)}),g=j.length>0?l(b,j[0]):!a.current.noIsolation;g&&b.cancelable&&b.preventDefault()}}},[]),u=d.useCallback(function(w,b,v,m){var j={name:w,delta:b,target:v,should:m,shadowParent:D2(v)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(g){return g!==j})},1)},[]),h=d.useCallback(function(w){n.current=El(w),r.current=void 0},[]),f=d.useCallback(function(w){u(w.type,Mv(w),w.target,l(w,e.lockRef.current))},[]),p=d.useCallback(function(w){u(w.type,El(w),w.target,l(w,e.lockRef.current))},[]);d.useEffect(function(){return gi.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,mi),document.addEventListener("touchmove",c,mi),document.addEventListener("touchstart",h,mi),function(){gi=gi.filter(function(w){return w!==o}),document.removeEventListener("wheel",c,mi),document.removeEventListener("touchmove",c,mi),document.removeEventListener("touchstart",h,mi)}},[]);var x=e.removeScrollBar,y=e.inert;return d.createElement(d.Fragment,null,y?d.createElement(o,{styles:$2(i)}):null,x?d.createElement(N2,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function D2(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const L2=f2(V0,O2);var Cm=d.forwardRef(function(e,t){return d.createElement($u,os({},e,{ref:t,sideCar:L2}))});Cm.classNames=$u.classNames;var F2=Object.defineProperty,Fe=(e,t)=>F2(e,"name",{value:t,configurable:!0}),U2=["Enter"," "],B2=["ArrowDown","PageUp","Home"],Q0=["ArrowUp","PageDown","End"],z2=[...B2,...Q0],_u="Menu",[Sh,W2,H2]=wu(_u),[si,X0]=Yn(_u,[H2,Au,Mu]),Em=Au(),J0=Mu(),[V2,Ba]=si(_u),[K2,Am]=si(_u),G2=Fe(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:a=!0}=e,l=Em(t),[c,u]=d.useState(null),h=d.useRef(!1),f=Kn(o),p=Tu(i);return d.useEffect(()=>{const x=Fe(()=>{h.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},"handleKeyDown"),y=Fe(()=>h.current=!1,"handlePointer");return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),d.useEffect(()=>{if(!n)return;const x=Fe(()=>f(!1),"handleBlur");return window.addEventListener("blur",x),()=>window.removeEventListener("blur",x)},[n,f]),s.jsx(c0,{...l,children:s.jsx(V2,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:s.jsx(K2,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:p,modal:a,children:r})})})},"Menu"),Y2=d.forwardRef(Fe(function(t,n){const{__scopeMenu:r,...i}=t,o=Em(r);return s.jsx(u0,{...o,...i,ref:n})},"MenuAnchor")),Z0="MenuPortal",[q2,Q2]=si(Z0,{forceMount:void 0}),X2=Fe(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=Ba(Z0,t);return s.jsx(q2,{scope:t,forceMount:n,children:s.jsx(kr,{present:n||o.open,children:s.jsx(fm,{asChild:!0,container:i,children:r})})})},"MenuPortal"),fr="MenuContent",[J2,ek]=si(fr),Z2=d.forwardRef(Fe(function(t,n){const r=Q2(fr,t.__scopeMenu),{forceMount:i=r.forceMount,...o}=t,a=Ba(fr,t.__scopeMenu),l=Am(fr,t.__scopeMenu);return s.jsx(Sh.Provider,{scope:t.__scopeMenu,children:s.jsx(kr,{present:i||a.open,children:s.jsx(Sh.Slot,{scope:t.__scopeMenu,children:l.modal?s.jsx(eP,{...o,ref:n}):s.jsx(tP,{...o,ref:n})})})})},"MenuContent")),eP=d.forwardRef(Fe(function(t,n){const r=Ba(fr,t.__scopeMenu),i=d.useRef(null),o=Ze(n,i);return d.useEffect(()=>{const a=i.current;if(a)return z0(a)},[]),s.jsx(tk,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Se(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),tP=d.forwardRef(Fe(function(t,n){const r=Ba(fr,t.__scopeMenu);return s.jsx(tk,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),nP=mr("MenuContent.ScrollLock"),tk=d.forwardRef(Fe(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:x,onDismiss:y,disableOutsideScroll:w,...b}=t,v=Ba(fr,r),m=Am(fr,r),j=Em(r),g=J0(r),S=W2(r),[k,N]=d.useState(null),C=d.useRef(null),A=Ze(n,C,v.onContentChange),E=d.useRef(0),_=d.useRef(""),L=d.useRef(0),B=d.useRef(null),R=d.useRef("right"),O=d.useRef(0),Y=w?Cm:d.Fragment,G=w?{as:nP,allowPinchZoom:!0}:void 0,M=Fe($=>{var Pe,ze;const ee=_.current+$,ce=S().filter(te=>!te.disabled),Ce=document.activeElement,J=(Pe=ce.find(te=>te.ref.current===Ce))==null?void 0:Pe.textValue,ge=ce.map(te=>te.textValue),xe=ck(ge,ee,J),je=(ze=ce.find(te=>te.textValue===xe))==null?void 0:ze.ref.current;Fe(function te(se){_.current=se,window.clearTimeout(E.current),se!==""&&(E.current=window.setTimeout(()=>te(""),1e3))},"updateSearch")(ee),je&&setTimeout(()=>je.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(E.current),[]),Pu();const W=d.useCallback($=>{var ce,Ce;return R.current===((ce=B.current)==null?void 0:ce.side)&&dk($,(Ce=B.current)==null?void 0:Ce.area)},[]);return s.jsx(J2,{scope:r,searchRef:_,onItemEnter:d.useCallback($=>{W($)&&$.preventDefault()},[W]),onItemLeave:d.useCallback($=>{var ee;W($)||((ee=C.current)==null||ee.focus(),N(null))},[W]),onTriggerLeave:d.useCallback($=>{W($)&&$.preventDefault()},[W]),pointerGraceTimerRef:L,onPointerGraceIntentChange:d.useCallback($=>{B.current=$},[]),children:s.jsx(Y,{...G,children:s.jsx(S0,{asChild:!0,trapped:o,onMountAutoFocus:Se(a,$=>{var ee;$.preventDefault(),(ee=C.current)==null||ee.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:s.jsx(um,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:x,onDismiss:y,children:s.jsx(F0,{asChild:!0,...g,dir:m.dir,orientation:"vertical",loop:i,currentTabStopId:k,onCurrentTabStopIdChange:N,onEntryFocus:Se(u,$=>{m.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(d0,{role:"menu","aria-orientation":"vertical","data-state":rk(v.open),"data-radix-menu-content":"",dir:m.dir,...j,...b,ref:A,style:{outline:"none",...b.style},onKeyDown:Se(b.onKeyDown,$=>{const ce=$.target.closest("[data-radix-menu-content]")===$.currentTarget,Ce=$.ctrlKey||$.altKey||$.metaKey,J=$.key.length===1;ce&&($.key==="Tab"&&$.preventDefault(),!Ce&&J&&M($.key));const ge=C.current;if($.target!==ge||!z2.includes($.key))return;$.preventDefault();const je=S().filter(Pe=>!Pe.disabled).map(Pe=>Pe.ref.current);Q0.includes($.key)&&je.reverse(),ak(je)}),onBlur:Se(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(E.current),_.current="")}),onPointerMove:Se(t.onPointerMove,Gc($=>{const ee=$.target,ce=O.current!==$.clientX;if($.currentTarget.contains(ee)&&ce){const Ce=$.clientX>O.current?"right":"left";R.current=Ce,O.current=$.clientX}}))})})})})})})},"MenuContentImpl")),nk=d.forwardRef(Fe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(tt.div,{role:"group",...i,ref:n})},"MenuGroup")),sP=d.forwardRef(Fe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(tt.div,{...i,ref:n})},"MenuLabel")),Nh="MenuItem",_v="menu.itemSelect",sk=d.forwardRef(Fe(function(t,n){const{disabled:r=!1,onSelect:i,...o}=t,a=d.useRef(null),l=Am(Nh,t.__scopeMenu),c=ek(Nh,t.__scopeMenu),u=Ze(n,a),h=d.useRef(!1),f=Fe(()=>{const p=a.current;if(!r&&p){const x=new CustomEvent(_v,{bubbles:!0,cancelable:!0});p.addEventListener(_v,y=>i==null?void 0:i(y),{once:!0}),bu(p,x),x.defaultPrevented?h.current=!1:l.onClose()}},"handleSelect");return s.jsx(rP,{...o,ref:u,disabled:r,onClick:Se(t.onClick,f),onPointerDown:p=>{var x;(x=t.onPointerDown)==null||x.call(t,p),h.current=!0},onPointerUp:Se(t.onPointerUp,p=>{var x;h.current||(x=p.currentTarget)==null||x.click()}),onKeyDown:Se(t.onKeyDown,p=>{r||p.target!==p.currentTarget||c.searchRef.current!==""&&p.key===" "||U2.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),rP=d.forwardRef(Fe(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:o,...a}=t,l=ek(Nh,r),c=J0(r),u=d.useRef(null),h=Ze(n,u),[f,p]=d.useState(!1),[x,y]=d.useState("");return d.useEffect(()=>{const w=u.current;w&&y((w.textContent??"").trim())},[a.children]),s.jsx(Sh.ItemSlot,{scope:r,disabled:i,textValue:o??x,children:s.jsx(U0,{asChild:!0,...c,focusable:!i,children:s.jsx(tt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...a,ref:h,onPointerMove:Se(t.onPointerMove,Gc(w=>{i?l.onItemLeave(w):(l.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Se(t.onPointerLeave,Gc(w=>l.onItemLeave(w))),onFocus:Se(t.onFocus,()=>p(!0)),onBlur:Se(t.onBlur,()=>p(!1))})})})},"MenuItemImpl")),iP="MenuRadioGroup",[oP,aP]=si(iP,{value:void 0,onValueChange:Fe(()=>{},"onValueChange")}),lP=d.forwardRef(Fe(function(t,n){const{value:r,onValueChange:i,...o}=t,a=Kn(i);return s.jsx(oP,{scope:t.__scopeMenu,value:r,onValueChange:a,children:s.jsx(nk,{...o,ref:n})})},"MenuRadioGroup")),cP="MenuRadioItem",uP=d.forwardRef(Fe(function(t,n){const{value:r,...i}=t,o=aP(cP,t.__scopeMenu),a=r===o.value;return s.jsx(fP,{scope:t.__scopeMenu,checked:a,children:s.jsx(sk,{role:"menuitemradio","aria-checked":a,...i,ref:n,"data-state":ok(a),onSelect:Se(i.onSelect,()=>{var l;return(l=o.onValueChange)==null?void 0:l.call(o,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),dP="MenuItemIndicator",[fP,ZU]=si(dP,{checked:!1}),hP=d.forwardRef(Fe(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(tt.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),pP="MenuSub",[eB,tB]=si(pP);function rk(e){return e?"open":"closed"}Fe(rk,"getOpenState");function ik(e){return e==="indeterminate"}Fe(ik,"isIndeterminate");function ok(e){return ik(e)?"indeterminate":e?"checked":"unchecked"}Fe(ok,"getCheckedState");function ak(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Fe(ak,"focusFirst");function lk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Fe(lk,"wrapArray");function ck(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let a=lk(e,Math.max(o,0));i.length===1&&(a=a.filter(u=>u!==n));const c=a.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}Fe(ck,"getNextMatch");function uk(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){const l=t[o],c=t[a],u=l.x,h=l.y,f=c.x,p=c.y;h>r!=p>r&&n<(f-u)*(r-h)/(p-h)+u&&(i=!i)}return i}Fe(uk,"isPointInPolygon");function dk(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return uk(n,t)}Fe(dk,"isPointerInGraceArea");function Gc(e){return t=>t.pointerType==="mouse"?e(t):void 0}Fe(Gc,"whenMouse");var mP=G2,gP=Y2,xP=X2,vP=Z2,yP=nk,jP=sP,wP=sk,bP=lP,kP=uP,SP=hP,NP=Object.defineProperty,gs=(e,t)=>NP(e,"name",{value:t,configurable:!0}),Rm="DropdownMenu",[CP,nB]=Yn(Rm,[X0]),xs=X0(),[EP,fk]=CP(Rm),AP=gs(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=xs(t),u=d.useRef(null),[h,f]=fo({prop:i,defaultProp:o??!1,onChange:a,caller:Rm});return s.jsx(EP,{scope:t,triggerId:Is(),triggerRef:u,contentId:Is(),open:h,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(p=>!p),[f]),modal:l,children:s.jsx(mP,{...c,open:h,onOpenChange:f,dir:r,modal:l,children:n})})},"DropdownMenu"),RP="DropdownMenuTrigger",TP=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...o}=t,a=fk(RP,r),l=xs(r),c=Ze(n,a.triggerRef);return s.jsx(gP,{asChild:!0,...l,children:s.jsx(tt.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...o,ref:c,onPointerDown:Se(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(a.onOpenToggle(),a.open||u.preventDefault())}),onKeyDown:Se(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&a.onOpenToggle(),u.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),PP=gs(e=>{const{__scopeDropdownMenu:t,...n}=e,r=xs(t);return s.jsx(xP,{...r,...n})},"DropdownMenuPortal"),IP="DropdownMenuContent",MP=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=fk(IP,r),a=xs(r),l=d.useRef(!1);return s.jsx(vP,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...i,ref:n,onCloseAutoFocus:Se(t.onCloseAutoFocus,c=>{var u;l.current||(u=o.triggerRef.current)==null||u.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:Se(t.onInteractOutside,c=>{const u=c.detail.originalEvent,h=u.button===0&&u.ctrlKey===!0,f=u.button===2||h;(!o.modal||f)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),$P=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=xs(r);return s.jsx(yP,{...o,...i,ref:n})},"DropdownMenuGroup")),_P=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=xs(r);return s.jsx(jP,{...o,...i,ref:n})},"DropdownMenuLabel")),OP=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=xs(r);return s.jsx(wP,{...o,...i,ref:n})},"DropdownMenuItem")),DP=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=xs(r);return s.jsx(bP,{...o,...i,ref:n})},"DropdownMenuRadioGroup")),LP=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=xs(r);return s.jsx(kP,{...o,...i,ref:n})},"DropdownMenuRadioItem")),FP=d.forwardRef(gs(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=xs(r);return s.jsx(SP,{...o,...i,ref:n})},"DropdownMenuSeparator")),Tm=AP,Pm=TP,Im=PP,Mm=MP,UP=$P,$m=_P,Ch=OP,BP=DP,zP=LP,lc=FP,WP=Object.defineProperty,go=(e,t)=>WP(e,"name",{value:t,configurable:!0}),_m="Tabs",[HP,sB]=Yn(_m,[Mu]),hk=Mu(),[VP,Om]=HP(_m),KP=d.forwardRef(go(function(t,n){const{__scopeTabs:r,value:i,onValueChange:o,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Tu(c),[p,x]=fo({prop:i,onChange:o,defaultProp:a??"",caller:_m});return s.jsx(VP,{scope:r,baseId:Is(),value:p,onValueChange:x,orientation:l,dir:f,activationMode:u,children:s.jsx(tt.div,{dir:f,"data-orientation":l,...h,ref:n})})},"Tabs")),GP="TabsList",YP=d.forwardRef(go(function(t,n){const{__scopeTabs:r,loop:i=!0,...o}=t,a=Om(GP,r),l=hk(r);return s.jsx(F0,{asChild:!0,...l,orientation:a.orientation,dir:a.dir,loop:i,children:s.jsx(tt.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:n})})},"TabsList")),qP="TabsTrigger",QP=d.forwardRef(go(function(t,n){const{__scopeTabs:r,value:i,disabled:o=!1,...a}=t,l=Om(qP,r),c=hk(r),u=Dm(l.baseId,i),h=Lm(l.baseId,i),f=i===l.value;return s.jsx(U0,{asChild:!0,...c,focusable:!o,active:f,children:s.jsx(tt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...a,ref:n,onMouseDown:Se(t.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?l.onValueChange(i):p.preventDefault()}),onKeyDown:Se(t.onKeyDown,p=>{o||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&l.onValueChange(i)}),onFocus:Se(t.onFocus,()=>{const p=l.activationMode!=="manual";!f&&!o&&p&&l.onValueChange(i)})})})},"TabsTrigger")),XP="TabsContent",JP=d.forwardRef(go(function(t,n){const{__scopeTabs:r,value:i,forceMount:o,children:a,...l}=t,c=Om(XP,r),u=Dm(c.baseId,i),h=Lm(c.baseId,i),f=i===c.value,p=d.useRef(f);return d.useEffect(()=>{const x=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(kr,{present:o||f,children:({present:x})=>s.jsx(tt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:h,tabIndex:0,...l,ref:n,style:{...t.style,animationDuration:p.current?"0s":void 0},children:x&&a})})},"TabsContent"));function Dm(e,t){return`${e}-trigger-${t}`}go(Dm,"makeTriggerId");function Lm(e,t){return`${e}-content-${t}`}go(Lm,"makeContentId");var ZP=KP,eI=YP,tI=QP,nI=JP;function De(e,t){if(!e)return"—";const n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function Ee(e,t=Date.now()){if(!e)return"";const n=new Date(e).getTime();if(Number.isNaN(n))return"";const r=Math.round((n-t)/1e3),i=Math.abs(r),[o,a]=i<60?[r,"second"]:i<3600?[Math.round(r/60),"minute"]:i<86400?[Math.round(r/3600),"hour"]:[Math.round(r/86400),"day"];return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(o,a)}function sI(e,t){if(e==null||!Number.isFinite(e))return"—";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:0}).format(e)}catch{return e.toFixed(2)}}function vt(e){return new Intl.NumberFormat("en-US").format(e)}function Eh(e){return[...e.cacheRead?[`cached ${vt(e.cacheRead)}`]:[],...e.cacheWrite?[`cache write ${vt(e.cacheWrite)}`]:[]].join(", ")}function rI(e){const t=Eh(e);return`${vt(e.input)} in${t?` (${t})`:""} / ${vt(e.output)} out`}function ln(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function Sa(e,t=8){return e.length<=t?e:e.slice(0,t)}function ms(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Xi(e){return e.replace(/<<<[^<>]*>>>/g,"")}function Nt(e,t,n){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?iI(r,n):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${Dv(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?vt(r):Dv(r):String(e)}case"date":return oI(String(e));default:return typeof e=="string"?e:typeof e=="number"?vt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function iI(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return sI(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function oI(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short",year:"numeric"}).format(n)}function Ov(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short"}).format(n)}function Dv(e){return String(Math.round(e*100)/100)}function aI(e,t,n=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,n),i=10**Math.floor(Math.log10(r)),o=[1,2,2.5,5,10].map(l=>l*i).find(l=>l>=r)??i*10,a=[];for(let l=Math.ceil(e/o)*o;l<=t+o/1e3;l+=o)a.push(Math.round(l*1e6)/1e6);return a.filter(l=>l>=e&&l<=t)}function lI({props:e}){if(e.bars.length===0)return s.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(o=>o.value),n=Math.max(0,...t),r=Math.min(0,...t),i=n-r||1;return s.jsx("div",{className:"wb-bars",children:e.bars.map(o=>{const a=Math.abs(o.value)/i;return s.jsxs("div",{className:"wb-bar-row",children:[s.jsx("div",{className:"wb-bar-cat",title:o.category,children:o.category}),s.jsx("div",{className:"wb-bar-track",children:s.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,a*100)}%`,background:o.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),s.jsx("div",{className:"wb-bar-val",children:Nt(o.value,e.unit,e.currency)})]},o.category)})})}const cI=/^(diff --git |index [0-9a-f]|--- (a\/|\/dev\/null)|\+\+\+ (b\/|\/dev\/null)|new file mode|deleted file mode|similarity index|rename (from|to) |old mode|new mode|Binary files )/,uI=/^(… |\.\.\. |\(no change\)$|\)/;function dI(e){return e.replace(/\n$/,"").split(`
|
|
81
|
-
`).map(n=>({kind:fI(n),text:n}))}function fI(e){return e.startsWith("@@")?"hunk":cI.test(e)||uI.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function hI({text:e,marks:t}){const n=e.toLowerCase(),r=[];for(const a of t){const l=a.trim().toLowerCase();if(l!=="")for(let c=n.indexOf(l);c!==-1;c=n.indexOf(l,c+l.length))r.push([c,c+l.length])}if(r.length===0)return s.jsx(s.Fragment,{children:e===""?" ":e});r.sort((a,l)=>a[0]-l[0]);const i=[];let o=0;for(const[a,l]of r)a<o||(a>o&&i.push(s.jsx("span",{children:e.slice(o,a)},`t${o}`)),i.push(s.jsx("mark",{className:"wb-diff-mark",children:e.slice(a,l)},`m${a}`)),o=l);return o<e.length&&i.push(s.jsx("span",{children:e.slice(o)},`t${o}`)),s.jsx(s.Fragment,{children:i})}function Yc({text:e,limit:t,more:n,label:r="Diff",marks:i}){const o=dI(e),a=t===void 0?o:o.slice(0,t),l=o.length-a.length;return s.jsxs("div",{className:"wb-diff-wrap",children:[s.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:a.map((c,u)=>s.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?s.jsx(hI,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),l>0?s.jsxs("p",{className:"wb-diff-more",children:[l," more line",l===1?"":"s",n?s.jsxs(s.Fragment,{children:[" · ",s.jsx("button",{type:"button",className:"wb-diff-open",onClick:n.onClick,children:n.label})]}):null]}):null]})}function pI({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:Nt(t.value,t.unit,null)})]},t.label))}):null,e.diff?s.jsx(Yc,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):s.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const Ft="#/",Ji="#/chat",it="#/agents",rt="#/activity",Zt="#/settings",Gr="#/files",mI="#/welcome";function Od(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function Al(e,t={}){const n=new URLSearchParams;t.q&&n.set("q",t.q),t.origin&&n.set("origin",t.origin),t.family&&n.set("family",t.family);const r=n.toString();return`${Gr}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function gI(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[2]??""),r={};return n.get("q")&&(r.q=n.get("q")),n.get("origin")&&(r.origin=n.get("origin")),n.get("family")&&(r.family=n.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function Ue(e,t,n){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function xI(e){if(pk(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...n?{tab:n}:{}}}catch{return null}}function Zo(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function pk(e){const t=/^#\/chat\/g\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{groupId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{}}}catch{return null}}function xt(e,t,n){return`${it}/${encodeURIComponent(e)}${t?`/${t}${n?`/${n}`:""}`:""}`}function vI(e){const t=/^#\/agents\/([^/]+)(?:\/([a-z-]+)(?:\/([a-z-]+))?)?$/.exec(e);if(!t)return null;try{return{agentId:decodeURIComponent(t[1]),...t[2]?{tab:t[2]}:{},...t[3]?{section:t[3]}:{}}}catch{return null}}function Zi(e){return`${rt}/conversations/${encodeURIComponent(e)}`}const yI="#/p";function Na(e,t,n){const r=`${yI}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return n?`${r}/${encodeURIComponent(n)}`:r}function Fm(e){const t=/^#\/p\/([^/?]+)\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{plugin:decodeURIComponent(t[1]),page:decodeURIComponent(t[2]),...t[3]?{item:decodeURIComponent(t[3])}:{}}}catch{return null}}const jI="p.";function Um(e,t){return`${Zt}/${encodeURIComponent(mk(e,t))}`}function wI(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const n=decodeURIComponent(t[1]);return{plugin:n,page:t[2]?decodeURIComponent(t[2]):n}}function mk(e,t){return`${jI}${e}${t===e?"":`.${t}`}`}function lt(e){return e?`${Zt}/${e}`:Zt}function bI(e){return`${lt("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function kI(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}const SI=[{route:Ft,label:"Home"},{route:Ji,label:"Chat"},{route:it,label:"Agents"},{route:rt,label:"Activity"},{route:Gr,label:"Files"},{route:Zt,label:"Settings"}],NI=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],CI=[{id:"you",label:"Profile",group:"you"},{id:"appearance",label:"Appearance",group:"you"},{id:"notifications",label:"Notifications",group:"you"},{id:"memory",label:"Memory",group:"you"},{id:"proposals",label:"Proposals",group:"you"},{id:"accounts",label:"Model accounts",group:"access"},{id:"computer",label:"Computer & browser",group:"access"},{id:"secrets",label:"Keys and secrets",group:"access"},{id:"watchers",label:"Watchers",group:"running"},{id:"backup",label:"Backup",group:"running"},{id:"system",label:"System",group:"running"},{id:"plugins",label:"All plugins",group:"plugins"}];function EI(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const Lv=lt("backup");function AI(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return Zi(decodeURIComponent(t[1]));const n=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(n)try{return Na("email","mail",n[1]?decodeURIComponent(n[1]):null)}catch{return Na("email","mail")}return e==="#/settings/email"?Um("email","settings"):{"#/overview":Ft,"#/approvals":Ft,"#/events":`${rt}/events`,"#/jobs":`${rt}/jobs`,"#/conversations":rt,"#/missions":`${it}?tab=missions`,"#/offers":`${it}?tab=offers`,"#/reminders":`${it}?tab=reminders`,"#/providers":lt("accounts"),"#/browser":lt("computer"),"#/sentinels":lt("watchers"),"#/settings/sentinels":lt("watchers")}[e]??null}function RI(e){if(e===""||e==="#"||e===Ft)return Ft;if(e.startsWith(Ji))return Ji;if(e.startsWith(it))return it;if(e.startsWith(rt))return rt;if(e.startsWith(Gr))return Gr;if(e.startsWith(Zt))return Zt;const t=Fm(e);return t?Na(t.plugin,t.page):Ft}const Bm="front-desk",zm=[{id:Bm,label:"Front desk",meaning:"Where things go when you do not say who."},{id:"overview",label:"Overview",meaning:"Answers /status and speaks for the watchers."},{id:"recap",label:"Recap",meaning:"Runs /recap."},{id:"maker",label:"Maker",meaning:"/new opens its interview."}],gk=new Set(zm.map(e=>e.id)),Fv=e=>gk.has(e);function Uv(e,t){const n=t.filter(r=>!gk.has(r));return[...zm.filter(r=>e.has(r.id)).map(r=>r.id),...n.filter((r,i)=>n.indexOf(r)===i)]}function TI(e,t){return e.find(n=>(n.roles??[]).includes(t))}const Bv=["coding","finance","mail","research","calendar","files","memory"],PI={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[Bm]:"buddi"},II=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function MI(e){const t=new Set(e.map(n=>n.split(".")[0]??n));for(const[n,r]of II)if(r.some(i=>t.has(i)))return n;return t.size>0&&[...t].every(n=>n==="memory")?"memory":null}let Ah=null;function $I(e){Ah=e}function za(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const n of e.roles??[]){const r=PI[n];if(r)return{key:r}}const t=MI(e.tools??[]);return t?{key:t}:Ah!==null&&e.id===Ah?{key:"buddi"}:{key:Bv[_I(e.id)%Bv.length]??"coding"}}function Wa(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function _I(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t}const OI=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function DI(e){const n=e.replace(/\r\n/g,`
|
|
82
|
-
`).split(`
|
|
83
|
-
|
|
84
|
-
`),r=n.pop()??"",i=[];for(const o of n){let a=null,l="message";const c=[];for(const u of o.split(`
|
|
85
|
-
`)){if(u===""||u.startsWith(":"))continue;const h=u.indexOf(":"),f=h===-1?u:u.slice(0,h),p=h===-1?"":u.slice(h+1).replace(/^ /,"");f==="id"?a=p:f==="event"?l=p:f==="data"&&c.push(p)}c.length===0&&l==="message"||i.push({id:a,name:OI.includes(l)?l:"ping",data:LI(c.join(`
|
|
86
|
-
`))})}return{events:i,rest:r}}function LI(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function xk(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),n=e.wait??(c=>new Promise(u=>setTimeout(u,c))),r=e.retryMs??1500;let i=e.lastEventId??null,o=!1,a=null;return(async()=>{var c,u,h,f;for(;!o;){(c=e.onStatus)==null||c.call(e,"connecting"),a=new AbortController;try{const p=await t(e.url,{credentials:"same-origin",signal:a.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!p.ok||!p.body)throw new Error(`stream ${p.status}`);(u=e.onStatus)==null||u.call(e,"open");const x=p.body.getReader(),y=new TextDecoder;let w="";for(;;){const{done:b,value:v}=await x.read();if(b)break;w+=y.decode(v,{stream:!0});const{events:m,rest:j}=DI(w);w=j;for(const g of m)e.onEvent(g),g.id!==null&&(i=g.id);if(o)break}}catch{}if(o)break;(h=e.onStatus)==null||h.call(e,"closed"),await n(r)}(f=e.onStatus)==null||f.call(e,"closed")})(),{close:()=>{o=!0,a==null||a.abort()},lastEventId:()=>i}}const FI="/api/chat/attention/stream";function vk(e,t){const n=(o,a)=>o.name.localeCompare(a.name),r=o=>e.filter(a=>a.anchor===o).sort(n),i=e.filter(o=>o.anchor!=="top"&&o.anchor!=="bottom").sort((o,a)=>o.id===t?a.id===t?0:-1:a.id===t?1:n(o,a));return{top:r("top"),middle:i,bottom:r("bottom")}}function yk(e,t){const n=vk(e,t);return[...n.top,...n.middle,...n.bottom]}function Ou(e){if(!e)return null;const t=[];return e.approvals>0&&t.push(e.approvals===1?"one approval is waiting for you":`${e.approvals} approvals are waiting for you`),e.question&&t.push("asked you a question and is holding for the answer"),t.length===0?null:t.join(", and ")}function UI(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function BI(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function zI(){const[e,t]=d.useState(null);return d.useEffect(()=>{let n=!1;const r=()=>{ue("/chat/attention").then(o=>{n||t(o)}).catch(()=>{})};r();const i=xk({url:FI,onEvent:()=>r()});return()=>{n=!0,i.close()}},[]),BI(e)}const Wm="maker";function jk(e){return e.filter(t=>t.available&&!t.roles.includes(Wm))}function wk(e){return jk(e).length>=2}function WI(e){var t;return((t=e.find(n=>n.roles.includes(Wm)))==null?void 0:t.name)??"the agent maker"}const HI="{{default}}";function VI(e,t){return e.split(HI).join(t??"your assistant")}function KI(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(n=>VI(n,t))}function GI(e){var n,r;const t=(n=e==null?void 0:e.intro)==null?void 0:n.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function YI(e){const t=(e??"·").trim().split(/\s+/).filter(Boolean);return t.length===0?"·":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function bk(e){var r,i;const t=(r=e.heldBack)==null?void 0:r.message.trim();if(t!==void 0&&t!=="")return`${e.name??"This agent"} is held back. ${t}`;const n=(i=e.unavailableReason)==null?void 0:i.trim();return n&&n!==""?`${e.name??"This agent"} cannot run: ${n}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const qI="Settings → Model accounts",QI="Install it in Settings → Plugins";function Rh(e){return e!=null&&e.heldBack?{section:"plugins",label:QI}:{section:"accounts",label:qI}}const XI={home:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),s.jsx("path",{d:"M5.2 8.4v7.4a1 1 0 0 0 1 1h2.6v-4.6h2.4v4.6h2.6a1 1 0 0 0 1-1V8.4"})]})],chat:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 10.6a4.9 4.9 0 0 1-4.9 4.9H7.8L3.6 18l.9-3A4.9 4.9 0 0 1 3 11V8.2A4.9 4.9 0 0 1 7.9 3.3h4.2A4.9 4.9 0 0 1 17 8.2Z"}),s.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),s.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),s.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),s.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,s.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[24,1.9,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),20],files:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 2.8h5.2L16.5 6.6v8.6a1.2 1.2 0 0 1-1.2 1.2H7.5a1.2 1.2 0 0 1-1.2-1.2V4a1.2 1.2 0 0 1 1.2-1.2z"}),s.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),s.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),s.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),s.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),s.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,s.jsx("path",{d:"M3.2 16.4V8.6M8.4 16.4V3.9M13.6 16.4v-5.8M3.2 16.4h13.6"})],bell:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),s.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),s.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),s.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),s.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),s.jsx("path",{d:"M2.9 10h14.2M10 2.9c3.4 3.7 3.4 10.5 0 14.2-3.4-3.7-3.4-10.5 0-14.2Z"})]})],person:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),s.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],sun:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),s.jsx("path",{d:"M10 2.6v1.6M10 15.8v1.6M2.6 10h1.6M15.8 10h1.6M4.8 4.8l1.1 1.1M14.1 14.1l1.1 1.1M4.8 15.2l1.1-1.1M14.1 5.9l1.1-1.1"})]})],notebook:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.5 3.2h8.3a1 1 0 0 1 1 1v11.6a1 1 0 0 1-1 1H5.5a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1Z"}),s.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),s.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),s.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],eye:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.4 10S5.2 4.8 10 4.8 17.6 10 17.6 10 14.8 15.2 10 15.2 2.4 10 2.4 10Z"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),s.jsx("path",{d:"M4 7.2v8a1.2 1.2 0 0 0 1.2 1.2h9.6a1.2 1.2 0 0 0 1.2-1.2v-8M8.2 10.4h3.6"})]})],chip:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),s.jsx("path",{d:"M8 2.8v2.6M12 2.8v2.6M8 14.6v2.6M12 14.6v2.6M2.8 8h2.6M2.8 12h2.6M14.6 8h2.6M14.6 12h2.6"})]})],camera:[17,1.5,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.6 6.2a1.4 1.4 0 0 1 1.4-1.4h2l1.1-1.6h2.8l1.1 1.6h2a1.4 1.4 0 0 1 1.4 1.4v6.4a1.4 1.4 0 0 1-1.4 1.4H4a1.4 1.4 0 0 1-1.4-1.4z"}),s.jsx("circle",{cx:"8.5",cy:"9.2",r:"2.4"})]})],clip:[17,1.5,s.jsx("path",{d:"M13.2 8 8.4 12.8a3 3 0 0 1-4.2-4.2l5.1-5.1a2 2 0 1 1 2.8 2.8l-5 5"})],mic:[17,1.5,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"6.3",y:"2.4",width:"4.4",height:"7.6",rx:"2.2"}),s.jsx("path",{d:"M3.9 8.4a4.6 4.6 0 0 0 9.2 0M8.5 13v2"})]})],speaker:[17,1.5,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.8 6.6h2.4l3.4-2.8v9.4l-3.4-2.8H2.8z"}),s.jsx("path",{d:"M11.2 6.2a3.2 3.2 0 0 1 0 4.6M13.2 4.4a5.8 5.8 0 0 1 0 8.2"})]})],send:[16,1.8,s.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],check:[16,1.8,s.jsx("path",{d:"M3.5 8.4 6.6 11.4 12.5 4.8"})],close:[16,1.8,s.jsx("path",{d:"M4.5 4.5l7 7M11.5 4.5l-7 7"})],thought:[13,1.4,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),s.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,s.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],copy:[16,1.5,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"5.6",y:"5.6",width:"7.6",height:"7.6",rx:"1.4"}),s.jsx("path",{d:"M10.4 5.6V4a1.2 1.2 0 0 0-1.2-1.2H4A1.2 1.2 0 0 0 2.8 4v5.2A1.2 1.2 0 0 0 4 10.4h1.6"})]})],play:[16,1.5,s.jsx("path",{d:"M5.2 3.4v9.2L12.6 8z"})],pause:[16,1.5,s.jsx("path",{d:"M5.6 3.6v8.8M10.4 3.6v8.8"})],stop:[16,1.5,s.jsx("rect",{x:"4.2",y:"4.2",width:"7.6",height:"7.6",rx:"1.2"})],download:[16,1.5,s.jsx("path",{d:"M8 2.8v7.2M4.9 7 8 10.1 11.1 7M3 12.8h10"})],out:[12,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),s.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,s.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,s.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,s.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],"chevron-down":[14,1.4,s.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),s.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),s.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,s.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,s.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,s.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,s.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-document":[16,1.4,s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,s.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 11l3.6-3.4 2.6 2.4 2-1.8 3.4 3M10.6 6.2h.01"})],"shape-preview":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 6h11.6M4.1 4.7h.01M6 4.7h.01"})],"shape-envelope":[16,1.4,s.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],"shape-structured":[16,1.4,s.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function Ae({name:e,size:t,className:n,...r}){const[i,o,a,l]=XI[e],c=t??l??i;return s.jsx("svg",{className:n,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:a})}const kk="buddi.rosterCollapsed";function JI(){try{return window.localStorage.getItem(kk)==="1"}catch{return!1}}function ZI(e){try{window.localStorage.setItem(kk,e?"1":"0")}catch{}}function Sk({agents:e,currentId:t,attention:n,onSelect:r,orientation:i="vertical",lastActivity:o,groups:a=[],currentGroupId:l=null,onSelectGroup:c,onNewGroup:u}){const h=[...e.top,...e.middle,...e.bottom],f=i==="vertical"?"right":"bottom",[p,x]=d.useState(JI),y=w=>s.jsx(eM,{agent:w,active:w.id===t,attention:n.get(w.id),side:f,onSelect:r,lastAt:(o==null?void 0:o.get(w.id))??null},w.id);return s.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&p?"true":void 0,children:[e.top.map(y),e.top.length>0&&e.middle.length>0?s.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!p&&e.middle.length>0?s.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,s.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(y),c&&wk(h)?s.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[s.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),s.jsxs("div",{className:"wb-groups-head",children:[s.jsx("span",{className:"wb-groups-label",children:"Groups"}),u?s.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"New group",title:"A team of agents in one conversation",onClick:u,children:s.jsx(Ae,{name:"plus"})}):null]}),a.map(w=>s.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":w.id===l?"true":void 0,"aria-current":w.id===l?"true":void 0,"aria-label":`${w.name}, ${w.members.length} agents`,onClick:()=>c(w.id),children:[s.jsxs("span",{className:"wb-face-mark wb-group-stack","aria-hidden":"true",children:[w.members.slice(0,3).map(b=>{const v=h.find(m=>m.id===b);return s.jsx(Hm,{className:"wb-group-chip",id:b,name:(v==null?void 0:v.name)??"?",face:v,initials:1},b)}),w.members.length>3?s.jsxs("span",{className:"wb-group-chip wb-group-more",children:["+",w.members.length-3]}):null]}),s.jsxs("span",{className:"wb-face-text",children:[s.jsx("span",{className:"wb-face-name",children:w.name}),s.jsx("span",{className:"wb-face-status",children:w.members.map(b=>{var v;return((v=h.find(m=>m.id===b))==null?void 0:v.name)??b}).join(", ")})]})]},w.id))]}):null]}),e.bottom.map(y),i==="vertical"?s.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":p?"Show agent names":"Hide agent names","aria-pressed":p,onClick:()=>x(w=>(ZI(!w),!w)),children:s.jsx(Ae,{name:p?"chevron-right":"chevron-left"})}):null]})}function eM({agent:e,active:t,attention:n,side:r,onSelect:i,lastAt:o=null}){const a=Ou(n),l=a?zv(a):e.available?o?`Last spoke ${Ee(o)}`:e.description:e.unavailableReason??"Cannot run right now",c=UI(n),u=e.unavailableReason??"This agent cannot run on this machine right now.",h=[e.name,e.available?null:"unavailable",a,t?"current":null].filter(f=>f!==null&&f!=="").join(" — ");return s.jsxs(Wc,{children:[s.jsx(Hc,{asChild:!0,children:s.jsxs("button",{className:"wb-face",...Wa(za(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":h,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[s.jsx(Hm,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),s.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[s.jsxs("span",{className:"wb-face-name",children:[e.name,s.jsxs("span",{className:"wb-face-handle",children:["@",e.handle]})]}),s.jsx("span",{className:"wb-face-status","data-tone":a?"critical":void 0,children:l})]}),c?s.jsx("span",{className:"wb-face-badge","data-kind":c.count===null?"dot":"count","data-testid":`agent-badge-${e.id}`,"aria-hidden":"true",children:c.count===null?"":c.count}):null,e.available?null:s.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:s.jsx(Ae,{name:"out"})})]})}),s.jsx(Vc,{children:s.jsxs(Kc,{className:"ui-tip",side:r,sideOffset:8,children:[s.jsx("span",{className:"ui-tip-title",children:e.name}),s.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:u}),a?s.jsx("span",{className:"ui-tip-alert",children:zv(a)}):null]})})]})}function zv(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function tM(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t%6+1}function Hm({className:e,id:t,name:n,face:r,tint:i,size:o,unavailable:a,initials:l=2}){const[c,u]=d.useState(null),h=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,f=r==null?void 0:r.avatar,p=h?"image":f==null?void 0:f.kind,x=t?Wa(za({id:t,accent:r==null?void 0:r.accent,roles:r==null?void 0:r.roles,tools:r==null?void 0:r.tools})):void 0;return s.jsx("span",{className:e,"data-tint":x?void 0:i,"data-size":o,"data-kind":p,"data-unavailable":a?"true":void 0,...x,"aria-hidden":"true",children:h?s.jsx("img",{src:h,alt:"",onError:()=>u(h)}):(f==null?void 0:f.kind)==="image"?s.jsx("img",{src:f.url,alt:""}):(f==null?void 0:f.kind)==="emoji"?f.value:YI(n).slice(0,l)})}function vs({id:e,name:t,size:n,unavailable:r,face:i}){return s.jsx(Hm,{className:"ui-avatar",id:e,tint:tM(e),name:t,size:n,unavailable:r,face:i})}function tn({agents:e,id:t,size:n}){const r=e.find(i=>i.id===t);return s.jsx(vs,{id:t,name:(r==null?void 0:r.name)??t,size:n,unavailable:r?!r.available:!1,face:r})}const Nk=d.createContext(null);function nM({picture:e,children:t}){return s.jsx(Nk.Provider,{value:e??null,children:t})}function Ck({size:e}){const t=d.useContext(Nk),[n,r]=d.useState(null);return!t||t===n?null:s.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:s.jsx("img",{src:t,alt:"",onError:()=>r(t)})})}const Ek=d.createContext([]);function vr({text:e,className:t}){const n=Th(e.replace(/\r\n/g,`
|
|
87
|
-
`).split(`
|
|
88
|
-
`));return s.jsx("div",{className:t??"wb-md",children:n.map((r,i)=>s.jsx(Ph,{block:r},i))})}const Wv=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,Hv=/^(#{1,6})\s+(.*?)\s*#*\s*$/,Vv=/^\s*([-*_])(\s*\1){2,}\s*$/,Rl=/^(\s*)([-*+])\s+(.*)$/,$o=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,Tl=/^\s*>\s?(.*)$/,Dd=/^\s*\|.*\|\s*$/,Kv=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function Th(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r.trim()===""){n+=1;continue}const i=Wv.exec(r);if(i){const l=i[2],c=[];for(n+=1;n<e.length&&!new RegExp(`^\\s*${l}\\s*$`).test(e[n]);)c.push(e[n]),n+=1;n+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
|
|
89
|
-
`)});continue}const o=Hv.exec(r);if(o){t.push({type:"h",level:o[1].length,text:o[2]}),n+=1;continue}if(Vv.test(r)){t.push({type:"hr"}),n+=1;continue}if(Tl.test(r)){const l=[];for(;n<e.length&&Tl.test(e[n]);)l.push(Tl.exec(e[n])[1]),n+=1;t.push({type:"quote",blocks:Th(l),raw:l.join(`
|
|
90
|
-
`)});continue}if(Dd.test(r)&&n+1<e.length&&Kv.test(e[n+1])){const l=Fd(r),c=Fd(e[n+1]).map(h=>{const f=h.startsWith(":"),p=h.endsWith(":");return f&&p?"center":p?"right":f?"left":null});n+=2;const u=[];for(;n<e.length&&Dd.test(e[n]);)u.push(Fd(e[n])),n+=1;t.push({type:"table",head:l,rows:u,align:c});continue}if(Rl.test(r)||$o.test(r)){const l=$o.exec(r)??Rl.exec(r),c=$o.test(r),u=l[1].length,h=c?Number(l[2]):1,f=[];for(;n<e.length;){const p=c?$o.exec(e[n]):Rl.exec(e[n]);if(!p||p[1].length!==u)break;const x=[p[3]];for(n+=1;n<e.length;){const y=e[n],w=y.trim()!==""&&Ld(y)>u,b=y.trim()===""&&n+1<e.length&&e[n+1].trim()!==""&&Ld(e[n+1])>u;if(!w&&!b)break;x.push(y.trim()===""?"":y.slice(Math.min(Ld(y),u+2))),n+=1}f.push(Th(x))}t.push({type:"list",ordered:c,start:h,items:f});continue}const a=[];for(;n<e.length;){const l=e[n];if(l.trim()===""||Wv.test(l)||Hv.test(l)||Vv.test(l)||Tl.test(l)||Rl.test(l)||$o.test(l)||Dd.test(l)&&n+1<e.length&&Kv.test(e[n+1]))break;a.push(l.trim()),n+=1}a.length>0&&t.push({type:"p",text:a.join(`
|
|
91
|
-
`)})}return t}function Ld(e){return e.length-e.trimStart().length}function Fd(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="";for(let i=0;i<t.length;i+=1){const o=t[i];if(o==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(o==="|"){n.push(r.trim()),r="";continue}r+=o}return n.push(r.trim()),n}function Ph({block:e}){switch(e.type){case"p":return s.jsx("p",{children:Bn(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),n=`h${Math.min(t+2,6)}`;return s.jsx(n,{className:"wb-md-h","data-level":t,children:Bn(e.text)})}case"code":return s.jsxs("div",{className:"wb-md-code-frame",children:[s.jsxs("div",{className:"wb-md-code-head",children:[s.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),s.jsx(Gv,{text:e.text,what:"code",always:!0})]}),s.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:s.jsx("code",{children:e.text})})]});case"quote":return s.jsxs("div",{className:"wb-md-copyable",children:[s.jsx("blockquote",{children:e.blocks.map((t,n)=>s.jsx(Ph,{block:t},n))}),s.jsx(Gv,{text:e.raw,what:"quote"})]});case"hr":return s.jsx("hr",{});case"list":{const t=e.items.map((n,r)=>s.jsx("li",{children:n.map((i,o)=>i.type==="p"?s.jsx(d.Fragment,{children:Bn(i.text)},o):s.jsx(Ph,{block:i},o))},r));return e.ordered?s.jsx("ol",{start:e.start,children:t}):s.jsx("ul",{children:t})}case"table":return s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table wb-md-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.head.map((t,n)=>s.jsx("th",{style:e.align[n]?{textAlign:e.align[n]}:void 0,children:Bn(t)},n))})}),s.jsx("tbody",{children:e.rows.map((t,n)=>s.jsx("tr",{children:t.map((r,i)=>s.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:Bn(r)},i))},n))})]})})}}function Gv({text:e,what:t,always:n=!1}){const[r,i]=d.useState("idle"),o=()=>{var a;if(!((a=navigator.clipboard)!=null&&a.writeText)){i("failed");return}navigator.clipboard.writeText(e).then(()=>i("done"),()=>i("failed")),window.setTimeout(()=>i("idle"),1500)};return s.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":n||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:o,children:r==="done"?"Copied":r==="failed"?"Select to copy":s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),s.jsx("path",{d:"M8.5 4.5V3a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4.5a1 1 0 0 0 1 1h1.5"})]})})}function sM({handle:e}){const n=d.useContext(Ek).find(r=>r.handle.toLowerCase()===e.toLowerCase());return n?s.jsxs(Wc,{children:[s.jsx(Hc,{asChild:!0,children:s.jsxs("a",{className:"wb-mention-link",href:Ue(n.id),children:["@",n.handle]})}),s.jsx(Vc,{children:s.jsxs(Kc,{className:"wb-agent-card",sideOffset:6,children:[s.jsx(vs,{id:n.id,name:n.name,face:n,unavailable:!n.available}),s.jsxs("span",{className:"wb-agent-card-text",children:[s.jsx("span",{className:"wb-agent-card-name",children:n.name}),s.jsx("span",{className:"wb-agent-card-desc",children:n.description}),s.jsxs("span",{className:"wb-agent-card-meta",children:[n.model,n.available?"":" · unavailable"]})]})]})})]}):s.jsxs(s.Fragment,{children:["@",e]})}const rM=new RegExp("(`+)([\\s\\S]*?[^`])\\1(?!`)|\\*\\*([^*]+?)\\*\\*|__([^_]+?)__|~~([^~]+?)~~|(?<![\\w*])\\*([^*\\n]+?)\\*(?![\\w*])|(?<![\\w_])_([^_\\n]+?)_(?![\\w_])|\\[([^\\]\\n]+)\\]\\((https?:\\/\\/[^\\s)]+)\\)|<?(https?:\\/\\/[^\\s<>)\\]]+[^\\s<>)\\].,;:!?'\"])>?|(?<![\\w@/])@([a-z0-9][a-z0-9_-]{0,63})(?![\\w-])","i");function Bn(e){const t=[];let n=e,r=0;for(;n!=="";){const i=rM.exec(n);if(!i){t.push(...Yv(n,r));break}i.index>0&&t.push(...Yv(n.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(s.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(s.jsx("strong",{children:Bn(i[3])},r)):i[4]!==void 0?t.push(s.jsx("strong",{children:Bn(i[4])},r)):i[5]!==void 0?t.push(s.jsx("s",{children:Bn(i[5])},r)):i[6]!==void 0?t.push(s.jsx("em",{children:Bn(i[6])},r)):i[7]!==void 0?t.push(s.jsx("em",{children:Bn(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(s.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:Bn(i[8])},r)):i[10]!==void 0?t.push(s.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(s.jsx(sM,{handle:i[11]},r)),n=n.slice(i.index+i[0].length)}return t}function Yv(e,t){return e.split(`
|
|
92
|
-
`).flatMap((r,i)=>i===0?[r]:[s.jsx("br",{},`${t}-br-${i}`),r])}function iM({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:Nt(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?s.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?s.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:s.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?s.jsx("div",{className:"wb-doc",children:s.jsx(vr,{text:e.text})}):s.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}function ye(e,t){if(t===""||t==="$")return e;let n=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,o="",a=""]=i;if(o!==""){if(n===null||typeof n!="object")return;n=n[o]}for(const l of a.match(/\d+/g)??[]){if(!Array.isArray(n))return;n=n[Number(l)]}if(n===void 0)return}return n}function Ne(e,t){if(t)return"const"in t?t.const:ye(e,t.path)}function ds(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function qe(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Lr(e){return Array.isArray(e)?e:[]}function oM(e,t){const n=Lr(ye(e,t.points)).map(i=>{const o=ds(ye(i,t.y)),a=qe(ye(i,t.x));return o===null||a===null?null:{x:a,y:o}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const o=ds(Ne(e,i.value));return o===null?null:{value:o,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:n,unit:t.unit??"number",currency:qe(Ne(e,t.currency)),label:qe(Ne(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:ds(Ne(e,t.shadeBelow)),events:aM(e,t)}}function aM(e,t){const n=t.events;if(!n)return[];const r=[],i=(o,a)=>{const l=qe(ye(o,n.label));if(l===null)return;const c=qe(ye(o,n.at))??a;c!==null&&r.push({at:c,label:l,amount:n.amount?ds(ye(o,n.amount)):null})};if(n.parent){for(const o of Lr(ye(e,t.points))){const a=qe(ye(o,t.x));for(const l of Lr(ye(o,n.parent)))i(l,a)}return r}for(const o of Lr(ye(e,n.path??t.points)))i(o,null);return r}function lM(e,t){const n=(t.columns??[]).map(l=>({key:l.key,label:l.label,type:l.type??"text"})),r=l=>(t.columns??[]).map(c=>{const u=ye(l,c.key);let h=null;if(c.bar){const f=ds(Ne(l,c.bar.max))??ds(Ne(e,c.bar.max)),p=ds(u);if(f!==null&&f>0&&p!==null){const x=Math.max(0,Math.min(1,p/f));h={fraction:x,tone:uM(x*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:qe(Ne(l,c.currency))??qe(Ne(e,c.currency)),bar:h}}),i=Lr(ye(e,t.rows)),o=t.groupBy?cM(i,t.groupBy,r):[{label:null,rows:i.map(r)}],a=(t.summary??[]).map(l=>({label:l.label,value:Ne(e,l.value),unit:l.unit??"text",currency:qe(Ne(e,l.currency)),tone:l.tone??"neutral"}));return{columns:n,groups:o,summary:a,empty:t.empty??"Nothing to show."}}function cM(e,t,n){const r=new Map;for(const i of e){const o=String(ye(i,t.key)??""),a=r.get(o);a?a.push(i):r.set(o,[i])}return[...r.entries()].map(([i,o])=>{var a;return{label:((a=t.labels)==null?void 0:a[i])??i,rows:o.map(n)}})}function uM(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,o)=>o.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function dM(e,t){return{bars:Lr(ye(e,t.bars)).map(r=>{const i=ds(ye(r,t.value)),o=qe(ye(r,t.category));return i===null||o===null?null:{category:o,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:qe(Ne(e,t.currency))}}function fM(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:Ne(e,r.value),unit:r.unit??"text",currency:qe(Ne(e,r.currency)),tone:r.tone??"neutral"}))};const n=ye(e,t.from??"$");return n===null||typeof n!="object"||Array.isArray(n)?{pairs:[]}:{pairs:Object.entries(n).map(([r,i])=>({label:Vt(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}function hM(e,t){const n=qe(Ne(e,t.kind)),r=n==="image"||n==="pdf"?n:"text",i=t.src?qe(ye(e,t.src)):null;return{kind:r,text:t.text?qe(ye(e,t.text)):null,src:i&&Rk(i)?i:null,title:qe(Ne(e,t.title)),metadata:(t.metadata??[]).map(o=>({label:o.label,value:Ne(e,o.value),unit:o.unit??"text"}))}}function pM(e,t){const n=t.diff?ye(e,t.diff):void 0;return{diff:typeof n=="string"&&n.trim()!==""?n:null,title:qe(Ne(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:Ne(e,r.value),unit:r.unit??"text"}))}}function mM(e,t){const n=t.output?ye(e,t.output):void 0,r=a=>{const l=a?ye(e,a):void 0;return typeof l=="number"&&Number.isInteger(l)?l:null},i=r(t.omittedBytes),o=t.elapsedMs?ye(e,t.elapsedMs):void 0;return{command:qe(Ne(e,t.command)),output:typeof n=="string"?n:null,exitCode:r(t.exitCode),elapsedMs:typeof o=="number"&&Number.isFinite(o)&&o>=0?o:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(a=>({label:a.label,value:Ne(e,a.value),unit:a.unit??"text"}))}}const gM=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ak(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&gM.test(t)?t.toLowerCase():null}function xM(e,t){return{artifactId:t.src?Ak(ye(e,t.src)):null,title:qe(Ne(e,t.title)),caption:qe(Ne(e,t.caption)),...t.captionLabel?{captionLabel:qe(Ne(e,t.captionLabel))}:{}}}function qv(e){if(!Rk(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const n=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return n?{plugin:n[1],name:n[2]}:null}function vM(e,t){const n=t.src?qe(ye(e,t.src)):null,r=t.port?ye(e,t.port):null,i=t.awaiting?qe(ye(e,t.awaiting)):null;return{target:n?qv(n):null,title:qe(Ne(e,t.title)),output:t.output?qe(ye(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?qv(i):null,reloadsItself:t.reloadsItself?ye(e,t.reloadsItself)===!0:!1,ports:t.ports?yM(ye(e,t.ports)):[]}}function yM(e){const t=Lr(e).filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>0&&n<=65535);return[...new Set(t)].sort((n,r)=>n-r)}function Rk(e){return e.startsWith("/")&&!e.startsWith("//")}function Vt(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Tk(e,t){const n=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:oM(t,n)};case"table":return{renderer:"table",props:lM(t,n)};case"bars":return{renderer:"bars",props:dM(t,n)};case"keyvalue":return{renderer:"keyvalue",props:fM(t,n)};case"document":return{renderer:"document",props:hM(t,n)};case"diff":return{renderer:"diff",props:pM(t,n)};case"terminal":return{renderer:"terminal",props:mM(t,n)};case"image":return{renderer:"image",props:xM(t,n)};case"preview":return{renderer:"preview",props:vM(t,n)};default:return{renderer:"structured",props:{value:t}}}}var jM=Object.defineProperty,Qn=(e,t)=>jM(e,"name",{value:t,configurable:!0}),Vm="Dialog",[Pk,rB]=Yn(Vm),[wM,Vs]=Pk(Vm),bM=Qn(e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!0}=e,l=d.useRef(null),c=d.useRef(null),[u,h]=fo({prop:r,defaultProp:i??!1,onChange:o,caller:Vm}),[f,p]=d.useState(0),[x,y]=d.useState(0);return s.jsx(wM,{scope:t,triggerRef:l,contentRef:c,contentId:Is(),titleId:Is(),descriptionId:Is(),titlePresent:f>0,descriptionPresent:x>0,setTitleCount:p,setDescriptionCount:y,open:u,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(w=>!w),[h]),modal:a,children:n})},"Dialog"),Ik="DialogPortal",[kM,Mk]=Pk(Ik,{forceMount:void 0}),SM=Qn(e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=Vs(Ik,t);return s.jsx(kM,{scope:t,forceMount:n,children:d.Children.map(r,a=>s.jsx(kr,{present:n||o.open,children:s.jsx(fm,{asChild:!0,container:i,children:a})}))})},"DialogPortal"),Ih="DialogOverlay",NM=d.forwardRef(Qn(function(t,n){const r=Mk(Ih,t.__scopeDialog),{forceMount:i=r.forceMount,...o}=t,a=Vs(Ih,t.__scopeDialog);return a.modal?s.jsx(kr,{present:i||a.open,children:s.jsx(EM,{...o,ref:n})}):null},"DialogOverlay")),CM=mr("DialogOverlay.RemoveScroll"),EM=d.forwardRef(Qn(function(t,n){const{__scopeDialog:r,...i}=t,o=Vs(Ih,r),a=Ab(),l=Ze(n,a);return s.jsx(Cm,{as:CM,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(tt.div,{"data-state":Km(o.open),...i,ref:l,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),Ca="DialogContent",AM=d.forwardRef(Qn(function(t,n){const r=Mk(Ca,t.__scopeDialog),{forceMount:i=r.forceMount,...o}=t,a=Vs(Ca,t.__scopeDialog);return s.jsx(kr,{present:i||a.open,children:a.modal?s.jsx(RM,{...o,ref:n}):s.jsx(TM,{...o,ref:n})})},"DialogContent")),RM=d.forwardRef(Qn(function(t,n){const r=Vs(Ca,t.__scopeDialog),i=d.useRef(null),o=Ze(n,r.contentRef,i);return d.useEffect(()=>{const a=i.current;if(a)return z0(a)},[]),s.jsx($k,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:Se(t.onCloseAutoFocus,a=>{var l;a.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Se(t.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&a.preventDefault()}),onFocusOutside:Se(t.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),TM=d.forwardRef(Qn(function(t,n){const r=Vs(Ca,t.__scopeDialog),i=d.useRef(!1),o=d.useRef(!1);return s.jsx($k,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var l,c;(l=t.onCloseAutoFocus)==null||l.call(t,a),a.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),a.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:a=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,a),a.defaultPrevented||(i.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=a.target;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})},"DialogContentNonModal")),$k=d.forwardRef(Qn(function(t,n){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=t,c=Vs(Ca,r);return Pu(),s.jsx(s.Fragment,{children:s.jsx(S0,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(um,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":Km(c.open),...l,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),PM="DialogTitle",IM=d.forwardRef(Qn(function(t,n){const{__scopeDialog:r,...i}=t,o=Vs(PM,r),{setTitleCount:a}=o;return on(()=>(a(l=>l+1),()=>a(l=>l-1)),[a]),s.jsx(tt.h2,{id:o.titleId,...i,ref:n})},"DialogTitle")),MM="DialogClose",$M=d.forwardRef(Qn(function(t,n){const{__scopeDialog:r,...i}=t,o=Vs(MM,r);return s.jsx(tt.button,{type:"button",...i,ref:n,onClick:Se(t.onClick,()=>o.onOpenChange(!1))})},"DialogClose"));function Km(e){return e?"open":"closed"}Qn(Km,"getState");const _M=5;function ne(e,t,n){const[r,i]=d.useState(void 0),[o,a]=d.useState(null),[l,c]=d.useState(!0),[u,h]=d.useState(0),[f,p]=d.useState(0),x=d.useRef(e);return x.current=e,d.useEffect(()=>{let y=!1;return c(!0),x.current().then(w=>{y||(i(w),a(null),p(0))}).catch(w=>{y||(a(w instanceof oe?w.message:String(w)),p(b=>b+1))}).finally(()=>{y||c(!1)}),()=>{y=!0}},[...t,u]),d.useEffect(()=>{if(!n||f>=_M)return;const y=window.setTimeout(()=>h(w=>w+1),n*2**f);return()=>window.clearTimeout(y)},[n,f,u]),{data:r,error:o,loading:l,reload:()=>{p(0),h(y=>y+1)}}}function ri(...e){return e.filter(Boolean).join(" ")}function P({variant:e,size:t,className:n,type:r="button",...i}){return s.jsx("button",{type:r,className:ri("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function cn({variant:e,size:t,className:n,...r}){return s.jsx("a",{className:ri("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function q({children:e,align:t,valign:n,className:r}){return s.jsx("div",{className:ri("ui-toolbar",r),"data-align":t,"data-valign":n,children:e})}function xo(){return s.jsx("span",{className:"ui-toolbar-spacer"})}function X({label:e,hint:t,inline:n,grow:r,wide:i,group:o,action:a,after:l,children:c}){const u=d.useId();return s.jsxs("div",{className:"ui-field","data-inline":n?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[a?s.jsxs("div",{className:"ui-field-row",children:[s.jsxs("label",{className:"ui-field-control",children:[s.jsx("span",{className:"ui-field-label",children:e}),c]}),a]}):o?s.jsxs("div",{className:"ui-field-control",role:"group","aria-labelledby":u,children:[s.jsx("span",{className:"ui-field-label",id:u,children:e}),c]}):s.jsxs("label",{className:"ui-field-control",children:[s.jsx("span",{className:"ui-field-label",children:e}),c]}),t?s.jsx("span",{className:"ui-field-hint",children:t}):null,l]})}function Bs({children:e,dense:t,columns:n}){return s.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,"data-columns":n===3?"3":void 0,children:e})}function ve({tone:e,mono:t,dot:n,children:r,className:i,title:o}){return s.jsxs("span",{className:ri("ui-pill",t&&"mono",i),"data-tone":e,title:o,children:[n?s.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function cc({children:e}){return s.jsx("span",{className:"ui-tag",children:e})}function Du({state:e}){const t=e==="succeeded"||e==="approved"||e==="fired"||e==="running"||e==="leased"?"good":e==="failed"||e==="rejected"||e==="unknown"||e==="error"||e==="refused"?"critical":e==="pending"||e==="suspended"||e==="expired"||e==="paused"?"warning":void 0;return s.jsx(ve,{tone:t,children:e})}function H({tone:e,title:t,children:n,role:r}){return s.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?s.jsx("div",{className:"ui-notice-title",children:t}):null,n]})}function re({message:e}){return e?s.jsx(H,{tone:"critical",role:"alert",children:e}):null}function ie({mascot:e,warm:t,title:n,action:r,children:i}){return t||n?s.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[n?s.jsx("div",{className:"ui-empty-title",children:n}):null,s.jsx("div",{children:i}),r]}):e?s.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[s.jsx(Ck,{size:"sm"}),s.jsx("p",{children:i})]}):s.jsx("p",{className:"ui-empty",children:i})}function Ct({icon:e,title:t,action:n,children:r}){return s.jsxs("div",{className:"ui-empty-state",children:[e?s.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?s.jsx(Ae,{name:e}):e}):null,s.jsx("div",{className:"ui-empty-state-title",children:t}),r?s.jsx("p",{className:"ui-empty-state-line",children:r}):null,n?s.jsx("div",{className:"ui-empty-state-action",children:n}):null]})}function OM({children:e}){return s.jsx("div",{className:"ui-page",children:e})}function Gm({title:e,lede:t,actions:n,before:r}){return s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[r,s.jsx("span",{children:e})]}),n?s.jsx("div",{className:"ui-page-actions",children:n}):null]}),t?s.jsx("p",{className:"ui-page-lede",children:t}):null]})}function fn({embedded:e,title:t,lede:n,actions:r,children:i}){return e?s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):s.jsxs(OM,{children:[s.jsx(Gm,{title:t,lede:n,actions:r}),i]})}function K({title:e,aside:t,actions:n,panel:r,flush:i,foot:o,children:a}){const l=e||t||n?s.jsxs("div",{className:"ui-section-head",children:[e?s.jsx("h3",{className:"ui-section-title",children:e}):s.jsx("span",{}),t||n?s.jsxs("div",{className:"ui-section-side",children:[t?s.jsx("span",{className:"ui-section-aside",children:t}):null,n?s.jsx("div",{className:"ui-section-actions",children:n}):null]}):null]}):null;return s.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[l,r?s.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[a,o?s.jsx("div",{className:"ui-panel-foot",children:o}):null]}):s.jsxs(s.Fragment,{children:[a,o?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:o}):null]})]})}function ct({title:e,tool:t,actions:n,flush:r,children:i}){return s.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||n?s.jsxs("header",{className:"ui-panel-head",children:[e?s.jsx("h3",{className:"ui-panel-title",children:e}):s.jsx("span",{}),t?s.jsx("span",{className:"ui-panel-tool",children:t}):null,n?s.jsx("div",{className:"ui-panel-actions",children:n}):null]}):null,i]})}function Yr({tone:e,title:t,meta:n,actions:r,children:i,foot:o,as:a="div"}){return s.jsxs(a,{className:"ui-card","data-tone":e,children:[t||n||r?s.jsxs("div",{className:"ui-card-head",children:[t?s.jsx("h3",{className:"ui-card-title",children:t}):null,n,r?s.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,o?s.jsx("div",{className:"ui-card-foot",children:o}):null]})}function V({gap:e,divided:t,children:n}){return s.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:n})}function DM({children:e}){return s.jsx("div",{className:"ui-row",children:e})}function Lu({inline:e,children:t}){return s.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function ls({label:e,value:t,note:n,tone:r,size:i}){return s.jsxs("div",{className:"ui-stat",children:[s.jsx("div",{className:"ui-stat-k",children:e}),s.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),n?s.jsx("div",{className:"ui-stat-n",children:n}):null]})}function Pt({items:e}){return s.jsx("dl",{className:"ui-kv",children:e.map((t,n)=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:t.value})]},t.key??n))})}function un({children:e}){return s.jsx("div",{className:"ui-table-wrap",children:s.jsx("table",{className:"ui-table",children:e})})}function _k({value:e,label:t}){const n=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return s.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-valuetext":`${n}%`,children:s.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${n}%`}})})}function ft({children:e,label:t}){return s.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function Et({summary:e,boxed:t,open:n,className:r,onToggle:i,children:o}){return s.jsxs("details",{className:ri("ui-details",r),"data-boxed":t?"true":void 0,open:n,onToggle:i?a=>i(a.currentTarget.open):void 0,children:[s.jsx("summary",{children:e}),o]})}function Qt({title:e,onClose:t,size:n,children:r}){return s.jsx(bM,{open:!0,onOpenChange:i=>{i||t()},children:s.jsxs(SM,{children:[s.jsx(NM,{className:"ui-sheet-overlay"}),s.jsxs(AM,{className:"ui-sheet","data-size":n,"aria-describedby":void 0,children:[s.jsxs("div",{className:"ui-sheet-head",children:[s.jsx(IM,{className:"ui-sheet-title",children:e}),s.jsx($M,{asChild:!0,children:s.jsx(P,{size:"sm",children:"Close"})})]}),r]})]})})}function Fu({level:e,label:t,children:n}){return s.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:n})}function Uu({href:e,active:t,count:n,onClick:r,children:i}){return s.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,n?s.jsx("span",{className:"ui-count",children:n}):null]})}function uc({label:e,options:t,value:n,onChange:r}){return s.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>s.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===n,onClick:()=>r(i.value),children:i.label},i.value))})}function Ut({children:e}){return s.jsx("div",{className:"ui-list",children:e})}function Gt({href:e,onClick:t,lead:n,title:r,sub:i,side:o}){const a=s.jsxs(s.Fragment,{children:[n,s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:r}),i?s.jsx("span",{className:"ui-list-sub",children:i}):null]}),o?s.jsx("span",{className:"ui-list-side",children:o}):null]});return e?s.jsx("a",{className:"ui-list-row",href:e,onClick:t?l=>{l.preventDefault(),t()}:void 0,children:a}):s.jsx("div",{className:"ui-list-row",children:a})}function Ok({href:e,onClick:t,current:n,lead:r,title:i,meta:o,sub:a,snippet:l,side:c}){return s.jsxs("a",{className:"ui-pick",href:e,"aria-current":n?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?s.jsx("span",{className:"ui-pick-lead",children:r}):null,s.jsxs("span",{className:"ui-pick-main",children:[s.jsxs("span",{className:"ui-pick-top",children:[s.jsx("span",{className:"ui-pick-title",children:i}),o?s.jsx("span",{className:"ui-pick-meta",children:o}):null]}),a||c?s.jsxs("span",{className:"ui-pick-line",children:[a?s.jsx("span",{className:"ui-pick-sub",children:a}):null,c?s.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,l?s.jsx("span",{className:"ui-pick-snippet",children:l}):null]})]})}function Dk({list:e,detail:t,empty:n,label:r,className:i}){return s.jsxs("div",{className:ri("ui-split",i),"data-open":t?"true":void 0,children:[s.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),s.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??s.jsx("p",{className:"ui-empty ui-split-empty",children:n})})]})}function qc({children:e,onRemove:t,label:n,disabled:r}){return s.jsxs("span",{className:"ui-chip",children:[e,s.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${n}`,onClick:t,disabled:r,children:"×"})]})}const LM=8;function FM({label:e,options:t,value:n,onChange:r,max:i,disabled:o,id:a}){const[l,c]=d.useState(!1),[u,h]=d.useState(""),[f,p]=d.useState(0),x=d.useRef(null),y=d.useRef(null),w=d.useRef(null),b=d.useRef(null),v=d.useId(),m=R=>{var O;return((O=t.find(Y=>Y.value===R))==null?void 0:O.label)??R},j=i!==void 0&&n.length>=i,g=t.filter(R=>!n.includes(R.value)),S=t.length>LM,k=u.trim().toLowerCase(),N=k===""?g:g.filter(R=>R.label.toLowerCase().includes(k)),C=Math.min(f,Math.max(0,N.length-1)),A=R=>{var O;c(!1),h(""),p(0),R&&((O=y.current)==null||O.focus())};d.useEffect(()=>{var O;if(!l)return;(O=S?w.current:b.current)==null||O.focus();const R=Y=>{x.current&&!x.current.contains(Y.target)&&A(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[l,S]);const E=R=>{const O=[...n,R];r(O),h(""),p(0);const Y=i!==void 0&&O.length>=i;(Y||O.length>=t.length)&&A(!Y)},_=R=>{if(R.key==="Escape")R.preventDefault(),A(!0);else if(R.key==="ArrowDown")R.preventDefault(),p(N.length===0?0:(C+1)%N.length);else if(R.key==="ArrowUp")R.preventDefault(),p(N.length===0?0:(C-1+N.length)%N.length);else if(R.key==="Enter"){R.preventDefault();const O=N[C];O&&E(O.value)}else R.key==="Backspace"&&u===""&&n.length>0&&(R.preventDefault(),r(n.slice(0,-1)))},L=R=>`${v}-${R}`,B=l&&N.length>0?L(C):void 0;return s.jsxs("div",{className:"ui-chippicker",ref:x,id:a,children:[n.map(R=>s.jsx(qc,{label:m(R),disabled:o,onRemove:()=>r(n.filter(O=>O!==R)),children:m(R)},R)),s.jsxs("div",{className:"ui-chippicker-add",children:[s.jsx("button",{ref:y,type:"button",className:"ui-btn","data-size":"sm","data-variant":"ghost","aria-haspopup":"listbox","aria-expanded":l,"aria-controls":l?v:void 0,disabled:o||j||g.length===0,onClick:()=>l?A(!1):c(!0),children:"Add…"}),l?s.jsxs("div",{className:"ui-menu ui-chippicker-menu",onKeyDown:_,children:[S?s.jsx("input",{ref:w,type:"search",className:"ui-chippicker-filter","aria-label":`Filter ${e}`,"aria-controls":v,"aria-activedescendant":B,value:u,onChange:R=>{h(R.target.value),p(0)}}):null,s.jsxs("div",{ref:b,id:v,role:"listbox","aria-multiselectable":"true","aria-label":e,"aria-activedescendant":S?void 0:B,tabIndex:S?-1:0,className:"ui-chippicker-list",children:[N.map((R,O)=>s.jsx("div",{id:L(O),role:"option","aria-selected":"false",className:"ui-menu-item","data-highlighted":O===C?"":void 0,onMouseEnter:()=>p(O),onMouseDown:Y=>Y.preventDefault(),onClick:()=>E(R.value),children:R.label},R.value)),N.length===0?s.jsx("p",{className:"ui-menu-empty",children:"Nothing matches"}):null]})]}):null]})]})}function Lk({main:e,filters:t,filtersOpen:n,onToggleFilters:r,active:i,chips:o,actions:a,onSubmit:l,label:c}){return s.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),l()},children:[s.jsxs("div",{className:"ui-searchbar-row",children:[e?s.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?s.jsxs(P,{"aria-expanded":n===!0,"aria-pressed":n===!0,onClick:r,children:["Filters",i?s.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?s.jsx("div",{className:"ui-searchbar-inline",children:t}):null,a?s.jsx("div",{className:"ui-searchbar-actions",children:a}):null]}),t&&r&&n?s.jsx("div",{className:"ui-searchbar-filters",children:t}):null,o?s.jsx("div",{className:"ui-searchbar-chips",children:o}):null]})}function UM({size:e}){return s.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function BM({quiet:e,still:t,className:n,children:r}){return s.jsx("div",{className:ri("ui-fieldbg",n),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function zM(e){const t={};for(const n of e??[])t[n.key]=n.default;return t}function Ym(e){const[t,n]=d.useState({}),r=e??[],i={...zM(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:s.jsx("div",{className:"ui-choices",children:r.map(o=>s.jsx(X,{label:o.label,inline:!0,children:s.jsx("select",{value:i[o.key],onChange:a=>n(l=>({...l,[o.key]:a.target.value})),children:o.options.map(a=>s.jsx("option",{value:a,children:a},a))})},o.key))})}}function WM({props:e,timezone:t="UTC",onDecided:n}){var m;const[r,i]=d.useState(null),[o,a]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let j=!1;return i(null),a(null),T.approval(e.approvalId).then(g=>{j||i(g)}).catch(g=>{j||a(g instanceof oe?g.message:String(g))}),()=>{j=!0}},[e.approvalId]);const{values:f,controls:p}=Ym(r==null?void 0:r.choices),x=(j,g)=>{h(j),a(null),(f&&j==="approve"?T.decide(e.approvalId,j,g,f):T.decide(e.approvalId,j,g)).then(S=>{i(S.action),n==null||n(S.action)}).catch(S=>a(S instanceof oe?S.message:String(S))).finally(()=>h(null))};if(o&&!r)return s.jsx("p",{className:"wb-empty",children:o});if(!r)return s.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const y=r.state==="pending",w=(m=r.permissionScopes)==null?void 0:m.includes("always"),b=HM(r),v=(r.preview??"").split(`
|
|
93
|
-
`).length>12||(r.preview??"").length>900;return s.jsxs("div",{children:[s.jsxs("div",{className:"ui-stats","data-inline":"true",children:[s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"Tool"}),s.jsx("div",{className:"ui-stat-v mono",children:r.tool})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"State"}),s.jsx("div",{className:"ui-stat-v","data-tone":VM(r.state),children:r.state})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:y?"Expires":"Decided"}),s.jsx("div",{className:"ui-stat-v","data-size":"sm",children:De(y?r.expiresAt:r.decidedAt,t)})]})]}),s.jsx(re,{message:o}),y?p:null,y?s.jsxs("div",{className:"wb-row-wrap wb-block",children:[s.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>x("approve"),children:u==="approve"?"Approving…":w?"Allow once":"Approve"}),w?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>x("approve","conversation"),children:"Auto: this conversation"}),s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>x("approve","always"),children:"Always: this agent"})]}):null,s.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>x("reject"),children:u==="reject"?"Rejecting…":"Reject"}),s.jsx("span",{className:"wb-hint",children:w?"Auto-mode and Always also approve future calls to this tool within that scope. Host permissions can be revoked under Host execution.":"This runs the action exactly as printed above."})]}):s.jsxs("p",{className:"muted",children:[r.state," ",r.decidedBy?`by ${r.decidedBy}`:""," ",r.decidedVia?`via ${r.decidedVia}`:""]}),s.jsx("h4",{className:"ui-stat-k wb-label",children:"Preview"}),s.jsxs("div",{className:"wb-doc wb-block","data-clamp":v&&!l?"true":void 0,children:[r.preview||"(this tool wrote no preview)",v&&!l?s.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]}),s.jsxs("details",{className:"ui-details wb-block",children:[s.jsx("summary",{children:"The envelope, field by field"}),s.jsx("dl",{className:"ui-kv",children:b.map(j=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:j.label}),s.jsx("dd",{className:j.mono?"mono":void 0,children:j.value})]},j.label))})]})]})}function HM(e){const t=[],n=e.envelope;if(n!==null&&typeof n=="object"&&!Array.isArray(n))for(const[i,o]of Object.entries(n))t.push({label:Vt(i),value:dc(o)});else n!=null&&t.push({label:"Envelope",value:dc(n)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,o]of Object.entries(r)){const a=`Argument · ${Vt(i)}`;t.some(l=>l.label===a)||t.push({label:a,value:dc(o)})}return t.push({label:"Action id",value:e.id,mono:!0},{label:"Tool version",value:e.toolVersion,mono:!0},{label:"Agent",value:e.agentId,mono:!0},{label:"Args hash",value:e.argsHash,mono:!0},{label:"Policy version",value:String(e.policyVersion)}),e.conversationId&&t.push({label:"Conversation",value:e.conversationId,mono:!0}),e.jobId&&t.push({label:"Job",value:e.jobId,mono:!0}),t}function dc(e){return e==null?"—":Array.isArray(e)?e.map(t=>dc(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):Nt(e,"text",null)}function VM(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const KM=new Set(["image/png","image/jpeg","image/gif","image/webp"]),GM=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Mh(e){const t=e!==null&&typeof e=="object"?e.artifacts:null;return Array.isArray(t)?t.flatMap(n=>{if(n===null||typeof n!="object")return[];const r=n;return typeof r.id!="string"||!GM.test(r.id)?[]:[{type:"attachment",artifactId:r.id,filename:typeof r.filename=="string"?r.filename:null,mime:typeof r.mime=="string"?r.mime:"application/octet-stream",kind:typeof r.kind=="string"?r.kind:"other",sizeBytes:null}]}):[]}function Fk(e){return KM.has(e.toLowerCase())}function yr(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function qr(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function dn(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qm(e,t){const n=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return n.startsWith("image/")?"image":n==="application/pdf"?"pdf":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":n==="text/csv"||n==="text/tab-separated-values"||n.includes("spreadsheet")||n.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":n.includes("zip")||n.includes("tar")||n.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":n==="application/json"||n.includes("javascript")||n.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":n.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const Fr={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function fc(e){return`artifact:${e}`}function YM(e){const t=qm(e.mime,e.filename);return{id:fc(e.artifactId),tool:Fr[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function qM({props:e}){const t=Ak(e.artifactId),[n,r]=d.useState(null),[i,o]=d.useState(null),[a,l]=d.useState(!1);if(d.useEffect(()=>{if(t===null)return;let h=!0;return r(null),o(null),l(!1),T.libraryEntry(t).then(f=>{h&&r({filename:f.entry.filename,sizeBytes:f.entry.sizeBytes})}).catch(()=>{}),()=>{h=!1}},[t]),t===null)return s.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(n==null?void 0:n.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,n!=null&&n.sizeBytes?dn(n.sizeBytes):null].filter(h=>h!==null);return s.jsxs("figure",{className:"wb-image",children:[s.jsx("div",{className:"wb-image-frame",children:a?s.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):s.jsx("a",{href:yr(t),className:"wb-image-link",title:"Open at full size",children:s.jsx("img",{src:yr(t),alt:e.caption??c,onLoad:h=>{const f=h.currentTarget;f.naturalWidth>0&&o({width:f.naturalWidth,height:f.naturalHeight})},onError:()=>l(!0)})})}),s.jsxs("figcaption",{className:"wb-image-caption",children:[s.jsxs(q,{children:[s.jsx("span",{className:"wb-image-name",children:c}),u.length>0?s.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(cn,{size:"sm",href:qr(t),download:(n==null?void 0:n.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?s.jsx(Et,{summary:e.captionLabel,className:"wb-image-note",children:s.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?s.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function QM({props:e}){return e.pairs.length===0?s.jsx("p",{className:"wb-empty",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:Nt(t.value,t.unit,t.currency)})]},t.label))})}const XM=8;function Uk({text:e,label:t="Output",className:n}){const r=d.useRef(null),i=d.useRef(!0);return d.useLayoutEffect(()=>{const o=r.current;o&&i.current&&(o.scrollTop=o.scrollHeight)},[e]),s.jsx("pre",{ref:r,className:n?`wb-terminal-body ${n}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:o=>{const a=o.currentTarget;i.current=a.scrollHeight-a.scrollTop-a.clientHeight<=XM},children:e})}function JM(e){if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?1:0)} s`;const n=Math.floor(t/60);return`${n} min ${Math.round(t-n*60)} s`}function ZM({text:e}){const[t,n]=d.useState("");return s.jsxs(s.Fragment,{children:[t?s.jsx("span",{role:"status",className:"wb-hint",children:t}):null,s.jsx(P,{size:"sm",onClick:()=>{var r;if(n(""),!((r=navigator.clipboard)!=null&&r.writeText)){n("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>n("Copied"),()=>n("Copy failed; select the text to copy."))},children:"Copy"})]})}function e$({props:e}){const t=e.output??"";return s.jsxs("div",{className:"wb-terminal",children:[s.jsxs(q,{className:"wb-terminal-head",children:[e.command!==null?s.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?s.jsxs(ve,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?s.jsx("span",{className:"wb-terminal-fact",children:JM(e.elapsedMs)}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?s.jsx(ZM,{text:t}):null]}),e.omittedBytes!==null?s.jsxs("p",{className:"wb-terminal-note",children:["First ",dn(e.omittedBytes)," not shown."]}):null,t!==""?s.jsx(Uk,{text:t}):s.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(n=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:n.label}),s.jsx("dd",{children:Nt(n.value,n.unit,null)})]},n.label))}):null]})}function t$(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function Qv(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function n$(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((n,r)=>n-r)}function s$({props:e}){var S;const[t,n]=d.useState(null),[r,i]=d.useState(null),[o,a]=d.useState(null),[l,c]=d.useState(!1),u=((S=e.target)==null?void 0:S.plugin)??null,h=n$(e),[f,p]=d.useState(null),x=f!==null&&h.includes(f)?f:e.port,y=e.target?x!==null&&x!==e.port?`${e.target.name}.${x}`:e.target.name:null,w=e.changes??0,b=d.useRef(w),[v,m]=d.useState(0);d.useEffect(()=>{w<=b.current||(b.current=w,e.reloadsItself||m(k=>k+1))},[w,e.reloadsItself]),d.useEffect(()=>{if(u===null||y===null)return;let k=!0;return n(null),i(null),a(null),m(0),T.previewLink(u,y).then(N=>{k&&(n(N.url),i(Qv(N.url)))}).catch(N=>{k&&a(N instanceof Error?N.message:"That preview could not be opened.")}),()=>{k=!1}},[u,y]);const j=()=>{u===null||y===null||T.previewLink(u,y).then(k=>i(k.url)).catch(()=>{})};if(e.target===null)return s.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",s.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const g=!(e.output===null||e.output==="");return s.jsxs("div",{className:"wb-preview","data-output":l||void 0,children:[s.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,h.length>1?s.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:x??"",onChange:k=>p(Number(k.target.value)),children:h.map(k=>s.jsxs("option",{value:k,children:[":",k]},k))}):null,g?s.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":l,onClick:()=>c(k=>!k),children:l?"Hide output":"Output"}):null,r?s.jsx("a",{className:"wb-preview-open",href:r,target:"_blank",rel:"noreferrer noopener",onPointerEnter:j,onFocus:j,title:"Through buddi: works from anywhere the dashboard does, including the tailnet.",children:"Open in a tab"}):null,x!==null&&t$()?s.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${x}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",x]}):null]}),s.jsxs("div",{className:"wb-preview-body",children:[t?s.jsx("iframe",{className:"wb-preview-frame",src:v===0?t:Qv(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},v):s.jsx("p",{className:"wb-empty wb-preview-frame",children:o??"Opening the preview…"}),g&&l?s.jsx(Uk,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const r$=50,i$=9,o$=24,a$=.6,l$=48,c$=/(amount|total|balance|price|cost|paid|pay|payment|net|spend|spent|due|limit|owed|fee|income|charge|burn|minimum|principal|interest|worth|cash|debt|deposit|credit|debit|value|revenue|budget|floor|avg|mean|median)/i,u$=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,d$=/^id$|(^|[a-z0-9])Id$|_id$/;function Ii(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function vn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Bk(...e){for(const t of e)if(vn(t))for(const n of["currency","currencyCode"]){const r=t[n];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function zk(e,t,n){const r=t.filter(i=>i!=null&&i!=="");return r.length===0?"text":r.every(i=>typeof i=="boolean")?"boolean":r.every(i=>typeof i=="number"&&Number.isFinite(i))?n!==null&&c$.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&u$.test(i))?"date":"text"}function f$(e,t){if(!d$.test(e))return!1;const n=t.filter(r=>!vo(r));return n.length<2?!1:new Set(n.map(r=>String(r))).size===n.length}function vo(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:vn(e)?Object.keys(e).length===0:!1}function Xv(e,t){const n=e.filter(vn);if(n.length===0||n.length/e.length<.8)return null;const r=n.slice(0,r$),i=new Map,o=[];for(const h of r)for(const f of Object.keys(h))i.has(f)||o.push(f),i.set(f,(i.get(f)??0)+1);if(i.size===0||i.size>o$||[...i.values()].reduce((h,f)=>h+f,0)/(i.size*r.length)<a$)return null;const l=[...i.keys()].sort((h,f)=>{const p=(i.get(f)??0)-(i.get(h)??0);return p!==0?p:o.indexOf(h)-o.indexOf(f)}),c=[],u=[];for(const h of l){const f=r.map(w=>w[h]),p=f.filter(w=>!vo(w));if(p.length===0||f$(h,f))continue;const x=Bk(r[0],t),y=zk(h,f,x);if(r.length>=4&&p.length===f.length&&f.every(w=>Ii(w)&&w===f[0])){u.push({label:Vt(h),value:f[0],type:y,currency:x});continue}if(c.push({key:h,label:Vt(h),type:y,currency:y==="currency"?x:null}),c.length===i$)break}return c.length===0?null:{columns:c,rows:n,constants:u}}function h$(e,t,n){const r=Bk(n);return{label:Vt(e),value:t,type:zk(e,[t],r),currency:r}}function Wk(e){return typeof e=="string"&&e.length>l$}function p$(e){return e==null?"This tool returned nothing.":typeof e=="string"&&e.trim()===""?"This tool returned an empty string.":Array.isArray(e)&&e.length===0?"This tool returned no items.":vn(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function $h(e){if(typeof e=="string"&&e.trim()!=="")return e;if(vn(e))for(const t of["message","error","reason","detail","description"]){const n=e[t];if(typeof n=="string"&&n.trim()!=="")return n;if(vn(n)){const r=$h(n);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function Qm(e,t={}){if(t.failed){let f=e;if(typeof e=="string")try{const p=JSON.parse(e.replace(/^tool-error:\s*/,""));vn(p)&&(f=p)}catch{}return{kind:"error",summary:$h(f),detail:Jv(f)}}if(vn(e)){const f=e.error,p=e.ok;if(typeof f=="string"&&f.trim()!==""||p===!1)return{kind:"error",summary:$h(e),detail:Jv(e)}}const n=p$(e);if(n)return{kind:"empty",note:n,stats:[]};if(Array.isArray(e)){const f=Xv(e,e);return f?{kind:"table",label:null,columns:f.columns,rows:f.rows,total:f.rows.length,stats:f.constants,notes:[],asides:[]}:e.every(Ii)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!vn(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,o=null;for(const[f,p]of r){if(!Array.isArray(p))continue;const x=Xv(p,e);if(x){(!i||x.rows.length>i.candidate.rows.length)&&(i={key:f,candidate:x});continue}p.length>0&&p.every(Ii)&&(!o||p.length>o.items.length)&&(o={key:f,items:p})}const a=(i==null?void 0:i.key)??(o==null?void 0:o.key)??null,l=[],c=[],u=[];for(const[f,p]of r)if(f!==a){if(Wk(p)){c.push(p);continue}if(Ii(p)){if(p==="")continue;l.push(h$(f,p,e));continue}p!==void 0&&u.push({label:Vt(f),value:p})}if(i)return{kind:"table",label:Vt(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...l,...i.candidate.constants],notes:c,asides:u};if(o)return{kind:"list",label:Vt(o.key),items:o.items,total:o.items.length,stats:l,notes:c,asides:u};const h=r.filter(([,f])=>Array.isArray(f)&&f.length===0);return h.length>0&&h.length===r.filter(([,f])=>Array.isArray(f)).length?{kind:"empty",note:`No ${h.map(([p])=>Vt(p).toLowerCase()).join(", ")} to show.`,stats:l}:r.every(([,f])=>Ii(f)||vn(f)||Array.isArray(f))?{kind:"record",pairs:l,notes:c,asides:u}:{kind:"tree",value:e}}function Jv(e){if(!vn(e))return null;const t=Object.entries(e).filter(([n])=>n!=="message"&&n!=="error");return t.length===0?null:Object.fromEntries(t)}const Qc=25,m$=3,_h=8,Hk=6;function Oh(e,t=0){if(t>Hk||vo(e)||Wk(e))return 0;if(Ii(e))return 1;if(Array.isArray(e)){let n=0;for(const r of e)if(n+=Oh(r,t+1),n>=_h)return n;return n}if(vn(e)){let n=0;for(const r of Object.values(e))if(n+=Oh(r,t+1),n>=_h)return n;return n}return 0}function Dh(e,t=0){if(t>Hk)return!1;if(Array.isArray(e))return e.some(o=>Dh(o,t+1));if(!vn(e))return!1;const n=e.artifactId??e.artifact_id;if(typeof n=="string"&&n.trim()!=="")return!0;const r=e.mime??e.mimeType??e.contentType,i=e.url??e.src??e.downloadUrl??e.path;return typeof r=="string"&&r.includes("/")&&typeof i=="string"&&i.trim()!==""?!0:Object.values(e).some(o=>Dh(o,t+1))}function g$(e){if(Dh(e))return!0;const t=Qm(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=m$;case"record":case"tree":return Oh(e)>=_h;default:return!1}}function Ud(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Xm(e){const t=Ud(e);if(!t)return null;const n=Ud(t.output)??t;if(typeof n.state!="string"||typeof n.stdout!="string"||typeof n.stderr!="string"||!(n.exitCode===null||typeof n.exitCode=="number"&&Number.isFinite(n.exitCode)))return null;const r=n===t?null:Ud(t.input),i=(r==null?void 0:r.command)??n.command;return{command:typeof i=="string"?i:null,input:r,result:n}}function x$({text:e,label:t}){const[n,r]=d.useState("");return s.jsxs("span",{className:"wb-command-copy",children:[s.jsx("button",{className:"ui-btn",onClick:()=>{var i;if(r(""),!((i=navigator.clipboard)!=null&&i.writeText)){r("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>r("Copied"),()=>r("Copy failed; select the text to copy."))},children:t}),n&&s.jsx("span",{role:"status",className:"wb-hint",children:n})]})}function Bd({title:e,text:t,error:n=!1}){return s.jsxs("section",{className:"wb-command-stream","data-error":n||void 0,children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("h4",{children:e}),s.jsx(x$,{text:t,label:`Copy ${e.toLowerCase()}`})]}),s.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function v$({value:e,children:t}){const{result:n,command:r,input:i}=e,o=n.state==="completed"&&n.exitCode!==null&&n.exitCode!==0,a=typeof n.signal=="string"&&n.signal?n.signal:null,l=n.state==="completed"&&n.exitCode===0,c=Object.fromEntries(Object.entries(n).filter(([h,f])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(h)&&f!==null&&f!==void 0&&f!=="")),u=Array.isArray(n.outputErrors)?n.outputErrors.filter(h=>typeof h=="string"):[];return s.jsxs("div",{className:"wb-command-result",children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("span",{className:"ui-pill","data-tone":l?"good":"critical",children:o?"Failed":n.state==="completed"&&a?"Terminated":n.state}),n.exitCode!==null&&s.jsxs("span",{className:"mono",children:["Exit code ",n.exitCode]}),a&&s.jsxs("span",{className:"mono",children:["Signal ",a]}),s.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&s.jsx(Bd,{title:"Command",text:r}),n.state==="output-limit"&&s.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),n.state==="timed-out"&&s.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),n.state==="cancelled"&&s.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),n.stdout?s.jsx(Bd,{title:"Output",text:n.stdout}):s.jsx("p",{className:"wb-note",children:"No standard output."}),n.stderr?s.jsx(Bd,{title:"Standard error",text:n.stderr,error:!0}):null,u.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"File export errors"}),u.map((h,f)=>s.jsx("p",{className:"wb-fail",children:h},f))]}),t,(Object.keys(c).length>0||i!==null)&&s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Execution details"}),s.jsx("pre",{children:ln({...c,...i?{input:i}:{}})})]})]})}const Pl=2,Zv=64;function y$({props:e}){const[t,n]=d.useState(!1),r=Xm(e.value),i=j$((r==null?void 0:r.result)??e.value),o=d.useMemo(()=>Qm(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return s.jsxs("div",{children:[!r&&s.jsx(ey,{files:i}),t?s.jsx("pre",{className:"ui-code",children:ln(e.value)}):r?s.jsx(v$,{value:r,children:i.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"Generated files"}),s.jsx(ey,{files:i})]})}):i.length?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Tool details"}),s.jsx(ty,{shape:o})]}):s.jsx(ty,{shape:o}),s.jsx("div",{className:"wb-row-end wb-section",children:s.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>n(a=>!a),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function j$(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(n=>n&&typeof n.id=="string"&&/^[0-9a-f-]{36}$/i.test(n.id)&&typeof n.filename=="string"):[]}function ey({files:e}){return e.length?s.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var n;return s.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?s.jsx(w$,{file:t}):null,s.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(n=t.mime)!=null&&n.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function w$({file:e}){const[t,n]=d.useState(!1);return t?s.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):s.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>n(!0)})}function ty({shape:e}){switch(e.kind){case"error":return s.jsxs("div",{children:[s.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"What came back with it"}),s.jsx("div",{className:"wb-tree",children:Ea(e.detail,1)})]})]});case"empty":return s.jsxs("div",{children:[s.jsx(zd,{stats:e.stats}),s.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=E$(e.columns,e.rows);return s.jsxs("div",{children:[s.jsx(zd,{stats:e.stats}),s.jsx(Wd,{notes:e.notes}),t?s.jsx(A$,{label:e.label,plan:t,rows:e.rows,total:e.total}):s.jsx(k$,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),s.jsx(Hd,{asides:e.asides})]})}case"list":return s.jsxs("div",{children:[s.jsx(zd,{stats:e.stats}),s.jsx(Wd,{notes:e.notes}),e.label?s.jsx("h4",{className:"wb-sub",children:e.label}):null,s.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,n)=>s.jsx("li",{children:Nt(t,"text",null)},n))}),e.total>100?s.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,s.jsx(Hd,{asides:e.asides})]});case"record":return s.jsxs("div",{children:[s.jsx(Wd,{notes:e.notes}),s.jsx(b$,{pairs:e.pairs}),s.jsx(Hd,{asides:e.asides})]});default:return s.jsx("div",{className:"wb-tree",children:Ea(e.value,0)})}}function zd({stats:e}){return e.length===0?null:s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:t.label}),s.jsx("div",{className:"ui-stat-v",children:Jm(t.value,t.type,t.currency)})]},t.label))})}const ny=200;function Wd({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=ny),n=e.filter(r=>r.length>ny);return s.jsxs(s.Fragment,{children:[t.map(r=>s.jsx("p",{className:"wb-note",children:r},r)),n.length>0?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:n.length===1?"A note that came with this result":`${n.length} notes that came with this result`}),n.map(r=>s.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function b$({pairs:e}){return e.length===0?s.jsx("p",{className:"wb-note",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:Jm(t.value,t.type,t.currency)})]},t.label))})}function Hd({asides:e}){return e.length===0?null:s.jsx("div",{className:"wb-section",children:e.map(t=>s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:t.label}),s.jsx("div",{className:"wb-tree",children:Ea(t.value,1)})]},t.label))})}function k$({label:e,columns:t,rows:n,total:r}){const[i,o]=d.useState(!1),a=r<=Qc+5?r:Qc,l=i?n:n.slice(0,a);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:t.map(c=>s.jsx("th",{className:Kk(c.type)?"num":void 0,children:c.label},c.key))})}),s.jsx("tbody",{children:l.map((c,u)=>s.jsx("tr",{children:t.map(h=>s.jsx(R$,{value:c[h.key],column:h},h.key))},u))})]})}),r>l.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",l.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>o(!0),children:["Show all ",r]})]}):null]})}const S$=/^(title|name|headline|subject|label|heading)$/i,N$=/^(url|link|href|uri|permalink)$/i;function Xc(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function C$(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Vk(e,t=48){try{const n=new URL(e),r=n.pathname==="/"?"":n.pathname,i=`${n.hostname.replace(/^www\./,"")}${r}${n.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function Il(e,t){const n=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return n.length===0?0:n.reduce((r,i)=>r+i.length,0)/n.length}function E$(e,t){if(t.length===0)return null;const n=e.filter(h=>h.type==="text"),r=n.find(h=>N$.test(h.key)&&t.some(f=>Xc(f[h.key])))??n.find(h=>{const f=t.map(p=>p[h.key]).filter(p=>!vo(p));return f.length>0&&f.filter(Xc).length/f.length>=.6});if(!r)return null;const i=n.filter(h=>h.key!==r.key),o=i.find(h=>S$.test(h.key))??i.find(h=>Il(t,h.key)>0);if(!o)return null;const l=[...i.filter(h=>h.key!==o.key)].sort((h,f)=>Il(t,f.key)-Il(t,h.key)),c=l[0]&&Il(t,l[0].key)>40?l[0]:null,u=e.filter(h=>h.key!==r.key&&h.key!==o.key&&h.key!==(c==null?void 0:c.key)).map(h=>h.key);return{url:r.key,title:o.key,description:(c==null?void 0:c.key)??null,meta:u}}function A$({label:e,plan:t,rows:n,total:r}){const[i,o]=d.useState(!1),a=r<=Qc+5?r:Qc,l=i?n:n.slice(0,a);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("ol",{className:"wb-records",children:l.map((c,u)=>{const h=c[t.url],f=Xc(h)?h.trim():null,p=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:f?Vk(f):"Untitled",x=t.description&&typeof c[t.description]=="string"?c[t.description]:null,y=f?C$(f):null,w=t.meta.map(b=>c[b]).filter(b=>!vo(b)&&typeof b!="object").map(b=>String(b)).filter(b=>y===null||b.replace(/^www\./,"")!==y);return s.jsxs("li",{className:"wb-record",children:[f?s.jsx("a",{className:"wb-record-title",href:f,target:"_blank",rel:"noopener noreferrer",children:p}):s.jsx("span",{className:"wb-record-title",children:p}),s.jsxs("div",{className:"wb-record-meta",children:[y?s.jsx("span",{className:"wb-record-host",title:f??void 0,children:y}):null,w.map((b,v)=>s.jsx("span",{children:b.length>60?`${b.slice(0,59)}…`:b},v))]}),x?s.jsx("p",{className:"wb-record-desc",children:x.length>280?`${x.slice(0,279)}…`:x}):null]},u)})}),r>l.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",l.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>o(!0),children:["Show all ",r]})]}):null]})}function R$({value:e,column:t}){if(vo(e))return s.jsx("td",{className:"wb-cell-soft",children:"—"});if(Xc(e)){const i=e.trim();return s.jsx("td",{className:"wb-cell-link",children:s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:Vk(i)})})}if(e!==null&&typeof e=="object"){const i=Array.isArray(e)?`${e.length} item${e.length===1?"":"s"}`:`${Object.keys(e).length} fields`;return s.jsx("td",{className:"wb-cell-soft",title:ln(e),children:i})}const n=Jm(e,t.type,t.currency),r=n.length>Zv?`${n.slice(0,Zv-1)}…`:n;return s.jsx("td",{className:Kk(t.type)?"num":"wb-cell-text",...r===n?{}:{title:n},children:r})}function Kk(e){return e==="number"||e==="currency"}function Jm(e,t,n){return e==null?"—":t==="boolean"?e?"yes":"no":Nt(e,t==="text"?"text":t,n)}function Ea(e,t){if(e===null)return s.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return s.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return s.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return s.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return s.jsx("span",{children:e===""?s.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return s.jsx("span",{className:"wb-tree-null",children:"none"});const i=s.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((o,a)=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[a,". "]}),Ea(o,t+1)]},a)),e.length>50?s.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=Pl?s.jsx(sy,{summary:`${e.length} items`,open:t===Pl,children:i}):i}const n=Object.entries(e);if(n.length===0)return s.jsx("span",{className:"wb-tree-null",children:"empty"});const r=s.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:n.map(([i,o])=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[Vt(i),": "]}),Ea(o,t+1)]},i))});return t>=Pl?s.jsx(sy,{summary:`${n.length} fields`,open:t===Pl,children:r}):r}function sy({summary:e,open:t,children:n}){return s.jsxs("details",{open:t,children:[s.jsx("summary",{className:"wb-tree-key",children:e}),n]})}function T$({props:e}){const t=e.groups.every(n=>n.rows.length===0);return s.jsxs("div",{children:[e.summary.length>0?s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(n=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:n.label}),s.jsx("div",{className:"ui-stat-v","data-tone":n.tone,children:Nt(n.value,n.unit,n.currency)})]},n.label))}):null,t?s.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((n,r)=>s.jsxs("div",{className:r>0?"wb-section":void 0,children:[n.label?s.jsx("h4",{className:"ui-stat-k wb-label",children:n.label}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.columns.map(i=>s.jsx("th",{className:Gk(i.type)?"num":void 0,"data-type":i.type,children:i.label},i.key))})}),s.jsx("tbody",{children:n.rows.map((i,o)=>s.jsx("tr",{children:i.map((a,l)=>{var c;return s.jsx(P$,{cell:a},((c=e.columns[l])==null?void 0:c.key)??l)})},o))})]})})]},n.label??r))]})}function P$({cell:e}){const t=Nt(e.value,e.type,e.currency);return e.bar?s.jsx("td",{className:"num",children:s.jsxs("div",{className:"wb-row wb-row-end",children:[s.jsx("div",{className:"ui-meter",role:"meter","aria-valuenow":Math.round(e.bar.fraction*100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":t,children:s.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),s.jsx("span",{className:"tnum",children:t})]})}):s.jsx("td",{className:Gk(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function Gk(e){return e==="number"||e==="currency"||e==="percent"}const xi=760,Vd=400,ot={top:18,right:18,bottom:36,left:66},I$=5;function M$({props:e}){const{points:t,referenceLines:n,unit:r,currency:i}=e;if(t.length===0)return s.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const o=[...t.map(g=>g.y),...n.map(g=>g.value)],a=Math.min(...o),l=Math.max(...o),c=l-a||Math.abs(l)||1,u=a-c*.08,h=l+c*.08,f=xi-ot.left-ot.right,p=Vd-ot.top-ot.bottom,x=g=>ot.left+(t.length===1?f/2:g/(t.length-1)*f),y=g=>ot.top+p-(g-u)/(h-u)*p,w=aI(a,l,4),b=_$(t.map(g=>g.y),e.mark),v=e.shadeBelow===null?[]:O$(t.map(g=>g.y),e.shadeBelow),m=t.map((g,S)=>`${S===0?"M":"L"}${x(S)},${y(g.y)}`).join(" "),j=g=>Nt(g,r,i);return s.jsxs("div",{children:[e.label?s.jsx("p",{className:"ui-panel-sub",children:e.label}):null,s.jsxs("div",{className:"wb-chart-layout",children:[s.jsx("div",{className:"wb-chart-plot",children:s.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${xi} ${Vd}`,role:"img","aria-label":$$(e,j),preserveAspectRatio:"xMidYMid meet",children:[v.map(g=>s.jsx("rect",{className:"wb-chart-breach",x:x(g.from),width:Math.max(2,x(g.to)-x(g.from)),y:ot.top,height:p},`band-${g.from}`)),w.map(g=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-grid",x1:ot.left,x2:xi-ot.right,y1:y(g),y2:y(g)}),s.jsx("text",{x:ot.left-8,y:y(g)+4,textAnchor:"end",children:j(g)})]},`tick-${g}`)),n.map(g=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-floor",x1:ot.left,x2:xi-ot.right,y1:y(g.value),y2:y(g.value)}),s.jsxs("text",{x:xi-ot.right,y:y(g.value)-6,textAnchor:"end",children:[g.label," ",j(g.value)]})]},`rule-${g.label}`)),s.jsx("line",{className:"wb-chart-axis",x1:ot.left,x2:ot.left,y1:ot.top,y2:ot.top+p}),s.jsx("line",{className:"wb-chart-axis",x1:ot.left,x2:xi-ot.right,y1:ot.top+p,y2:ot.top+p}),s.jsx("path",{className:"wb-chart-series",d:m}),b!==null?s.jsxs("g",{children:[s.jsx("circle",{className:"wb-chart-min",cx:x(b),cy:y(t[b].y),r:4.5}),s.jsx("text",{x:x(b),y:y(t[b].y)+20,textAnchor:"middle",children:j(t[b].y)})]}):null,D$(t.length).map(g=>s.jsx("text",{x:x(g),y:Vd-10,textAnchor:"middle",children:Ov(t[g].x)},`x-${g}`))]})}),e.events.length>0?s.jsxs("aside",{className:"wb-chart-events",children:[s.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),s.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((g,S)=>s.jsxs("li",{className:"wb-chart-event",children:[s.jsxs("span",{children:[s.jsx("span",{className:"wb-chart-event-day",children:Ov(g.at)}),g.label]}),g.amount===null?null:s.jsx("span",{className:g.amount<0?"tnum critical":"tnum good",children:Nt(g.amount,r,i)})]},`${g.at}-${g.label}-${S}`))})]}):null]})]})}function $$(e,t){const n=e.points.map(a=>a.y),r=e.points[0],i=e.points[e.points.length-1],o=e.referenceLines.map(a=>`${a.label} at ${t(a.value)}`).join(", ");return[`${e.points.length} points from ${r==null?void 0:r.x} to ${i==null?void 0:i.x}`,`low ${t(Math.min(...n))}, high ${t(Math.max(...n))}`,o].filter(Boolean).join("; ")}function _$(e,t){if(!t||e.length===0)return null;let n=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[n]:e[r]>e[n])&&(n=r);return n}function O$(e,t){const n=[];let r=null;return e.forEach((i,o)=>{i<t?r===null&&(r=o):r!==null&&(n.push({from:r,to:o}),r=null)}),r!==null&&n.push({from:r,to:e.length-1}),n}function D$(e,t=I$){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const n=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*n));return[...r].sort((i,o)=>i-o)}const Dn=e=>e,Lh={timeseries:Dn(M$),table:Dn(T$),bars:Dn(lI),keyvalue:Dn(QM),document:Dn(iM),diff:Dn(pI),terminal:Dn(e$),image:Dn(qM),preview:Dn(s$),envelope:Dn(WM),structured:Dn(y$)},L$="structured";function F$(e){return(Jc(e)?Lh[e]:void 0)??Lh[L$]}function Jc(e){return Object.prototype.hasOwnProperty.call(Lh,e)}function U$({renderer:e,props:t,timezone:n,onDecided:r}){const i=F$(e),a=Jc(e)?t:{value:t};return s.jsx(i,{props:a,timezone:n,onDecided:r})}function B$({profile:e,onChange:t}){return s.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[s.jsx("p",{className:"wb-prof-lead",children:e.description}),s.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?s.jsx(Kd,{children:"Opens by default"}):null,s.jsx(Kd,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(n=>s.jsx(Kd,{title:`A surface command that asks for "${n}" lands on this agent.`,children:Vt(n)},n))]}),e.available?null:s.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[s.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),s.jsx(_o,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:s.jsxs("ul",{className:"wb-prof-list",children:[s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),s.jsx("span",{className:"wb-prof-row-desc",children:"When it knows the likely answers, it can show one-tap choices in the dashboard and Telegram. You can still write a different answer when the question allows it."})]}),s.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),s.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),s.jsx("span",{className:"wb-prof-row-desc",children:"A request to send, spend, publish or otherwise affect the world appears in the conversation with the exact action. Answering a question never approves it."})]}),s.jsxs("span",{className:"wb-prof-gate",children:[s.jsx(Yk,{}),"Exact action"]})]})]})}),s.jsx(_o,{title:"What it can do",note:z$(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?s.jsx("p",{className:"wb-prof-empty",children:"No tools at all. It answers from the conversation and from what it remembers, and it can change nothing."}):[...e.tools].sort((n,r)=>+(r.gated>0)-+(n.gated>0)).map(n=>s.jsx(W$,{family:n},n.family))}),s.jsx(_o,{title:"What it runs on",children:s.jsxs("dl",{className:"wb-prof-kv",children:[s.jsx(Oo,{label:"Provider",children:e.engine.provider}),s.jsx(Oo,{label:"Model",children:s.jsx("span",{className:"mono",children:e.engine.model})}),s.jsxs(Oo,{label:"Credential",children:[e.engine.credentialKind," from"," ",s.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),s.jsxs(Oo,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),s.jsx(Oo,{label:"Language",children:Y$(e.engine.language)})]})}),e.skills.length>0?s.jsx(_o,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:s.jsx("ul",{className:"wb-prof-list",children:e.skills.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:n.name}),n.description?s.jsx("span",{className:"wb-prof-row-desc",children:n.description}):null]}),s.jsxs("span",{className:"wb-prof-row-side",title:n.file,children:[n.scope==="private"?"its own":"shared"," · ",n.provenance]})]},n.file))})}):null,e.delegates.length>0?s.jsx(_o,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:s.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsxs("span",{className:"wb-prof-row-name mono",children:["@",n.handle]}),s.jsx("span",{className:"wb-prof-row-desc",children:n.description})]}),s.jsx("span",{className:"wb-prof-row-side",children:n.available?n.name:`${n.name} · cannot run`})]},n.id))})}):null,s.jsxs("footer",{className:"wb-prof-foot",children:[s.jsx("p",{className:"wb-prof-note",children:e.note}),s.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?s.jsxs("button",{className:"ui-btn","data-testid":"agent-profile-change",title:e.changeVia.prompt,onClick:()=>t({agentId:e.changeVia.agentId,prompt:e.changeVia.prompt}),children:["Ask @",e.changeVia.handle," to change this"]}):null]})]})}function z$(e){if(e.toolCount===0)return"Nothing. This agent holds no tools.";const t=`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`;if(e.gatedCount===0)return`${t}, every one of them running without asking you. None of them can send, spend or write to the world.`;const n=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${n}.`}function W$({family:e}){const t=[...e.tools].sort((n,r)=>Number(r.gated)-Number(n.gated));return s.jsxs("section",{className:"wb-prof-family",children:[s.jsxs("h4",{className:"wb-prof-family-head",children:[s.jsx("span",{className:"wb-prof-family-name",children:Vt(e.family)}),s.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),s.jsx("ul",{className:"wb-prof-list",children:t.map(n=>s.jsx(H$,{tool:n},n.name))})]})}function H$({tool:e}){return s.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:G$(e.name)}),s.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?s.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[s.jsx(Yk,{}),"Needs your approval"]}):s.jsx("span",{className:"wb-prof-auto",title:K$(e.tier),children:V$(e.tier)})]})}function V$(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function K$(e){return e==="auto"?"Called during a run without asking you. It reads, or records something you can see.":`Tier "${e}" does not execute in this build; a call to it is refused.`}function G$(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function Y$(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function _o({title:e,note:t,tone:n,children:r}){return s.jsxs("section",{className:"wb-prof-section",children:[s.jsx("h3",{className:"wb-prof-title",children:e}),t?s.jsx("p",{className:"wb-prof-note-lead","data-tone":n,children:t}):null,r]})}function Oo({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"wb-prof-k",children:e}),s.jsx("dd",{className:"wb-prof-v",children:t})]})}function Kd({children:e,title:t}){return s.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function Yk(){return s.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),s.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const ry=16e3,q$=10*6e4,Q$="The microphone is blocked for this page: allow it in the browser’s site settings to talk.",qk="This browser cannot record here: talking needs a microphone and a secure page (https or localhost).";function X$(){const e=window;return e.AudioContext??e.webkitAudioContext}function J$(e){const t=e&&typeof e=="object"&&"name"in e?String(e.name):"";return t==="NotAllowedError"||t==="SecurityError"||t==="PermissionDeniedError"?Q$:t==="NotFoundError"||t==="DevicesNotFoundError"?"No microphone was found on this computer.":t==="NotReadableError"?"The microphone is in use by another app.":qk}async function Z$(e){var c;const t=X$();if(!((c=navigator.mediaDevices)!=null&&c.getUserMedia)||!t)throw Object.assign(new Error(qk),{name:"Unsupported"});const n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),r=new t,i=r.createMediaStreamSource(n),o=r.createScriptProcessor(4096,1,1),a=[];o.onaudioprocess=u=>{const h=u.inputBuffer.getChannelData(0);a.push(new Float32Array(h));let f=0;for(let p=0;p<h.length;p++)f+=h[p]*h[p];e(Math.min(1,Math.sqrt(f/h.length)*6))},i.connect(o),o.connect(r.destination),r.state==="suspended"&&await r.resume().catch(()=>{});const l=()=>{o.onaudioprocess=null;try{i.disconnect(),o.disconnect()}catch{}n.getTracks().forEach(u=>u.stop()),r.close().catch(()=>{})};return{async stop(){const u=r.sampleRate;return l(),n_(t_(e_(a),u,ry),ry)},cancel:l}}function e_(e){const t=new Float32Array(e.reduce((r,i)=>r+i.length,0));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t}function t_(e,t,n){if(t<=n)return e;const r=t/n,i=new Float32Array(Math.floor(e.length/r));for(let o=0;o<i.length;o++){const a=Math.floor(o*r),l=Math.min(e.length,Math.floor((o+1)*r));let c=0;for(let u=a;u<l;u++)c+=e[u];i[o]=l>a?c/(l-a):0}return i}function n_(e,t){const n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(o,a)=>{for(let l=0;l<a.length;l++)r.setUint8(o+l,a.charCodeAt(l))};i(0,"RIFF"),r.setUint32(4,36+e.length*2,!0),i(8,"WAVEfmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,"data"),r.setUint32(40,e.length*2,!0);for(let o=0;o<e.length;o++){const a=Math.max(-1,Math.min(1,e[o]));r.setInt16(44+o*2,Math.round(a<0?a*32768:a*32767),!0)}return new Blob([n],{type:"audio/wav"})}const Fh="buddi.readAloud";function s_(){try{return window.localStorage.getItem(Fh)==="on"}catch{return!1}}function r_(e){try{e?window.localStorage.setItem(Fh,"on"):window.localStorage.removeItem(Fh)}catch{}}let rs=null,ea=null,Aa=0,Uh=null;const Bh=new Set;function Zc(e){Uh!==e&&(Uh=e,Bh.forEach(t=>t()))}function i_(){return Uh}function o_(e){return Bh.add(e),()=>Bh.delete(e)}function Qk(e){return Ha(),Zc(e),Aa}function iy(e){return e===Aa}function Ha(){Aa++,rs&&(rs.pause(),rs.removeAttribute("src")),ea&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(ea),ea=null,Zc(null)}async function a_(e,t,n=null){var i;const r=Qk(n);try{const o=await fetch(e,{credentials:"same-origin"});if(!o.ok)throw new Error(`The spoken reply could not be fetched (${o.status}).`);const a=new Blob([await o.arrayBuffer()],{type:t});if(r!==Aa)return;rs||(rs=new Audio,(i=rs.addEventListener)==null||i.call(rs,"ended",()=>Zc(null))),ea=URL.createObjectURL(a),rs.src=ea,await rs.play()}catch(o){throw r===Aa&&Zc(null),o}}const l_=new Set(["audio/ogg","audio/mpeg","audio/mp4","audio/wav","audio/x-wav","audio/webm"]);function Xk(e){return l_.has(e.toLowerCase().split(";")[0].trim())}function oy(e){if(e===null||!Number.isFinite(e)||e<0)return"–:––";const t=Math.floor(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Jk({artifactId:e,name:t,mime:n,sizeBytes:r}){const i=d.useRef(null),o=d.useRef(null),[a,l]=d.useState(!1),[c,u]=d.useState(!1),[h,f]=d.useState(!1),[p,x]=d.useState(0),[y,w]=d.useState(null);d.useEffect(()=>()=>{var m;(m=i.current)==null||m.pause(),o.current&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(o.current)},[]);const b=async()=>{const m=i.current;if(m){if(a){m.pause();return}Ha(),f(!1);try{if(!o.current){u(!0);const j=await fetch(qr(e),{credentials:"same-origin"});if(!j.ok)throw new Error(String(j.status));o.current=URL.createObjectURL(new Blob([await j.arrayBuffer()],{type:n})),m.src=o.current}await m.play()}catch{f(!0)}finally{u(!1)}}},v=h?"Could not play. Download it instead.":`${oy(p)} / ${oy(y)}`;return s.jsxs("span",{className:"wb-audio","data-testid":"audio-card","data-playing":a?"true":void 0,children:[s.jsx("button",{type:"button",className:"ui-icon-btn wb-audio-play","data-size":"sm","aria-label":a?`Pause ${t}`:`Play ${t}`,disabled:c,onClick:()=>void b(),children:s.jsx(Ae,{name:a?"pause":"play",size:14})}),s.jsxs("span",{className:"wb-file-text",children:[s.jsx("span",{className:"wb-file-name",title:t,children:t}),s.jsxs("span",{className:"wb-file-meta","data-testid":"audio-time",children:[c?"Loading…":v,!h&&dn(r)?` · ${dn(r)}`:""]})]}),s.jsx("a",{className:"ui-icon-btn wb-audio-download","data-size":"sm",href:qr(e),download:t,"aria-label":`Download ${t}`,title:"Download",children:s.jsx(Ae,{name:"download",size:14})}),s.jsx("audio",{ref:i,preload:"none",onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>{l(!1),x(0)},onTimeUpdate:m=>x(m.currentTarget.currentTime),onLoadedMetadata:m=>w(Number.isFinite(m.currentTarget.duration)?m.currentTarget.duration:null),onDurationChange:m=>w(Number.isFinite(m.currentTarget.duration)?m.currentTarget.duration:null)})]})}const Gd=1e5,Yd=200,qd=30;function Zk({artifactId:e,filename:t,mime:n,family:r,available:i=!0}){const[o,a]=d.useState(!1);return i?r==="image"&&!o?s.jsx("figure",{className:"file-preview file-preview-image",children:s.jsx("img",{src:yr(e),alt:t??"Image",onError:()=>a(!0)})}):r==="audio"&&Xk(n)?s.jsx("div",{className:"file-preview file-preview-audio",children:s.jsx(Jk,{artifactId:e,name:t??"Audio",mime:n})}):r==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:yr(e),type:"application/pdf","aria-label":t??"PDF",children:s.jsx(H,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?s.jsx(c_,{artifactId:e,filename:t,mime:n,family:r}):s.jsx(H,{children:"Preview not supported for this kind of file. Download it to open it."}):s.jsx(H,{children:"The file is no longer available; its record is kept."})}function c_({artifactId:e,filename:t,mime:n,family:r}){const[i,o]=d.useState("loading");if(d.useEffect(()=>{let l=!1;return o("loading"),fetch(yr(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();l||o({text:u.slice(0,Gd),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>Gd})}).catch(()=>{l||o("failed")}),()=>{l=!0}},[e]),i==="loading")return s.jsx("div",{className:"file-preview",children:s.jsx(ie,{children:"Loading preview…"})});if(i==="failed")return s.jsx(H,{children:"The preview could not be loaded. Download the file to open it."});const a=r==="table"&&(/csv|tab-separated/.test(n)||/\.(csv|tsv)$/i.test(t??""));return s.jsxs("div",{className:"file-preview",children:[a?s.jsx(d_,{text:i.text,delimiter:/tab|\.tsv$/i.test(n+(t??""))?" ":","}):s.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?s.jsxs("p",{className:"muted",children:["Showing the first ",Gd.toLocaleString()," characters. The download has the whole file."]}):null]})}function u_(e,t,n,r){const i=[];let o=[],a="",l=!1,c=!1,u=!1;const h=()=>{o.length<r?o.push(a):c=!0,a=""},f=()=>{h(),i.push(o),o=[]};let p=0;for(;p<e.length;p+=1){if(i.length>=n){u=e.slice(p).trim()!=="";break}const x=e[p];if(l){x==='"'?e[p+1]==='"'?(a+='"',p+=1):l=!1:a+=x;continue}if(x==='"'){l=!0;continue}if(x===t){h();continue}if(x!=="\r"){if(x===`
|
|
94
|
-
`){f();continue}a+=x}}return i.length<n&&(a!==""||o.length>0)&&f(),{rows:i,truncatedRows:u,truncatedCols:c}}function d_({text:e,delimiter:t}){const n=d.useMemo(()=>u_(e,t,Yd+1,qd),[e,t]),[r,...i]=n.rows;if(!r)return s.jsx("p",{className:"muted",children:"The file is empty."});const o=Math.min(qd,n.rows.reduce((l,c)=>Math.max(l,c.length),0)),a=Array.from({length:o},(l,c)=>c);return s.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:a.map(l=>s.jsx("th",{children:r[l]??""},l))})}),s.jsx("tbody",{children:i.slice(0,Yd).map((l,c)=>s.jsx("tr",{children:a.map(u=>s.jsx("td",{children:l[u]??""},u))},c))})]}),n.truncatedRows||n.truncatedCols?s.jsxs("p",{className:"muted",children:["Showing the first ",Yd," rows",n.truncatedCols?` and ${qd} columns`:"",". The download has the whole file."]}):null]})}function f_({attachment:e}){const t=qm(e.mime,e.filename),n=e.filename??"Untitled file";return s.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[s.jsx(Zk,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),s.jsxs("dl",{className:"ui-kv",children:[s.jsx("dt",{children:"Type"}),s.jsxs("dd",{children:[Fr[t],s.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Size"}),s.jsx("dd",{children:dn(e.sizeBytes)})]}):null,s.jsx("dt",{children:"Id"}),s.jsx("dd",{className:"mono",children:e.artifactId})]}),s.jsx("div",{className:"ui-toolbar","data-align":"end",children:s.jsx("a",{className:"ui-btn",href:qr(e.artifactId),download:n,children:"Download"})})]})}const ay=80,h_=["query","path","url","dir"],p_=["message","task"];function Zm(e,t){const n=m_(t);if(!n)return null;const r=vi(n.command);if(r!==null){const a=vi(n.name);return Ml(a===null?r:`${a}: ${r}`)}for(const a of h_){const l=vi(n[a]);if(l!==null)return Ml(l)}const i=vi(n.action);if(i!==null){const a=p_.map(l=>vi(n[l])).find(l=>l!==null)??null;return Ml(a===null?i:`${i} · ${a}`)}const o=Object.values(n).filter(a=>typeof a=="string");return o.length===1?Ml(vi(o[0])):null}function vi(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function Ml(e){return e===null?null:e.length>ay?`${e.slice(0,ay-1)}…`:e}function m_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Ra="agent.delegate";function g_(e){if(e===null||typeof e!="object")return null;const t=e,n=t.conversationId;if(typeof n!="string"||n==="")return null;const r=t.agentId??t.agent;return{conversationId:n,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function x_(e){if(typeof e=="string")return e;if(e===null||typeof e!="object")return null;const t=e.text;return typeof t=="string"?t:null}const zh="canvas.show",ly="canvas.clear",cy=12;function Bi(e){return`${e.plugin}/${e.name}`}function v_(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function y_({messages:e,descriptors:t}){const n=new Map(t.filter(o=>o.renderer==="preview").map(o=>[o.tool,o]));if(n.size===0)return[];const r=new Map,i=[];for(const o of e)for(const a of o.blocks??[]){if(a.type==="tool_use"&&r.set(a.id,a.name),a.type!=="tool_result"||a.ok===!1)continue;const l=n.get(a.name||r.get(a.toolUseId)||"");if(!l)continue;const c=Tk(l,eS(a.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:o.at??null})}return i}function j_({messages:e,descriptors:t,awaiting:n,folded:r,served:i}){var u;const o=new Map(t.map(h=>[h.tool,h])),a=new Map;let l=[],c=0;for(const h of e)for(const f of h.blocks??[]){if(f.type==="tool_use"){if(a.set(f.id,{name:f.name,input:f.input,at:h.at??null}),f.name===zh){const g=b_(f.id,f.input,h.at??null);g&&l.push(g)}if(f.name===ly&&(l=[]),f.name===Ra){const g=g_(f.input);g&&l.push({id:f.id,tool:Ra,title:"Delegation",renderer:"delegate",props:{...g,result:null},at:h.at??null,source:"delegate",substantial:!0})}continue}if(f.type!=="tool_result"||f.name===zh||f.name===ly)continue;const p=a.get(f.toolUseId),x=h.at??(p==null?void 0:p.at)??null,y=f.name||(p==null?void 0:p.name)||"tool",w=l.find(g=>g.source==="delegate"&&g.id===f.toolUseId);if(w&&((u=f.delegation)==null?void 0:u.state)==="waiting"){w.props={...w.props,result:null,waiting:{approvalId:f.delegation.approvalId}},f.delegation.approvalId&&(w.tone="warning");continue}if(w){w.props={...w.props,result:{ok:f.ok,text:x_(f.ok?f.output:f.error??f.output),...f.ok&&Mh(f.output).length>0?{files:Mh(f.output)}:{}}},f.ok||(w.tone="critical");continue}const b=f.approval?Hh(f):(n==null?void 0:n.get(f.toolUseId))??Hh(f);if(b){l.push({id:f.toolUseId,tool:y,title:"Approval",renderer:"envelope",props:{approvalId:b},at:x,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(y))continue;const v=eS(f.output);if(f.ok===!1){l.push({id:f.toolUseId,tool:y,title:fs(y),renderer:"structured",props:{value:f.error??v??null,failed:!0},at:x,tone:"critical",source:"fallback",substantial:!1});continue}v_(v)&&(c+=1);const m=o.get(y);if(m){const g=Tk(m,v),{renderer:S}=g;let{props:k}=g;if(S==="preview"){const N=k,C=N.target??(N.awaiting&&(i!=null&&i.has(Bi(N.awaiting)))?N.awaiting:null);if(C===null)continue;k={...N,target:C,awaiting:null};const A=Bi(C);l=l.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&Bi(E.props.target)===A))}l.push({id:f.toolUseId,tool:y,title:m.title??fs(y),renderer:S,props:k,at:x,source:"descriptor",substantial:Wh(S,k)});continue}const j={value:Xm(v)?{input:p==null?void 0:p.input,output:v}:v};k_("structured",j)&&l.push({id:f.toolUseId,tool:y,title:fs(y),renderer:"structured",props:j,at:x,source:"fallback",substantial:Wh("structured",j)})}for(const h of l)h.source==="descriptor"&&h.renderer==="preview"&&(h.props={...h.props,changes:c});return w_(l)}const uy="forAgent";function eS(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(uy in e))return e;const{[uy]:t,...n}=e;return n}function w_(e){if(e.length<=cy)return e;const t=e.length-cy;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function b_(e,t,n){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:o}=t,a=typeof r=="string"&&Jc(r)?r:"structured";return{id:e,tool:zh,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:a,props:a==="structured"&&!Jc(String(r))?{value:o}:o,at:n,substantial:!0,source:"canvas"}}function k_(e,t){const n=t??{};return!!(n.failed===!0||Wh(e,t)||Qm(n.value).kind==="error")}function Wh(e,t){const n=t??{};switch(e){case"timeseries":return $l(n.points)>0;case"bars":return $l(n.bars)>0;case"keyvalue":return $l(n.pairs)>0;case"document":return!!n.text||!!n.src;case"diff":return!!n.diff;case"terminal":return!!n.output||!!n.command;case"image":return!!n.artifactId;case"preview":return!!n.target;case"envelope":return!0;case"table":return(Array.isArray(n.groups)?n.groups:[]).some(i=>$l(i.rows)>0);default:return Xm(n.value)?!0:n.failed===!0?!1:g$(n.value)}}function $l(e){return Array.isArray(e)?e.length:0}function Hh(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const n=nS(t,0);if(n)return n}return null}function S_(e,t,n={}){var l,c;const r=e.flatMap(u=>u.blocks),i=r.find(u=>u.type==="tool_use"&&u.id===t);if((i==null?void 0:i.type)!=="tool_use")return null;const o=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),a=(l=n.redactInputOf)!=null&&l.has(i.name)?tS(i.input):i.input;return{id:t,tool:i.name,title:fs(i.name),renderer:"structured",props:{value:{input:a,...(o==null?void 0:o.type)==="tool_result"?{status:((c=o.approval)==null?void 0:c.state)??(o.ok?"completed":"failed"),output:o.output,...o.error?{error:o.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const N_=new Set(["value","text","password","secret","code"]);function tS(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=N_.has(n)&&typeof r=="string"?"— withheld —":tS(r);return t}function nS(e,t){if(t>3||e===null||typeof e!="object")return null;const n=e,r=n.reason,i=n.actionId??n.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const o of Object.values(n)){const a=nS(o,t+1);if(a)return a}return null}function fs(e){const t=e.split(".");return t.length===1?Vt(e):t.map(n=>Vt(n)).join(" · ")}function eg({name:e,mime:t,sizeBytes:n,thumbnail:r,state:i,error:o,onOpen:a,onRemove:l,size:c="md"}){const u=qm(t,e),h=[Fr[u],dn(n)].filter(Boolean).join(" · "),f=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wb-file-visual","data-family":u,children:r?s.jsx("img",{src:r,alt:""}):s.jsx(tg,{family:u})}),s.jsxs("span",{className:"wb-file-text",children:[s.jsx("span",{className:"wb-file-name",title:e,children:e}),s.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":h})]})]});return s.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?o:void 0,children:[a?s.jsx("button",{type:"button",className:"wb-file-open",onClick:a,"aria-label":`Open ${e}`,children:f}):s.jsx("span",{className:"wb-file-open",children:f}),l?s.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:l,children:s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:s.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function tg({family:e}){const t={width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"image":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),s.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),s.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),s.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),s.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),s.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return s.jsxs("svg",{...t,children:[s.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),s.jsx("path",{d:"M11.5 2.5V7H16"})]})}}const C_=1e3;function E_({messageId:e,text:t,onReadAloud:n}){const[r,i]=d.useState(!1),o=d.useRef(null),a=d.useSyncExternalStore(o_,i_)===e;d.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const l=()=>{var c;(c=navigator.clipboard)==null||c.writeText(t).then(()=>{i(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>i(!1),C_)},()=>{})};return s.jsxs("div",{className:"wb-reply-actions","data-testid":"reply-actions",children:[s.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":r?"Copied":"Copy",title:r?"Copied":"Copy",onClick:l,children:s.jsx(Ae,{name:r?"check":"copy",size:14})}),r?s.jsx("span",{className:"wb-reply-copied",role:"status",children:"Copied"}):null,n?s.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":a?"Stop reading aloud":"Read aloud",title:a?"Stop reading aloud":"Read aloud","aria-pressed":a,onClick:()=>a?Ha():n(e,t),children:s.jsx(Ae,{name:a?"stop":"play",size:14})}):null]})}function A_(e){const t=R_(e);if(!t)return null;const n=Qd(t.diff);if(n!==null)return{kind:"diff",diff:n};const r=Qd(t.command),i=Qd(t.plain),o=Xd(t.exitCode);return r!==null&&(i!==null||o!==null||Xd(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:o,elapsedMs:Xd(t.elapsedMs)}:null}function Qd(e){return typeof e=="string"&&e.trim()!==""?e:null}function Xd(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function R_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const dy="offer:",sS="owner:interjection";function T_(e){return e===sS}function P_(e){if(typeof e!="string"||!e.startsWith(dy))return null;const t=e.slice(dy.length).trim();return t===""?null:t}function rS({messages:e,live:t,now:n,onOpen:r,working:i=!1,partial:o=null,agents:a,speakers:l,coordinatorId:c,workingAs:u,onOpenFile:h,onReadAloud:f,children:p,agentName:x,emptyHint:y,empty:w,plain:b=!1,workingLine:v,runs:m}){var N,C;const j=d.useRef(null);d.useEffect(()=>{var A;(A=j.current)==null||A.scrollIntoView({block:"end"})},[e.length,t.length,i,o==null?void 0:o.text.length,o==null?void 0:o.thinking.length,!!p]);const g=o&&!o.settled&&(o.text!==""||o.thinking!==""),S=e.filter(A=>(A.blocks??[]).some(z_)),k=U_(S,m??[]);return s.jsx(Ek.Provider,{value:a??l??[],children:s.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[S.length===0&&t.length===0?w??s.jsx("p",{className:"wb-chat-empty",children:y}):null,S.map((A,E)=>{const _=A.speaker??null,L=l?_==="owner"||_===null&&A.role==="user":A.role==="user",B=l&&_==="room",R=l&&_&&_!=="owner"&&_!=="room"?l.find(J=>J.id===_)??null:null,O=S[E-1],Y=E===0||(l?((O==null?void 0:O.speaker)??null)!==_:O.role!==A.role);if(B)return s.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(A.blocks??[]).filter(J=>J.type==="text").map((J,ge)=>s.jsx("span",{children:J.text},ge))},A.id);const G=(A.blocks??[]).filter(J=>J.type==="approval_result");if(G.length>0)return s.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:G.map((J,ge)=>s.jsx(W_,{block:J},ge))},A.id);const M=A.role==="user"&&T_(_),W=A.role==="user"?P_(_):null;if(W){const J=(A.blocks??[]).filter(ge=>ge.type==="text").map(ge=>ge.text).join(`
|
|
95
|
-
`);return s.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:s.jsx("div",{className:"wb-bubble wb-bubble-offer",title:J,children:W})},A.id)}const $=l&&R&&A.role==="user"?D_(A):null;if($){const J=S.slice(E+1).find(xe=>xe.role==="assistant"&&xe.speaker&&xe.speaker!==R.id),ge=J!=null&&J.speaker?l.find(xe=>xe.id===J.speaker):void 0;return s.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[s.jsxs("summary",{children:[R.name," asked ",(ge==null?void 0:ge.name)??"a member",$.request?`: ${$.request.length>120?`${$.request.slice(0,119)}…`:$.request}`:""]}),$.request?s.jsx("p",{children:$.request}):null]},A.id)}const ee=k.get(A.id)??null,ce=F_(A,e),Ce=!L&&!M&&!b?L_(A):"";return s.jsxs("div",{className:"wb-msg","data-role":L||M?"user":"assistant",children:[M?s.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,Y&&!L&&!M?s.jsxs("div",{className:"wb-msg-who",children:[R&&l?s.jsx(tn,{agents:l,id:R.id,size:"sm"}):null,s.jsx("span",{children:R?R.name:x??"Assistant"}),R&&c===R.id?s.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null]}):null,ce.length>0?s.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:ce.map(J=>s.jsx("span",{role:"listitem",children:Xk(J.mime)?s.jsx(Jk,{artifactId:J.artifactId,name:J.filename??"Untitled file",mime:J.mime,sizeBytes:J.sizeBytes}):s.jsx(eg,{name:J.filename??"Untitled file",mime:J.mime,sizeBytes:J.sizeBytes,thumbnail:Fk(J.mime)?yr(J.artifactId):null,...h?{onOpen:()=>h(J)}:{}})},J.artifactId))}):null,(A.blocks??[]).map((J,ge)=>{const xe=$_(A.blocks??[],ge,e);if(xe==="inside")return null;if(xe)return s.jsx(__,{refusals:xe.refusals},ge);if(J.type==="thinking")return b||J.text.trim()===""?null:s.jsx(Vh,{text:J.text},ge);if(J.type==="text")return J.text.trim()===""?null:L?s.jsx("div",{className:"wb-bubble",children:J.text},ge):s.jsx("div",{className:"wb-bubble","data-rich":"true",children:s.jsx(vr,{text:J.text})},ge);if(J.type==="attachment")return null;if(J.type==="tool_use"){if(b)return null;const je=ng(e,J.id),Pe=je?K_(je):null;return s.jsx(Kh,{label:Pe&&!(je!=null&&je.delegation)?`Approval · ${J.name}`:fs(J.name),tool:J.name,ok:(je==null?void 0:je.ok)??null,running:je===null,...Pe?{status:Pe.status,waiting:Pe.waiting,approval:!0}:{},gist:Zm(J.name,J.input),body:je?A_(je.output):null,opens:!0,onOpen:()=>r(J.id)},ge)}return null}),ee?s.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:B_(ee)}):null,Ce!==""?s.jsx(E_,{messageId:A.id,text:Ce,onReadAloud:f}):null]},A.id)}),g?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[((N=S.at(-1))==null?void 0:N.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??x??"Assistant"}):null,o.thinking!==""&&!b?s.jsx(Vh,{text:o.thinking,live:o.text==="",seconds:O_(o.thinkingStartedAt,o.textStartedAt??n)}):null,o.text!==""?s.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[s.jsx(vr,{text:o.text}),s.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null]}):null,i&&t.length===0&&!g?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"working",children:[((C=S.at(-1))==null?void 0:C.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??x??"Assistant"}):null,s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[v??`${u??x??"The agent"} is working`,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})]}):null,t.map(A=>s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx(Kh,{label:fs(A.name),tool:A.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((n-A.startedAt)/1e3)),opens:!1,onOpen:()=>r(A.toolUseId)})},A.toolUseId)),p,s.jsx("div",{ref:j})]})})}function I_(e){var t,n;return((n=(t=/ may delegate to ([^;]*);/.exec(e)??/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:n.trim())||null}const M_="delegation refused:";function $_(e,t,n){const r=o=>{const a=e[o];if(!a||a.type!=="tool_use"||a.name!==Ra)return null;const l=ng(n,a.id);if(!l||l.ok!==!1)return null;const c=typeof l.error=="string"?l.error:String(l.error??"");if(!c.trimStart().startsWith(M_))return null;const u=a.input??{};return{target:typeof u.agent=="string"&&u.agent!==""?u.agent:"a colleague",message:c}};if(!r(t))return null;if(r(t-1))return"inside";const i=[];for(let o=t;;o+=1){const a=r(o);if(!a)break;i.push(a)}return i.length<2?null:{refusals:i}}function __({refusals:e}){const[t,n]=d.useState(!1),r=e.map(l=>I_(l.message)).find(l=>l!==null)??null,i=e.map(l=>l.target),o=i.slice(0,3),a=`Delegation refused ${e.length} times: ${o.join(", ")}${i.length>o.length?", …":""}`+(r?` (allowed: ${r})`:"");return s.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>n(l=>!l),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:a}),s.jsx(Ae,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("div",{className:"wb-refusals-list",children:e.map((l,c)=>s.jsxs("div",{className:"wb-refusal",children:[s.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsxs("span",{className:"wb-tool-label",children:[fs(Ra)," · ",l.target]}),s.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),s.jsx("p",{className:"wb-refusal-why",children:l.message})]},c))}):null]})}function O_(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function Vh({text:e,live:t=!1,seconds:n=null}){const[r,i]=d.useState(!1),o=t?`Thinking${n!==null&&n>0?` · ${n}s`:""}`:n!==null&&n>0?`Thought for ${n}s`:"Thoughts";return s.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[s.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(a=>!a),children:[t?s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}):s.jsx(Ae,{name:"thought"}),s.jsx("span",{children:o}),s.jsx(Ae,{name:"arrow",className:"wb-tool-arrow"})]}),r?s.jsx("div",{className:"wb-thought-text",children:s.jsx(vr,{text:e})}):null]})}function D_(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",n=/You are a member of the group "[^"]*"\. @([\w-]+), the coordinator, asks you now:\n\n([\s\S]*?)(?:\n\nAnswer for the room|$)/.exec(t);return n?{handle:n[1],request:n[2].trim()}:null}function L_(e){return(e.blocks??[]).filter(t=>t.type==="text").map(t=>t.text.trim()).filter(t=>t!=="").join(`
|
|
96
|
-
|
|
97
|
-
`)}function F_(e,t){const n=[],r=new Set,i=o=>{r.has(o.artifactId)||(r.add(o.artifactId),n.push(o))};for(const o of e.blocks??[])if(o.type==="attachment"&&i(o),o.type==="tool_use"&&o.name===Ra){const a=ng(t,o.id);a!=null&&a.ok&&Mh(a.output).forEach(i)}return n}function U_(e,t){const n=t.filter(a=>a.startedAt!==null&&a.finishedAt!==null),r=(a,l)=>l.at!==""&&l.at>=a.startedAt&&l.at<=a.finishedAt,i=(a,l)=>a!==l&&a.startedAt>=l.startedAt&&a.finishedAt<=l.finishedAt&&(a.startedAt>l.startedAt||a.finishedAt<l.finishedAt),o=new Map;for(const a of n){if(a.stopped!=="max_turns"&&a.stopped!=="max_tokens"||a.noticed!==!0||a.runId===null)continue;let l=null;for(const c of e)c.role!=="assistant"||!r(a,c)||(l=c);l===null||n.some(c=>i(c,a)&&r(c,l))||o.has(l.id)||o.set(l.id,a)}return o}function B_(e){if(e.stopped==="max_tokens")return"Length limit reached · answer cut off";const t=e.turns;return t===null?"Turn budget reached":`Turn budget reached · ${t} ${t===1?"step":"steps"}`}function z_(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function W_({block:e}){const[t,n]=d.useState(!1),r=e.state==="succeeded";return s.jsxs("div",{className:"wb-approval","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":r,"aria-expanded":t,onClick:()=>n(i=>!i),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":r?"true":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":fs(e.name)}),s.jsx("span",{className:"wb-tool-elapsed",children:e.state}),s.jsx(Ae,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("pre",{className:"wb-approval-output mono",children:H_(e.output)}):null]})}function H_(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const V_=40;function K_(e){var n,r;if(((n=e.delegation)==null?void 0:n.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(Hh(e))return{status:"waiting",waiting:!0};const t=(r=e.approval)==null?void 0:r.state;return t?t==="approved"||t==="executing"?{status:"approved",waiting:!0}:t==="succeeded"?{status:"approved",waiting:!1}:{status:t,waiting:!1}:null}function Kh({label:e,tool:t,ok:n,running:r,elapsed:i,opens:o,onOpen:a,status:l,waiting:c=!1,approval:u=!1,gist:h=null,body:f=null}){const[p,x]=d.useState(!1),y=s.jsxs(s.Fragment,{children:[r?s.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):s.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":n===!1?"false":"true","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e}),h?s.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:h}):null,i===void 0?null:s.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),l||n===!1?s.jsx("span",{className:"wb-tool-elapsed",children:l??"failed"}):null]}),w={"data-ok":n===null?void 0:n,"data-running":r,"data-gist":h?!0:void 0,"data-approval":u||void 0};return f?s.jsxs("div",{className:"wb-toolcall","data-open":p||void 0,children:[s.jsxs("div",{className:"wb-tool","data-split":"true",...w,children:[s.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":p,onClick:()=>x(b=>!b),children:[s.jsx(Ae,{name:"chevron",className:"wb-tool-chevron"}),y]}),o?s.jsxs(Wc,{children:[s.jsx(Hc,{asChild:!0,children:s.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:a,children:s.jsx(Ae,{name:"arrow",className:"wb-tool-arrow"})})}),s.jsx(Vc,{children:s.jsxs(Kc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),p?s.jsx(G_,{body:f,onOpen:o?a:null}):null]}):o?s.jsxs(Wc,{children:[s.jsx(Hc,{asChild:!0,children:s.jsxs("button",{className:"wb-tool",...w,onClick:a,children:[y,s.jsx(Ae,{name:"arrow",className:"wb-tool-arrow"})]})}),s.jsx(Vc,{children:s.jsxs(Kc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):s.jsx("span",{className:"wb-tool","data-static":"true",...w,children:y})}function G_({body:e,onOpen:t}){const n=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return s.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:s.jsx(Yc,{text:e.diff,limit:V_,...n?{more:n}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:Y_(e.elapsedMs)].filter(i=>i!==null);return s.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[s.jsxs("div",{className:"wb-tool-command",children:[s.jsx("code",{className:"mono",children:e.command}),r.length>0?s.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?s.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function Y_(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function ng(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}const iS="approval-dock";function q_(){var t;const e=document.getElementById(iS);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const Q_=["workspace","cwd","workdir","root"];function X_({approvals:e,timezone:t,now:n,version:r,onDecided:i,onSay:o,onOpenFull:a}){const[l,c]=d.useState([]),u=e.filter(p=>!l.includes(p.approvalId)),h=u[0];if(!h)return null;const f=p=>c(x=>x.includes(p)?x:[...x,p]);return s.jsx(J_,{item:h,count:u.length,timezone:t,now:n,version:r,onSettled:p=>{f(h.approvalId),p&&i(p)},onSay:o,onOpenFull:()=>a(h.toolUseId)},h.approvalId)}function J_({item:e,count:t,timezone:n,now:r,version:i,onSettled:o,onSay:a,onOpenFull:l}){var C;const[c,u]=d.useState(null),[h,f]=d.useState(null),[p,x]=d.useState(null),[y,w]=d.useState("");d.useEffect(()=>{let A=!1;return T.approval(e.approvalId).then(E=>{A||(u(E),E.state!=="pending"&&o(E))}).catch(E=>{A||f(E instanceof oe?E.message:String(E))}),()=>{A=!0}},[e.approvalId,i]);const b=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;d.useEffect(()=>{b&&c&&o({...c,state:"expired"})},[b]);const{values:v,controls:m}=Ym(c==null?void 0:c.choices),j=(A,E)=>{const _=y.trim();x(A),f(null),(v&&A==="approve"?T.decide(e.approvalId,A,E,v):T.decide(e.approvalId,A,E)).then(L=>{o(L.action),_&&a(_)}).catch(L=>{f(L instanceof oe?L.message:String(L)),x(null)})},g=p!==null||c===null||c.state!=="pending",S=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,k=c?Zm(c.tool,c.canonicalArgs)??eO(c.preview):null,N=c?Z_(c):null;return s.jsxs("section",{id:iS,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?s.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,s.jsx("strong",{children:c?fs(c.tool):"Loading the request…"}),e.askedBy?s.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),k||N?s.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[k?s.jsx("code",{className:"wb-dock-gist",children:k}):null,N?s.jsxs("span",{className:"wb-dock-where",children:["in ",s.jsx("span",{className:"mono",children:N})]}):null]}):null,m?s.jsx("div",{className:"wb-dock-section",children:m}):null,s.jsx(re,{message:h}),s.jsx("div",{className:"wb-dock-section",children:s.jsx("input",{className:"wb-dock-instead",value:y,onChange:A=>w(A.target.value),onKeyDown:A=>{A.key==="Enter"&&A.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:p!==null})}),s.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[s.jsxs("span",{className:"wb-dock-meta",children:[c?s.jsxs(s.Fragment,{children:["Expires ",De(c.expiresAt,n)," · "]}):null,s.jsx("button",{type:"button",className:"wb-link",onClick:l,children:"See the full request on the Canvas"})]}),s.jsx(P,{variant:"ghost",size:"sm",disabled:g,onClick:()=>j("reject"),children:p==="reject"?"Rejecting…":"Reject"}),S?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",size:"sm",disabled:g,onClick:()=>j("approve","conversation"),children:"Auto: this conversation"}),s.jsx(P,{size:"sm",disabled:g,onClick:()=>j("approve","always"),children:"Always: this agent"})]}):null,s.jsx(P,{variant:"good",size:"sm",disabled:g,onClick:()=>j("approve"),children:p==="approve"?"Approving…":S?"Allow once":"Approve"})]})]})}function Z_(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const n of Q_){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function eO(e){const t=(e??"").split(`
|
|
98
|
-
`).map(n=>n.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const tO=2e3;function nO({conversationId:e,agentId:t,runId:n=null,result:r=null,waiting:i=null,agents:o=[]}){const a=r!==null,[l,c]=d.useState(a),u=!l||i!==null,{data:h,error:f}=ne(()=>_e.conversation(e),[e,l,(i==null?void 0:i.approvalId)??null],u?tO:void 0),p=(h==null?void 0:h.runs)??[],x=n===null?null:p.find(g=>g.runId===n)??null,y=a||i===null&&(n!==null?x!==null&&x.finishedAt!==null:p.length>0&&p.every(g=>g.finishedAt!==null));d.useEffect(()=>{y&&c(!0)},[y]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":y?"done":"working",b=o.find(g=>g.id===t)??null,v=(b==null?void 0:b.name)??(h==null?void 0:h.agentId)??t,m=(h==null?void 0:h.messages)??[],j=(r==null?void 0:r.text)??sO(m);return s.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":w,children:[s.jsxs("header",{className:"wb-delegate-head",children:[s.jsx(tn,{agents:o,id:t}),s.jsxs("div",{className:"wb-delegate-who",children:[s.jsx("strong",{children:v}),s.jsx("span",{className:"wb-delegate-status","data-status":w,role:"status",children:w==="working"?s.jsxs(s.Fragment,{children:["Working",s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]}):w==="waiting"?"Waiting for your approval":w==="failed"?"Failed":"Done"})]})]}),f?s.jsx("p",{className:"muted",children:f}):null,s.jsx("div",{className:"wb-delegate-work",children:m.map((g,S)=>s.jsx("div",{className:"wb-delegate-turn",children:(g.blocks??[]).map((k,N)=>{if(k.type==="thinking")return k.text.trim()===""?null:s.jsx(Vh,{text:k.text},N);if(k.type==="tool_use"){const C=iO(rO(m,k.id));return s.jsx(Kh,{label:fs(k.name),tool:k.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:Zm(k.name,k.input),opens:!1,onOpen:()=>{}},N)}return null})},g.id??S))}),j?s.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:s.jsx(vr,{text:j})}):w==="working"||w==="waiting"?s.jsxs("p",{className:"muted",children:[v," has not answered yet."]}):null,r!=null&&r.files&&r.files.length>0?s.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${v} made`,"data-testid":"delegate-files",children:r.files.map(g=>s.jsx("a",{role:"listitem",href:qr(g.artifactId),download:!0,children:s.jsx(eg,{name:g.filename??"Untitled file",mime:g.mime,sizeBytes:g.sizeBytes,thumbnail:Fk(g.mime)?yr(g.artifactId):null})},g.artifactId))}):null,s.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?s.jsx(P,{variant:"accent",onClick:()=>q_(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,s.jsx("a",{className:"ui-btn",href:Ue(t||(h==null?void 0:h.agentId)||"",e),children:"Open this conversation"})]})]})}function sO(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.role!=="assistant")continue;const r=(n.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
|
|
99
|
-
|
|
100
|
-
`);if(r!=="")return r}return null}function rO(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function iO(e){var n;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(n=e.approval)==null?void 0:n.state;return t==="pending"?{running:!1,ok:null,waiting:!0,status:"waiting approval"}:t==="approved"||t==="executing"?{running:!0,ok:null,waiting:!1,status:"running"}:t==="succeeded"?{running:!1,ok:!0,waiting:!1,status:void 0}:t?{running:!1,ok:!1,waiting:!1,status:t}:{running:!1,ok:e.ok,waiting:!1,status:void 0}}const fy=1024*1024;function oO({files:e,agentId:t,root:n,revision:r}){const[i,o]=d.useState({kind:"dir",path:""});return d.useEffect(()=>o({kind:"dir",path:""}),[e.plugin,t]),s.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?s.jsx(aO,{files:e,agentId:t,root:n,path:i.path,revision:r,go:o}):s.jsx(lO,{files:e,agentId:t,root:n,path:i.path,revision:r,go:o})})}function oS({root:e,path:t,go:n}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((o,a)=>({label:o,path:r.slice(0,a+1).join("/")}))];return s.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((o,a)=>{const l=a===i.length-1;return s.jsxs("span",{className:"wb-files-crumb",children:[a>0?s.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,l?s.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:o.label}):s.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>n({kind:"dir",path:o.path}),children:o.label})]},o.path)})})}function aO({files:e,agentId:t,root:n,path:r,revision:i,go:o}){const[a,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1),[p,x]=d.useState(null);d.useEffect(()=>{let b=!1;return u(null),T.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(v=>{b||l(v.data)}).catch(v=>{b||u(v instanceof Error?v.message:String(v))}),()=>{b=!0}},[e.plugin,e.list,t,r,i]),d.useEffect(()=>x(null),[r]);const y=async()=>{f(!0),x(null);try{const b=await fetch(T.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!b.ok){const g=await b.json().catch(()=>null);x((g==null?void 0:g.error)??"The archive could not be made.");return}const v=await b.blob(),m=URL.createObjectURL(v),j=document.createElement("a");j.href=m,j.download=`${r===""?n:r.split("/").at(-1)}.zip`,j.click(),window.setTimeout(()=>URL.revokeObjectURL(m),1e4)}catch{x("The archive could not be made.")}finally{f(!1)}},w=a&&a.path===r?a.entries:null;return s.jsxs(s.Fragment,{children:[s.jsxs(q,{children:[s.jsx(oS,{root:n,path:r,go:o}),s.jsx(xo,{}),s.jsx(P,{size:"sm",onClick:()=>void y(),disabled:h||w===null||w.length===0,children:h?"Packing…":"Download as archive"})]}),p?s.jsx(H,{tone:"warning",role:"alert",children:p}):null,c?s.jsx(H,{tone:"critical",role:"alert",children:c}):null,w===null?c?null:s.jsx(ie,{children:"Reading the folder…"}):w.length===0?s.jsx(ie,{children:r===""?s.jsxs(s.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",s.jsx("a",{href:Gr,children:"Files library"})," and mention it here."]}):"This folder is empty."}):s.jsx(Ut,{children:w.map(b=>s.jsx(Gt,{href:"#",onClick:()=>o({kind:b.kind,path:b.path}),lead:s.jsx(uO,{kind:b.kind}),title:s.jsxs("span",{className:"mono",children:[b.name,b.kind==="dir"?"/":""]}),side:b.kind==="file"?dn(b.bytes):void 0},b.path))}),a&&a.path===r&&(a.skipped>0||a.truncated)?s.jsxs("p",{className:"wb-files-note",children:[a.truncated?`Only the first ${a.entries.length} entries are shown. `:"",a.skipped>0?`${a.skipped} ${a.skipped===1?"entry is":"entries are"} not shown: symbolic links and protected paths are never read.`:""]}):null]})}function lO({files:e,agentId:t,root:n,path:r,revision:i,go:o}){const[a,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1);d.useEffect(()=>{let v=!1;return u(null),T.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(m=>{v||l(m.data)}).catch(m=>{v||u(m instanceof Error?m.message:String(m))}),()=>{v=!0}},[e.plugin,e.stat,t,r,i]);const p=a&&a.path===r?a:null,x=p?`${p.bytes}-${Math.round(p.mtimeMs)}`:"",y=p?T.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v:x}):"",w=T.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),b=(p==null?void 0:p.type)==="text"&&p.bytes<=fy;return s.jsxs(s.Fragment,{children:[s.jsxs(q,{children:[s.jsx(oS,{root:n,path:r,go:o}),s.jsx(xo,{}),b?s.jsx(P,{size:"sm","aria-pressed":h,onClick:()=>f(v=>!v),children:"Wrap"}):null,s.jsx(cn,{size:"sm",href:w,download:(p==null?void 0:p.name)??r.split("/").at(-1),children:"Download"})]}),c?s.jsx(H,{tone:"critical",role:"alert",children:c}):null,p===null?c?null:s.jsx(ie,{children:"Reading the file…"}):p.type==="image"?s.jsx("figure",{className:"wb-files-picture",children:s.jsx("img",{src:y,alt:p.name})}):p.type==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:y,type:"application/pdf","aria-label":p.name,children:s.jsx(H,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):b?s.jsx(cO,{src:y,wrap:h}):s.jsxs(s.Fragment,{children:[s.jsx(H,{children:p.type==="text"?`This file is over ${dn(fy)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),s.jsx(Pt,{items:[{label:"Size",value:dn(p.bytes)},{label:"Type",value:s.jsx("span",{className:"mono",children:p.mime})}]})]})]})}function cO({src:e,wrap:t}){const[n,r]=d.useState(null),[i,o]=d.useState(!1);return d.useEffect(()=>{let a=!1;return o(!1),fetch(e,{credentials:"same-origin"}).then(async l=>{if(!l.ok)throw new Error(String(l.status));const c=await l.text();a||r(c)}).catch(()=>{a||o(!0)}),()=>{a=!0}},[e]),i?s.jsx(H,{tone:"critical",children:"The file could not be read."}):n===null?s.jsx(ie,{children:"Reading the file…"}):n===""?s.jsx(ie,{children:"This file is empty."}):s.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:n})}function uO({kind:e}){return s.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:e==="dir"?s.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}const dO=3,fO=152,hO=104,pO=100,mO=2,hy=5;function gO({renderables:e,activeId:t,onActivate:n,timezone:r,onDecided:i,onChangeAgent:o,face:a,descriptors:l,grantedTools:c,agentName:u,maxTabs:h,browserPanel:f,agents:p,onClose:x,loading:y=!1}){const[w,b]=xO(h);if(e.length===0)return s.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[s.jsx("div",{className:"wb-canvas-tabs",ref:w,"aria-hidden":"true",children:s.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),s.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:y?null:s.jsxs("div",{className:"wb-empty",children:[a?s.jsx("span",{className:"wb-empty-face",children:a}):null,s.jsx("p",{className:"ui-empty wb-empty-line",children:bO(u,kO(l??[],c??[]))})]})})]});const v=e.some(g=>g.id===t)?t:e[e.length-1].id,{shown:m,hidden:j}=vO(e,v,b);return s.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:s.jsxs(ZP,{value:v,onValueChange:n,className:"contents",children:[s.jsxs("div",{className:"wb-canvas-tabs",ref:w,children:[s.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),s.jsx(eI,{className:"wb-tabstrip","aria-label":"Canvas",children:m.map(g=>s.jsxs("div",{className:"wb-tab-item",children:[s.jsxs(tI,{value:g.id,className:"wb-tab","data-tone":g.tone,onKeyDown:S=>{S.key==="Delete"&&x&&py(g)&&(S.preventDefault(),x(g.id))},children:[g.tone==="warning"||g.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":g.tone,"aria-hidden":"true"}):null,s.jsx("span",{className:"wb-tab-text",children:g.title})]}),x&&py(g)?s.jsx("button",{className:"wb-tab-close","aria-label":`Close ${g.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>x(g.id),children:"×"}):null]},g.id))}),s.jsx(yO,{items:j,onActivate:n,timezone:r})]}),e.map(g=>s.jsx(nI,{value:g.id,className:"wb-canvas-body","data-renderer":g.source==="descriptor"&&g.renderer==="preview"?"preview":void 0,"data-dense":NO.has(g.renderer)?"true":void 0,children:s.jsxs("section",{className:"ui-panel","data-flush":g.source==="descriptor"&&g.renderer==="preview"?"true":void 0,children:[g.source!=="browser"&&g.source!=="files"&&!(g.source==="descriptor"&&g.renderer==="preview")?s.jsxs("header",{className:"ui-panel-head",children:[s.jsx("h2",{className:"ui-panel-title",children:g.title}),s.jsx("span",{className:"ui-panel-tool mono",children:g.tool})]}):null,g.tone==="critical"?s.jsxs("p",{className:"muted",children:["Recorded tool failure",g.at?` · ${new Date(g.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,g.source==="browser"?f:g.source==="profile"?s.jsx(B$,{...g.props,...o?{onChange:o}:{}}):g.source==="artifact"?s.jsx(f_,{...g.props}):g.source==="files"?s.jsx(oO,{...g.props}):g.source==="delegate"?s.jsx(nO,{...g.props,agents:p??[]}):s.jsx(U$,{renderer:g.renderer,props:g.props,timezone:r,onDecided:i})]})},g.id))]})})}function py(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function xO(e){const[t,n]=d.useState(hy),r=d.useRef(null);return[d.useCallback(o=>{var l;if((l=r.current)==null||l.disconnect(),r.current=null,!o||e!==void 0||typeof ResizeObserver>"u")return;const a=()=>{const c=o.clientWidth;if(c===0)return;const u=Math.floor((c-pO-hO)/fO);n(Math.max(mO,Math.min(hy,u)))};a(),r.current=new ResizeObserver(a),r.current.observe(o)},[e]),e??t]}function vO(e,t,n){const r=new Set(e.filter(o=>o.id===t||o.source==="approval"||o.pinned===!0).map(o=>o.id)),i=new Set(r);for(let o=e.length-1;o>=0&&i.size<n;o-=1)i.add(e[o].id);return{shown:e.filter(o=>i.has(o.id)),hidden:e.filter(o=>!i.has(o.id))}}function yO({items:e,onActivate:t,timezone:n}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return s.jsxs(Tm,{modal:!1,children:[s.jsx(Pm,{asChild:!0,children:s.jsxs("button",{className:"wb-tab wb-tab-more","data-tone":r??void 0,"aria-label":`${e.length} more ${e.length===1?"view":"views"} in this conversation`,children:[r?s.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,s.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),s.jsx(Ae,{name:"chevron-down"})]})}),s.jsx(Im,{children:s.jsxs(Mm,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[s.jsx($m,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>s.jsxs(Ch,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[s.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),s.jsx("span",{className:"ui-menu-note mono",children:jO(i.at,n)??i.tool})]},i.id))]})})]})}function jO(e,t){if(!e)return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit"}).format(n)}const wO={timeseries:"charts",table:"tables",bars:"comparisons",keyvalue:"figures",document:"pages it read",diff:"diffs",terminal:"command output",image:"pictures",preview:"running apps",envelope:"drafts",structured:"results"};function bO(e,t){const n=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>wO[i.renderer]??"results"))].slice(0,3);return r.length>0?`${n} lands here: ${r.join(", ")}.`:`${n} lands here.`}function kO(e,t){const n=new Set(t),r=new Set,i=e.filter(c=>{if(!n.has(c.tool))return!1;const u=SO(c);return r.has(u)?!1:(r.add(u),!0)}),o=new Set,a=i.filter(c=>o.has(c.renderer)?!1:(o.add(c.renderer),!0)),l=i.filter(c=>!a.includes(c));return[...a,...l].slice(0,dO)}function SO(e){return e.title&&e.title.trim()!==""?e.title:e.tool.split(".").map(t=>t.replace(/[_-]+/g," ")).join(" · ").replace(/\b\w/,t=>t.toUpperCase())}const NO=new Set(["table","diff","files"]),CO=3.5*6e4,EO=2e3;function AO(e,t,n={}){const[r,i]=d.useState({served:new Set,live:new Set,scope:t}),o=d.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};o.current=u.served,i(u)}const a=n.check??T.previewCheck,l=n.everyMs??EO,c=e.map(u=>`${Bi(u)}@${u.at??""}`).join("|");return d.useEffect(()=>{const u=new Map;for(const x of e){const y=Bi(x);if(o.current.has(y))continue;const w=x.at===null?Number.NaN:Date.parse(x.at),b=Number.isNaN(w)?0:w+CO,v=u.get(y);(!v||b>v.until)&&u.set(y,{plugin:x.plugin,name:x.name,until:b})}if(u.size===0)return;let h=!1,f;const p=async()=>{const x=Date.now();for(const[y,w]of[...u]){const b=await a(w.plugin,w.name).catch(()=>null);if(h)return;const v=x<=w.until;b!=null&&b.ok?(u.delete(y),i(m=>{const j={served:new Set(m.served).add(y),live:v?new Set(m.live).add(y):m.live,scope:m.scope};return o.current=j.served,j})):v||u.delete(y)}!h&&u.size>0&&(f=setTimeout(()=>void p(),l))};return p(),()=>{h=!0,f!==void 0&&clearTimeout(f)}},[c,t,a,l]),r}const Gh="workspace-files";function RO(e){let t=0;for(const n of e)for(const r of n.blocks??[]){if(r.type!=="tool_result"||r.ok===!1)continue;const i=r.output;if(i===null||typeof i!="object"||Array.isArray(i))continue;const{diff:o,path:a}=i;typeof o=="string"&&o.trim()!==""&&typeof a=="string"&&a!==""&&(t+=1)}return t}function TO(e){const[t,n]=d.useState(null);return d.useEffect(()=>{if(n(null),!e)return;let r=!1;return(async()=>{var o;const i=await T.pages();for(const a of Array.isArray(i==null?void 0:i.files)?i.files:[]){const l=await T.pageQuery(a.plugin,a.workspace,{agent:e}).catch(()=>null),c=(o=l==null?void 0:l.data)==null?void 0:o.workspace;if(c&&typeof c.name=="string")return{files:a,agentId:e,root:c.name}}return null})().then(i=>{r||n(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function PO(e,t){return{id:Gh,tool:"",title:"Files",renderer:"files",props:{files:e.files,agentId:e.agentId,root:e.root,revision:t},at:null,source:"files",pinned:!0,substantial:!1}}function Yh(e){return`agent-properties:${e}`}function IO(e){return{id:Yh(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function MO(e){return!e||e.download===0?"Fetching the browser…":e.phase==="downloading"?`Fetching ${e.what}… ${e.percent}%`:e.phase==="installing"?`Setting up ${e.what}…`:e.phase==="done"?"Installed.":"The install stopped."}function aS({progress:e}){return s.jsxs(V,{gap:"sm",children:[s.jsx("span",{role:"status",children:MO(e)}),s.jsx(_k,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function $O(e,t,n,r){const i=e.width||1,o=e.height||1,a=t.pageScaleFactor||1,l=(n-e.left)*(t.deviceWidth/i)/a,c=((r-e.top)*(t.deviceHeight/o)-t.offsetTop)/a,u=(h,f)=>Math.max(0,Math.min(Math.round(h),Math.round(f)));return{x:u(l,t.deviceWidth),y:u(c,t.deviceHeight)}}function Jd(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function my(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const _O=4e3;function OO(e){return e.replace(/\r\n?/g,`
|
|
101
|
-
`).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,_O)}const DO=["left","middle","right"],LO=33;function FO(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function UO(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const n=t.getUint16(1);if(e.byteLength<3+n)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,n))),jpeg:new Blob([new Uint8Array(e,3+n)],{type:"image/jpeg"})}}catch{return null}}function BO(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function zO({sessionId:e,csrf:t,onGiveBack:n,connect:r}){const[i,o]=d.useState("connecting"),[a,l]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,x]=d.useState(!1),[y,w]=d.useState(0),b=d.useRef(null),v=d.useRef(null),m=d.useRef(null),j=d.useRef({at:0});d.useEffect(()=>{const R=r??(G=>new WebSocket(G));let O=!0,Y;try{Y=R(BO())}catch{o("lost");return}return Y.binaryType="arraybuffer",b.current=Y,Y.onopen=()=>Y.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),Y.onmessage=G=>{if(!O)return;if(typeof G.data!="string"){const W=UO(G.data);if(!W||(f($=>$&&FO($,W.metadata)?$:W.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(W.jpeg).then($=>{var ce,Ce,J;const ee=v.current;if(!O||!ee){(ce=$.close)==null||ce.call($);return}(ee.width!==$.width||ee.height!==$.height)&&(ee.width=$.width,ee.height=$.height),(Ce=ee.getContext("2d"))==null||Ce.drawImage($,0,0),(J=$.close)==null||J.call($)}).catch(()=>{});return}const M=JSON.parse(G.data);if(M.type==="driving"){o("driving"),l(null);return}(M.type==="refused"||M.type==="ended")&&(l(M.error??"The screen cannot be driven from here."),o("refused"))},Y.onclose=()=>{O&&o(G=>G==="refused"?G:"lost")},Y.onerror=()=>{O&&o(G=>G==="refused"?G:"lost")},()=>{O=!1,b.current=null;try{Y.close()}catch{}}},[e,t,y,r]),d.useEffect(()=>()=>{clearTimeout(j.current.timer)},[]);const g=d.useCallback(R=>{const O=b.current;if(O)try{O.send(JSON.stringify({type:"input",input:R}))}catch{}},[]),S=R=>{var G;const O=v.current;if(!O||!h)return null;const Y=(G=O.getBoundingClientRect)==null?void 0:G.call(O);return Y?$O(Y,h,R.clientX,R.clientY):null},k=R=>{const O=j.current,Y=Date.now();clearTimeout(O.timer),O.timer=void 0;const G=O.at+LO-Y;if(G<=0){O.at=Y,O.pending=void 0,g(R);return}O.pending=R,O.timer=setTimeout(()=>{const M=j.current.pending;j.current.timer=void 0,j.current.pending=void 0,j.current.at=Date.now(),M&&g(M)},G)},N=()=>{const R=j.current;clearTimeout(R.timer),R.timer=void 0;const O=R.pending;R.pending=void 0,O&&(R.at=Date.now(),g(O))},C=R=>O=>{var M,W;const Y=S(O);if(!Y)return;R==="mousePressed"&&(O.preventDefault(),(W=(M=v.current)==null?void 0:M.focus)==null||W.call(M));const G={kind:"mouse",type:R,x:Y.x,y:Y.y,button:DO[O.button]??"left",clickCount:R==="mouseMoved"?0:Math.min(3,Math.max(1,O.detail||1)),modifiers:Jd(O)};if(R==="mouseMoved"){k(G);return}N(),g(G)},A=R=>{const O=S(R);O&&(N(),g({kind:"wheel",x:O.x,y:O.y,deltaX:Math.round(R.deltaX),deltaY:Math.round(R.deltaY)}))},E=R=>R.ctrlKey||R.metaKey||R.altKey,_=R=>{var Y,G;if(R.key==="Escape"&&E(R)){x(!1),(G=(Y=R.target).blur)==null||G.call(Y);return}if(R.preventDefault(),(R.metaKey||R.ctrlKey)&&(R.key==="v"||R.key==="V"))return;const O=Jd(R);if(my(R.key)&&!E(R)){g({kind:"key",type:"char",key:R.key,code:R.code,text:R.key,modifiers:O});return}g({kind:"key",type:"keyDown",key:R.key,code:R.code,modifiers:O})},L=R=>{R.key==="Escape"&&E(R)||(R.preventDefault(),!((R.metaKey||R.ctrlKey)&&(R.key==="v"||R.key==="V"))&&(my(R.key)&&!E(R)||g({kind:"key",type:"keyUp",key:R.key,code:R.code,modifiers:Jd(R)})))},B=R=>{var Y;R.preventDefault();const O=OO(((Y=R.clipboardData)==null?void 0:Y.getData("text/plain"))??"");O!==""&&g({kind:"text",text:O})};return s.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[s.jsxs("div",{className:"hand-bar",children:[s.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),s.jsxs(q,{align:"end",children:[s.jsx(P,{size:"sm",variant:p?"accent":"ghost","aria-pressed":p,onClick:()=>{var O,Y,G,M;const R=!p;x(R),R?(Y=(O=m.current)==null?void 0:O.focus)==null||Y.call(O):(M=(G=m.current)==null?void 0:G.blur)==null||M.call(G)},children:"Keyboard"}),s.jsx(P,{size:"sm",variant:"accent",onClick:n,children:"Give it back"})]})]}),i==="lost"?s.jsxs(H,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",s.jsx(q,{align:"end",children:s.jsx(P,{size:"sm",variant:"accent",onClick:()=>{o("connecting"),w(R=>R+1)},children:"Reconnect"})})]}):null,i==="refused"&&a?s.jsx(H,{tone:"warning",role:"status",children:a}):null,s.jsx("div",{className:"hand-screen",children:c?s.jsx("canvas",{ref:v,className:"hand-picture",role:"img","aria-label":"The host browser, live","data-testid":"hand-picture",tabIndex:0,onMouseDown:C("mousePressed"),onMouseUp:C("mouseReleased"),onMouseMove:C("mouseMoved"),onWheel:A,onKeyDown:_,onKeyUp:L,onPaste:B,onContextMenu:R=>R.preventDefault()}):s.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),s.jsx("input",{ref:m,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:_,onKeyUp:L,onPaste:B,onBlur:()=>x(!1)})]})}function WO(e){return e==="darwin"?"this Mac":"this computer"}let Zd=null;function sg(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{let n=!0;return Zd??(Zd=T.session().then(r=>r.platform,()=>{Zd=null})),Zd.then(r=>{n&&t(r)}),()=>{n=!1}},[]),WO(e)}function HO({embedded:e,timezone:t}={}){var c;const{data:n,error:r,reload:i}=ne(()=>T.browser(),[],3e3),o=ne(()=>T.session(),[]),a=(c=o.data)!=null&&c.platform?o.data.platform==="darwin":!0,l=!!o.data||!!o.error;return s.jsxs(fn,{embedded:e,title:"Computer & browser",children:[s.jsx(re,{message:r}),!n||!l?s.jsx(ie,{children:"Checking the host…"}):s.jsx(VO,{data:n,macOS:a,reload:i,timezone:t},JSON.stringify(n.settings??null))]})}function VO({data:e,macOS:t,reload:n,timezone:r}){var N,C,A;const[i,o]=d.useState(!1),[a,l]=d.useState(null),[c,u]=d.useState(!1),h=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,f=(h==null?void 0:h.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),p=f==="computer",x=(N=e.sessions)!=null&&N.length?e.sessions:e.session?[e]:[],y=x.length>0||e.busy,w=async E=>{o(!0),l(null);try{await E()}catch(_){l(_ instanceof Error?_.message:String(_))}finally{o(!1),n()}},b=E=>void w(()=>T.browserSettings(E)),v=e.permissions,m=f==="playwright"?e.browser:void 0,j=((C=m==null?void 0:m.install)==null?void 0:C.state)==="running",g=(m==null?void 0:m.engine)==="none",S=!!e.enabled&&!g&&!(m!=null&&m.problem)&&(!p||!(v!=null&&v.supported)||v.accessibility&&v.screenRecording),k=p?"Ready. Agents can use your computer within the apps you allow below.":f==="extension"?"Ready. Agents work in your Chrome, in background tabs, through the buddi extension.":(m==null?void 0:m.engine)==="chrome"?"Ready. Agents work in their own browser, a separate Google Chrome profile. Your apps are never touched.":"Ready. Agents work in their own browser. Your apps are never touched.";return s.jsxs(V,{gap:"lg",children:[s.jsx(re,{message:a}),s.jsx(K,{title:"Status",panel:!0,actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",disabled:i,onClick:()=>void w(()=>T.computerPermissions(!1)),children:"Check again"}),p&&!S&&(v!=null&&v.supported)?s.jsx(P,{size:"sm",variant:"accent",disabled:i||y,onClick:()=>void w(()=>T.computerPermissions(!0)),children:"Request macOS permissions"}):null,g||j?s.jsx(P,{size:"sm",variant:"accent",disabled:i||j,onClick:()=>void w(()=>T.browserInstall()),children:j?"Installing…":"Install Chromium"}):null]}),children:s.jsxs(V,{children:[e.enabled?g?s.jsxs(H,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",s.jsx("code",{children:"buddi browser install"})," on this machine."]}):m!=null&&m.problem?s.jsx(H,{tone:"warning",children:m.message}):S?s.jsx(H,{tone:"good",children:k}):s.jsx(H,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):s.jsx(H,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),p?v!=null&&v.supported?s.jsxs("ul",{className:"perm-list",children:[s.jsxs("li",{className:"perm-row",children:[s.jsx(ve,{tone:v.accessibility?"good":"warning",children:v.accessibility?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Accessibility"}),s.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),s.jsxs("li",{className:"perm-row",children:[s.jsx(ve,{tone:v.screenRecording?"good":"warning",children:v.screenRecording?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Screen Recording"}),s.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):v?s.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,((A=m==null?void 0:m.install)==null?void 0:A.state)==="running"?s.jsx(aS,{progress:m.install.progress}):m!=null&&m.install?s.jsx("p",{className:"muted",role:"status",children:m.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${m.install.line??"no reason given"}`}):null,m!=null&&m.headless&&!g?s.jsx("p",{className:"muted",children:"The agents’ browser runs headless on this machine, since it has no display. Watch it and take over from the conversation’s Canvas."}):null,p&&(v!=null&&v.message)?s.jsx("p",{className:"muted",children:v.message}):null,p&&(v!=null&&v.supported)&&!S?s.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),s.jsx(K,{title:"Who is driving",panel:!0,actions:x.length>0?s.jsx(P,{variant:"danger",size:"sm",disabled:i,onClick:()=>void w(()=>T.browserControl("stop")),children:p?"Stop computer control":"Stop all browsers"}):void 0,children:x.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nobody right now. Ask an agent to open a website or one of the allowed apps, and you will see it working on that conversation’s Canvas."}):s.jsx("div",{className:"ui-list",children:x.map(E=>s.jsxs("a",{className:"ui-list-row",href:Ue(E.session.agentId,E.session.conversationId),children:[s.jsx(vs,{id:E.session.agentId,name:E.session.agentId,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:E.session.task}),s.jsxs("span",{className:"ui-list-sub",children:[E.session.agentId,", ",E.busy?"working":E.state,", ",E.session.steps," of ",E.session.maxSteps," steps"]})]}),s.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},E.session.id))})}),h?s.jsxs(s.Fragment,{children:[s.jsx(K,{title:"How agents get a screen",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?s.jsx(ef,{current:h.mode,value:"computer",disabled:i||y||!e.enabled,title:"Use my apps",body:"Agents work in your own windows, signed in as you, in the browser profile you choose below. One agent at a time. Releasing control leaves everything open.",onPick:()=>b({...h,mode:"computer"})}):null,s.jsx(ef,{current:h.mode,value:"playwright",disabled:i||y||!e.enabled,title:"Give agents their own browser",body:"A separate browser profile with its own tabs, one per conversation. Your apps are never touched.",onPick:()=>b({...h,mode:"playwright"})}),s.jsx(ef,{current:h.mode,value:"extension",disabled:i||y||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>b({...h,mode:"extension"})})]}),t?null:s.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),y?s.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,h.mode==="extension"?s.jsx(qO,{busy:i,timezone:r}):null]})}),t?s.jsx(K,{title:"Apps agents may use",panel:!0,children:s.jsxs(V,{children:[h.mode!=="computer"?s.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,s.jsx(QO,{settings:h,disabled:i||y||!e.enabled,onChange:b,onAdd:()=>u(!0)}),s.jsx(Et,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Agents see what is on screen in these apps, and what they see goes to the agent’s model provider. Allow only apps you want operated."}),s.jsx("p",{children:"Never type a password or a sign-in code in chat. Sign in yourself, in the app, while you have taken over."}),s.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?s.jsx(tD,{chosen:h.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),h.allowedApps.includes(E)||b({...h,allowedApps:[...h.allowedApps,E]})}}):null]}):null]})}const KO="kmbckpnnjfggeffkkbmkggojnolkdokb";async function GO(){var e;try{if(typeof chrome>"u"||!((e=chrome==null?void 0:chrome.runtime)!=null&&e.sendMessage))return null;const t=await chrome.runtime.sendMessage(KO,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function YO(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function qO({busy:e,timezone:t}){const{data:n,error:r,reload:i}=ne(()=>T.extension(),[],3e3),o=sg(),a=ne(()=>GO(),[],3e3).data??null,[l,c]=d.useState(""),[u,h]=d.useState(!1),[f,p]=d.useState(null),x=(a==null?void 0:a.state)==="pairing"?a.code??"":"";d.useEffect(()=>{x&&c(x)},[x]);const y=async m=>{h(!0),p(null);try{await m()}catch(j){p(j instanceof Error?j.message:String(j))}finally{h(!1),i()}},w=e||u,b=t??Intl.DateTimeFormat().resolvedOptions().timeZone,v=s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),s.jsx(ft,{label:"The unpacked extension",children:(n==null?void 0:n.path)??"…"})]});return s.jsxs(V,{divided:!0,children:[s.jsx(re,{message:r??f}),s.jsxs(q,{children:[s.jsx(ve,{tone:n!=null&&n.connected?"good":"warning",children:n!=null&&n.connected?"Connected":"Not connected"}),s.jsxs("span",{className:"muted",children:[n!=null&&n.connected&&n.pairedAt?`Paired with Chrome on ${o} since ${De(n.pairedAt,b)}`:n!=null&&n.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",n!=null&&n.extension?` · extension ${n.extension}`:""]})]}),s.jsxs(V,{children:[s.jsxs("p",{className:"muted",children:[a?`The browser you are reading this in has the extension, version ${a.version}.`:n!=null&&n.connected?"The browser you are reading this in has no buddi extension. You only need it here to pair this browser instead.":"The browser you are reading this in has no buddi extension yet.",(a==null?void 0:a.state)==="paired"?" It is already paired with a buddi.":"",(a==null?void 0:a.state)==="disconnected"?" It is not connected yet: press Connect in its popup.":""]}),a&&!YO(a.gateway)?s.jsx(H,{tone:"warning",children:`The extension is pointed at ${a.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),n!=null&&n.pending?s.jsxs(q,{valign:"end",children:[s.jsx(X,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:s.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:l,onChange:m=>c(m.target.value)})}),s.jsx(xo,{}),s.jsx(P,{variant:"accent",disabled:w||l.replace(/[^0-9]/g,"").length!==6,onClick:()=>void y(async()=>{await T.pairExtension(l),c("")}),children:"Pair"})]}):null,n!=null&&n.connected?s.jsx(Et,{summary:"Pair a different browser",children:v}):v,s.jsx(q,{align:"end",children:s.jsx(P,{variant:"danger",disabled:w||!(n!=null&&n.pairedAt),onClick:()=>void y(()=>T.forgetExtension()),children:"Forget this browser"})})]})}function ef({current:e,value:t,title:n,body:r,disabled:i,onPick:o}){const a=e===t;return s.jsxs("button",{type:"button",role:"radio","aria-checked":a,className:"mode-option",disabled:i,onClick:()=>{a||o()},children:[s.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),s.jsxs("span",{className:"mode-option-text",children:[s.jsx("span",{className:"mode-option-title",children:n}),s.jsx("span",{className:"mode-option-body",children:r})]})]})}function QO({settings:e,disabled:t,onChange:n,onAdd:r}){const i=ne(()=>T.installedApps(),[]),o=a=>{var l,c;return((c=(l=i.data)==null?void 0:l.apps.find(u=>u.id===a))==null?void 0:c.name)??a};return s.jsxs(s.Fragment,{children:[e.allowedApps.length===0?s.jsx(ie,{children:"No apps yet. Agents cannot touch anything until you add one."}):s.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(a=>s.jsxs("li",{className:"ui-list-row",children:[s.jsx(vs,{id:a,name:o(a),size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[o(a),a===e.browserApp?s.jsx(ve,{tone:"accent",className:"app-role",children:"browser"}):null]}),s.jsx("span",{className:"ui-list-sub mono",children:a})]}),s.jsxs(q,{children:[a!==e.browserApp&&eD(a)?s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,browserApp:a}),children:"Use as browser"}):null,a===e.browserApp?s.jsx("span",{className:"muted",children:"In use as the browser"}):s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,allowedApps:e.allowedApps.filter(l=>l!==a)}),children:"Remove"})]})]},a))}),s.jsxs(q,{children:[s.jsx(P,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),s.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&XO.includes(e.browserApp)?s.jsx(JO,{settings:e,disabled:t,onChange:n}):null]})}const XO=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function JO({settings:e,disabled:t,onChange:n}){var a;const i=((a=ne(()=>T.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:a.profiles)??[],o=e.browserProfile?i.some(l=>l.directory===e.browserProfile):!0;return s.jsx(X,{label:"Browser profile",hint:e.browserProfile?"Websites open in this profile, signed in as it is.":"Not chosen: websites open in whichever profile’s window is in front, or the last one you used.",children:s.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:l=>{const{browserProfile:c,...u}=e;n(l.target.value?{...u,browserProfile:l.target.value}:u)},children:[s.jsx("option",{value:"",children:"Whichever is in front"}),!o&&e.browserProfile?s.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(l=>s.jsxs("option",{value:l.directory,children:[l.name,l.directory==="Default"?"":` (${l.directory})`]},l.directory))]})})}const ZO=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function eD(e){return ZO.includes(e)}function tD({chosen:e,onClose:t,onPick:n}){const r=ne(()=>T.installedApps(),[]),[i,o]=d.useState(""),[a,l]=d.useState(""),c=d.useMemo(()=>{var f;const u=((f=r.data)==null?void 0:f.apps)??[],h=i.trim().toLowerCase();return u.filter(p=>!h||p.name.toLowerCase().includes(h)||p.id.toLowerCase().includes(h)).slice(0,60)},[r.data,i]);return s.jsxs(Qt,{title:"Add an app",onClose:t,children:[s.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>o(u.target.value)}),s.jsx(re,{message:r.error}),r.data?c.length===0?s.jsx(ie,{children:"No app matches."}):s.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const h=e.includes(u.id);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx(vs,{id:u.id,name:u.name,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:u.name}),s.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),s.jsx(P,{size:"sm",disabled:h,onClick:()=>n(u.id),children:h?"Allowed":"Allow"})]},u.id)})}):s.jsx(ie,{children:"Reading your Applications folder…"}),s.jsx(Et,{summary:"Add by bundle identifier instead",children:s.jsxs(q,{children:[s.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:a,onChange:u=>l(u.target.value)}),s.jsx(P,{disabled:!a.trim(),onClick:()=>n(a.trim()),children:"Allow this identifier"})]})})]})}function nD({data:e,error:t,reload:n,compact:r=!1,refresh:i,screenshotSrc:o,onScreenshotError:a,onScreenshotLoad:l,controls:c=!0}){var A,E,_;const[u,h]=d.useState(!1),[f,p]=d.useState(null),[x,y]=d.useState(null),[w,b]=d.useState(null),v=async L=>{h(!0),p(null),b(null);try{const B=L!=="stop"&&(e!=null&&e.session)?await T.browserControl(L,e.session.id):await T.browserControl(L);L==="takeover"?B.hand&&B.session?y(B.session.id):b(B.handMessage??null):y(null)}catch(B){p(B instanceof Error?B.message:String(B))}finally{h(!1),n()}},m=x&&((A=e==null?void 0:e.session)==null?void 0:A.id)===x&&e.state==="paused"?x:null,j=!!(e!=null&&e.enabled)&&!u,g=(e==null?void 0:e.mode)==="computer",S=(e==null?void 0:e.mode)==="extension",k=g?"Stop computer control interrupts native input and revokes access. Take over pauses agent input. Release ends this conversation’s control without closing your apps. Already dispatched actions cannot be undone. Avoid using the same mouse and keyboard while the agent is working.":"Stop all browsers closes every session and revokes access until you resume. Take over, Resume and Close & release affect only the selected conversation. An in-flight action is interrupted by closing its tabs. Actions already submitted cannot be undone.",N=e!=null&&e.busy?"Working":(e==null?void 0:e.state)==="running"?"Ready":(e==null?void 0:e.state)??"Connecting",C=e!=null&&e.busy||(e==null?void 0:e.state)==="running"?"good":(e==null?void 0:e.state)==="stopped"||(e==null?void 0:e.state)==="error"?"critical":void 0;return s.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[s.jsxs("div",{className:"browser-heading",children:[s.jsxs("div",{children:[r?null:s.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),s.jsx("h2",{className:"browser-title",children:g?"Computer":S?"Your browser":"Browser"})]}),s.jsx(ve,{tone:C,children:s.jsx("span",{role:"status",children:N})})]}),r?s.jsx("a",{className:"browser-full-view",href:"#/browser",children:g?"Open computer view & settings ↗":"Open full browser view ↗"}):s.jsx("p",{className:"ui-page-lede",children:g?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":S?"Your own Chrome, signed in as you, working in background tabs grouped as “buddi”. You keep browsing.":"A real browser window, driven by your assistant. You stay in control."}),s.jsx(re,{message:t??f}),c?s.jsxs(q,{children:[s.jsx(P,{variant:"danger",disabled:!j||(e==null?void 0:e.state)==="stopped",onClick:()=>void v("stop"),children:g?"Stop computer control":"Stop all browsers"}),s.jsx(P,{disabled:!j||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void v("takeover"),children:"Take over"}),s.jsx(P,{disabled:!j||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void v("resume"),children:"Resume access"}),s.jsx(P,{disabled:!j||!(e!=null&&e.session),onClick:()=>void v("release"),children:g?"Release control":"Close & release"})]}):null,c?r?s.jsx(Et,{summary:"About these controls",children:s.jsx("p",{className:"muted",children:k})}):s.jsx("p",{className:"muted",children:k}):null,w?s.jsx(H,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!m?s.jsx(H,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?s.jsxs("div",{className:"browser-task",children:[s.jsxs("div",{className:"ui-row",children:[s.jsx("strong",{children:e.session.agentId}),s.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:s.jsx("p",{children:e.session.task}),s.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",new Date(e.session.expiresAt).toLocaleTimeString()]})]}):s.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?g?"No agent is driving. Ask an agent granted browser.* to open a website or an allowed native app.":"No agent is driving. Ask an agent granted browser.* to open a website.":"The host browser is unavailable. Start buddi serve on a machine with a desktop session."}),m?s.jsx(zO,{sessionId:m,csrf:ei(),onGiveBack:()=>void v("resume")}):null,s.jsxs("div",{className:"browser-window",hidden:!!m,children:[s.jsxs("div",{className:"browser-address",children:[s.jsx("span",{"aria-hidden":"true",children:"◉"}),s.jsx("span",{children:((E=e==null?void 0:e.page)==null?void 0:E.url)??(g?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?s.jsxs("figure",{children:[s.jsx("img",{src:o??`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:""}${i?`&tick=${i}`:""}`,alt:`Last browser observation: ${e.page.title||e.page.url}`,...a?{onError:a}:{},...l?{onLoad:l}:{}},o??e.page.id),s.jsxs("figcaption",{children:["Last observation · ",new Date(e.page.capturedAt).toLocaleTimeString()," · ",e.page.title||"Untitled page"]})]}):s.jsxs("div",{className:"browser-empty",children:[s.jsx("strong",{children:g?"Your selected app will appear here":"Your browser activity will appear here"}),s.jsx("p",{children:g?"Only the selected app window is captured, not the whole desktop. This preview is not interactive.":"This is a view of the host browser, not a second browser or a remote desktop."})]})]}),(((_=e==null?void 0:e.page)==null?void 0:_.tabs.length)??0)>1?s.jsx(Et,{summary:`${e.page.tabs.length} open tabs`,children:s.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(L=>s.jsxs("li",{children:[L.title||L.id," — ",L.url]},L.id))})}):null,s.jsxs("p",{className:"muted",children:[g?"Sign in directly in the host app during takeover. Don’t send passwords or MFA codes in chat. Native apps retain your existing logins and documents. Secure accessibility fields are masked; other sensitive window content can still appear in screenshots.":"Sign in directly in this conversation’s host tab during takeover. Don’t send passwords or MFA codes in chat. Agent tabs share saved logins and cookies."," ",m?"While you are driving this is a live view of the page; nothing you type is kept.":"Screenshots update after agent actions; this is not a live video feed."]})]})}const sD=2e3,rD=5;function iD(e,t){if(!e.hasScreenshot||!e.page)return null;const n=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${n}`}function oD({status:e,error:t,reload:n,steps:r,live:i,focusedStepId:o=null}){var j;const[a,l]=d.useState(0),[c,u]=d.useState(0),h=c>=rD;d.useEffect(()=>{if(!i||h)return;const g=window.setInterval(()=>{typeof document<"u"&&document.hidden||l(S=>S+1)},sD);return()=>window.clearInterval(g)},[i,h]);const f=d.useRef(null);i&&(e!=null&&e.session)&&(f.current=e);const[p,x]=d.useState(null),y=d.useRef(null),w=((j=e==null?void 0:e.page)==null?void 0:j.id)??null;d.useEffect(()=>{const g=i&&e?iD(e):null;if(!g||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let S=!1;return(async()=>{try{const k=await fetch(g);if(!k.ok||S)return;const N=await k.blob();if(S)return;const C=URL.createObjectURL(N);y.current&&URL.revokeObjectURL(y.current),y.current=C,x(C)}catch{}})(),()=>{S=!0}},[i,w]),d.useEffect(()=>()=>{y.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(y.current)},[]);const b=f.current,v=i?e:b?p?b:{...b,hasScreenshot:!1}:e,m=r.at(-1)??null;return s.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[s.jsx(nD,{data:v,error:t,reload:n,compact:!0,controls:i,...i?{refresh:a}:{},...!i&&p?{screenshotSrc:p}:{},onScreenshotError:()=>u(g=>g+1),onScreenshotLoad:()=>u(0)}),i?h?s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"This session has ended. What is on this panel is the last thing it showed."}),s.jsx(aD,{steps:r,newestId:(m==null?void 0:m.id)??null,focusedId:o??null,live:i})]})}function aD({steps:e,newestId:t,focusedId:n,live:r}){const i=d.useRef(null);return d.useEffect(()=>{var a;if(!n||!i.current)return;const o=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(n):n}"]`);(a=o==null?void 0:o.scrollIntoView)==null||a.call(o,{block:"nearest"})},[n]),e.length===0?s.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):s.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:s.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((o,a)=>{const l=o.awaiting?"awaiting":o.ok===null?"running":o.ok?"ok":"failed";return s.jsxs("li",{"data-step":o.id,className:"wb-browser-step","data-state":l,"data-newest":o.id===t?"true":void 0,"data-focused":o.id===n?"true":void 0,children:[s.jsx("span",{className:"wb-browser-index mono",children:a+1}),s.jsxs("span",{className:"wb-browser-what",children:[s.jsx("strong",{children:o.action}),o.target?s.jsx("span",{className:"muted wb-browser-target",children:o.target}):null,o.error?s.jsx("span",{className:"wb-browser-error",children:o.error}):null]}),s.jsx("span",{className:"wb-browser-outcome","data-state":l,children:l==="awaiting"?"Awaiting approval":l==="running"?"Working":l==="ok"?"Done":"Failed"})]},o.id)})})})}function lD({agentId:e,conversationId:t}){const{data:n,error:r,reload:i}=ne(()=>T.host(e,t),[e,t],2e3),[o,a]=d.useState(null),[l,c]=d.useState(!1),u=async x=>{c(!0),a(null);try{await x(),i()}catch(y){a(y instanceof Error?y.message:String(y))}finally{c(!1)}},h=(n==null?void 0:n.permissions)??[],f=(n==null?void 0:n.runs)??[],p=h.some(x=>!x.conversationId)?"Always allowed":h.length?"Conversation auto-mode":"Ask each time";return s.jsx(Et,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":p}${f.length?` · ${f.length} running`:""}`,children:s.jsxs(V,{gap:"sm",children:[s.jsx("p",{className:"muted",children:"Commands run as your user, not in a sandbox. Auto-mode covers all commands within its scope. Stop interrupts a command; revoke also ends the permission. Neither undoes completed changes."}),s.jsx(re,{message:o??r}),h.map(x=>s.jsxs(q,{children:[s.jsxs("span",{children:[x.agentId,": ",x.conversationId?"conversation auto-mode":"always allowed"]}),s.jsx(P,{size:"sm",disabled:l,onClick:()=>void u(()=>T.revokeHost(x.id)),children:"Revoke permission"})]},x.id)),h.length?null:s.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),f.map(x=>s.jsxs(V,{gap:"sm",children:[s.jsxs("p",{children:[x.agentId," · ",s.jsx("span",{className:"mono",children:x.cwd})]}),s.jsx(ft,{children:x.command}),s.jsx(ft,{label:"Command output",children:x.stdout||x.stderr?`${x.stdout}
|
|
102
|
-
${x.stderr}`:"Waiting for output…"}),s.jsx(q,{children:s.jsx(P,{size:"sm",variant:"danger",disabled:l,onClick:()=>void u(()=>T.stopHost(x.agentId,x.conversationId)),children:"Stop command"})})]},x.actionId))]})})}const lS="browser.act",cD="browser.status",hc=new Set([lS,cD]);function uD(e,t,n){const r=e==null?void 0:e.session;return!r||!t||!n||r.agentId!==t||r.conversationId!==n?null:{id:`host-browser:${r.id}`,title:e.mode==="computer"?"Computer":"Browser",tool:"Host browser",renderer:"browser",source:"browser",pinned:!0,props:{},at:null,substantial:!1}}function dD(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function fD(e){var r;const t=[],n=new Map;for(const i of e)for(const o of i.blocks??[]){if(o.type==="tool_use"&&o.name===lS){const l={id:o.id,action:hD(o.input)??"act",target:pD(o.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(l),n.set(o.id,l);continue}if(o.type!=="tool_result")continue;const a=n.get(o.toolUseId);if(a){if(((r=o.approval)==null?void 0:r.state)==="pending"){a.awaiting=!0,a.ok=null,a.error=null;continue}a.awaiting=!1,a.ok=o.ok,a.error=o.ok?null:mD(o)}}return t}function gy(e,t){var r;let n=!1;for(const i of e)for(const o of i.blocks??[])if(o.type==="tool_use"&&o.id===t&&(n=hc.has(o.name)),o.type==="tool_result"&&o.toolUseId===t&&((r=o.approval)==null?void 0:r.state)==="pending")return null;return n?t:null}function hD(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function pD(e){if(e===null||typeof e!="object")return null;const t=e;for(const r of["url","appId","direction","key","tabId"]){const i=t[r];if(typeof i=="string"&&i!=="")return i}const n=t.target;if(n!==null&&typeof n=="object"){const r=n,i=r.name;if(typeof i=="string"&&i!=="")return i;const o=r.ref;if(typeof o=="string"&&o!=="")return o;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function mD(e){for(const t of[e.error,e.output]){if(typeof t=="string"&&t.trim()!=="")return t.trim();if(t!==null&&typeof t=="object")for(const n of["message","error","reason"]){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function gD({agentId:e,groupId:t,currentId:n,timezone:r,onSelect:i,onNew:o}){const[a,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(0);return d.useEffect(()=>{let p=!1;return l(null),u(null),(t?_e.groupConversations(t):_e.conversations(e,100)).then(x=>{p||l(x.conversations)}).catch(x=>{p||u(x instanceof Error?x.message:String(x))}),()=>{p=!0}},[e,t,h]),s.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[s.jsxs("div",{className:"ui-toolbar",children:[s.jsx("strong",{children:"Past conversations"}),s.jsx("button",{className:"ui-btn",onClick:o,children:"New conversation"})]}),c?s.jsxs("p",{role:"alert",children:[c," ",s.jsx("button",{className:"ui-btn",onClick:()=>f(p=>p+1),children:"Retry"})]}):a===null?s.jsx("p",{className:"muted",children:"Loading conversations…"}):a.length===0?s.jsx("p",{className:"muted",children:"No conversations yet."}):s.jsx("ul",{children:a.map(p=>s.jsx("li",{children:s.jsxs("a",{href:t?Zo(t,p.id):Ue(e,p.id),"aria-current":p.id===n?"page":void 0,onClick:x=>{x.button===0&&!x.metaKey&&!x.ctrlKey&&!x.shiftKey&&!x.altKey&&(x.preventDefault(),i(p.id))},children:[s.jsx("span",{children:p.preview||p.opening||"Untitled conversation"}),s.jsxs("small",{children:[De(p.lastMessageAt??p.startedAt??p.createdAt??null,r)," · ",p.messageCount," messages",p.id===n?" · Current":""]})]})},p.id))}),s.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(a==null?void 0:a.length)===100?s.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const cS="buddi.dismissedTabs";function xD(){try{const e=JSON.parse(sessionStorage.getItem(cS)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(n=>typeof n=="string")))}catch{return{}}}function xy(e){try{sessionStorage.setItem(cS,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const vD=350,yD=60;function jD({conversationId:e,onText:t,onNotice:n}){const[r,i]=d.useState("idle"),o=d.useRef("idle"),a=m=>{o.current=m,i(m)},l=d.useRef(null),c=d.useRef(null),u=d.useRef(null),h=d.useRef(null),f=d.useRef(null),p=d.useRef({onText:t,onNotice:n,conversationId:e});p.current={onText:t,onNotice:n,conversationId:e};const x=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},y=async()=>{if(o.current!=="idle")return;p.current.onNotice(null),a("starting"),c.current=null;let m;try{m=await Z$(S=>{var k;return(k=f.current)==null?void 0:k.call(f,S)})}catch(S){h.current=null,a("idle"),p.current.onNotice(J$(S));return}const j=c.current;c.current=null;const g=o.current;if(j==="discard"||g!=="starting"){m.cancel(),g==="starting"&&a("idle");return}l.current=m,a("recording"),u.current=window.setTimeout(()=>void w(!1),q$),j&&w(j.sendNow)},w=async m=>{h.current=null;const j=l.current;if(!j){o.current==="starting"&&(c.current={sendNow:m});return}l.current=null,x(),a("transcribing");try{const g=await j.stop();if(g.size<=44){p.current.onNotice("Nothing was recorded.");return}const S=new File([g],`recording-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.wav`,{type:"audio/wav"}),k=await _e.attach(S),N=p.current.conversationId,C=await _e.transcribe({artifactId:k.artifactId,...N?{conversationId:N}:{}});p.current.onText(C.text,m)}catch(g){p.current.onNotice(g instanceof oe||g instanceof Error?g.message:String(g))}finally{a("idle")}},b=()=>{h.current=null;const m=l.current;if(!m){o.current==="starting"&&(c.current="discard");return}l.current=null,x(),m.cancel(),a("idle")};d.useEffect(()=>{const m=j=>{if(h.current===null)return;const g=Date.now()-h.current;h.current=null,g>=vD&&w(j.shiftKey)};return window.addEventListener("pointerup",m),()=>window.removeEventListener("pointerup",m)},[]);const v=r==="starting"||r==="recording";return d.useEffect(()=>{if(!v)return;const m=j=>{j.isComposing||j.repeat||(j.key==="Escape"?(j.preventDefault(),j.stopPropagation(),b()):j.key==="Enter"&&(j.preventDefault(),j.stopPropagation(),w(j.shiftKey)))};return window.addEventListener("keydown",m,!0),()=>window.removeEventListener("keydown",m,!0)},[v]),d.useEffect(()=>()=>{var m;(m=l.current)==null||m.cancel(),x()},[]),{state:r,hold:()=>{h.current=Date.now(),y()},start:()=>{h.current=null,y()},finish:m=>void w(m),discard:b,levels:f}}function wD({disabled:e,voice:t}){const n=i=>{e||i.button>0||t.state!=="idle"||(i.preventDefault(),t.hold())},r=i=>{i.detail!==0||e||t.state!=="idle"||t.start()};return s.jsx("button",{type:"button",className:"ui-icon-btn wb-mic","data-size":"sm","aria-label":"Talk",title:"Talk: click to start, or hold to speak and let go to stop",disabled:e,onPointerDown:n,onClick:r,onContextMenu:i=>i.preventDefault(),children:s.jsx(Ae,{name:"mic"})})}function bD({voice:e}){const t=d.useRef(null),n=e.state==="transcribing";return d.useEffect(()=>{var r;(r=t.current)==null||r.focus()},[]),s.jsxs("div",{className:"wb-listening",role:"group","aria-label":"Recording","data-phase":n?"transcribing":"listening",children:[s.jsx("p",{className:"wb-listening-label","aria-live":"polite",children:n?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wb-listening-spinner","aria-hidden":"true"}),"Transcribing…"]}):"Listening…"}),s.jsxs("div",{className:"wb-listening-row",children:[s.jsx(kD,{sink:e.levels,frozen:n}),s.jsx("button",{type:"button",className:"wb-send","data-variant":"quiet","aria-label":"Discard recording",title:"Discard (Escape)",disabled:n,onClick:()=>e.discard(),children:s.jsx(Ae,{name:"close"})}),s.jsx("button",{ref:t,type:"button",className:"wb-send","aria-label":"Stop and transcribe",title:"Stop and transcribe (Enter); Shift sends at once",disabled:n,onClick:r=>e.finish(r.shiftKey),children:s.jsx(Ae,{name:"check"})})]})]})}function kD({sink:e,frozen:t}){const[n,r]=d.useState(()=>Array(yD).fill(0));return d.useEffect(()=>{if(!t)return e.current=i=>r(o=>[...o.slice(1),i]),()=>{e.current=null}},[t]),s.jsx("div",{className:"wb-wave","aria-hidden":"true","data-testid":"waveform",children:n.map((i,o)=>s.jsx("span",{className:"wb-wave-bar",style:{"--level":i.toFixed(3)}},o))})}const SD="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",_l="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",ND=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function CD(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(SD);let n;try{n=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(ND(i))return null;throw new Error(_l)}try{const i=e.document??document,o=i.createElement("video");o.muted=!0,o.playsInline=!0,o.srcObject=n,await new Promise((h,f)=>{o.onloadedmetadata=()=>h(),o.onerror=()=>f(new Error(_l))}),await o.play(),await new Promise(h=>{const f=o.requestVideoFrameCallback;typeof f=="function"?f.call(o,()=>h()):setTimeout(h,120)});const a=i.createElement("canvas");a.width=o.videoWidth,a.height=o.videoHeight;const l=a.getContext("2d");if(!l||a.width===0)throw new Error(_l);l.drawImage(o,0,0);const c=await new Promise(h=>a.toBlob(h,"image/png"));if(!c)throw new Error(_l);const u=(((r=e.now)==null?void 0:r.call(e))??new Date).toISOString().slice(0,19).replace("T"," ").replace(/:/g,".");return new File([c],`Tab ${u}.png`,{type:"image/png"})}finally{n.getTracks().forEach(i=>i.stop())}}const vy="Send files once the agent has answered.",qh="wb-composer-input",uS=d.forwardRef(function({disabled:t,running:n,onSend:r,onStop:i,agentName:o,draft:a,model:l,setupHref:c,thinking:u,onThinking:h,onOpenFile:f,mentions:p,history:x,threadKey:y,conversationId:w,readAloud:b,onReadAloud:v,placeholder:m},j){var qa;const g=y?`buddi.draft.${y}`:null,S=U=>{if(!U)return"";try{return window.localStorage.getItem(U)??""}catch{return""}},[k,N]=d.useState(()=>S(g)),[C,A]=d.useState([]),[E,_]=d.useState(!1),[L,B]=d.useState(null),[R,O]=d.useState(!1),Y=d.useRef(null),G=d.useRef(null),[M,W]=d.useState(null),[$,ee]=d.useState(0),ce=M&&p?p.filter(U=>U.handle.toLowerCase().startsWith(M.query.toLowerCase())||U.name.toLowerCase().startsWith(M.query.toLowerCase())).slice(0,6):[],Ce=(U,pe)=>{if(!p||p.length===0){W(null);return}const He=U.slice(0,pe),pt=/(^|\s)@([\w-]*)$/.exec(He);if(!pt){W(null);return}W({start:pe-pt[2].length-1,query:pt[2]}),ee(0)},J=U=>{if(!M)return;const pe=G.current,He=pe?pe.selectionStart:k.length,pt=`${k.slice(0,M.start)}@${U} ${k.slice(He)}`;N(pt),xe<0&&te(pt),W(null),window.requestAnimationFrame(()=>{if(!pe)return;const En=M.start+U.length+2;pe.focus(),pe.setSelectionRange(En,En),Xn()})},ge=x??[],[xe,je]=d.useState(-1),Pe=d.useRef(k),ze=d.useRef(g);if(ze.current!==g){ze.current=g;const U=S(g);Pe.current=U,U!==k&&(N(U),je(-1),W(null))}const te=U=>{if(Pe.current=U,!!g)try{U===""?window.localStorage.removeItem(g):window.localStorage.setItem(g,U)}catch{}},se=U=>{N(U),W(null);const pe=G.current;pe&&(pe.value=U,pe.setSelectionRange(U.length,U.length)),window.requestAnimationFrame(Xn)},we=U=>!U.value.slice(0,U.selectionStart??U.value.length).includes(`
|
|
103
|
-
`),be=()=>k===""||xe>=0&&k===ge[xe],We=()=>{xe<0||(je(-1),se(Pe.current))},fe=C.some(U=>U.state==="uploading"),D=C.length>0,de=n&&D,Ke=!t&&!fe&&!de&&k.trim()!=="",nt=U=>{for(const pe of Array.from(U??[])){const He=`${pe.name}:${pe.size}:${Math.random().toString(36).slice(2,8)}`,pt=pe.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(pe):null;A(En=>[...En,{key:He,filename:pe.name||"Pasted image",mime:pe.type||"application/octet-stream",sizeBytes:pe.size,thumbnail:pt,state:"uploading"}]),_e.attach(pe).then(En=>A(ai=>ai.map(Xt=>Xt.key===He?{...Xt,state:"ready",uploaded:En}:Xt))).catch(En=>A(ai=>ai.map(Xt=>Xt.key===He?{...Xt,state:"failed",error:En instanceof oe?En.message:String(En)}:Xt)))}},$e=U=>{U.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(U.thumbnail)},Sn=U=>{const pe=C.find(He=>He.key===U);pe&&($e(pe),pe.state==="ready"&&pe.uploaded&&_e.discardAttachment(pe.uploaded.artifactId).catch(()=>{})),A(He=>He.filter(pt=>pt.key!==U))};d.useImperativeHandle(j,()=>({addFiles:U=>{var pe;nt(U),(pe=G.current)==null||pe.focus()},focus:()=>{var U;return(U=G.current)==null?void 0:U.focus()}}));const Nn=d.useRef(C);Nn.current=C,d.useEffect(()=>()=>Nn.current.forEach($e),[]);const Gs=d.useRef(0);d.useEffect(()=>{if(!a||a.at===Gs.current)return;Gs.current=a.at,N(pe=>pe.trim()===""?a.text:pe),xe<0&&k.trim()===""&&te(a.text);const U=G.current;U&&(U.focus(),window.requestAnimationFrame(()=>{U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,200)}px`,U.setSelectionRange(U.value.length,U.value.length)}))},[a]);const Xn=()=>{const U=G.current;U&&(U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,200)}px`)},ws=U=>{const pe=(U??k).trim();if(U===void 0?!Ke:t||fe||de||pe==="")return;const He=C.filter(pt=>pt.state==="ready"&&pt.uploaded).map(pt=>pt.uploaded);r(pe,He),C.forEach($e),je(-1),te(""),N(""),A([]),window.requestAnimationFrame(Xn)},bs=U=>{if(M&&ce.length>0){if(U.key==="ArrowDown"){U.preventDefault(),ee(pe=>(pe+1)%ce.length);return}if(U.key==="ArrowUp"){U.preventDefault(),ee(pe=>(pe-1+ce.length)%ce.length);return}if(U.key==="Enter"||U.key==="Tab"){U.preventDefault(),J(ce[$].handle);return}if(U.key==="Escape"){U.preventDefault(),W(null);return}}if(U.key==="ArrowUp"&&!U.shiftKey&&!U.altKey&&!U.metaKey&&!U.ctrlKey){const pe=U.currentTarget;if(ge.length>0&&xe+1<ge.length&&we(pe)&&be()){U.preventDefault(),xe<0&&(Pe.current=k),je(xe+1),se(ge[xe+1]);return}}if(U.key==="ArrowDown"&&!U.shiftKey&&!U.altKey&&!U.metaKey&&!U.ctrlKey&&xe>=0&&k===ge[xe]){if(U.preventDefault(),xe===0){We();return}je(xe-1),se(ge[xe-1]);return}if(U.key==="Escape"&&xe>=0){U.preventDefault(),We();return}U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),ws())},oi=U=>{var He;const pe=Array.from(((He=U.clipboardData)==null?void 0:He.files)??[]);pe.length!==0&&(U.preventDefault(),nt(pe))},hn=C.filter(U=>U.state==="failed"),Cn=hn.length,ks=jD({conversationId:w??null,onNotice:B,onText:(U,pe)=>{const He=k.trim()===""?U:`${k.replace(/\s+$/,"")} ${U}`;if(pe){ws(He);return}se(He),xe<0&&te(He)}}),Le=ks.state!=="idle",Jn=d.useRef(!1);return d.useEffect(()=>{var U;Jn.current&&!Le&&((U=G.current)==null||U.focus(),window.requestAnimationFrame(Xn)),Jn.current=Le},[Le]),s.jsx("div",{className:"wb-composer","data-testid":"composer",children:s.jsxs("div",{className:"wb-composer-box","data-focused":R||Le,"data-disabled":t,"data-listening":Le||void 0,children:[C.length>0?s.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:C.map(U=>s.jsx("span",{role:"listitem",children:s.jsx(eg,{name:U.filename,mime:U.mime,sizeBytes:U.sizeBytes,thumbnail:U.thumbnail,state:U.state,error:U.error,onRemove:()=>Sn(U.key),...f&&U.state==="ready"&&U.uploaded?{onOpen:()=>f(ED(U.uploaded))}:{},size:"sm"})},U.key))}):null,s.jsxs("label",{className:"sr-only",htmlFor:qh,children:["Message ",o]}),s.jsx("textarea",{id:qh,ref:G,value:k,rows:2,placeholder:n?`${o} is working…`:m??`Message ${o}`,onChange:U=>{N(U.target.value),xe<0&&te(U.target.value),Ce(U.target.value,U.target.selectionStart??U.target.value.length),Xn()},onFocus:()=>O(!0),onBlur:()=>O(!1),onKeyDown:bs,onPaste:oi,disabled:t,hidden:Le}),Le?s.jsx(bD,{voice:ks}):null,!Le&&M&&ce.length>0?s.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:ce.map((U,pe)=>s.jsxs("button",{type:"button",role:"option","aria-selected":pe===$,className:"wb-mention","data-active":pe===$||void 0,onMouseDown:He=>{He.preventDefault(),J(U.handle)},children:[s.jsxs("span",{className:"wb-mention-handle",children:["@",U.handle]}),s.jsx("span",{className:"wb-mention-name",children:U.name})]},U.handle))}):null,s.jsxs("div",{className:"wb-composer-row",hidden:Le,children:[s.jsx("input",{ref:Y,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:U=>{nt(U.target.files),U.target.value=""}}),s.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Attach a file",title:"Attach a file — or paste one, or drop it anywhere on the chat",onClick:()=>{var U;return(U=Y.current)==null?void 0:U.click()},disabled:t,children:s.jsx(Ae,{name:"clip"})}),s.jsx(wD,{disabled:t,voice:ks}),s.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Snap a tab",title:"Snap a tab — one picture of another tab in this browser, attached here",onClick:()=>{B(null),_(!0),CD().then(U=>{var pe;U&&(nt([U]),(pe=G.current)==null||pe.focus())}).catch(U=>B(U instanceof Error?U.message:String(U))).finally(()=>_(!1))},disabled:t||E,children:s.jsx(Ae,{name:"camera"})}),l?c?s.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),l]}):s.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),l]}):null,h?s.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":Ol(u),disabled:t||n,title:n?`Wait for ${o} to finish — this run started with thinking ${Ol(u)?"on":"off"}`:Ol(u)?"Reasoning before the answer is on. Click to turn it off — answers come back faster.":"Reasoning before the answer is off. Click to turn it on.",onClick:()=>h(Ol(u)?"off":"on"),children:[s.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,v?s.jsx("button",{type:"button",className:"ui-icon-btn wb-read-aloud","data-size":"sm","aria-label":"Read replies aloud","aria-pressed":!!b,title:b?"Replies are read aloud. Click to stop.":"Read replies aloud, through the voice chosen in Settings → Speech",onClick:()=>v(!b),children:s.jsx(Ae,{name:"speaker"})}):null,s.jsx("span",{className:"wb-hint","data-shown":k!==""&&!n||Cn>0||de||L!==null,"data-tone":Cn>0||L!==null?"critical":void 0,children:Cn>0?Cn===1&&((qa=hn[0])!=null&&qa.error)?hn[0].error:`${Cn} files failed to upload and will not be sent`:L!==null?L:de?vy:"Enter sends, Shift+Enter for a new line"}),n?s.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,s.jsx("button",{className:"wb-send","aria-label":"Send",title:de?vy:fe?"Waiting for the upload to finish":n?`Send — ${o} picks it up between steps`:"Send",onClick:()=>ws(),disabled:!Ke,children:s.jsx(Ae,{name:"send"})})]})]})})});function Ol(e){return(e??"on")==="on"}function ED(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function AD({question:e,disabled:t,onAnswer:n,onSkip:r}){const[i,o]=d.useState("");return d.useEffect(()=>{if(t)return;const a=l=>{l.key!=="Escape"||l.defaultPrevented||(l.preventDefault(),r())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,r]),s.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),s.jsx(P,{className:"wb-question-skip",variant:"ghost",size:"sm",disabled:t,onClick:r,title:"Skip this question (Esc). The agent carries on without an answer.",children:"Skip"}),s.jsx("strong",{children:e.question})]}),e.options.length>0?s.jsx("div",{className:"wb-question-options",children:e.options.map((a,l)=>s.jsxs("button",{className:"wb-question-option","data-recommended":a.recommended||void 0,disabled:t,onClick:()=>n(a.label,a.id),children:[s.jsx("span",{className:"wb-question-number",children:l+1}),s.jsxs("span",{children:[s.jsxs("span",{className:"wb-question-label",children:[a.label,a.recommended?s.jsx("em",{children:"Recommended"}):null]}),a.hint?s.jsx("small",{children:a.hint}):null]})]},a.id))}):null,e.allowOther?s.jsxs("form",{className:"wb-question-other",onSubmit:a=>{a.preventDefault(),i.trim()&&n(i.trim())},children:[s.jsx("input",{value:i,onChange:a=>o(a.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),s.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,s.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function RD(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function TD(e){const t=e/36e5;if(t>=1&&Number.isInteger(t))return`${t} hour${t===1?"":"s"}`;const n=Math.round(e/6e4);return`${n} minute${n===1?"":"s"}`}function PD(e){const{lifetime:t,startedAt:n,now:r,timezone:i}=e;if(!t||t.messages<=0)return{text:"New conversation",title:"Nothing has been said in this one yet.",tone:"quiet"};const o=`A conversation ends after ${TD(t.idleTimeoutMs)} idle, or once its transcript grows past ${Math.round(t.maxChars/1e3)}k characters. What the agent remembers about you carries over.`,a=`${t.messages} message${t.messages===1?"":"s"}`;if(RD(t,r))return{text:`${a} · your next message starts a fresh one`,title:o,tone:"note"};const l=n?Ee(n,r):"";return{text:l===""?a:`${a} · started ${l}`,title:n?`Started ${De(n,i)}. ${o}`:o,tone:"quiet"}}const pc=320,dS="buddi.chatWidth";function ID({timezone:e,agents:t,agentId:n,defaultAgentId:r=null,group:i=null,onEditGroup:o,onSelectAgent:a,attention:l,agentsInHeader:c,narrow:u,canvasOpen:h,onOpenCanvas:f,onCloseCanvas:p,newConversationSignal:x,requestedConversationId:y,requestedTab:w,onConversationOpened:b}){var zg,Wg,Hg,Vg,Kg,Gg;const v=sg(),[m,j]=d.useState([]),[g,S]=d.useState(null),[k,N]=d.useState(null),[C,A]=d.useState(null),[E,_]=d.useState([]),[L,B]=d.useState([]),[R,O]=d.useState(null),[Y,G]=d.useState(!1),[M,W]=d.useState(new Map),[$,ee]=d.useState(null),[ce,Ce]=d.useState(xD),[J,ge]=d.useState([]),[xe,je]=d.useState(!1),Pe=d.useRef(0),ze=d.useRef(null),[te,se]=d.useState(!1),we=d.useRef(x??0),be=d.useRef(n),We=d.useRef({agentId:n,conversationId:g});We.current={agentId:n,conversationId:g};const fe=ce[g??""]??[],[D,de]=d.useState(null),[Ke,nt]=d.useState(null),[$e,Sn]=d.useState(null),[Nn,Gs]=d.useState([]),[Xn,ws]=d.useState(!1),[bs,oi]=d.useState(()=>Date.now()),[hn,Cn]=d.useState(MD),ks=d.useRef(null),[Le,Jn]=d.useState(null),[qa,U]=d.useState(!1),[pe,He]=d.useState(null),[pt,En]=d.useState(s_),ai=d.useRef(pt);ai.current=pt;const Xt=d.useRef(null),[bg,Vu]=d.useState(null),aN=d.useCallback(I=>{En(I),r_(I),I||Ha()},[]),[lN,cN]=d.useState(null),[uN,kg]=d.useState(null);d.useEffect(()=>{if(!n)return;const I=DD(n);I&&He({text:I,at:Date.now()})},[n]);const Cr=i?`group:${i.id}`:n??null,An=[...t.top,...t.middle,...t.bottom],he=An.find(I=>I.id===n)??null,dN=ne(()=>T.providerAccounts(),[]),li=i?i.members.map(I=>An.find(z=>z.id===I)).filter(I=>!!I):[],[Ku,Sg]=d.useState(null);d.useEffect(()=>{let I=!1;return _e.views().then(z=>{I||j(z.views??[])}).catch(()=>{}),()=>{I=!0}},[]),d.useEffect(()=>{if(!n)return;const I=be.current===n;if(be.current=n,I&&y&&y===We.current.conversationId)return;let z=!1;return S(null),N(null),A(null),_([]),de(null),G(!1),ee(null),ge([]),Xa(null),se(!1),Jn(null),y?(y!=="new"?S(y):A(Cr),()=>{z=!0}):((i?_e.groupConversations(i.id):_e.conversations(n)).then(ae=>{if(z)return;const me=[...ae.conversations??[]].sort($D)[0];me?(S(me.id),b==null||b(n,me.id)):A(Cr)}).catch(()=>{z||A(Cr)}),()=>{z=!0})},[n,i==null?void 0:i.id,Cr,y,b]);const Zn=d.useCallback(I=>_e.conversation(I).then(z=>{if(We.current.conversationId===I){if(z.agentId!==We.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(z),_(ae=>ae.filter(me=>!tf(z,me)))}}).catch(z=>{We.current.conversationId===I&&de(qs(z))}),[]);d.useEffect(()=>{if(!g)return;let I=!1;return W(new Map),B([]),_e.conversation(g).then(z=>{if(!I){if(z.agentId!==n)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(z),_(ae=>ae.filter(me=>!tf(z,me)))}}).catch(z=>{I||de(qs(z))}),()=>{I=!0}},[g,n]),d.useEffect(()=>{if(!g)return;let I=!1;const z=window.setInterval(()=>{_e.conversation(g).then(ae=>{I||ae.agentId!==We.current.agentId||(N(ae),_(me=>me.filter(Ie=>!tf(ae,Ie))))}).catch(()=>{})},3e3);return()=>{I=!0,window.clearInterval(z)}},[g,n]),d.useEffect(()=>{if(!g)return;const I=xk({url:_e.streamUrl(g),onEvent:z=>{var ae;switch(z.name){case"run.started":Xt.current=null,G(!0),O(null),Sg(At(z.data.agentId));break;case"live":{const me=At(z.data.runId)??"",Ie=Number(z.data.turn??0),ke=z.data.kind==="thinking"?"thinking":"text",zt=At(z.data.text)??"",Ss=Date.now();if(ke==="text"){const es=Xt.current;Xt.current=es&&es.runId===me&&es.turn===Ie?{...es,text:es.text+zt}:{runId:me,turn:Ie,text:zt}}O(es=>{const fi=es&&es.runId===me&&es.turn===Ie?es:{runId:me,turn:Ie,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return ke==="thinking"?{...fi,thinking:fi.thinking+zt,thinkingStartedAt:fi.thinkingStartedAt??Ss}:{...fi,text:fi.text+zt,textStartedAt:fi.textStartedAt??Ss}});break}case"live.snapshot":{const me=At(z.data.runId)??"",Ie=Number(z.data.turn??0),ke=At(z.data.text)??"",zt=At(z.data.thinking)??"",Ss=Number(z.data.startedAt??Date.now());Xt.current={runId:me,turn:Ie,text:ke},O({runId:me,turn:Ie,text:ke,thinking:zt,thinkingStartedAt:zt?Ss:null,textStartedAt:ke?Ss:null,settled:!1});break}case"live.settle":{const me=At(z.data.runId)??"",Ie=Number(z.data.turn??0);O(ke=>ke&&ke.runId===me&&ke.turn===Ie?{...ke,settled:!0}:ke);break}case"tool.called":{const me=At(z.data.toolUseId)??At(z.data.id),Ie=At(z.data.name)??At(z.data.tool)??"tool";me&&B(ke=>[...ke.filter(zt=>zt.toolUseId!==me),{toolUseId:me,name:Ie,startedAt:Date.now()}]);break}case"tool.result":{const me=At(z.data.toolUseId)??At(z.data.id);me&&B(Ie=>Ie.filter(ke=>ke.toolUseId!==me)),Zn(g);break}case"message.appended":Zn(g).then(()=>{O(me=>me!=null&&me.settled?null:me)});break;case"awaiting-approval":{const me=At(z.data.approvalId)??At(z.data.actionId),Ie=At(z.data.toolUseId);me&&Ie&&W(ke=>new Map(ke).set(Ie,me)),B(ke=>ke.filter(zt=>zt.toolUseId!==Ie)),Zn(g);break}case"run.finished":{G(!1),B([]),O(null),Sg(null);const me=At(z.data.message);de(me??null);const Ie=((ae=Xt.current)==null?void 0:ae.text.trim())??"";Xt.current=null,!me&&Ie!==""&&ai.current&&jy(Ie,g).then(ke=>{ke&&Vu(ke)}),Zn(g);break}}}});return()=>I.close()},[g,Zn]),d.useEffect(()=>{const I=window.setInterval(()=>oi(Date.now()),L.length===0?6e4:1e3);return()=>window.clearInterval(I)},[L.length]);const Qa=ne(()=>n&&g?T.browser({agentId:n,conversationId:g}):Promise.resolve(void 0),[n,g],1500),ci=Qa.error?void 0:Qa.data,wo=ci!=null&&ci.session&&ci.session.agentId===n&&ci.session.conversationId===g?ci:void 0,Er=uD(wo,n,g),Ar=(Er==null?void 0:Er.id)??null,[bo,fN]=d.useState(null),Ng=wo==null?void 0:wo.mode;d.useEffect(()=>{Er&&n&&g&&fN({agentId:n,conversationId:g,tab:dD(Er,Ng)})},[Ar,Ng,n,g]);const hN=bo&&bo.agentId===n&&bo.conversationId===g&&!fe.includes(bo.tab.id)?bo.tab:null,Mt=Er??hN,pN=d.useMemo(()=>fD((k==null?void 0:k.messages)??[]),[k]),[mN,Xa]=d.useState(null),gN=d.useMemo(()=>y_({messages:(k==null?void 0:k.messages)??[],descriptors:m}),[k,m]),ui=AO(gN,g??null),Gu=TO(i?null:n),Cg=d.useMemo(()=>RO((k==null?void 0:k.messages)??[]),[k]),pn=d.useMemo(()=>{const z=j_({messages:(k==null?void 0:k.messages)??[],descriptors:m,awaiting:M,served:ui.served,...Mt?{folded:hc}:{}}).filter(ae=>ae.source==="approval"||!fe.includes(ae.id));if($&&!fe.includes($)&&!z.some(ae=>ae.id===$)){const ae=S_((k==null?void 0:k.messages)??[],$,{redactInputOf:hc});ae&&!hc.has(ae.tool)&&z.push(ae)}Mt&&z.push(Mt);for(const ae of J)z.push(YM(ae));return Gu&&z.unshift(PO(Gu,Cg)),Le?[...z,IO(Le)]:z},[k,m,M,Le,Ar,Mt==null?void 0:Mt.title,$,ce,g,J,ui.served,Gu,Cg]),xN=d.useMemo(()=>{var z;const I=[];for(const ae of(k==null?void 0:k.messages)??[]){if(ae.role!=="user"||ae.speaker&&ae.speaker!=="owner")continue;const me=(z=ae.blocks.find(Ie=>Ie.type==="text"))==null?void 0:z.text.trim();me&&I.unshift(me)}return I},[k]),Yu=d.useMemo(()=>pn.filter(I=>I.source==="approval"),[pn]),Ja=Yu.at(-1)??null,Za=d.useMemo(()=>[...Yu.map(I=>({approvalId:I.props.approvalId,toolUseId:I.id})),...((k==null?void 0:k.delegatedApprovals)??[]).map(I=>({approvalId:I.approvalId,toolUseId:I.toolUseId??"",askedBy:BD(I.chain,An)}))],[Yu,k==null?void 0:k.delegatedApprovals]),ko=d.useMemo(()=>{for(let I=pn.length-1;I>=0;I-=1){const z=pn[I];if(z!=null&&z.substantial)return z.id}return null},[pn]),el=d.useRef(null),qu=((zg=pn.filter(I=>(I.source!=="browser"||I.pinned===!0)&&I.id!==Gh).at(-1))==null?void 0:zg.id)??((Wg=pn.filter(I=>I.id!==Gh).at(-1))==null?void 0:Wg.id)??null;d.useEffect(()=>{if(ko&&ko!==el.current){el.current=ko,ee(ko);return}$===null&&qu&&ee(qu)},[ko,$,qu]);const Eg=d.useRef(ui.live);d.useEffect(()=>{const I=Eg.current;Eg.current=ui.live;const z=[...ui.live].filter(Ie=>!I.has(Ie));if(z.length===0||Ja||$!==null&&$!==el.current)return;const me=[...pn].reverse().find(Ie=>Ie.source==="descriptor"&&Ie.renderer==="preview"&&Ie.props.target!==null&&z.includes(Bi(Ie.props.target)));me&&ee(me.id)},[ui.live,pn,Ja,$]);const Ag=d.useRef(null);d.useEffect(()=>{Ar!==Ag.current&&(Ag.current=Ar,Ar&&!Ja&&ee(Ar))},[Ar,Ja]);const Rg=d.useRef(null),So=w==="browser"?(Mt==null?void 0:Mt.id)??null:null;d.useEffect(()=>{!So||Rg.current===So||(Rg.current=So,ee(So))},[So]);const Qu=(Mt==null?void 0:Mt.id)??null;d.useEffect(()=>{!Qu||!$||gy((k==null?void 0:k.messages)??[],$)!==null&&(Xa($),ee(Qu))},[Qu,$,k]);const Tg=I=>{ge(z=>z.some(ae=>ae.artifactId===I.artifactId)?z:[...z,I]),ee(fc(I.artifactId)),u&&(f==null||f())},tl=!i&&he&&!he.available?bk(he):null,Pg=Rh(i?null:he),Ig=((k==null?void 0:k.offers)??[]).filter(I=>!Nn.includes(I.id)&&Date.parse(I.expiresAt)>bs),vN=he&&uN===he.id?lN:(he==null?void 0:he.thinking)??null,yN=I=>{if(!he)return;const z=he.id;kg(z),cN(I),T.setAgentEngine(z,{thinking:I}).catch(ae=>{kg(null),de(ae instanceof oe?ae.message:String(ae))})},Mg=(I,z)=>{if(!n)return;const ae=z.map(ke=>ke.artifactId),me=Y,Ie={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:I},...z.map(ke=>({type:"attachment",artifactId:ke.artifactId,filename:ke.filename,mime:ke.mime,kind:ke.kind,sizeBytes:ke.sizeBytes}))],...me?{speaker:sS}:{}};_(ke=>me?[...ke,Ie]:[Ie]),de(null),nt(null),G(!0),(i?_e.sendToGroup(i.id,{...g?{conversationId:g}:{},text:I,attachmentIds:ae}):_e.send(n,{...g?{conversationId:g}:{},text:I,attachmentIds:ae})).then(async ke=>{We.current.agentId!==n||We.current.conversationId!==g||(nt(ke.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),ke.conversationId!==g?(N(null),S(ke.conversationId)):await Zn(ke.conversationId),ke.queued===!0&&_(zt=>zt.filter(Ss=>Ss.id!==Ie.id)),b==null||b(n,ke.conversationId))}).catch(ke=>{_(zt=>zt.filter(Ss=>Ss.id!==Ie.id)),de(qs(ke)),G(!1)})},jN=I=>{de(null),Sn(I),Gs(z=>[...z,I]),T.takeOffer(I,g??void 0).then(z=>{z.runId&&(nt(null),G(!0)),g&&Zn(g)}).catch(z=>{Gs(ae=>ae.filter(me=>me!==I)),de(qs(z)),g&&Zn(g)}).finally(()=>Sn(null))},wN=(I,z)=>$g({answer:I,...z?{optionId:z}:{}}),bN=()=>$g({answer:"",skipped:!0}),$g=I=>{const z=k==null?void 0:k.question;z&&(de(null),ws(!0),G(!0),_e.answerQuestion(z.id,I).then(()=>{if(g)return Zn(g)}).catch(ae=>{de(qs(ae)),G(!1)}).finally(()=>ws(!1)))},kN=()=>{if(n){if(Le){Jn(null);return}U(!0),T.agentProfile(n).then(I=>{Jn(I),ee(Yh(I.id)),u&&(f==null||f())}).catch(I=>de(qs(I))).finally(()=>U(!1))}},SN=I=>{He({text:I.prompt,at:Date.now()}),a(I.agentId),u&&(p==null||p())},NN=()=>{g&&_e.cancel(g).catch(I=>de(qs(I))).finally(()=>{G(!1),B([])})},nl=d.useCallback(()=>{if(S(null),N(null),_([]),G(!1),de(null),nt(null),B([]),W(new Map),ee(null),ge([]),Xa(null),el.current=null,i){_e.startGroupConversation(i.id).then(({conversationId:I})=>{S(I),n&&(b==null||b(n,I))}).catch(I=>de(qs(I)));return}A(Cr),n&&(b==null||b(n,"new"))},[n,i,Cr,b]);d.useEffect(()=>{x&&x!==we.current&&(we.current=x,nl())},[x,nl]);const _g=I=>{g&&Zn(g),T.overview().catch(()=>{}),I.state!=="pending"&&W(z=>new Map([...z].filter(([,ae])=>ae!==I.id)))},sl=d.useRef(!1);d.useEffect(()=>{const I=ae=>{if(!sl.current)return;const me=Math.max(pc,Math.min(720,ae.clientX-52));Cn(me)},z=()=>{if(sl.current){sl.current=!1;try{hn!==null&&window.localStorage.setItem(dS,String(hn))}catch{}}};return window.addEventListener("pointermove",I),window.addEventListener("pointerup",z),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",z)}},[hn]);const CN=((Hg=An.find(I=>I.id===r))==null?void 0:Hg.name)??null,Og=i?[]:KI(he,CN),Dg=!(k&&k.conversationId===g)&&!(!g&&C!==null&&C===Cr),Lg=Dg?s.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&he?s.jsx(BM,{quiet:!0,still:!0,className:"wb-chat-field",children:s.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[s.jsx(tn,{agents:An,id:he.id,size:"xl"}),s.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${he.name}.`}),s.jsx("p",{className:"wb-chat-intro",children:GI(he)}),Og.length>0?s.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${he.name}`,children:Og.map(I=>s.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var z;He({text:I,at:Date.now()}),(z=ze.current)==null||z.focus()},children:I},I))}):null]})}):null,Fg=s.jsx(gO,{renderables:pn,activeId:$,onActivate:ee,onClose:I=>{Le&&I===Yh(Le.id)?Jn(null):J.some(z=>fc(z.artifactId)===I)?ge(z=>z.filter(ae=>fc(ae.artifactId)!==I)):g&&Ce(z=>{const ae={...z,[g]:[...new Set([...z[g]??[],I])]};return xy(ae),ae}),$===I&&ee(null)},timezone:e,onDecided:_g,onChangeAgent:SN,agents:An,browserPanel:Mt?s.jsx(oD,{status:wo,error:Qa.error,reload:Qa.reload,steps:pN,live:Er!==null,focusedStepId:mN},Mt.id):null,descriptors:m,grantedTools:i?li.flatMap(I=>I.tools??[]):(he==null?void 0:he.tools)??[],...he?{agentName:he.name}:{},loading:Dg,...!i&&he?{face:s.jsx(tn,{agents:An,id:he.id,size:"xl"})}:{}}),Ug=(Kg=(Vg=[...(k==null?void 0:k.messages)??[],...E].find(I=>I.role==="user"))==null?void 0:Vg.blocks.find(I=>I.type==="text"))==null?void 0:Kg.text.trim(),Bg=Ug?Ug.split(`
|
|
104
|
-
`)[0]:"New conversation",di=PD({lifetime:(k==null?void 0:k.lifetime)??null,startedAt:(k==null?void 0:k.startedAt)??null,now:bs,timezone:e});return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"wb-chat",ref:ks,style:u||hn===null?void 0:{width:hn},"data-sized":!u&&hn!==null?"true":void 0,"data-testid":"chat-column","data-dropping":xe||void 0,onDragEnter:I=>{Dl(I)&&(I.preventDefault(),Pe.current+=1,je(!0))},onDragOver:I=>{Dl(I)&&(I.preventDefault(),I.dataTransfer.dropEffect="copy")},onDragLeave:I=>{Dl(I)&&(Pe.current=Math.max(0,Pe.current-1),Pe.current===0&&je(!1))},onDrop:I=>{var z;Dl(I)&&(I.preventDefault(),Pe.current=0,je(!1),n&&((z=ze.current)==null||z.addFiles(I.dataTransfer.files)))},children:[xe?s.jsx("div",{className:"wb-drop","aria-hidden":"true",children:s.jsxs("div",{className:"wb-drop-card",children:[s.jsx(_D,{}),s.jsx("strong",{children:"Drop to attach"}),s.jsx("span",{children:he?`It goes with your next message to ${he.name}`:"Pick an agent first"})]})}):null,s.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&he?Wa(za(he)):{},children:[s.jsxs("div",{className:"wb-head-row",children:[i?s.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:li.slice(0,3).map(I=>s.jsx(tn,{agents:An,id:I.id,size:"sm"},I.id))}):he?s.jsx("a",{className:"wb-head-face",href:xt(he.id),"aria-label":`${he.name}'s page`,children:s.jsx(tn,{agents:An,id:he.id})}):null,s.jsxs("div",{className:"wb-head-text",children:[i?s.jsx("span",{className:"wb-head-title",children:i.name}):s.jsx("span",{className:"wb-head-title",title:Bg,children:Bg}),s.jsx("span",{className:"wb-head-meta","data-tone":di.tone,title:i?`${li.map(I=>I.name).join(", ")}. Coordinator: ${(he==null?void 0:he.name)??i.coordinator}.`:di.title,children:i?`${li.map(I=>I.name).join(", ")} · ${di.text}`:he?s.jsxs(s.Fragment,{children:[s.jsx("a",{className:"wb-head-name",href:xt(he.id),title:`${he.name}'s page`,children:he.name})," ",s.jsxs("span",{className:"wb-head-handle",children:["@",he.handle]}),` · ${di.tone==="quiet"&&di.text==="New conversation"?`on ${v}`:di.text}`]}):"No agent"})]}),s.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!n,onClick:()=>{se(!1),nl()},children:s.jsx(Ae,{name:"plus",size:16})}),s.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":te,"data-open":te?"true":void 0,disabled:!n,onClick:()=>se(I=>!I),children:s.jsx(LD,{})}),u?s.jsxs("button",{className:"ui-btn",onClick:f,disabled:pn.length===0,children:["Canvas",pn.length>0?` (${pn.length})`:""]}):null,s.jsx(UD,{disabled:!n,items:i?[...li.map(I=>({label:I.name,hint:I.id===i.coordinator?"Coordinator · open page":"Member · open page",href:xt(I.id)})),...o?[{label:"Members…",hint:"Name, coordinator, who is in the room",testId:"group-members",onSelect:o}]:[]]:[{label:Le?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:qa,onSelect:kN},...he?[{label:"Set up",hint:"Identity, model and access",href:xt(he.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:xt(he.id)}]:[]]})]}),c?s.jsx(Sk,{agents:t,currentId:n,attention:l,onSelect:a,orientation:"horizontal"}):null]}),te&&n?s.jsx(gD,{agentId:n,...i?{groupId:i.id}:{},currentId:g,timezone:e,onNew:()=>{se(!1),nl()},onSelect:I=>{if(I===g){se(!1);return}se(!1),N(null),_([]),G(!1),ee(null),de(null),nt(null),ge([]),S(I),b==null||b(n,I,!1)}}):null,n&&g?s.jsx(lD,{agentId:n,conversationId:g},`${n}:${g}`):null,D?s.jsx("div",{className:"wb-chat-notice",children:s.jsx(re,{message:D})}):null,Ke?s.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:Ke}):null,k!=null&&k.carriedOver?s.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:k.carriedOver}):null,s.jsx(rS,{messages:[...(k==null?void 0:k.messages)??[],...E],live:L,now:bs,working:Y,partial:R,agents:An,...k!=null&&k.runs?{runs:k.runs}:{},...i?{speakers:An,coordinatorId:i.coordinator}:{},...Ku?{workingAs:((Gg=An.find(I=>I.id===Ku))==null?void 0:Gg.name)??Ku}:{},onOpenFile:Tg,onReadAloud:(I,z)=>{Vu(null),jy(z,g??void 0,I).then(ae=>{ae&&Vu(ae)})},onOpen:I=>{if(Mt){const z=gy([...(k==null?void 0:k.messages)??[],...E],I);if(z){Xa(z),ee(Mt.id),u&&(f==null||f());return}}g&&Ce(z=>{const ae={...z,[g]:(z[g]??[]).filter(me=>me!==I)};return xy(ae),ae}),ee(I),u&&(f==null||f())},...he?{agentName:he.name}:{},...Lg?{empty:Lg}:{},emptyHint:he?`Nothing here yet. Ask ${he.name} for something.`:"Loading agents…"}),Ig.length>0?s.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:Ig.map(I=>s.jsx("button",{className:"ui-btn",disabled:$e!==null,title:I.prompt,onClick:()=>jN(I.id),children:I.label},I.id))}):null,tl?s.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:s.jsxs(H,{tone:"warning",role:"status",children:[tl," ",s.jsx("a",{href:lt(Pg.section),children:Pg.label})]})}):Za.length>0?s.jsx(X_,{approvals:Za,timezone:e,now:bs,version:k,onDecided:_g,onSay:I=>Mg(I,[]),onOpenFull:I=>{ee(I),u&&(f==null||f())}}):null,tl||Za.length>0?null:k!=null&&k.question?s.jsx(AD,{question:k.question,disabled:Xn||Y,onAnswer:wN,onSkip:bN},k.question.id):null,tl?null:s.jsxs("div",{hidden:Za.length>0||!!(k!=null&&k.question),"data-testid":"composer-slot",children:[s.jsx(uS,{ref:ze,disabled:!n,running:Y,onSend:Mg,onStop:NN,agentName:i?i.name:(he==null?void 0:he.name)??"the agent",draft:pe,history:xN,threadKey:g??(i?`group:${i.id}`:n),model:i?null:(he==null?void 0:he.model)??null,setupHref:i?null:he?xt(he.id,"setup","brain"):null,thinking:vN,...!i&&he&&b0(k0(he,dN.data))?{onThinking:yN}:{},...i?{mentions:li.map(I=>({handle:I.handle,name:I.name}))}:{},onOpenFile:Tg,conversationId:g??null,readAloud:pt,onReadAloud:aN}),bg?s.jsx("p",{className:"wb-voice-note",role:"status",children:bg}):null]})]}),u?h?s.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[s.jsxs("div",{className:"wb-sheet-head",children:[s.jsx("strong",{children:"Canvas"}),s.jsx("button",{className:"ui-btn",onClick:p,children:"Close"})]}),Fg]}):null:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:I=>{var z,ae;sl.current=!0,(ae=(z=I.currentTarget).setPointerCapture)==null||ae.call(z,I.pointerId)},onKeyDown:I=>{const z=ae=>{var me;return ae??((me=ks.current)==null?void 0:me.offsetWidth)??pc};I.key==="ArrowLeft"&&Cn(ae=>Math.max(pc,z(ae)-16)),I.key==="ArrowRight"&&Cn(ae=>Math.min(720,z(ae)+16))}}),Fg]})]})}function MD(){try{const e=window.localStorage.getItem(dS),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=pc?t:null}catch{return null}}function $D(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function At(e){return typeof e=="string"&&e!==""?e:null}function qs(e){return e instanceof oe||e instanceof Error?e.message:String(e)}function tf(e,t){var r;const n=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!n)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const o=e.messages[i];if(o.role!=="user")continue;const a=o.blocks.find(l=>l.type==="text");if(a)return a.text.trim()===n}return!1}function Dl(e){var n;const t=(n=e.dataTransfer)==null?void 0:n.types;return!!(t&&Array.from(t).includes("Files"))}function _D(){return s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),s.jsx("path",{d:"M5 19.5v2a2.5 2.5 0 0 0 2.5 2.5h13a2.5 2.5 0 0 0 2.5-2.5v-2"})]})}const Qh="buddi.chatDraft";function OD(e,t){try{window.sessionStorage.setItem(Qh,JSON.stringify({agentId:e,text:t}))}catch{}}function DD(e){try{const t=window.sessionStorage.getItem(Qh);if(!t)return null;const n=JSON.parse(t);return n.agentId!==e||typeof n.text!="string"?null:(window.sessionStorage.removeItem(Qh),n.text)}catch{return null}}function LD(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),s.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function FD(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[s.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function UD({items:e,disabled:t}){const[n,r]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!n)return;const o=l=>{i.current&&!i.current.contains(l.target)&&r(!1)},a=l=>{l.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",o),window.addEventListener("keydown",a),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("keydown",a)}},[n]),s.jsxs("div",{className:"wb-head-menu",ref:i,children:[s.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":"More about this agent","aria-haspopup":"menu","aria-expanded":n,"data-open":n?"true":void 0,disabled:t,onClick:()=>r(o=>!o),children:s.jsx(FD,{})}),n?s.jsx("div",{className:"ui-menu wb-head-menu-list",role:"menu",children:e.map(o=>o.href?s.jsxs("a",{className:"ui-menu-item",role:"menuitem",href:o.href,onClick:()=>r(!1),children:[s.jsx("span",{className:"ui-menu-item-text",children:o.label}),o.hint?s.jsx("span",{className:"ui-menu-item-hint",children:o.hint}):null]},o.label):s.jsxs("button",{className:"ui-menu-item",role:"menuitem","data-testid":o.testId,disabled:o.disabled,onClick:()=>{var a;r(!1),(a=o.onSelect)==null||a.call(o)},children:[s.jsx("span",{className:"ui-menu-item-text",children:o.label}),o.hint?s.jsx("span",{className:"ui-menu-item-hint",children:o.hint}):null]},o.label))}):null]})}function BD(e,t){const n=o=>{var a;return`@${((a=t.find(l=>l.id===o))==null?void 0:a.handle)??o}`},[r,...i]=e;return r===void 0?"":[n(r),...i.map(o=>`asked by ${n(o)}`)].join(", ")}let yy=!1;const zD=new Set(["missing","unconfigured","not-english"]);async function jy(e,t,n=null){const r=Qk(n);try{const i=await _e.say({text:e,...t?{conversationId:t}:{}});return iy(r)&&await a_(i.audioUrl,i.mime,n),null}catch(i){iy(r)&&Ha();const o=i instanceof oe&&i.detail&&typeof i.detail=="object"?i.detail.reason:void 0;return typeof o=="string"&&zD.has(o)&&(n!==null||!yy)?(yy=!0,i.message):null}}const fS=3;function WD(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function HD(e){return e.state==="shown"&&e.seenAt===null}function VD(e){const[t,n]=d.useState([]),r=d.useRef(new Set),i=d.useRef(new Set),o=d.useCallback(()=>{e&&T.notifications(20).then(({notifications:l})=>{const c=l.filter(u=>HD(u)&&!r.current.has(u.id));n(u=>{const h=new Set(u.map(p=>p.id)),f=c.filter(p=>!h.has(p.id));return f.length===0?u:[...u,...f].sort((p,x)=>x.createdAt.localeCompare(p.createdAt))})}).catch(()=>{})},[e]);d.useEffect(()=>{for(const l of t.slice(0,fS))i.current.has(l.id)||(i.current.add(l.id),T.notificationSeen(l.id).catch(()=>{}))},[t]);const a=d.useCallback(l=>{r.current.add(l),n(c=>c.filter(u=>u.id!==l))},[]);return{queue:t,refresh:o,dismiss:a}}function KD({queue:e,agents:t,navigate:n,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,fS),o=e.length-i.length;return s.jsxs("section",{className:"nt-toasts","aria-label":"Notifications",children:[i.map(a=>s.jsxs("div",{className:"ui-toast nt-toast","data-tone":WD(a.kind),role:"status",children:[a.agentId?s.jsx(tn,{agents:t,id:a.agentId,size:"sm"}):null,s.jsxs("div",{className:"nt-toast-main",children:[s.jsx("div",{className:"ui-toast-title",children:a.title}),a.text?s.jsx("div",{className:"ui-toast-body nt-toast-line",children:GD(a.text)}):null,a.link?s.jsx("a",{className:"nt-toast-link",href:a.link,onClick:l=>{l.preventDefault(),r(a.id),n(a.link)},children:"See"}):null]}),s.jsx("button",{type:"button",className:"nt-toast-x","aria-label":`Dismiss ${a.title}`,onClick:()=>r(a.id),children:"×"})]},a.id)),o>0?s.jsxs("p",{className:"nt-toasts-more",children:["and ",o," more"]}):null]})}function GD(e){var t;return((t=e.split(`
|
|
105
|
-
`).find(n=>n.trim()!==""))==null?void 0:t.trim())??""}const YD=3e4,qD=1e3;function QD(e,t,n){const r=d.useRef(t);r.current=t;const i=d.useRef(n);i.current=n,d.useEffect(()=>{if(!e)return;let o=!1,a=-1/0,l=null,c=null,u=!0;const h=()=>document.visibilityState!=="hidden",f=v=>{var m;a=Date.now(),T.presence(v).catch(j=>{var g;j instanceof oe&&j.status===401&&(o=!0,(g=i.current)==null||g.call(i))}),v==="active"&&((m=r.current)==null||m.call(r))},p=v=>{if(o||(l=v,c!==null))return;const m=a+qD-Date.now();if(m<=0){l=null,f(v);return}c=window.setTimeout(()=>{if(c=null,o||l===null)return;const j=l;l=null,f(j)},m)},x=()=>{u=!0,h()&&p("active")},y=()=>{u=!1,p("away")},w=()=>p(h()?"active":"away");h()&&p("active");const b=window.setInterval(()=>{h()&&u&&p("active")},YD);return window.addEventListener("focus",x),window.addEventListener("blur",y),document.addEventListener("visibilitychange",w),()=>{o=!0,window.clearInterval(b),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",x),window.removeEventListener("blur",y),document.removeEventListener("visibilitychange",w)}},[e])}function wy({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:o}){return!t&&!wk(e)?s.jsx(Qt,{title:"A new group",onClose:n,children:s.jsxs(H,{children:["A group needs two agents. Make another one with ",WI(e)," first."]})}):s.jsx(JD,{agents:XD(e,t),group:t??null,onClose:n,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...o?{onArchived:o}:{}})}function XD(e,t){const n=jk(e),r=((t==null?void 0:t.members)??[]).filter(i=>!n.some(o=>o.id===i)).map(i=>e.find(o=>o.id===i)).filter(i=>i!==void 0);return[...n,...r]}function JD({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:o}){var C,A;const a=t!==null,[l,c]=d.useState((t==null?void 0:t.name)??""),[u,h]=d.useState((t==null?void 0:t.members)??[]),[f,p]=d.useState((t==null?void 0:t.coordinator)??((C=e.find(E=>E.roles.includes(Bm)))==null?void 0:C.id)??((A=e[0])==null?void 0:A.id)??""),[x,y]=d.useState(!1),[w,b]=d.useState(!1),[v,m]=d.useState(null),j=[...new Set([f,...u])].filter(Boolean),g=l.trim()!==""&&f!==""&&j.length>=2,S=E=>h(_=>_.includes(E)?_.filter(L=>L!==E):[..._,E]),k=async()=>{y(!0),m(null);try{t?i==null||i(await _e.updateGroup(t.id,{name:l.trim(),coordinator:f,members:j})):r==null||r(await _e.createGroup({name:l.trim(),coordinator:f,members:j.filter(E=>E!==f)}))}catch(E){m(E instanceof oe?E.message:String(E))}finally{y(!1)}},N=async()=>{if(t){y(!0),m(null);try{await _e.archiveGroup(t.id),o==null||o(t.id)}catch(E){m(E instanceof oe?E.message:String(E)),y(!1)}}};return s.jsx(Qt,{title:a?`${t.name}: members`:"A new group",onClose:n,children:s.jsxs(V,{children:[s.jsx(X,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:s.jsx("input",{value:l,autoFocus:!0,maxLength:80,onChange:E=>c(E.target.value),placeholder:"Household finances"})}),s.jsx(X,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:s.jsx("select",{value:f,onChange:E=>p(E.target.value),children:e.map(E=>s.jsx("option",{value:E.id,children:E.name},E.id))})}),s.jsx(X,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:s.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(E=>E.id!==f).map(E=>s.jsxs("label",{className:"group-pick-row","data-on":u.includes(E.id)||void 0,children:[s.jsx("input",{type:"checkbox",checked:u.includes(E.id),onChange:()=>S(E.id)}),s.jsx(tn,{agents:e,id:E.id,size:"sm"}),s.jsxs("span",{className:"group-pick-text",children:[s.jsx("span",{className:"group-pick-name",children:E.name}),s.jsx("span",{className:"group-pick-desc",children:E.description})]})]},E.id))})}),s.jsx(H,{children:"Members read what is said in this group and what they recall from shared and group memory. Nothing an agent knows privately is brought in on its own: what enters the room is seen by the room."}),a?s.jsx(H,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,v?s.jsx(H,{tone:"critical",children:v}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!g||x,onClick:()=>void k(),children:x?a?"Saving…":"Creating…":a?"Save":"Create group"})]}),a?s.jsx("div",{className:"group-archive",children:w?s.jsxs(V,{children:[s.jsxs(H,{tone:"warning",children:["Archive ",t.name,"? It leaves the rail and takes no new requests. Everything said in it stays readable."]}),s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:()=>b(!1),children:"Keep it"}),s.jsx(P,{variant:"danger",disabled:x,"data-testid":"group-archive-confirm",onClick:()=>void N(),children:"Archive group"})]})]}):s.jsx(P,{variant:"ghost",disabled:x,"data-testid":"group-archive",onClick:()=>b(!0),children:"Archive group"})}):null]})})}function rg(e){const[t,n]=d.useState(null),[r,i]=d.useState(null),[o,a]=d.useState(null);return{busy:t,note:r,failure:o,decide:async(c,u,h,f)=>{var x,y,w,b;n(c),a(null),i(null);let p;try{const v=f?await T.decide(c,u,h,f):await T.decide(c,u,h);p={decision:u,...(x=v.execution)!=null&&x.state?{state:v.execution.state}:{},...v.execution&&"result"in v.execution?{result:v.execution.result}:{}},i(u==="reject"?`Rejected ${v.action.tool}.`:((y=v.execution)==null?void 0:y.state)==="succeeded"?`Approved and done: ${v.action.tool}.`:`Approved ${v.action.tool}: ${((w=v.execution)==null?void 0:w.state)??"no execution"}${(b=v.execution)!=null&&b.message?` (${v.execution.message})`:""}`)}catch(v){a(v instanceof Error?v.message:String(v))}finally{n(null),e(p)}}}}function ig({action:e,timezone:t,busy:n,onDecide:r,agentName:i}){var h,f;const[o,a]=d.useState(!1),{values:l,controls:c}=Ym(e.choices),u=p=>l?r(e.id,"approve",p,l):r(e.id,"approve",p);return s.jsxs(Yr,{tone:"accent",title:e.tool,meta:s.jsxs(s.Fragment,{children:[s.jsxs(ve,{children:["v",e.toolVersion]}),s.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[s.jsx(ft,{children:e.preview}),s.jsxs("p",{className:"ui-card-meta",children:["Expires ",De(e.expiresAt,t)," (",Ee(e.expiresAt),"). Policy v",e.policyVersion,", args ",Sa(e.argsHash,12),e.jobId?`, job ${Sa(e.jobId)}`:"","."]}),c,s.jsxs(q,{children:[s.jsx(P,{variant:"good",disabled:n,onClick:()=>u(),children:(h=e.permissionScopes)!=null&&h.length?"Allow once":"Approve"}),(f=e.permissionScopes)!=null&&f.length?s.jsxs(s.Fragment,{children:[s.jsx(P,{disabled:n,onClick:()=>u("conversation"),children:"Auto: this conversation"}),s.jsx(P,{disabled:n,onClick:()=>u("always"),children:"Always: this agent"})]}):null,s.jsx(P,{variant:"danger",disabled:n,onClick:()=>r(e.id,"reject"),children:"Reject"}),s.jsx(P,{variant:"ghost",onClick:()=>a(p=>!p),"aria-expanded":o,children:o?"Hide envelope":"Show envelope"})]}),o?s.jsxs("div",{className:"ui-card-foot",children:[s.jsx(K,{title:"Envelope: everything that decides what the world will see",children:s.jsx(ft,{children:ln(e.envelope)})}),s.jsx(K,{title:"Canonical arguments",children:s.jsx(ft,{children:ln(e.canonicalArgs)})})]}):null]})}function hS(e,t,n){const[r,i]=d.useState(!1),[o,a]=d.useState(null),[l,c]=d.useState(null);return{accept:()=>{e&&(i(!0),c(null),T.acceptPluginAgent(e,t).then(h=>{a(h.agent)}).catch(h=>c(h instanceof oe?h.message:String(h))).finally(()=>i(!1)))},busy:r,created:o,failure:l}}function pS({agent:e}){return s.jsxs(H,{tone:"good",role:"status",children:["@",e.handle," is ready. ",s.jsxs("a",{href:Ue(e.id),children:["Talk to @",e.handle]})]})}function mS(e,t,n){const r=e.canonicalArgs;return e.tool==="platform.accept_plugin_agent"&&(r==null?void 0:r.plugin)===t&&typeof r.agent=="string"&&r.agent.toLowerCase()===n.toLowerCase()}function ZD(e,t){var i;const n=ne(()=>T.approvals(),[e,t],15e3);return{action:((i=n.data)==null?void 0:i.pending.find(o=>mS(o,e,t)))??null,reload:n.reload}}function eL({action:e,onDecided:t}){const{busy:n,failure:r,decide:i}=rg(o=>t(o));return s.jsxs(V,{gap:"sm",children:[s.jsx(ig,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:n===e.id,onDecide:(o,a,l,c)=>{i(o,a,l,c)}}),s.jsx(re,{message:r})]})}function og({plugin:e,agent:t,text:n,label:r,handle:i,onDismiss:o}){var f;const a=hS(e,t),l=ZD(e,t),[c,u]=d.useState(null),h=a.created??c;if(h)return s.jsx(pS,{agent:h});if(l.action){const p=i??((f=/@(\S+)/.exec(r))==null?void 0:f[1])??t;return s.jsxs(V,{gap:"sm",children:[s.jsx("span",{children:n}),s.jsx(eL,{action:l.action,onDecided:x=>{(x==null?void 0:x.decision)==="approve"&&x.state==="succeeded"?u({id:t,handle:p,name:p}):l.reload()}})]})}return s.jsxs(V,{gap:"sm",children:[s.jsxs(q,{children:[s.jsx("span",{children:n}),s.jsx(xo,{}),o?s.jsx(P,{variant:"ghost",disabled:a.busy,onClick:o,children:"Not now"}):null,s.jsx(P,{variant:"accent",disabled:a.busy,onClick:a.accept,children:r})]}),s.jsx(re,{message:a.failure})]})}function gS(){var t;const e=ne(()=>T.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function xS({offers:e,reload:t}){return e.length===0?null:s.jsx(K,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:s.jsx(V,{gap:"sm",divided:!0,children:e.map(n=>s.jsx(og,{plugin:n.plugin,agent:n.agent,text:n.text,label:`Create @${n.handle}`,handle:n.handle,onDismiss:()=>{T.dismissAgentOffer(n.plugin,n.agent).then(t,t)}},`${n.plugin}/${n.agent}`))})})}const tL=512*1024,nL=/^[A-Za-z0-9+/]*={0,2}$/;function vS(e){const t=e==null?void 0:e.play;if(typeof t!="object"||t===null)return null;const{mime:n,data:r}=t;return typeof n!="string"||!/^audio\/[a-z0-9.+-]+$/i.test(n.split(";")[0].trim())||typeof r!="string"||r===""||!nL.test(r)||Math.floor(r.length*3/4)>tL+2?null:{mime:n,data:r}}function yS(e){const t=e==null?void 0:e.message;return typeof t=="string"&&t.trim()!==""?t:null}let As=null,ta=null,Ta=null;const Xh=new Set;function jS(){for(const e of Xh)e()}function zo(){As&&(As.onended=null,As.onerror=null,As.pause()),ta&&URL.revokeObjectURL(ta),ta=null,Ta!==null&&(Ta=null,jS())}async function wS(e,t){zo();const n=atob(e.data),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);As??(As=new Audio),ta=URL.createObjectURL(new Blob([r],{type:e.mime})),Ta=t,As.onended=zo,As.onerror=zo,As.src=ta,jS();try{await As.play()}catch{throw zo(),new Error("The browser would not play the sound.")}}function by(e){e!==void 0&&Ta!==e||zo()}function sL(){return d.useSyncExternalStore(e=>(Xh.add(e),()=>Xh.delete(e)),()=>Ta,()=>null)}const ag=d.createContext(null),eu=d.createContext(!1);function jt(){const e=d.useContext(ag);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function Jh(e,t=new Set){if(Array.isArray(e))for(const n of e)Jh(n,t);else if(e&&typeof e=="object"){const n=e.query;typeof n=="string"&&t.add(n);for(const r of Object.values(e))Jh(r,t)}return t}function bS(e,t){if(t.size===0)return!1;for(const n of Jh(e))if(t.has(n))return!0;return!1}function kS(){const[e,t]=d.useState(!1);return d.useEffect(()=>{if(!e)return;const n=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",n),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",n),window.removeEventListener("blur",n)}},[e]),[e,()=>t(n=>!n)]}function SS({revealed:e,onToggle:t}){return s.jsx(P,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function NS(){return s.jsx("p",{className:"muted",children:"Hidden until you show it."})}function CS({children:e}){const[t,n]=kS();return s.jsxs(V,{gap:"sm",children:[s.jsx(q,{align:"end",children:s.jsx(SS,{revealed:t,onToggle:n})}),t?s.jsx(eu.Provider,{value:!0,children:e}):s.jsx(NS,{})]})}function lg(e){return e===void 0||e==="neutral"?void 0:e}function Zh(e){return lg(e)}function rL(e){const t=lg(e);return t==="accent"?void 0:t}function Hn(e,t){if(!t)return!0;const n=ye(e,t.path),r=t.in!==void 0?t.in.includes(n):n===t.equals;return t.not===!0?!r:r}function cg(e,t,n){if("chat"in t){const o=Ne(n,t.chat);return o==null?"":Ue(String(o))}if("proposals"in t)return bI(e.plugin);const r=e.pages.find(o=>o.id===t.page);if((r==null?void 0:r.place)==="settings")return Um(e.plugin,t.page);const i=t.item===void 0?null:Ne(n,t.item);return Na(e.plugin,t.page,i==null?null:String(i))}function iL(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(n,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(n,r)=>{const i=ye(t.row,r);return i==null?"":String(i)})}function ep(e,t){if(e===void 0)return;if(typeof e=="string")return e;const n=Ne(t,e);return n==="good"||n==="warning"||n==="critical"||n==="neutral"?n:void 0}function ES(e,t,n){const r={};for(const[i,o]of Object.entries(e??{})){let a;"param"in o?a=n.params[o.param]:"route"in o?a=o.route==="plugin"?n.plugin:o.route==="page"?n.page:n.item:a=Ne(t,o),!(a==null||a==="")&&(r[i]=String(a))}return r}function Qr(e,t){var r,i,o;const n={};for(const[a,l]of Object.entries(e??{}))if("row"in l)n[a]=ye(t.row,l.row);else if("field"in l){if((r=t.omit)!=null&&r.has(l.field))continue;const c=(i=t.fields)==null?void 0:i[l.field],u=(o=t.shape)==null?void 0:o.find(h=>h.name===l.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;n[a]=c}else"selected"in l?n[a]=t.selected??[]:"param"in l?n[a]=t.scope.params[l.param]:n[a]=Ne(t.data,l);return n}function ys(e,t,n){const r=jt(),i=e?ES(e.params,t,r):{},o=JSON.stringify([(e==null?void 0:e.query)??null,i,r.version]),a=ne(()=>e?T.pageQuery(r.plugin,e.query,i).then(l=>l.data):Promise.resolve(void 0),[o],n);return{data:a.data,error:a.error,loading:a.loading}}function Va(){const e=jt(),t=d.useId(),[n,r]=d.useState(null),[i,o]=d.useState(null),[a,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(null),p=(b,v)=>{if(b.done===void 0)return null;if(typeof b.done=="string")return b.done;const m=Ne(v,b.done);return m==null?null:String(m)},x=(b,v,m)=>{const j=b??"refresh";if(typeof j=="object"){const g=cg(e,j.route,v);g===""?e.refresh():e.navigate(g);return}j==="close"&&(m==null||m()),e.refresh()},y=async(b,v,m)=>{r(b.tool),o(null),l(null);try{const j=await T.pageAct(e.plugin,{tool:b.tool,args:v});if(j.approvalId){u(j.approvalId),f({then:b.then,ref:b,...m?{onDone:m}:{}});return}u(null),f(null);const g=vS(j.result);l(p(b,j.result)??(g?yS(j.result):null)),g&&await wS(g,t),x(b.then,j.result,m)}catch(j){o(j instanceof Error?j.message:String(j)),e.refresh()}finally{r(null)}},w=b=>{if(!b){e.refresh();return}const v=h;if(u(null),f(null),v&&b.decision==="approve"&&b.state==="succeeded"){l(p(v.ref,b.result)),x(v.then,void 0,v.onDone);return}e.refresh()};return{running:n,busy:n!==null,error:i,done:a,approvalId:c,waiting:(h==null?void 0:h.ref.pending)??null,settle:w,run:y}}function eo({action:e,args:t,disabled:n,running:r,count:i,row:o,onRun:a}){const[l,c]=d.useState(!1),u=f=>iL(f,{...i===void 0?{}:{count:i},row:o}),h=u(e.label);return l&&e.confirm?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),s.jsx(P,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsxs(P,{variant:e.tone==="danger"?"danger":"accent",disabled:n,onClick:()=>{c(!1),a(e,t)},children:["Yes, ",h.toLowerCase()]})]}):s.jsx(P,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:n,onClick:()=>e.confirm?c(!0):a(e,t),children:r&&e.busy?e.busy:h})}function tu({id:e,onDecided:t}){const n=jt(),r=ne(()=>T.approval(e),[e,n.version]),{busy:i,note:o,failure:a,decide:l}=rg(c=>{t?t(c):n.refresh()});return r.error?s.jsx(re,{message:r.error}):r.data?s.jsxs(V,{children:[s.jsx(ig,{action:r.data,timezone:n.timezone,busy:i===e,onDecide:(c,u,h,f)=>{l(c,u,h,f)}}),o?s.jsx(H,{tone:"good",role:"status",children:o}):null,s.jsx(re,{message:a})]}):s.jsx(ie,{children:"Loading the approval…"})}function yo({act:e}){return e.error?s.jsx(re,{message:e.error}):e.approvalId?e.waiting?s.jsxs(V,{children:[s.jsx(H,{role:"status",children:e.waiting}),s.jsx(tu,{id:e.approvalId,onDecided:e.settle})]}):s.jsx(tu,{id:e.approvalId,onDecided:e.settle}):e.done?s.jsx(H,{tone:"good",role:"status",children:e.done}):null}function nu(e,t){const n={};for(const r of e){const i=r.from===void 0?void 0:ye(t,r.from);n[r.name]=r.multiple?Array.isArray(i)?i.map(String):[]:i!==void 0?i:r.type==="checkbox"?!1:""}return n}function oL(e,t,n){const r=jt(),i=e.optionsFrom,o=i?{...ES(i.query.params,n,r),...Object.fromEntries((i.dependsOn??[]).map(c=>[c,String(t[c]??"")]).filter(([,c])=>c!==""))}:{},a=JSON.stringify([(i==null?void 0:i.query.query)??null,o,r.version]),l=ne(()=>i?T.pageQuery(r.plugin,i.query.query,o).then(c=>c.data):Promise.resolve(void 0),[a]);return i?{options:to(l.data,i.rows).map(c=>({value:String(ye(c,i.value)??""),label:String(ye(c,i.label)??"")})),loading:l.loading}:{options:e.options??[],loading:!1}}function aL({field:e,fields:t,value:n,values:r,data:i,disabled:o,compact:a,onChange:l}){const c=oL(e,r,i),u={id:`f-${e.name}`,required:e.required,name:e.name,disabled:o,...a&&e.hint?{title:e.hint}:{}},h=a?void 0:e.hint;if(e.type==="select"&&e.multiple){const p=Array.isArray(n)?n.map(String):[],y=e.max!==void 0&&p.length>=e.max?`Up to ${e.max}; remove one to add another.`:void 0;return s.jsx(X,{label:e.label,hint:a?void 0:[h,y].filter(Boolean).join(" ")||void 0,group:!0,children:s.jsx(FM,{id:u.id,label:e.label,options:c.options,value:p,max:e.max,disabled:o,onChange:l})})}if(e.type==="select"){const p=s.jsxs("select",{...u,value:String(n??""),onChange:x=>l(x.target.value),children:[s.jsx("option",{value:"",children:c.loading?"Loading…":"—"}),c.options.map(x=>s.jsx("option",{value:x.value,children:x.label},x.value))]});return e.action&&!a?s.jsx(lL,{field:e,action:e.action,fields:t??[e],values:r,data:i,disabled:o,hint:h,children:p}):s.jsx(X,{label:e.label,hint:h,children:p})}if(e.type==="textarea")return s.jsx(X,{label:e.label,hint:h,wide:!0,children:s.jsx("textarea",{...u,value:String(n??""),onChange:p=>l(p.target.value),rows:6})});if(e.type==="checkbox")return s.jsx(X,{label:e.label,hint:h,inline:!0,wide:!a,children:s.jsx("input",{...u,type:"checkbox",checked:n===!0,onChange:p=>l(p.target.checked)})});const f=e.type==="secret"?"password":e.type==="number"?"number":e.type;return s.jsx(X,{label:e.label,hint:h,children:s.jsx("input",{...u,type:f,value:n==null?"":String(n),min:e.min,max:e.max,step:e.step,...a&&e.hint?{placeholder:e.hint}:{},onChange:p=>l(e.type==="number"?cL(p.target.value):p.target.value)})})}function lL({field:e,action:t,fields:n,values:r,data:i,disabled:o,hint:a,children:l}){const c=jt(),u=d.useId(),h=sL()===u,[f,p]=d.useState(!1),[x,y]=d.useState(null),[w,b]=d.useState(null),[v,m]=d.useState(null);d.useEffect(()=>()=>by(u),[u]);const j=ug(n,r,i),g=t.args!==void 0?Qr(t.args,{data:i,fields:r,shape:n,omit:j,scope:c}):Object.fromEntries(Object.entries(r).filter(([N,C])=>!j.has(N)&&C!=="")),S=async()=>{if(h){by(u);return}p(!0),y(null),b(null),m(null);try{const N=await T.pageAct(c.plugin,{tool:t.tool,args:g});if(N.approvalId){m(N.approvalId);return}y(yS(N.result));const C=vS(N.result);C&&await wS(C,u)}catch(N){b(N instanceof Error?N.message:String(N))}finally{p(!1)}},k=h?"Stop":t.label;return s.jsx(X,{label:e.label,hint:a,action:s.jsx(P,{"data-shape":"icon","aria-label":f?`${t.label}: working`:k,title:k,"aria-busy":f||void 0,"aria-pressed":t.icon==="play"?h:void 0,disabled:o===!0||f,onClick:()=>void S(),children:f?s.jsx("span",{className:"ui-spinner","aria-hidden":"true"}):s.jsx(Ae,{name:h?"stop":t.icon??"arrow"})}),after:w?s.jsx(re,{message:w}):v?s.jsx(tu,{id:v,onDecided:()=>m(null)}):x?s.jsx("span",{className:"ui-field-hint",role:"status",children:x}):null,children:l})}function cL(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function AS(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function ug(e,t,n){const r=AS(t,n);return new Set(e.filter(i=>i.when!==void 0&&!Hn(r,i.when)||i.disabledWhen!==void 0&&Hn(r,i.disabledWhen)).map(i=>i.name))}function dg({fields:e,values:t,data:n,disabled:r,compact:i,columns:o,onChange:a}){const l=AS(t,n);return s.jsx(Bs,{dense:i,columns:o,children:e.filter(c=>c.when===void 0||Hn(l,c.when)).map(c=>s.jsx(aL,{field:c,fields:e,compact:i,value:t[c.name],values:t,data:n,disabled:r===!0||c.disabledWhen!==void 0&&Hn(l,c.disabledWhen),onChange:u=>a(c.name,u)},c.name))})}const Pa=d.createContext(!1),RS=d.createContext(!1),TS=d.createContext(!1);function Ks({title:e,note:t,actions:n,children:r}){const i=d.useContext(Pa);return s.jsx(K,{title:e,aside:t,actions:n,panel:i,children:s.jsx(Pa.Provider,{value:!1,children:s.jsx(RS.Provider,{value:i,children:r})})})}function zs({component:e,data:t,choose:n,chosen:r}){const i=jt(),o=d.useContext(eu);if(!Hn(t,e.when))return null;if(e.kind!=="section"&&!o&&bS(e,i.sensitive))return s.jsx(CS,{children:s.jsx(zs,{component:e,data:t,...n?{choose:n}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return s.jsx(uL,{component:e,data:t});case"notice":return s.jsx(H,{tone:lg(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(Ne(t,e.text)??"")});case"link":return s.jsx(dL,{component:e,data:t});case"progress":return s.jsx(hL,{component:e,data:t});case"stats":return s.jsx(pL,{component:e,data:t});case"list":return s.jsx(gL,{component:e,data:t,...n?{onChoose:n}:{},...r===void 0?{}:{chosen:r}});case"table":return s.jsx(xL,{component:e,data:t});case"detail":return s.jsx(jL,{component:e,data:t});case"form":return s.jsx(wL,{component:e,data:t});case"search":return s.jsx(SL,{component:e,data:t});case"list-detail":return s.jsx(NL,{component:e,data:t});case"repeat":return s.jsx(CL,{component:e,data:t});case"expand":return s.jsx(EL,{component:e,data:t});case"button":return s.jsx(AL,{component:e,data:t});case"approval":return s.jsx(TL,{component:e,data:t});case"artifact":return s.jsx(PL,{component:e,data:t});case"editor":return s.jsx(IL,{component:e,data:t});case"agent-offer":return s.jsx(RL,{component:e});default:return null}}function uL({component:e,data:t}){const n=jt(),r=d.useContext(eu),[i,o]=kS(),a=!r&&bS(e.body,n.sensitive),l=a&&!i,c=d.useContext(Pa);let u=e.body.length;const h=x=>x.kind==="button"||x.kind==="link"||x.kind==="form"&&x.drawer!==void 0&&!x.title;for(;c&&u>0&&h(e.body[u-1]);)u-=1;const f=e.body.slice(0,u),p=[...e.actions??[],...e.body.slice(u)];return s.jsx(Ks,{title:e.title,note:e.note,actions:p.length>0||a?s.jsxs(s.Fragment,{children:[p.map((x,y)=>s.jsx(zs,{component:x,data:t},y)),a?s.jsx(SS,{revealed:i,onToggle:o}):null]}):void 0,children:s.jsx(V,{gap:"lg",divided:c,children:l?s.jsx(NS,{}):s.jsx(eu.Provider,{value:r||a,children:f.map((x,y)=>s.jsx(zs,{component:x,data:t},y))})})})}function dL({component:e,data:t}){const n=jt(),r=cg(n,e.to,t);return r===""?null:s.jsx(q,{children:s.jsx(cn,{href:r,onClick:i=>{i.preventDefault(),n.navigate(r)},children:e.label})})}function ky(e){return Math.round(e/1e6)}function fL(e,t){const n=ds(Ne(t,e.value))??0,r=e.total?ds(Ne(t,e.total)):null,i=e.total?r&&r>0?n/r:0:n,o=Math.max(0,Math.min(1,i)),a=Math.floor(o*100),l=i>=1,c=e.total&&r&&r>0?`${ky(n)} of ${Math.max(1,ky(r))} MB · ${a}%`:`${a}%`;return{percent:a,full:l,line:c}}function hL({component:e,data:t}){const n=c=>c===void 0?"":typeof c=="string"?c:String(Ne(t,c)??""),r=n(e.label),i=n(e.done),{percent:o,full:a,line:l}=fL(e,t);return s.jsxs(V,{gap:"sm",children:[r?s.jsx("span",{children:r}):null,a&&i?s.jsx("span",{role:"status",children:i}):s.jsxs(s.Fragment,{children:[s.jsx(_k,{value:o,label:r||"Progress"}),s.jsx("span",{role:"status",children:l})]})]})}function pL({component:e,data:t}){const n=ys(e.query,t);return s.jsxs(Ks,{title:e.title,note:e.note,children:[s.jsx(re,{message:n.error}),n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsx(Lu,{children:e.items.map((r,i)=>s.jsx(ls,{label:r.label,value:Nt(Ne(n.data,r.value),r.unit??"text",null),tone:rL(r.tone)},i))})]})}function PS(e,t,n,r){const i=(t.meta??[]).map(u=>String(Ne(n,u)??"")).filter(u=>u!==""),o=String(Ne(n,t.title)??""),a=t.to&&!r?cg(e,t.to,n):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,h)=>{const f=Ne(n,u.value);if(f==null||f==="")return null;const p=mL(u,f,n);return s.jsx(ve,{tone:Zh(p.tone),children:p.text},h)});return{text:o,href:a,pills:s.jsx(s.Fragment,{children:c}),meta:i.join(" · "),title:a?s.jsx("a",{href:a,onClick:u=>{u.preventDefault(),e.navigate(a)},children:o}):o,sub:t.sub?String(Ne(n,t.sub)??""):null,side:s.jsxs(s.Fragment,{children:[c,i.length>0?s.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function mL(e,t,n){const r=String(t),i=e.labels??{},o=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(o,r)?o[r]:ep(e.tone,n)}}function to(e,t){const n=ye(e,t);return Array.isArray(n)?n:[]}function IS(e,t,n){const r=[],i=new Set;return e.forEach((o,a)=>{const l=t===void 0?void 0:ye(o,t),c=l==null||l===""?null:String(l);if(c===null){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: row ${a} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:o})}),r}function gL({component:e,data:t,onChoose:n,chosen:r}){var S;const i=jt(),o=d.useContext(TS),a=ys(e.query,t),l=Va(),[c,u]=d.useState([]),h=o&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,f=to(a.data,e.rows),p=e.collapsed?to(a.data,e.collapsed.rows):[],x={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},y=IS([...f,...p],e.key??((S=e.select)==null?void 0:S.key),x),w=new Map(y.map(k=>[k.row,k.key])),b=new Set(y.map(k=>k.row)),v=new Set(y.filter(({row:k})=>{var N;return((N=e.select)==null?void 0:N.disabledWhen)===void 0||!Hn(k,e.select.disabledWhen)}).map(({key:k})=>k)),m=c.filter(k=>v.has(k)),j=d.useMemo(()=>{const k=f.filter(C=>b.has(C));if(!e.groupBy)return[{label:null,rows:k}];const N=new Map;for(const C of k){const A=String(ye(C,e.groupBy.key)??"");N.set(A,[...N.get(A)??[],C])}return[...N].map(([C,A])=>{var E,_;return{label:((_=(E=e.groupBy)==null?void 0:E.labels)==null?void 0:_[C])??C,rows:A}})},[f,e.groupBy,y.length]),g=k=>k.map(N=>{var L;const C=PS(i,e.item,N,n),A=w.get(N);if(h&&(n||C.href))return s.jsx(Ok,{href:C.href??"#",current:r===A,onClick:()=>n?n(A):i.navigate(C.href),title:C.text,meta:C.meta,sub:C.sub,side:C.pills},A);const E=((L=e.select)==null?void 0:L.disabledWhen)!==void 0&&Hn(N,e.select.disabledWhen),_=(e.actions??[]).filter(B=>Hn(N,B.when));return s.jsx(Gt,{lead:e.select?s.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(A),onClick:B=>B.stopPropagation(),onChange:B=>u(R=>B.target.checked?[...R,A]:R.filter(O=>O!==A))}):void 0,title:n?s.jsx("a",{href:"#","aria-current":r===A?"true":void 0,onClick:B=>{B.preventDefault(),n(A)},children:C.text}):C.title,sub:C.sub,side:s.jsxs(s.Fragment,{children:[C.side,_.map((B,R)=>s.jsx(eo,{action:B,args:Qr(B.args,{data:a.data,row:N,scope:i}),disabled:l.busy,running:l.running===B.tool,row:N,onRun:(O,Y)=>void l.run(O,Y)},R))]})},A)});return s.jsxs(Ks,{title:e.title,note:e.note,children:[s.jsx(re,{message:a.error}),s.jsx(yo,{act:l}),j.every(k=>k.rows.length===0)?a.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(fg,{text:e.empty??"Nothing here yet."}):s.jsxs(Ut,{children:[e.select?s.jsx(Gt,{lead:s.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:v.size>0&&m.length===v.size,disabled:v.size===0,onChange:k=>u(k.target.checked?[...v]:[])}),title:s.jsxs("span",{className:"muted",children:[v.size," to choose from"]})}):null,j.map((k,N)=>s.jsxs("div",{children:[k.label?s.jsx("div",{className:"ui-list-group",children:k.label}):null,g(k.rows)]},N))]}),e.collapsed&&p.some(k=>b.has(k))?s.jsx(Et,{summary:`${e.collapsed.label} (${p.filter(k=>b.has(k)).length})`,children:s.jsx(Ut,{children:g(p.filter(k=>b.has(k)))})}):null,e.bulk&&e.bulk.length>0?s.jsxs(q,{align:"end",children:[s.jsxs("span",{className:"ui-toolbar-note",children:[m.length," selected"]}),e.bulk.map((k,N)=>{const C=m.length>0||k.all!==!0?m:[...v];return s.jsx(eo,{action:k,args:Qr(k.args,{data:a.data,selected:C,scope:i}),count:C.length,disabled:l.busy||C.length===0,running:l.running===k.tool,onRun:(A,E)=>{u([]),l.run(A,E)}},N)})]}):null]})}function xL({component:e,data:t}){const n=jt(),r=ys(e.query,t),i=Va(),o=to(r.data,e.rows);return s.jsxs(Ks,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),s.jsx(yo,{act:i}),o.length===0?r.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(fg,{text:e.empty??"Nothing here yet."}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[e.columns.map(a=>s.jsx("th",{children:a.label},a.key)),e.actions&&e.actions.length>0?s.jsx("th",{"aria-label":"Actions"}):null]})}),s.jsx("tbody",{children:o.map((a,l)=>s.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:Nt(ye(a,c.key),c.type??"text",null);return s.jsx("td",{"data-fit":c.fit,title:vL(c,a,u),children:c.pill?s.jsx(yL,{column:c,row:a}):c.fit==="truncate"?s.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?s.jsx("td",{children:s.jsx(q,{align:"end",children:e.actions.filter(c=>Hn(a,c.when)).map((c,u)=>s.jsx(eo,{action:c,args:Qr(c.args,{data:r.data,row:a,scope:n}),disabled:i.busy,running:i.running===c.tool,row:a,onRun:(h,f)=>void i.run(h,f)},u))})}):null]},l))})]})]})}function vL(e,t,n){if(e.hint){const r=ye(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&n?n:void 0}function yL({column:e,row:t}){var a,l;const n=ye(t,e.key);if(Array.isArray(n))return s.jsx(s.Fragment,{children:n.map((c,u)=>{var w;const h=c,f=typeof h=="object"&&h!==null?h.value:c;if(f==null||f==="")return null;const p=typeof h=="object"&&h!==null?h.tone:void 0,x=(w=e.pill)==null?void 0:w.labels,y=x&&Object.prototype.hasOwnProperty.call(x,String(f))?x[String(f)]:Nt(f,e.type??"text",null);return s.jsx(ve,{tone:Zh(ep(typeof p=="string"?p:void 0,t)),children:y},u)})});const r=(a=e.pill)==null?void 0:a.labels,i=String(n),o=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:Nt(n,e.type??"text",null);return s.jsx(ve,{tone:Zh(ep((l=e.pill)==null?void 0:l.tone,t)),children:o})}function jL({component:e,data:t}){const n=ys(e.query,t);return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsx(Ks,{title:e.title,note:e.note,children:s.jsxs(V,{gap:"lg",children:[e.fields.length>0?s.jsx(Pt,{items:e.fields.map(r=>({key:r.label,label:r.label,value:Nt(Ne(n.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>s.jsx(zs,{component:r,data:n.data},i))]})})}function wL({component:e,data:t}){const n=jt(),r=ys(e.initial,t),i=Va(),[o,a]=d.useState(!1),l=JSON.stringify([r.data??null,n.version]),c=s.jsx(bL,{component:e,data:t,initialData:r.data,act:i,onDone:()=>a(!1)},l);return e.drawer?s.jsxs(K,{title:e.title,aside:e.note,actions:s.jsx(P,{variant:"accent",onClick:()=>a(!0),children:e.drawer.button}),children:[s.jsx(yo,{act:i}),o?s.jsx(Qt,{title:e.drawer.title,onClose:()=>a(!1),children:c}):null]}):s.jsxs(Ks,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),c]})}function bL({component:e,data:t,initialData:n,act:r,onDone:i}){const o=d.useContext(RS),a=jt(),[l,c]=d.useState(()=>nu(e.fields,n)),u=ug(e.fields,l,n),h=e.fields.some(f=>f.required&&!u.has(f.name)&&(l[f.name]===""||l[f.name]===void 0||Array.isArray(l[f.name])&&l[f.name].length===0));return s.jsxs(V,{children:[s.jsx(dg,{fields:e.fields,columns:e.columns,values:l,data:n,onChange:(f,p)=>c(x=>({...x,[f]:p}))}),e.drawer?null:s.jsx(yo,{act:r}),s.jsx(q,{align:"end",className:o?"ui-panel-foot":void 0,children:s.jsx(eo,{action:e.submit,args:Qr(e.submit.args,{data:t,fields:l,shape:e.fields,omit:u,scope:a}),disabled:r.busy||h,running:r.running===e.submit.tool,onRun:(f,p)=>void r.run(f,p,i)})})]})}function kL(e,t){var r;if(e.type==="checkbox")return e.label;const n=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${n?n.label:t}`}function Sy(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function SL({component:e,data:t}){const n=jt(),[r,i]=d.useState(()=>nu(e.fields,t)),[o,a]=d.useState(e.auto===!0),[l,c]=d.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),h=ys(o&&u?e.query:void 0,t),f=to(h.data,e.rows),p=e.count===void 0?void 0:ye(h.data,e.count),x=e.note===void 0?void 0:ye(h.data,e.note),y=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==y),b=C=>{n.setParams(Object.fromEntries(e.fields.map(A=>[A.name,String(C[A.name]??"")||null]))),a(!0)},v=(C,A)=>{const E={...r,[C]:A};i(E),e.auto&&b(E)},m=()=>{const C=nu(e.fields,null);i(C),e.auto?b(C):(n.setParams(Object.fromEntries(e.fields.map(A=>[A.name,null]))),a(!1))},j=o?w.filter(C=>Sy(n.params[C.name])):[],g=y?j.map(C=>s.jsx(qc,{label:C.label,onRemove:()=>{const A={...r,[C.name]:C.type==="checkbox"?!1:""};i(A),b(A)},children:kL(C,String(n.params[C.name]))},C.name)):[],S=w.filter(C=>Sy(r[C.name])).length,k=e.auto&&!e.reset?null:s.jsxs(s.Fragment,{children:[e.reset?s.jsx(P,{variant:"ghost",onClick:m,children:"Clear"}):null,e.auto?null:s.jsx(P,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),N=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return s.jsx(Ks,{title:e.title,children:s.jsxs(V,{children:[s.jsx(Lk,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&b(r)},main:y?s.jsx("input",{id:`f-${y.name}`,name:y.name,type:y.type==="email"?"email":"search","aria-label":y.label,placeholder:y.hint??y.label,title:y.hint,required:y.required,value:String(r[y.name]??""),onChange:C=>v(y.name,C.target.value)}):void 0,filters:w.length>0?s.jsx(dg,{fields:w,values:r,data:t,compact:!0,onChange:v}):void 0,...y&&w.length>0?{filtersOpen:l,onToggleFilters:()=>c(C=>!C),active:S}:{},chips:g.length>0?g:void 0,actions:k}),s.jsx(re,{message:h.error}),o&&(p!==void 0||x!==void 0)?s.jsxs("p",{className:"ui-card-meta",children:[p===void 0?"":`${Nt(p,"number",null)} in all. `,x===void 0?"":String(x)]}):null,o?f.length===0?s.jsx(ie,{children:h.loading?"Searching…":e.empty??"Nothing matches."}):s.jsx("div",{className:"ui-panel","data-flush":"true",children:s.jsx(Ut,{children:f.map((C,A)=>{const E=PS(n,N,C);return s.jsx(Gt,{title:E.title,sub:E.sub,side:E.side},A)})})}):null]})})}function NL({component:e,data:t}){const n=jt(),r=e.selection==="local",[i,o]=d.useState(null),a=r?i:n.params[e.param]??n.item,l=r&&i!==null?{...n,params:{...n.params,[e.param]:i}}:null,c=s.jsx(V,{gap:"lg",divided:!0,children:e.detail.map((u,h)=>s.jsx(zs,{component:u,data:t},h))});return s.jsx(Pa.Provider,{value:!1,children:s.jsx(Dk,{list:s.jsx(TS.Provider,{value:!0,children:s.jsx(zs,{component:e.list,data:t,chosen:a??null,...r?{choose:o}:{}})}),detail:a?l?s.jsx(ag.Provider,{value:l,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function CL({component:e,data:t}){const n=jt(),[r,i]=d.useState(!1),o=ys(e.query,t,r&&e.poll?e.poll.seconds*1e3:void 0),a=e.poll!==void 0&&o.data!==void 0&&Hn(o.data,e.poll.while);d.useEffect(()=>i(a),[a]);const l=to(o.data,e.rows);return s.jsxs(Ks,{title:e.title,note:e.note,children:[s.jsx(re,{message:o.error}),l.length===0?o.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(fg,{text:e.empty??"Nothing here yet."}):s.jsx(V,{gap:"lg",divided:!0,children:IS(l,e.key,{plugin:n.plugin,page:n.page,component:`repeat "${e.title??e.rows}"`}).map(({key:c,row:u})=>s.jsx(K,{children:s.jsx(V,{children:e.body.map((h,f)=>s.jsx(zs,{component:h,data:u},f))})},c))})]})}function EL({component:e,data:t}){const[n,r]=d.useState(!1),i=ys(n?e.query:void 0,t),o=typeof e.label=="string"?e.label:String(Ne(t,e.label)??"");return s.jsxs(Et,{summary:o,boxed:!0,onToggle:a=>r(a),children:[s.jsx(re,{message:i.error}),i.data===void 0?s.jsx(ie,{children:"Loading…"}):s.jsx(V,{children:e.body.map((a,l)=>s.jsx(zs,{component:a,data:i.data},l))})]})}function AL({component:e,data:t}){const n=jt(),r=Va();return s.jsxs(s.Fragment,{children:[s.jsx(q,{align:"end",children:s.jsx(eo,{action:e.action,args:Qr(e.action.args,{data:t,row:t,scope:n}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,o)=>void r.run(i,o)})}),s.jsx(yo,{act:r})]})}function RL({component:e}){const t=jt();return s.jsx(og,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function TL({component:e,data:t}){const n=ye(t,e.path);return typeof n!="string"||n===""?null:s.jsx(tu,{id:n})}function PL({component:e,data:t}){const n=ye(t,e.path);return typeof n!="string"||n===""?null:s.jsx(q,{children:s.jsx("a",{href:qr(n),children:e.label})})}function IL({component:e,data:t}){const n=ys(e.query,t),r=Va();return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsxs(s.Fragment,{children:[s.jsx(yo,{act:r}),s.jsx(ML,{component:e,data:t,loaded:n.data,act:r},JSON.stringify(n.data))]})}function ML({component:e,data:t,loaded:n,act:r}){const i=jt(),[o,a]=d.useState(()=>nu(e.fields,n)),l={...o,version:ye(n,e.version)},c=ug(e.fields,o,n),u=e.readOnlyWhen!==void 0&&Hn(n,e.readOnlyWhen),h=(e.actions??[]).filter(x=>x.placement==="leading"),f=(e.actions??[]).filter(x=>x.placement!=="leading"),p=(x,y)=>s.jsx(eo,{action:x,args:Qr(x.args,{data:t,fields:l,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===x.tool,onRun:(w,b)=>void r.run(w,b)},`${x.tool}-${y}`);return s.jsx(Ks,{title:e.title,note:e.note,children:s.jsxs(V,{children:[s.jsx(dg,{fields:e.fields,values:o,data:n,disabled:u,onChange:(x,y)=>a(w=>({...w,[x]:y}))}),u?null:s.jsxs(q,{align:"end",children:[h.map(p),h.length>0?s.jsx(xo,{}):null,p(e.save,-1),f.map(p)]}),e.footnote?s.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function MS({page:e,item:t,navigate:n,timezone:r,embedded:i,siblings:o}){const[a,l]=d.useState({}),[c,u]=d.useState(0),h={plugin:e.plugin,page:e.id,pages:o??[e],item:t??null,params:{...a,...t?{item:t}:{},..._L(e,t)},setParams:y=>l(w=>{const b={...w};for(const[v,m]of Object.entries(y))m===null?delete b[v]:b[v]=m;return b}),navigate:n,timezone:r,version:c,refresh:()=>u(y=>y+1),sensitive:new Set(e.sensitive??[])},f=e.body[0],p=!i&&(f==null?void 0:f.kind)==="notice"&&typeof f.text=="string"&&f.when===void 0&&f.title===void 0&&(f.tone===void 0||f.tone==="neutral")?f.text:void 0,x=p===void 0?e:{...e,body:e.body.slice(1)};return s.jsx(ag.Provider,{value:h,children:s.jsx(fn,{embedded:i,title:e.title,lede:p,children:s.jsx($L,{page:x,boxed:i===!0})})})}function $L({page:e,boxed:t}){const n=jt();return e.data&&n.sensitive.has(e.data.query)?s.jsx(CS,{children:s.jsx(Ny,{page:e,boxed:t})}):s.jsx(Ny,{page:e,boxed:t})}function Ny({page:e,boxed:t}){const n=ys(e.data,null);return s.jsxs(V,{gap:"lg",divided:!t,children:[s.jsx(re,{message:n.error}),s.jsx(Pa.Provider,{value:t,children:e.body.map((r,i)=>s.jsx(zs,{component:r,data:n.data??null},i))})]})}function _L(e,t){if(!t)return{};const n=[],r=i=>{for(const o of i)o.kind==="list-detail"?(n.push(o.param),r(o.detail)):(o.kind==="section"||o.kind==="detail"||o.kind==="expand")&&r(o.body)};return r(e.body),Object.fromEntries(n.map(i=>[i,t]))}function OL(e){return s.jsx(MS,{...e,embedded:!0})}function fg({text:e}){const t=e.search(/[.!?]\s/),n=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return s.jsx(Ct,{title:n,children:r||null})}function Cy(e,t){return(e??[]).filter(n=>n.place===t).map((n,r)=>({page:n,index:r})).sort((n,r)=>(n.page.order??0)-(r.page.order??0)||n.index-r.index).map(n=>n.page)}function $S(e=!1){const[t,n]=d.useState([]);return d.useEffect(()=>{if(e)return;let r=!1;return Promise.resolve().then(()=>T.pages()).then(i=>{r||n(Array.isArray(i==null?void 0:i.pages)?i.pages:[])}).catch(()=>{}),()=>{r=!0}},[e]),{all:t,rail:Cy(t,"rail"),settings:Cy(t,"settings"),find:(r,i)=>t.find(o=>o.plugin===r&&o.id===i)}}const Ey=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],DL=["","image","pdf","table","text","code","audio","video","archive","file"];function LL({hash:e,timezone:t,navigate:n,agents:r}){var B;const i=gI(e),o=(i==null?void 0:i.artifactId)??null,a=(i==null?void 0:i.filters.origin)??"",l=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,h]=d.useState(c);d.useEffect(()=>{h(c)},[c]);const f=(R,O=!1)=>n(Al(o,{q:c,origin:a,family:l,...R}),O);d.useEffect(()=>{if(u===c)return;const R=window.setTimeout(()=>f({q:u},!0),250);return()=>window.clearTimeout(R)},[u]);const[p,x]=d.useState(null),[y,w]=d.useState(null),[b,v]=d.useState(null),[m,j]=d.useState(!1),[g,S]=d.useState(!1),k=R=>{var O;return R?((O=r.find(Y=>Y.id===R))==null?void 0:O.name)??R:""},N=d.useRef(0);d.useEffect(()=>{const R=++N.current;x(null),w(null),j(!1),v(null),T.library({...c?{q:c}:{},...a?{origin:a}:{},...l?{family:l}:{}}).then(O=>{N.current===R&&(x(O.entries),w(O.next))}).catch(O=>{N.current===R&&v(O instanceof oe?O.message:String(O))})},[c,a,l]);const C=()=>{if(!y||m)return;j(!0);const R=N.current;T.library({...c?{q:c}:{},...a?{origin:a}:{},...l?{family:l}:{},cursor:y}).then(O=>{N.current===R&&(x(Y=>{const G=new Set((Y??[]).map(M=>M.id));return[...Y??[],...O.entries.filter(M=>!G.has(M.id))]}),w(O.next))}).catch(O=>{N.current===R&&v(O instanceof oe?O.message:String(O))}).finally(()=>{N.current===R&&j(!1)})},A=(a?1:0)+(l?1:0),E=((B=Ey.find(R=>R.id===a))==null?void 0:B.label)??a,_=s.jsxs(s.Fragment,{children:[p===null?s.jsx(ie,{children:"Loading…"}):p.length===0?s.jsx(ie,{children:"No file matches that."}):s.jsx(Ut,{children:p.map(R=>s.jsx(Ok,{href:Al(R.id,{q:c,origin:a,family:l}),current:R.id===o,onClick:()=>n(Al(R.id,{q:c,origin:a,family:l})),lead:s.jsx("span",{className:"files-row-visual","data-family":R.family,children:R.family==="image"&&!R.deleted?s.jsx("img",{src:yr(R.id),alt:"",loading:"lazy"}):s.jsx(tg,{family:R.family})}),title:R.filename??"Untitled file",meta:s.jsx("span",{title:De(R.createdAt,t),children:Ee(R.createdAt)}),sub:`${Fr[R.family]} · ${dn(R.sizeBytes)} · ${_S(R,k)}${FL(R,k)}`},R.id))}),y?s.jsx("div",{className:"files-more",children:s.jsx(P,{size:"sm",onClick:C,disabled:m,children:m?"Loading…":"Show more"})}):null]}),L=p!==null&&p.length===0&&!c&&!a&&!l&&!u;return s.jsxs("div",{className:"ui-page files","data-selected":o?"true":void 0,children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Files"}),s.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),L?s.jsx(Ct,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):s.jsxs(s.Fragment,{children:[s.jsx(Lk,{label:"Files",onSubmit:()=>f({q:u},!0),main:s.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:R=>h(R.target.value)}),filters:s.jsxs(Bs,{dense:!0,children:[s.jsx(X,{label:"Origin",children:s.jsx("select",{value:a,"aria-label":"Origin",onChange:R=>f({origin:R.target.value}),children:Ey.map(R=>s.jsx("option",{value:R.id,children:R.label},R.id))})}),s.jsx(X,{label:"Kind",children:s.jsx("select",{value:l,"aria-label":"Kind",onChange:R=>f({family:R.target.value}),children:DL.map(R=>s.jsx("option",{value:R,children:R===""?"Any kind":Fr[R]},R))})})]}),filtersOpen:g,onToggleFilters:()=>S(R=>!R),active:A,chips:A>0?s.jsxs(s.Fragment,{children:[a?s.jsx(qc,{label:"Origin",onRemove:()=>f({origin:""}),children:E}):null,l?s.jsx(qc,{label:"Kind",onRemove:()=>f({family:""}),children:Fr[l]}):null]}):void 0}),s.jsx(re,{message:b}),s.jsx(Dk,{className:"files-split",label:"Files",list:_,detail:o?s.jsx(UL,{id:o,timezone:t,agents:r,navigate:n,onBack:()=>n(Al(null,{q:c,origin:a,family:l}))},o):void 0,empty:"Choose a file to see it here."})]})]})}function FL(e,t){var i,o;const n=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(o=e.context)!=null&&o.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[n,r].filter(Boolean).map(a=>` · ${a}`).join("")}function _S(e,t){return e.origin==="uploaded"?"You sent it":e.origin==="produced"?`Made by ${t(e.agentId)||"an agent"}`:e.agentId?`Saved by ${t(e.agentId)}`:"Origin unknown"}function UL({id:e,timezone:t,agents:n,navigate:r,onBack:i}){const[o,a]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let m=!1;return a(null),h(null),T.libraryEntry(e).then(j=>{m||a(j)}).catch(j=>{m||h(j instanceof oe&&j.status===404?"This file is no longer in the library.":j instanceof oe?j.message:String(j))}),()=>{m=!0}},[e]);const f=m=>{var j;return m?((j=n.find(g=>g.id===m))==null?void 0:j.name)??m:""};if(u)return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(P,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsx(H,{tone:"critical",children:u})]});if(!o)return s.jsx("div",{className:"files-detail-body",children:s.jsx(ie,{children:"Loading…"})});const{entry:p,contexts:x,contextsTotal:y,available:w}=o,b=p.filename??"Untitled file",v=()=>{c(!0),T.libraryEntry(e,x.length).then(m=>a(j=>j&&{...j,contexts:[...j.contexts,...m.contexts],contextsTotal:m.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(P,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsxs("header",{className:"files-detail-head",children:[s.jsx("span",{className:"files-detail-mark","data-family":p.family,"aria-hidden":"true",children:s.jsx(tg,{family:p.family})}),s.jsxs("div",{className:"files-detail-text",children:[s.jsx("h3",{className:"files-detail-name",children:b}),s.jsxs("p",{className:"files-detail-meta",children:[Fr[p.family]," · ",dn(p.sizeBytes)," · ",De(p.createdAt,t)]})]}),w?s.jsx("a",{className:"ui-btn","data-variant":"accent",href:qr(p.id),download:b,children:"Download"}):null]}),w?null:s.jsx(H,{tone:"warning",children:"The file's bytes are no longer on this machine. What is known about it stays here; the download will not work."}),s.jsx(Zk,{artifactId:p.id,filename:p.filename,mime:p.mime,family:p.family,available:w}),s.jsx(Pt,{items:[{label:"Origin",value:_S(p,f)},...p.agentId&&p.origin==="produced"?[{label:"Made by",value:s.jsxs("span",{className:"files-agent",children:[s.jsx(tn,{agents:n,id:p.agentId,size:"sm"}),f(p.agentId)]})}]:[],{label:"Type",value:s.jsx("span",{className:"mono",children:p.mime})},{label:"Id",value:s.jsx("span",{className:"mono",children:p.id})}]}),s.jsxs("section",{className:"files-conversations",children:[s.jsx("h4",{className:"ui-section-title",children:"Conversations"}),x.length===0?s.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):s.jsx("ul",{className:"files-ctx",role:"list",children:x.map(m=>{const j=m.groupId?Zo(m.groupId,m.conversationId):Ue(m.conversationAgentId,m.conversationId),g=m.groupId?m.groupName??"a group":f(m.conversationAgentId);return s.jsxs("li",{className:"files-ctx-row",children:[s.jsxs("span",{className:"files-ctx-text",children:[s.jsx("span",{children:m.groupId?`Group: ${g}`:g}),s.jsxs("span",{className:"muted",children:[" · ",m.kind==="produced"?`made by ${f(m.agentId)||"an agent"}`:m.kind==="reused"?"sent again":"sent by you"," · ",Ee(m.at)]})]}),s.jsx("a",{className:"ui-btn","data-size":"sm",href:j,onClick:S=>{S.preventDefault(),r(j)},children:"Open conversation"})]},`${m.conversationId}:${m.kind}`)})}),x.length<y?s.jsx(q,{align:"end",children:s.jsx(P,{size:"sm",onClick:v,disabled:l,children:l?"Loading…":`Show ${y-x.length} more`})}):null]})]})}const BL={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe"};function OS(e){return e&&BL[e]||"plug"}function zL({attention:e,place:t,onNavigate:n,theme:r,onTheme:i,plugins:o=[],updateAvailable:a=!1,version:l}){return s.jsxs("nav",{className:"rail","aria-label":"Places",children:[s.jsx("a",{className:"rail-mark",href:Ft,onClick:c=>{c.preventDefault(),n(Ft)},"aria-label":"buddi home",children:s.jsx(UM,{})}),SI.filter(c=>c.route!==Zt).map(c=>s.jsx(nf,{label:c.label,href:c.route,active:t===c.route,badge:c.route===Ft?e:0,onClick:()=>n(c.route),children:Ay[c.route]},c.route)),o.map(c=>{const u=Na(c.plugin,c.id);return s.jsx(nf,{label:c.title,href:u,active:t===u,badge:0,onClick:()=>n(u),children:s.jsx(Ae,{name:OS(c.icon)})},u)}),s.jsx("div",{className:"rail-spacer"}),s.jsx(nf,{label:"Settings",href:Zt,active:t===Zt,badge:0,dot:a?"a newer buddi is ready":void 0,onClick:()=>n(Zt),children:Ay[Zt]}),s.jsx(HL,{theme:r,onTheme:i,onNavigate:n,version:l})]})}const WL=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function HL({theme:e,onTheme:t,onNavigate:n,version:r}){var l,c;const o=((c=(l=ne(()=>T.owner(),[]).data)==null?void 0:l.preferredName)==null?void 0:c.trim())||null,a=(o??"You").slice(0,1).toUpperCase();return s.jsx("div",{className:"rail-owner",children:s.jsxs(Tm,{modal:!1,children:[s.jsx(Pm,{asChild:!0,children:s.jsx("button",{type:"button",className:"rail-owner-btn","aria-label":o?`You: ${o}`:"You",children:s.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:a})})}),s.jsx(Im,{children:s.jsxs(Mm,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[s.jsxs("div",{className:"rail-owner-head",children:[s.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:a}),s.jsxs("span",{className:"rail-owner-who",children:[s.jsx("span",{className:"rail-owner-name",children:o??"You"}),s.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),s.jsx(lc,{className:"ui-menu-sep"}),s.jsx($m,{className:"ui-menu-label",children:"Theme"}),s.jsx("div",{className:"rail-owner-theme",children:s.jsx(uc,{label:"Theme",options:WL,value:e,onChange:t})}),s.jsx(lc,{className:"ui-menu-sep"}),s.jsx(Ch,{className:"ui-menu-item",onSelect:()=>n(lt("appearance")),children:"Change appearance"}),r?s.jsxs(s.Fragment,{children:[s.jsx(lc,{className:"ui-menu-sep"}),s.jsxs(Ch,{className:"ui-menu-item rail-owner-version","data-update":r.updateAvailable?"true":void 0,onSelect:()=>n(lt("system")),children:[s.jsxs("span",{className:"mono",children:["buddi ",r.current]}),r.updateAvailable&&r.latest?s.jsxs("span",{className:"rail-owner-update",children:["A newer buddi is ready: ",r.latest]}):null]})]}):null]})})]})})}function nf({label:e,href:t,active:n,badge:r,dot:i,onClick:o,children:a}){return s.jsxs("a",{className:"rail-link",href:t,"data-active":n?"true":void 0,"aria-current":n?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:i?`${e}, ${i}`:e,onClick:l=>{l.preventDefault(),o()},children:[s.jsxs("span",{className:"rail-icon",children:[a,r>0?s.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null,r===0&&i?s.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"rail-dot","aria-hidden":"true"}):null]}),s.jsx("span",{className:"rail-label",children:e})]})}const Ay={[Gr]:s.jsx(Ae,{name:"files"}),[Ft]:s.jsx(Ae,{name:"home"}),[Ji]:s.jsx(Ae,{name:"chat"}),[it]:s.jsx(Ae,{name:"agents"}),[rt]:s.jsx(Ae,{name:"activity"}),[Zt]:s.jsx(Ae,{name:"settings"})};function VL(e){return e instanceof HTMLElement?e.isContentEditable?!0:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function KL(e,t=!0){d.useEffect(()=>{if(!t)return;const n=r=>{if(r.key!=="/"||r.defaultPrevented||r.ctrlKey||r.metaKey||r.altKey||VL(r.target))return;r.preventDefault();const i=document.getElementById(qh);if(i instanceof HTMLTextAreaElement){!i.disabled&&!i.hidden&&i.focus();return}e(Ft)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t])}const DS="buddi.theme";function GL(e=LS()){try{const t=e==null?void 0:e.getItem(DS);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function YL(e,t=LS()){try{t==null||t.setItem(DS,e)}catch{}}function qL(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function LS(){try{return window.localStorage}catch{return}}const FS="buddi.ground",US="buddi.pageWidth";function QL(e=WS()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},n=t(FS),r=t(US);return{theme:GL(e),ground:n==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function BS(e,t=document.documentElement){t&&(qL(e.theme,t),e.ground==="sand"?t.setAttribute("data-ground","sand"):t.removeAttribute("data-ground"),e.width==="wide"?t.removeAttribute("data-width"):t.setAttribute("data-width",e.width))}function XL(e,t=WS()){YL(e.theme,t);try{t==null||t.setItem(FS,e.ground),t==null||t.setItem(US,e.width)}catch{}}let zi=null;const tp=new Set;function np(){return zi||(zi=QL()),zi}function JL(e){return tp.add(e),()=>tp.delete(e)}function ZL(e){zi={...np(),...e},BS(zi),XL(zi);for(const t of tp)t()}function zS(){return[d.useSyncExternalStore(JL,np,np),ZL]}function WS(){try{return window.localStorage}catch{return}}function eF({timezone:e,embedded:t}){var p,x;const{data:n,error:r,reload:i}=ne(()=>T.sentinels(),[],3e4),o=ne(()=>T.missions(),[]),[a,l]=d.useState(null),c=((x=(p=o.data)==null?void 0:p.missions.find(y=>y.id==="sentinel-wake"))==null?void 0:x.agentId)??null,u=async(y,w)=>{l(null);try{await T.snoozeAlert(y,w),i()}catch(b){l(b instanceof Error?b.message:String(b))}},h=((n==null?void 0:n.open)??[]).filter(y=>!y.snoozedAt),f=((n==null?void 0:n.open)??[]).filter(y=>y.snoozedAt);return s.jsxs(fn,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[s.jsx(re,{message:r??a}),s.jsx(H,{children:"An alert closes on its own once the fact behind it changes: record the payment, update the balance, and the watcher clears it on its next run. Snooze one you have decided to live with; it stays quiet until it resolves."}),s.jsx(sf,{title:"Open",findings:h,timezone:e,askAgentId:c,onSnooze:y=>u(y,!0),empty:"Nothing open. Your watchers are quiet."}),f.length>0?s.jsx(sf,{title:"Snoozed",findings:f,timezone:e,askAgentId:c,onSnooze:y=>u(y,!1),empty:""}):null,s.jsx(sf,{title:"Resolved",findings:(n==null?void 0:n.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),s.jsx(ct,{title:"Waiting for the weekly recap",flush:!0,children:!n||n.digest.length===0?s.jsx(Ct,{icon:"bell",title:"Nothing waiting for the recap"}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Title"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Noted"})]})}),s.jsx("tbody",{children:n.digest.map(y=>s.jsxs("tr",{children:[s.jsxs("td",{children:[Xi(y.title),s.jsx(VS,{text:Xi(y.detail)})]}),s.jsx("td",{children:s.jsx(HS,{severity:y.severity})}),s.jsx("td",{className:"nowrap",children:De(y.createdAt,e)})]},y.id))})]})})]})}function HS({severity:e}){return s.jsx(ve,{tone:e==="urgent"?"critical":void 0,children:e})}function VS({text:e}){const[t,n]=d.useState(!1),r=e.length>240||e.split(`
|
|
106
|
-
`).length>3;return s.jsxs("div",{className:"sub alert-detail","data-clamp":r&&!t?"true":void 0,children:[e,r?s.jsx("button",{type:"button",className:"wb-link alert-more",onClick:()=>n(i=>!i),children:t?"Less":"More"}):null]})}function tF(e){return`About this alert: "${Xi(e.title)}". ${Xi(e.detail)}
|
|
107
|
-
|
|
108
|
-
What should I do about it, and what do you need from me to clear it?`}function sf({title:e,findings:t,timezone:n,askAgentId:r,onSnooze:i,empty:o}){const a=e==="Snoozed";return s.jsx(ct,{title:e,flush:!0,children:t.length===0?s.jsx(ie,{children:o}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Finding"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Since"}),i?s.jsx("th",{}):null]})}),s.jsx("tbody",{children:t.map(l=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:Xi(l.title)}),s.jsx(VS,{text:Xi(l.detail)}),l.data?s.jsx(Et,{summary:"evidence",children:s.jsx(ft,{children:ln(l.data)})}):null]}),s.jsx("td",{children:s.jsx(HS,{severity:l.severity})}),s.jsxs("td",{className:"nowrap",children:[De(l.firstSeenAt,n),s.jsxs("div",{className:"sub",title:De(l.lastSeenAt,n),children:["last seen ",Ee(l.lastSeenAt)]})]}),i?s.jsx("td",{children:s.jsxs(q,{align:"end",children:[r?s.jsx(cn,{size:"sm",href:Ue(r,"new"),onClick:()=>OD(r,tF(l)),children:"Ask about it"}):null,s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(l.key),children:a?"Wake":"Snooze"})]})}):null]},l.key))})]})})}const Ry=5e3,Ty=50;function nF({timezone:e,embedded:t}){var v;const[n,r]=d.useState(""),[i,o]=d.useState(""),[a,l]=d.useState(null),c=ne(()=>T.eventKinds(),[]),{data:u,error:h}=ne(()=>T.events({kind:n||void 0,q:i||void 0,limit:Ty}),[n,i],Ry),[f,p]=d.useState({events:[],cursor:null,busy:!1,error:null});d.useEffect(()=>{p({events:[],cursor:null,busy:!1,error:null})},[n,i]);const x=f.events.length>0?f.cursor:(u==null?void 0:u.nextCursor)??null,y=async()=>{if(x){p(m=>({...m,busy:!0,error:null}));try{const m=await T.events({kind:n||void 0,q:i||void 0,before:x,limit:Ty});p(j=>({events:[...j.events,...m.events],cursor:m.nextCursor,busy:!1,error:null}))}catch(m){p(j=>({...j,busy:!1,error:m instanceof Error?m.message:String(m)}))}}},w=new Set(((u==null?void 0:u.events)??[]).map(m=>m.id)),b=[...(u==null?void 0:u.events)??[],...f.events.filter(m=>!w.has(m.id))];return s.jsxs(fn,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[s.jsxs(q,{children:[s.jsxs("select",{"aria-label":"Event kind",value:n,onChange:m=>r(m.target.value),children:[s.jsx("option",{value:"",children:"every kind"}),(((v=c.data)==null?void 0:v.kinds)??[]).map(m=>s.jsxs("option",{value:m.kind,children:[m.kind," (",m.count,")"]},m.kind))]}),s.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:m=>o(m.target.value),size:28}),n||i?s.jsx(P,{onClick:()=>{r(""),o("")},children:"Clear"}):null,s.jsxs("span",{className:"muted",children:["refreshes every ",Ry/1e3,"s"]})]}),s.jsx(re,{message:h}),s.jsx(ct,{flush:!0,children:!u||b.length===0?s.jsx(ie,{children:"No events match."}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"#"}),s.jsx("th",{children:"When"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Payload"})]})}),s.jsx("tbody",{children:b.map(m=>s.jsxs("tr",{"data-clickable":"true",onClick:()=>l(m),children:[s.jsx("td",{className:"mono muted",children:m.id}),s.jsxs("td",{className:"nowrap",children:[De(m.createdAt,e),s.jsx("div",{className:"sub",children:Ee(m.createdAt)})]}),s.jsx("td",{className:"mono nowrap",children:m.kind}),s.jsx("td",{className:"mono muted",children:ms(ln(m.payload).replace(/\s+/g," "),120)})]},m.id))})]})}),x||f.error?s.jsxs(q,{children:[s.jsxs("span",{className:"muted",children:[b.length," shown",x?", older ones are kept":"","."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),f.error?s.jsx("span",{className:"critical",children:f.error}):null,x?s.jsx(P,{disabled:f.busy,onClick:()=>void y(),children:f.busy?"Loading…":"Load older"}):null]}):null,a?s.jsxs(Qt,{title:a.kind,onClose:()=>l(null),children:[s.jsxs("p",{className:"muted",children:["Event ",a.id," · ",De(a.createdAt,e),a.conversationId?s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:`#/conversations/${a.conversationId}`,children:"conversation"})]}):null]}),s.jsx(ft,{children:ln(a.payload)})]}):null]})}const sF=["pending","leased","suspended","failed","succeeded","cancelled"],Do=50;function rF({timezone:e,embedded:t,initialState:n}){const[r,i]=d.useState(n??""),[o,a]=d.useState(null),[l,c]=d.useState(null),{data:u,error:h,reload:f}=ne(()=>T.jobs({...r?{state:r}:{},limit:String(Do)}),[r],1e4),[p,x]=d.useState({jobs:[],done:!1,busy:!1});d.useEffect(()=>{x({jobs:[],done:!1,busy:!1})},[r]);const y=async()=>{x(N=>({...N,busy:!0}));try{const N=await T.jobs({...r?{state:r}:{},limit:String(Do),offset:String(Do+p.jobs.length)});x(C=>({jobs:[...C.jobs,...N.jobs],done:N.jobs.length<Do,busy:!1}))}catch(N){c(N instanceof Error?N.message:String(N)),x(C=>({...C,busy:!1}))}},w=new Set(((u==null?void 0:u.jobs)??[]).map(N=>N.id)),b=[...(u==null?void 0:u.jobs)??[],...p.jobs.filter(N=>!w.has(N.id))],v=r?(u==null?void 0:u.counts[r])??0:Object.values((u==null?void 0:u.counts)??{}).reduce((N,C)=>N+C,0),m=!p.done&&b.length<v&&((u==null?void 0:u.jobs.length)??0)>=Do,[j,g]=d.useState(null),S=async N=>{c(null),g(N);try{const C=(await T.jobs({state:"failed",limit:"500"})).jobs;for(const A of C)await(N==="retry"?T.retryJob(A.id):T.cancelJob(A.id));f()}catch(C){c(C instanceof Error?C.message:String(C))}finally{g(null)}},k=async N=>{c(null);try{await N,a(null),f()}catch(C){c(C instanceof Error?C.message:String(C))}};return s.jsxs(fn,{embedded:t,title:"Jobs",lede:`${u!=null&&u.paused?"Paused: nothing is being claimed. ":""}Bounded retries with backoff; past the budget a job waits for you.`,actions:t?void 0:s.jsx(P,{size:"sm",variant:u!=null&&u.paused?"accent":void 0,onClick:()=>k(T.setPaused(!((u==null?void 0:u.paused)??!1))),children:u!=null&&u.paused?"Resume the queue":"Pause the queue"}),children:[s.jsxs(q,{children:[s.jsxs("select",{"aria-label":"Job state",value:r,onChange:N=>i(N.target.value),children:[s.jsx("option",{value:"",children:"every state"}),sF.map(N=>s.jsxs("option",{value:N,children:[N," (",(u==null?void 0:u.counts[N])??0,")"]},N))]}),((u==null?void 0:u.counts.failed)??0)>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("span",{className:"muted",children:[u.counts.failed," failed."]}),s.jsx(P,{size:"sm",disabled:j!==null,onClick:()=>void S("retry"),children:j==="retry"?"Retrying…":"Retry all failed"}),s.jsx(P,{size:"sm",variant:"danger",disabled:j!==null,onClick:()=>void S("cancel"),children:j==="cancel"?"Cancelling…":"Cancel all failed"})]}):null]}),s.jsx(re,{message:h??l}),s.jsx(ct,{flush:!0,children:!u||b.length===0?s.jsx(ie,{children:"No jobs match."}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"State"}),s.jsx("th",{className:"num",children:"Attempts"}),s.jsx("th",{children:"Last error"}),s.jsx("th",{children:"Updated"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:b.map(N=>s.jsxs("tr",{children:[s.jsxs("td",{className:"clickable",onClick:()=>a(N),children:[N.kind,s.jsx("div",{className:"sub mono",children:Sa(N.id)})]}),s.jsxs("td",{children:[s.jsx(Du,{state:N.state}),N.suspendedReason?s.jsx("div",{className:"sub",children:ms(N.suspendedReason,40)}):null]}),s.jsxs("td",{className:"num",children:[N.attempts,"/",N.maxAttempts]}),s.jsx("td",{className:N.lastError?"critical":"muted",children:N.lastError?ms(N.lastError,80):"—"}),s.jsxs("td",{className:"nowrap",children:[De(N.updatedAt,e),s.jsx("div",{className:"sub",children:Ee(N.updatedAt)})]}),s.jsx("td",{children:s.jsxs(q,{align:"end",children:[["failed","cancelled","suspended"].includes(N.state)?s.jsx(P,{size:"sm",onClick:()=>k(T.retryJob(N.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(N.state)?s.jsx(P,{size:"sm",variant:"danger",onClick:()=>k(T.cancelJob(N.id)),children:"Cancel"}):null]})})]},N.id))})]})}),m?s.jsxs(q,{children:[s.jsxs("span",{className:"muted",children:[b.length," of ",v," shown."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{disabled:p.busy,onClick:()=>void y(),children:p.busy?"Loading…":"Load older"})]}):null,o?s.jsxs(Qt,{title:o.kind,onClose:()=>a(null),children:[s.jsx("p",{className:"muted mono",children:o.id}),s.jsx(K,{title:"Payload",children:s.jsx(ft,{children:ln(o.payload)})}),s.jsx(K,{title:"Result",children:s.jsx(ft,{children:ln(o.result)})}),o.conversationId?s.jsx("p",{children:s.jsx("a",{href:`#/conversations/${o.conversationId}`,children:"open the transcript"})}):null]}):null]})}const iF=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function oF({hash:e,timezone:t,navigate:n,agents:r}){var u,h;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),o=f=>{var p;return((p=r.find(x=>x.id===f))==null?void 0:p.name)??f};if(i){let f=i[1];try{f=decodeURIComponent(f)}catch{}return s.jsx(cF,{id:f,timezone:t,navigate:n,nameOf:o})}const a=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",l=(h=/[?&]state=([a-z]+)/.exec(e))==null?void 0:h[1],c=f=>p=>{p.preventDefault(),n(f)};return s.jsxs("div",{className:"ui-page",children:[s.jsx(Gm,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:s.jsx(fF,{})}),s.jsx(hF,{}),s.jsx(Fu,{children:iF.map(f=>{const p=f.id==="conversations"?rt:`${rt}/${f.id}`;return s.jsx(Uu,{href:p,active:a===f.id,onClick:c(p),children:f.label},f.id)})}),a==="conversations"?s.jsx(aF,{timezone:t,navigate:n,nameOf:o,agents:r}):null,a==="jobs"?s.jsx(rF,{timezone:t,embedded:!0,initialState:l},l??""):null,a==="approvals"?s.jsx(lF,{timezone:t,nameOf:o}):null,a==="alerts"?s.jsx(eF,{timezone:t,embedded:!0}):null,a==="events"?s.jsx(nF,{timezone:t,embedded:!0}):null]})}function aF({timezone:e,navigate:t,nameOf:n,agents:r}){const{data:i,error:o}=ne(()=>T.conversations(),[],3e4);return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:o}),s.jsx(ct,{flush:!0,children:i?i.conversations.length===0?s.jsx(Ct,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):s.jsx(Ut,{children:i.conversations.map(a=>s.jsx(Gt,{href:Zi(a.id),onClick:()=>t(Zi(a.id)),lead:s.jsx(tn,{agents:r,id:a.agentId,size:"sm"}),title:a.opening?ms(a.opening,100):"Untitled conversation",sub:`${n(a.agentId)}, ${a.messageCount} message${a.messageCount===1?"":"s"}, ${a.runs} run${a.runs===1?"":"s"}, ${rI(a.usage)}`,side:s.jsx("span",{title:De(a.lastMessageAt??a.createdAt,e),children:Ee(a.lastMessageAt??a.createdAt)})},a.id))}):s.jsx(ie,{children:"Loading…"})})]})}function lF({timezone:e,nameOf:t}){const{data:n,error:r}=ne(()=>T.approvals(),[],1e4),i=[...(n==null?void 0:n.pending)??[],...(n==null?void 0:n.recent)??[]];return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:r}),s.jsx(ct,{flush:!0,children:n?i.length===0?s.jsx(Ct,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Tool"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Asked by"}),s.jsx("th",{children:"Decided"}),s.jsx("th",{children:"Created"})]})}),s.jsx("tbody",{children:i.map(o=>s.jsxs("tr",{children:[s.jsxs("td",{children:[o.tool,s.jsx("div",{className:"sub mono",children:Sa(o.id)})]}),s.jsx("td",{children:s.jsx(Du,{state:o.state})}),s.jsx("td",{children:t(o.agentId)}),s.jsx("td",{className:"nowrap",children:o.decidedAt?s.jsxs(s.Fragment,{children:[De(o.decidedAt,e),s.jsxs("div",{className:"sub",children:["via ",o.decidedVia??"—"]})]}):s.jsx("span",{className:"muted",children:"—"})}),s.jsxs("td",{className:"nowrap",children:[De(o.createdAt,e),s.jsx("div",{className:"sub",children:Ee(o.createdAt)})]})]},o.id))})]}):s.jsx(ie,{children:"Loading…"})})]})}function cF({id:e,timezone:t,navigate:n,nameOf:r}){const[i,o]=d.useState(null),[a,l]=d.useState(null);d.useEffect(()=>{let u=!1;return T.conversation(e).then(h=>{u||o(h)}).catch(h=>{u||l(h instanceof Error?h.message:String(h))}),()=>{u=!0}},[e]);const c=u=>h=>{h.preventDefault(),n(u)};return s.jsxs("div",{className:"ui-page",children:[s.jsx("p",{className:"page-crumbs",children:s.jsx("a",{href:rt,onClick:c(rt),children:"Activity"})}),s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[s.jsx(P,{size:"sm",onClick:()=>n(rt),children:"← Back"}),s.jsx("span",{children:"Transcript"})]}),i?s.jsx("div",{className:"ui-page-actions",children:s.jsx(cn,{size:"sm",href:Ue(i.agentId,e),onClick:c(Ue(i.agentId,e)),children:"Open in chat"})}):null]}),s.jsx("p",{className:"ui-page-lede mono",children:e})]}),s.jsx(re,{message:a}),i?s.jsxs(s.Fragment,{children:[s.jsxs(Lu,{children:[s.jsx(ls,{label:"Agent",value:r(i.agentId),size:"sm"}),s.jsx(ls,{label:"Runs",value:i.runs.length}),s.jsx(ls,{label:"Tokens",value:`${vt(i.usage.input)} / ${vt(i.usage.output)}`,note:Eh(i.usage)?`input / output, ${Eh(i.usage)}`:"input / output"}),s.jsx(ls,{label:"Started",value:De(i.createdAt,t),size:"sm"})]}),i.runs.length>0?s.jsx(ct,{title:"Runs",flush:!0,children:s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{className:"num",children:"Turns"}),s.jsx("th",{children:"Stopped"}),s.jsx("th",{className:"num",children:"Tokens"}),s.jsx("th",{className:"num",children:"Cached"})]})}),s.jsx("tbody",{children:i.runs.map((u,h)=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[De(u.startedAt,t)," ",u.resumed?s.jsx(ve,{children:"resumed"}):null]}),s.jsx("td",{className:"nowrap",children:De(u.finishedAt,t)}),s.jsx("td",{className:"num",children:u.turns??"—"}),s.jsxs("td",{children:[u.stopped??"—",u.actionId?s.jsxs("div",{className:"sub mono",children:["action ",Sa(u.actionId)]}):null]}),s.jsxs("td",{className:"num muted nowrap",children:[vt(u.usage.input)," / ",vt(u.usage.output)]}),s.jsx("td",{className:"num muted nowrap",children:u.usage.cacheRead||u.usage.cacheWrite?vt((u.usage.cacheRead??0)+(u.usage.cacheWrite??0)):"—"})]},h))})]})}):null,s.jsx(K,{title:"Messages",children:s.jsx(V,{children:i.messages.map(u=>s.jsxs("article",{className:"transcript-msg",children:[s.jsxs("header",{className:"transcript-who",children:[u.speaker===Py?"approved action, result":u.role,", ",De(u.createdAt,t)]}),s.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?s.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===Py?u.blocks.map((h,f)=>s.jsx(uF,{block:h},f)):u.blocks.map((h,f)=>s.jsx(dF,{block:h},f))]})]},u.id))})})]}):s.jsx(ie,{children:"Loading…"})]})}const Py="approval:resume";function uF({block:e}){return s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),s.jsx(ft,{children:e.type==="text"?e.text??"":ln(e)})]})}function dF({block:e}){return e.type==="text"?s.jsx("div",{className:"transcript-text",children:s.jsx(vr,{text:e.text??""})}):e.type==="thinking"?s.jsxs("details",{className:"transcript-thinking",children:[s.jsx("summary",{children:"Thoughts"}),s.jsx("div",{className:"transcript-thinking-text",children:s.jsx(vr,{text:e.text??""})})]}):e.type==="tool_use"?s.jsxs("div",{className:"transcript-tool",children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),s.jsx(ft,{children:ln(e.input)})]}):e.type==="tool_result"?s.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),s.jsx(ft,{children:e.content??""})]}):s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:e.type}),s.jsx(ft,{children:ln(e.ref)})]})}function fF(){const{data:e,reload:t}=ne(()=>T.overview(),[],1e4),[n,r]=d.useState(!1);if(!e)return null;const i=()=>{r(!0),T.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return s.jsx(P,{size:"sm",variant:e.paused?"accent":void 0,disabled:n,onClick:i,children:e.paused?"Resume all":"Pause all"})}function hF(){const{data:e}=ne(()=>T.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,n=t("leased");return s.jsxs(Lu,{children:[s.jsx(ls,{label:"Jobs done",value:vt(t("succeeded"))}),s.jsx(ls,{label:"Failed",value:vt(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),s.jsx(ls,{label:"Queued",value:vt(t("pending")),note:`${n} running`}),s.jsx(ls,{label:"Approvals",value:vt(e.approvals.pending),note:"waiting for you"})]})}const pF=["replay-all","coalesce","latest-only","skip-after-deadline"];function KS({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:o}=ne(()=>T.missions(),[],3e4),a=((r==null?void 0:r.missions)??[]).filter(h=>!n||h.agentId===n),[l,c]=d.useState(null),u=async h=>{c(null);try{await h,o()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.jsxs(fn,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[s.jsx(re,{message:i??l}),!r||a.length===0?s.jsxs(Ct,{icon:"calendar",title:"No missions yet",children:["Run ",s.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):s.jsx(V,{children:a.map(h=>s.jsx(mF,{mission:h,timezone:e,onRun:u},h.id))})]})}function mF({mission:e,timezone:t,onRun:n}){const[r,i]=d.useState(!1);return s.jsxs(Yr,{tone:e.enabled?"good":"muted",title:s.jsxs(s.Fragment,{children:[e.name," ",s.jsx("span",{className:"mono muted",children:e.id})]}),meta:s.jsxs(s.Fragment,{children:[s.jsx(ve,{mono:!0,children:e.agentId}),e.alwaysDeliver?s.jsx(ve,{children:"always delivers"}):null,e.enabled?null:s.jsx(ve,{tone:"warning",children:"disabled"})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",onClick:()=>n(T.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(o=>!o),"aria-expanded":r,children:r?"Less":"More"})]}),children:[s.jsxs("p",{className:"ui-card-meta",children:[e.schedule?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${De(e.nextRun,t)} (${Ee(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",s.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${Ee(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?s.jsxs("div",{className:"ui-card-foot",children:[e.schedule?s.jsxs(q,{children:[s.jsx(X,{inline:!0,label:"Misfire policy",children:s.jsx("select",{value:e.schedule.misfirePolicy,onChange:o=>n(T.setMisfirePolicy(e.id,o.target.value)),children:pF.map(o=>s.jsx("option",{value:o,children:o},o))})}),s.jsx("span",{className:"muted",children:"What a week asleep does: replay every instant, coalesce into one, keep only the latest, or skip past a deadline."})]}):null,s.jsx(K,{title:"Prompt",children:s.jsx(ft,{children:e.prompt})}),s.jsx(K,{title:"Recent occurrences",children:s.jsx(ct,{flush:!0,children:e.occurrences.length===0?s.jsx(ie,{children:"Never run."}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Scheduled"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{children:"Detail"})]})}),s.jsx("tbody",{children:e.occurrences.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"nowrap",children:De(o.scheduledAt,t)}),s.jsx("td",{children:s.jsx(Du,{state:o.state})}),s.jsx("td",{className:"nowrap",children:De(o.finishedAt,t)}),s.jsxs("td",{className:o.error?"critical":"muted",children:[o.error?ms(o.error,120):null,o.runConversationId?s.jsx("a",{href:`#/conversations/${o.runConversationId}`,children:"transcript"}):null]})]},o.id))})]})})})]}):null]})}function gF(e,t){const n=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${n}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function GS({ids:e,agentName:t,onDone:n}){const r=e.length,[i,o]=d.useState(!1),[a,l]=d.useState(!1);return r<=0?null:i?s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:gF(r,t)}),s.jsx(P,{size:"sm",variant:"danger",disabled:a,onClick:()=>{l(!0),T.dismissOffers(e).then(()=>{o(!1),n()}).finally(()=>l(!1))},children:`Dismiss ${r}`}),s.jsx(P,{size:"sm",variant:"ghost",disabled:a,onClick:()=>o(!1),children:"Keep them"})]}):s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>o(!0),children:"Dismiss all"})}function YS({embedded:e,agentId:t,agentName:n}){const{data:r,error:i,reload:o}=ne(()=>T.offers(),[],2e4),a=v=>!t||v.agentId===t,l=((r==null?void 0:r.offers)??[]).filter(a),c=((r==null?void 0:r.closed)??[]).filter(a),[u,h]=d.useState(null),[f,p]=d.useState(null),[x,y]=d.useState(null),w=async(v,m)=>{h(null),p(v);try{const j=await T.takeOffer(v);y(j.jobId?`On it — ${m}. Started as job ${j.jobId}.`:`Taken — ${m}. No worker is running here, so nothing has started yet.`),o()}catch(j){h(j instanceof Error?j.message:String(j))}finally{p(null)}},b=async(v,m)=>{h(null),p(v);try{await T.dismissOffer(v),y(`Dismissed — ${m}. It will not come back.`),o()}catch(j){h(j instanceof Error?j.message:String(j))}finally{p(null)}};return s.jsxs(fn,{embedded:e,title:"Offers",lede:"Things an agent already worked out that you might want done. Taking one asks that agent the sentence it wrote. It authorizes nothing, and anything that would leave this machine still comes back to you as an approval.",children:[s.jsx(re,{message:i??u}),x?s.jsx(H,{tone:"good",role:"status",children:x}):null,l.length>0?s.jsxs(q,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(GS,{ids:l.map(v=>v.id),agentName:n,onDone:()=>{y(null),o()}})]}):null,!r||l.length===0?s.jsx(Ct,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):s.jsx(V,{children:l.map(v=>s.jsx(Yr,{tone:"accent",title:v.label,meta:s.jsxs(s.Fragment,{children:[s.jsx(ve,{mono:!0,children:v.agentId}),s.jsxs("span",{className:"muted",children:["expires ",Ee(v.expiresAt)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{size:"sm",variant:"ghost",disabled:f===v.id,onClick:()=>void b(v.id,v.label),children:"Not now"}),s.jsx(P,{variant:"accent",size:"sm",disabled:f===v.id,onClick:()=>void w(v.id,v.label),children:"Take"})]}),children:s.jsx("p",{className:"ui-card-meta",children:v.prompt})},v.id))}),c.length>0?s.jsxs(Et,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[s.jsx(ct,{flush:!0,children:s.jsx(Ut,{children:c.map(v=>s.jsx(Gt,{title:v.label,sub:`${v.agentId} — ${IT(v)}`,side:Ee(v.dismissedAt??v.lapsedAt??v.createdAt)},v.id))})}),s.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const xF=["fact","observation","todo"];function qS({embedded:e,agents:t,timezone:n,agentId:r}){const{data:i,error:o,reload:a}=ne(()=>T.memory(r),[r],3e4),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),x=g=>{var S;return g==="shared"?"Everyone":((S=t.find(k=>k.id===g))==null?void 0:S.name)??g},y=async g=>{p(null);try{await g,a()}catch(S){p(S instanceof oe?S.message:String(S))}},w={nameOf:x,timezone:n,onChangePreference:g=>c({key:g.key,scope:g.scope}),onForgetPreference:g=>void y(T.forgetPreference({key:g.key,scope:g.scope})),onEditNote:g=>h(g),onForgetNote:g=>void y(T.forgetNote(g.id))},b=r?x(r):"",v=r&&i?{preferences:i.preferences.filter(g=>g.scope===r),notes:i.notes.filter(g=>g.scope===r)}:null,m=r&&i?{preferences:i.preferences.filter(g=>g.scope==="shared"),notes:i.notes.filter(g=>g.scope==="shared")}:null,j=s.jsx(P,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return s.jsxs(fn,{embedded:e,title:"Memory",lede:"What your agents have kept about you. Correct anything here; they see the change on their next turn.",children:[s.jsx(re,{message:o??f}),v&&m?s.jsxs(V,{gap:"lg",children:[s.jsx(K,{title:"Preferences",aside:`what you told ${b} alone`,actions:j,panel:!0,flush:!0,children:s.jsx(rf,{preferences:v.preferences,empty:`Nothing stated to ${b} alone yet.`,...w})}),s.jsx(K,{title:"Notes",aside:`what ${b} wrote down for itself`,panel:!0,flush:!0,children:s.jsx(of,{notes:v.notes,empty:`${b} has kept no private notes yet.`,...w})}),s.jsx(Et,{summary:`Shared with every agent, which ${b} also reads · ${m.preferences.length} preferences, ${m.notes.length} notes`,children:s.jsxs(V,{gap:"lg",children:[s.jsx(K,{title:"Shared preferences",panel:!0,flush:!0,children:s.jsx(rf,{preferences:m.preferences,empty:"No shared preferences.",...w})}),s.jsx(K,{title:"Shared notes",panel:!0,flush:!0,children:s.jsx(of,{notes:m.notes,empty:"No shared notes.",...w})})]})})]}):s.jsxs(V,{gap:"lg",children:[s.jsx(K,{title:"Preferences",aside:"what you said you want, one current value each",actions:j,panel:!0,flush:!0,children:i?s.jsx(rf,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...w}):s.jsx(ie,{children:"Loading…"})}),s.jsx(K,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?s.jsx(of,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...w}):s.jsx(ie,{children:"Loading…"})})]}),l?s.jsx(vF,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:l,onClose:()=>c(null),onSave:async g=>{await y((async()=>{await T.setPreference(g),l.key===g.key&&l.scope!==g.scope&&await T.forgetPreference({key:l.key,scope:l.scope})})()),c(null)}}):null,u?s.jsx(yF,{note:u,agents:t,onClose:()=>h(null),onSave:g=>y(T.updateNote(u.id,g)).then(()=>h(null))}):null]})}function rf({preferences:e,empty:t,nameOf:n,onChangePreference:r,onForgetPreference:i}){return e.length===0?s.jsx(ie,{children:t}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Preference"}),s.jsx("th",{children:"Value"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{className:"num",children:"Since"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:o.key}),s.jsx("td",{children:o.value}),s.jsx("td",{children:s.jsx(QS,{scope:o.scope,name:n(o.scope)})}),s.jsxs("td",{className:"num muted",title:o.updatedAt??"",children:[o.updatedAt?Ee(o.updatedAt,Date.now()):"",o.revision>1?` · rev ${o.revision}`:""]}),s.jsx("td",{className:"num",children:s.jsxs(q,{align:"end",children:[s.jsx(P,{size:"sm",onClick:()=>r(o),title:"Store a new value for this key",children:"Change"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>i(o),children:"Forget"})]})})]},`${o.scope}:${o.key}`))})]})}function of({notes:e,empty:t,nameOf:n,timezone:r,onEditNote:i,onForgetNote:o}){return e.length===0?s.jsx(ie,{children:t}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Note"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{children:"Written by"}),s.jsx("th",{className:"num",children:"When"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(a=>s.jsxs("tr",{children:[s.jsx("td",{className:"memory-note",children:a.content}),s.jsx("td",{children:s.jsx(ve,{tone:a.kind==="todo"?"warning":a.kind==="fact"?"good":void 0,children:a.kind})}),s.jsx("td",{children:s.jsx(QS,{scope:a.scope,name:n(a.scope)})}),s.jsx("td",{className:"muted",children:a.createdByAgent?n(a.createdByAgent):""}),s.jsxs("td",{className:"num muted",title:a.createdAt??"",children:[a.createdAt?Ee(a.createdAt,Date.now()):"",a.expiresAt?s.jsxs("span",{className:"memory-expires",children:[" · until ",new Date(a.expiresAt).toLocaleDateString(void 0,{timeZone:r})]}):null]}),s.jsx("td",{className:"num",children:s.jsxs(q,{align:"end",children:[s.jsx(P,{size:"sm",onClick:()=>i(a),children:"Edit"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>o(a),children:"Forget"})]})})]},a.id))})]})}function QS({scope:e,name:t}){return s.jsx(ve,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function XS({value:e,agents:t,onChange:n}){return s.jsxs("select",{value:e,onChange:r=>n(r.target.value),children:[s.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>s.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function vF({agents:e,existing:t,initial:n,onClose:r,onSave:i}){const o=t.find(m=>m.key===n.key&&m.scope===n.scope),[a,l]=d.useState(n.key),[c,u]=d.useState((o==null?void 0:o.value)??""),[h,f]=d.useState(n.scope),[p,x]=d.useState(!1),y=a.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(m=>m.key===y&&m.scope===h),b=!o||y!==o.key||c.trim()!==o.value||h!==o.scope,v=y!==""&&c.trim()!==""&&b;return s.jsx(Qt,{title:"A preference",onClose:r,children:s.jsxs(V,{children:[s.jsx(H,{children:'A preference is a standing choice, in your words: "paid biweekly on Thursdays", "answers short, numbers first". Storing the same key again records a correction and keeps the old value in the history.'}),s.jsx(X,{label:"Key",hint:y&&y!==a?`Stored as ${y}`:"Short and stable, like reporting_currency or tone.",children:s.jsx("input",{value:a,autoFocus:n.key==="",onChange:m=>l(m.target.value),placeholder:"reporting_currency"})}),s.jsx(X,{label:"Value",children:s.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:n.key!=="",onChange:m=>u(m.target.value),placeholder:"EUR"})}),s.jsx(X,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:s.jsx(XS,{value:h,agents:e,onChange:f})}),w&&w!==o?s.jsxs(H,{tone:"warning",children:['This replaces the value already stored for this key here, "',w.value,'" (revision ',w.revision,")."]}):null,o&&h!==o.scope?s.jsxs(H,{children:["It moves: the copy for ",o.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:r,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!v||p,onClick:()=>{x(!0),i({key:y,value:c.trim(),scope:h}).finally(()=>x(!1))},children:o?"Save change":"Save"})]})]})})}function yF({note:e,agents:t,onClose:n,onSave:r}){var x;const[i,o]=d.useState(e.content),[a,l]=d.useState(e.scope),[c,u]=d.useState(e.kind),[h,f]=d.useState(!1),p=i.trim()!==e.content||a!==e.scope||c!==e.kind;return s.jsx(Qt,{title:"A note",onClose:n,children:s.jsxs(V,{children:[s.jsx(X,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:s.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:y=>o(y.target.value)})}),s.jsxs(Bs,{children:[s.jsx(X,{label:"Kind",children:s.jsx("select",{value:c,onChange:y=>u(y.target.value),children:xF.map(y=>s.jsx("option",{value:y,children:y},y))})}),s.jsx(X,{label:"Who sees it",children:s.jsx(XS,{value:a,agents:t,onChange:l})})]}),e.createdByAgent?s.jsxs("p",{className:"muted",children:["Written by ",((x=t.find(y=>y.id===e.createdByAgent))==null?void 0:x.name)??e.createdByAgent,e.createdAt?`, ${Ee(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{variant:"accent",disabled:!p||i.trim()===""||h,onClick:()=>{f(!0);const y={};i.trim()!==e.content&&(y.content=i.trim()),a!==e.scope&&(y.scope=a),c!==e.kind&&(y.kind=c),r(y).finally(()=>f(!1))},children:"Save"})]})]})})}function jF({agentId:e,agentName:t}){const{data:n,error:r,reload:i}=ne(()=>T.agentSkills(e),[e],3e4),[o,a]=d.useState(null),[l,c]=d.useState(null),[u,h]=d.useState(null),f=async y=>{a(null),c(null),h(y.name);try{const w=await T.removeSkill(e,y.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){a(w instanceof oe?w.message:String(w))}finally{h(null)}};if(!n)return r?s.jsx(re,{message:r}):s.jsx(ie,{children:"Loading…"});const p=n.skills.filter(y=>y.learned!==null),x=n.skills.filter(y=>y.learned===null);return s.jsxs(V,{divided:!0,children:[s.jsx(re,{message:r??o}),l?s.jsx(H,{tone:"good",role:"status",children:l}):null,s.jsx(K,{title:"Learned",aside:s.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:p.length===0?s.jsx(Ct,{icon:"bulb",title:"Nothing learned yet",children:n.writable?`When ${t} proposes a procedure and you keep it on Settings → Proposals, it appears here.`:`${t} ships with buddi, so it keeps no learned skills of its own until it is yours.`}):s.jsx(ct,{flush:!0,children:s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"Version"}),s.jsx("th",{children:"Came from"}),s.jsx("th",{className:"num",children:"Kept"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:p.map(y=>s.jsx(bF,{skill:y,busy:u===y.name,onRemove:()=>void f(y)},y.name))})]})})}),s.jsx(K,{title:"From files and plugins",aside:s.jsx("span",{className:"muted",children:"read-only here"}),children:x.length===0?s.jsx(ie,{children:"No other skills."}):s.jsx(ct,{flush:!0,children:s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"What it is for"}),s.jsx("th",{children:"Whose"})]})}),s.jsx("tbody",{children:x.map(y=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(Et,{summary:s.jsx("span",{className:"mono",children:y.name}),children:[s.jsx(ft,{children:y.body}),s.jsx("p",{className:"muted mono skill-file",children:y.file})]})}),s.jsx("td",{children:y.description}),s.jsx("td",{children:s.jsxs(V,{gap:"sm",children:[s.jsx(ve,{children:y.scope==="shared"?"shared":`${t} only`}),s.jsx("span",{className:"muted",children:wF(y)})]})})]},`${y.scope}:${y.name}`))})]})})})]})}function wF(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function bF({skill:e,busy:t,onRemove:n}){const r=e.learned;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(Et,{summary:s.jsxs("span",{children:[r.title," ",s.jsx("span",{className:"muted mono",children:e.name})]}),children:[s.jsxs("p",{className:"muted",children:["When: ",e.description]}),s.jsx(ft,{children:e.body}),s.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),s.jsx("td",{children:s.jsxs(V,{gap:"sm",children:[s.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?s.jsx(ve,{tone:"warning",children:"untrusted text in view"}):null]})}),s.jsx("td",{children:s.jsxs(V,{gap:"sm",children:[r.conversation?s.jsx("a",{href:Zi(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):s.jsx("span",{className:"muted",children:"no conversation"}),s.jsx("a",{href:lt("proposals"),children:"the proposal"}),r.sources.length>0?s.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>s.jsx("li",{className:"mono",children:i},i))}):null]})}),s.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?Ee(r.keptAt,Date.now()):""}),s.jsx("td",{className:"num",children:s.jsx(q,{align:"end",children:s.jsx(P,{size:"sm",variant:"ghost",disabled:t,onClick:n,children:"Remove"})})})]})}function JS({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:o}=ne(()=>T.reminders(),[],3e4),a=((r==null?void 0:r.reminders)??[]).filter(h=>!n||h.agentId===n),[l,c]=d.useState(null),u=async h=>{c(null);try{await T.cancelReminder(h),o()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.jsxs(fn,{embedded:t,title:"Reminders",lede:"A reminder wakes an agent with a note and the instruction to check before it speaks, never a message queued for delivery.",children:[s.jsx(re,{message:i??l}),s.jsx(ct,{flush:!0,children:r?a.length===0?s.jsx(Ct,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Due"}),s.jsx("th",{children:"Agent"}),s.jsx("th",{children:"Note"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:a.map(h=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[De(h.dueAt,e),s.jsx("div",{className:"sub",children:Ee(h.dueAt)})]}),s.jsx("td",{className:"mono",children:h.agentId}),s.jsxs("td",{children:[h.text,h.context?s.jsx(Et,{summary:"context",children:s.jsx(ft,{children:ln(h.context)})}):null]}),s.jsxs("td",{children:[s.jsx(Du,{state:h.state}),h.cancelReason?s.jsx("div",{className:"sub",children:h.cancelReason}):null]}),s.jsx("td",{children:h.state==="pending"?s.jsx(P,{size:"sm",variant:"danger",onClick:()=>u(h.id),children:"Cancel"}):null})]},h.id))})]}):s.jsx(ie,{children:"Loading…"})})]})}function hg({accountId:e,label:t,value:n,onChange:r,disabled:i=!1}){const[o,a]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(""),[f,p]=d.useState(!1),x=d.useRef(0),y=async m=>{if(!e)return;const j=++x.current;c(!0),h("");try{const g=await T.accountModels(e,m);j===x.current&&a(g)}catch(g){j===x.current&&h(g instanceof Error?g.message:"Could not load models. Custom entry is still available.")}finally{j===x.current&&c(!1)}};if(d.useEffect(()=>(a(null),p(!1),h(""),y(!1),()=>{x.current++}),[e]),!e)return s.jsxs(s.Fragment,{children:[s.jsx(X,{label:t,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:m=>r(m.target.value)})}),s.jsx("p",{className:"ui-toolbar-note",children:"Save and connect the account to load its model list. You can enter a model manually now."})]});const w=(o==null?void 0:o.models)??[],b=!!n&&!w.some(m=>m.id===n),v=[o&&!w.length?"This account returned no models. You can enter a custom model.":null,o!=null&&o.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,o?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(X,{label:t,children:s.jsxs("select",{value:f?"__buddi_custom__":n,disabled:i,onChange:m=>{m.target.value==="__buddi_custom__"?p(!0):(p(!1),r(m.target.value))},children:[s.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),b&&s.jsxs("option",{value:n,children:[n," (current",o?", not listed":"",")"]}),w.map(m=>s.jsxs("option",{value:m.id,children:[m.name===m.id?m.id:`${m.name} — ${m.id}`,m.isDefault?" (provider default)":""]},m.id)),s.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),s.jsx(P,{disabled:i||l,onClick:()=>void y(!0),children:l?"Loading models…":"Refresh models"}),f&&s.jsx(X,{label:`Custom ${t.toLowerCase()}`,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:m=>r(m.target.value)})}),u&&s.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),v.length>0&&s.jsx("p",{className:"ui-toolbar-note",children:v.join(" ")})]})}function kF(e,t){const n=new Set(t),r=[],i=new Set;for(const o of e){for(const l of o.tools)i.add(l.name);const a=o.tools.filter(l=>n.has(l.name));a.length!==0&&(o.glob&&a.length===o.tools.length?r.push(o.glob):r.push(...a.map(l=>l.name)))}return r.push(...t.filter(o=>!i.has(o))),r}function SF(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const NF="This agent will not remember anything between conversations.";function CF({view:e,chosen:t,onChange:n,disabled:r}){var S;const[i,o]=d.useState(""),[a,l]=d.useState(null),[c,u]=d.useState(()=>new Set),h=k=>u(N=>{const C=new Set(N);return C.has(k)?C.delete(k):C.add(k),C}),f=k=>{o(k),u(new Set)},p=d.useId(),x=new Set(t),y=new Set(e.groups.flatMap(k=>k.tools.filter(N=>N.core).map(N=>N.name))),w=(k,N)=>{const C=N.filter(A=>x.has(A));if(C.length!==0){if(C.some(A=>y.has(A))){l({plugin:k,names:C});return}n(t.filter(A=>!C.includes(A)))}},b=k=>{n([...t,...k.filter(N=>!x.has(N))])},v=i.trim().toLowerCase(),m=(k,N)=>v===""||k.toLowerCase().includes(v)||N.toLowerCase().includes(v),j=e.groups.map(k=>({group:k,tools:k.tools.filter(N=>m(N.name,N.description))})).filter(k=>k.tools.length>0),g=(((S=e.suggested)==null?void 0:S.tools)??[]).filter(k=>!x.has(k.name));return s.jsxs("div",{className:"tool-picker",children:[e.suggested&&g.length>0?s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${p}-suggested`,children:[s.jsx("div",{className:"tool-picker-head",children:s.jsx("span",{id:`${p}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),s.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:g.map(k=>s.jsxs("li",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title mono",children:k.name}),s.jsx("span",{className:"ui-list-sub",children:k.description})]}),s.jsx(P,{size:"sm",disabled:r,"aria-label":`Add ${k.name}`,onClick:()=>b([k.name]),children:"Add"})]},k.name))})]}):null,s.jsxs("label",{className:"tool-picker-search",children:[s.jsx("span",{className:"ui-field-label",children:"Find a tool"}),s.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:k=>f(k.target.value)})]}),j.length===0?s.jsxs(ie,{children:["No installed tool matches “",i.trim(),"”."]}):null,j.map(({group:k,tools:N})=>{const C=k.tools.filter(R=>R.grantable).map(R=>R.name),A=k.tools.filter(R=>x.has(R.name)).length,E=!!k.glob&&A===k.tools.length,_=`${p}-${k.plugin}`,L=`${p}-${k.plugin}-list`,B=v!==""?!c.has(k.plugin):c.has(k.plugin);return s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":_,"data-open":B?"true":void 0,children:[s.jsxs("div",{className:"tool-picker-head",children:[s.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":B,"aria-controls":L,onClick:()=>h(k.plugin),children:[s.jsx(EF,{}),s.jsx("span",{id:_,className:"tool-picker-plugin",children:k.plugin}),s.jsx("span",{className:"muted",children:E?`all ${k.tools.length}`:`${A} of ${k.tools.length} granted`})]}),s.jsx(P,{size:"sm",variant:"ghost","aria-label":`All ${k.plugin} tools`,disabled:r||C.every(R=>x.has(R)),onClick:()=>b(C),children:"all"}),s.jsx(P,{size:"sm",variant:"ghost","aria-label":`No ${k.plugin} tools`,disabled:r||!C.some(R=>x.has(R)),onClick:()=>w(k.plugin,C),children:"none"})]}),(a==null?void 0:a.plugin)===k.plugin?s.jsx(H,{tone:"warning",role:"alert",children:s.jsxs("div",{className:"tool-picker-confirm",children:[s.jsx("span",{children:NF}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{size:"sm",onClick:()=>l(null),children:"Keep"}),s.jsx(P,{size:"sm",variant:"danger",onClick:()=>{n(t.filter(R=>!a.names.includes(R))),l(null)},children:"Remove"})]})}):null,s.jsx("ul",{id:L,className:"ui-list tool-picker-list",hidden:!B,children:N.map(R=>{const O=`${p}-${R.name}`;return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:O,checked:x.has(R.name),disabled:r||!R.grantable,onChange:Y=>Y.target.checked?b([R.name]):w(k.plugin,[R.name])}),s.jsxs("label",{htmlFor:O,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[s.jsx("span",{className:"mono",children:R.name}),R.core?s.jsx(ve,{tone:"accent",children:"core"}):null,R.gated?s.jsx(ve,{tone:"warning",children:"asks you"}):null]}),s.jsx("span",{className:"ui-list-sub",children:R.grantable?R.description:`${R.description} Granted only by editing the file by hand.`})]})]},R.name)})})]},k.plugin)})]})}function EF(){return s.jsx("svg",{className:"tool-picker-chevron",viewBox:"0 0 11 11","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const AF="buddi",RF=["core","coding","finance","garage","mail","maker","playground","research"],Ka=e=>`./mascot/${e}.png`,TF=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],PF="Introduce yourself by name, say one thing you can do today, and ask one question.",F={opening:["Hi. I'm buddi. I live on this computer, and I'm about to introduce you to your first assistant.","Nothing you tell me leaves this machine, except what your assistant sends to the AI you pick in a minute."],later:"Set up later",name:{ask:"First, what should we call you?",placeholder:"Your first name",submit:"That's me"},clock:{ask:(e,t)=>`Nice to meet you, ${e}. I'll set your clock to ${t}, which is what this browser says. Right?`,yes:"Yes",another:"Pick another",label:"Your clock",answer:e=>e},brain:{ask:"Your assistant needs a brain: an AI it thinks with. Which of these do you already have?",cards:{claude:{title:"Claude",line:"I pay for Claude",know:"Uses your Claude plan's monthly Agent SDK credits; after them, an API key."},chatgpt:{title:"ChatGPT",line:"I pay for ChatGPT",know:"Uses your ChatGPT plan through OpenAI's Codex backend. Sign in with a code."},gemini:{title:"Gemini",line:"I have a Google AI key"},key:{title:"A key from Anthropic or OpenAI",line:"I have an API key"},ollama:{title:"Ollama",line:"Free, on this computer"},cloud:{title:"Ollama Cloud, one tap",line:"Free to start, no key"},service:{title:"Another service, or Ollama Cloud with a key",line:"I have an address and a key"}},claude:{start:"Sign in with Claude",open:"Open the Claude sign-in page",paste:"Paste what Claude gave you",finish:"Done",waiting:"Sign in, then paste the code Claude shows you."},chatgpt:{label:"ChatGPT",codeBefore:"Here is your code: ",codeAfter:". Open the link, enter it, and approve buddi on openai.com.",code:"Your code",open:"Open openai.com",again:"Try again",failed:"The sign-in did not finish. Try again."},cloud:{label:"Ollama Cloud",waiting:"Press Connect on the ollama.com page. Sign in there first if it asks. I will notice.",open:"Open the ollama.com page",again:"Try again"},gemini:{label:"Gemini",field:"Your Google AI key",placeholder:"Paste it here",submit:"Use this key",get:"Get a key at aistudio.google.com"},key:{field:"Your key",placeholder:"Paste it here",submit:"Use this key",which:"Not right?",anthropic:"Anthropic",openai:"OpenAI",refused:"That key was refused. Check it and paste it again."},ollama:{found:"Found it, running now",missing:"Install Ollama, then come back",connect:"Use Ollama",download:"Get Ollama",looking:"Looking for it on this computer…"},model:{ask:"Which one should it think with?",label:"The model",submit:"Use this one",change:"Think with another"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking Ollama…",cloud:"Asking Ollama Cloud…",claude:"Checking with Claude…",chatgpt:"Asking ChatGPT…",gemini:"Asking Gemini…"},back:"Back",service:{address:"Address",addressPlaceholder:"The address they gave you",key:"Key",submit:"Connect it"},works:e=>`That works. Your assistant will think with ${e}.`,refused:e=>e,answer:e=>e},browser:{chrome:"Your assistant will browse with Google Chrome.",chromium:"Your assistant will browse with its own Chromium.",needs:"Your assistant needs a browser of its own to look at websites. I am fetching one now, about 150 MB.",installing:"Fetching the browser…",launching:"Making sure it opens…",installed:"Installed.",skip:"Skip for now",skipped:"Skipped. Settings → Computer & browser can install it whenever you like.",missing:"No browser for your assistant yet. Settings → Computer & browser can install one.",failed:e=>`That did not work: ${e}`,retry:"Try again"},assistant:{ask:"Last thing: your assistant. I've picked a name and a face; change either, or keep them.",name:"Name",face:"A face",mascot:e=>e==="core"?"Buddi Blob":`Buddi Blob, ${e}`,purpose:"What should it help you with?",purposeValue:["You're not a chatbot. You're becoming someone this person can count on.","","Some starting truths:","",`- Help for real. No "Great question", no "I'd be happy to". Do the thing, then say what you did.`,"- Have a view. Prefer things, disagree when you should, say when something is a bad idea. A search engine with manners is not a colleague.","- Look before you ask. Read the file, check what you remember, try it. Come back with an answer and one question at most.","- You are a guest here. You can see messages, files and a calendar. Treat that with care, keep what you learn to yourself, and never lecture.","- Remember what matters. Names, preferences, the things they said once and expect you to keep.","- When you change how you work, say so. This file is yours to grow, and the owner should always know what it says."].join(`
|
|
109
|
-
`),submit:"Introduce us"},restore:{offer:"I have a backup from another buddi",file:"The backup file",passphrase:"Its passphrase",passphraseHint:"Only if it was locked with one.",submit:"Restore",cancel:"Never mind",started:"Right. Give me a couple of minutes.",phases:{stopping:"Putting everything down for a moment.",snapshot:"Keeping a copy of what is here now, just in case.",database:"Bringing back your conversations and everything you told it to remember.",recovery:"Almost there. Nothing will run on its own until you say so.",files:"Bringing back your files.",starting:"Starting back up.",done:"That is everything.","rolled-back":"That did not work, so I put everything back the way it was.",failed:"That did not work."},welcome:e=>`Welcome back, ${e}.`,keys:"A backup never carries keys, so the AI you think with needs its key one more time."},tagline:"Setting up, on this Mac.",taglineElsewhere:"Setting up, on this computer.",handover:{waiting:"One moment.",looking:e=>`${e} is looking around…`,slow:"Still waking up. A brain on this computer takes a minute the first time.",silent:"Your assistant isn't answering. The AI you picked may be down; try again, or pick another brain above.",again:"Pick another brain"},offers:{phone:"Talk to me from your phone",notNow:"Not now"},done:{said:"You're all set. This conversation carries on in your dashboard.",leaving:"Opening buddi…",ready:"Ready when you are.",open:"Open buddi"},telegram:{how:"Two minutes: open Telegram, message @BotFather, send /newbot, paste the token it gives you here.",field:"The token",submit:"Save it",restart:"Saved. It will be ready the next time buddi starts.",scan:"Scan this with your phone and press Start.",expired:"That code has run out. I can make you another one.",newCode:"Show a new code",paired:"That is your phone, talking to me. You can close this and carry on there."},change:"change"},IF=(e,t)=>!!e&&!!t&&e.kind===t.kind&&(e.kind==="mascot"?e.role===t.role:e.kind==="emoji"?e.value===t.value:!0);async function ZS(e){const t=await fetch(Ka(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const n=await t.blob();return new File([n],`buddi-blob-${e}.png`,{type:"image/png"})}function e1({face:e,onPick:t,label:n=F.assistant.face,kept:r,disabled:i,disableEmoji:o,children:a}){return s.jsxs("div",{className:"meet-faces",role:"group","aria-label":n,children:[s.jsxs("div",{className:"meet-face-row",children:[r?s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":(e==null?void 0:e.kind)==="kept"?"true":void 0,"aria-pressed":(e==null?void 0:e.kind)==="kept","aria-label":"The current picture",disabled:i,onClick:()=>t({kind:"kept",url:r}),children:s.jsx("img",{src:r,alt:""})}):null,RF.map(l=>{const c={kind:"mascot",role:l},u=IF(e,c);return s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":F.assistant.mascot(l),disabled:i,onClick:()=>t(c),children:s.jsx("img",{src:Ka(l),alt:""})},l)})]}),s.jsx("div",{className:"meet-face-row",children:TF.map(l=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===l;return s.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||o,onClick:()=>t({kind:"emoji",value:l}),children:l},l)})}),a]})}const MF=["mirror","en","fr"],t1=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"access",label:"Access"}],Iy=e=>{var t;return((t=t1.find(n=>n.id===e))==null?void 0:t.id)??"identity"};function $F({agentId:e,section:t,navigate:n}){var w,b,v;const{data:r,error:i,reload:o}=ne(()=>T.agents(),[]),[a,l]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(Iy(t));d.useEffect(()=>f(Iy(t)),[t]);const p=m=>{f(m),n==null||n(xt(e,"setup",m))},x=async m=>{l(null),u(null);try{const j=await m;u(j.changed.length===0?`No file change needed. ${j.note}.`:`Changed ${j.changed.join(", ")}. ${j.note}.`),o()}catch(j){l(j instanceof Error?j.message:String(j))}},y=r==null?void 0:r.agents.find(m=>m.id===e);return s.jsxs(V,{gap:"lg",children:[s.jsx(Fu,{level:"secondary",label:"Setup",children:t1.map(m=>s.jsx(Uu,{href:xt(e,"setup",m.id),active:h===m.id,onClick:j=>{j.preventDefault(),p(m.id)},children:m.label},m.id))}),s.jsx(re,{message:i??a}),c?s.jsx(H,{tone:"good",role:"status",children:c}):null,r?y?s.jsx(_F,{agent:y,all:r.agents,engine:r.engines.find(m=>m.id===y.id),providers:r.providers,accounts:r.providerAccounts,shown:h,onShow:p,onRun:x,onSaved:o},`${y.id}:${(w=r.engines.find(m=>m.id===y.id))==null?void 0:w.model}:${(v=(b=r.providerAccounts)==null?void 0:b.bindings.find(m=>m.agentId===y.id))==null?void 0:v.accountId}`):s.jsx(ie,{children:"This agent is not installed as a file."}):s.jsx(ie,{children:"Loading…"})]})}function _F({agent:e,all:t,engine:n,providers:r,accounts:i,shown:o,onShow:a,onRun:l,onSaved:c}){const u=(n==null?void 0:n.provider)??e.provider.kind,h=r.find(g=>g.kind===u),f=(n==null?void 0:n.model)??e.model,[p,x]=d.useState(String((n==null?void 0:n.maxTurns)??e.maxTurns)),y=g=>{l(T.setAgentEngine(e.id,g))},w=g=>{const S=r.find(k=>k.kind===g);y({provider:g,model:(S==null?void 0:S.defaultModel)??f})},b=(h==null?void 0:h.models.map(g=>g.id))??[],v=b.includes(f)?b:[f,...b],m=n?n.available:!0,j=(n==null?void 0:n.unavailableReason)??"no credential";return s.jsxs(s.Fragment,{children:[s.jsx("div",{hidden:o!=="identity",children:s.jsxs(V,{gap:"lg",children:[m?null:s.jsxs(H,{tone:"warning",children:["This agent cannot run right now."," ",s.jsx("a",{href:xt(e.id,"setup","brain"),onClick:g=>{g.preventDefault(),a("brain")},children:"See Brain."})]}),s.jsx(OF,{agent:e,onSaved:c})]})}),s.jsx("div",{hidden:o!=="brain",children:s.jsxs(V,{gap:"lg",children:[m?null:s.jsxs(H,{tone:"warning",children:["This agent cannot run right now: ",j,"."]}),s.jsx(K,{panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsxs(K,{title:"Runs on",children:[i?s.jsx(UF,{agentId:e.id,accounts:i,onRun:l}):s.jsxs(Bs,{children:[s.jsx(X,{label:"Provider",children:s.jsx("select",{value:u,onChange:g=>w(g.target.value),children:r.map(g=>s.jsxs("option",{value:g.kind,children:[g.kind,g.usable?"":" (no credential)"]},g.kind))})}),s.jsxs(X,{label:"Model",children:[s.jsx("input",{list:`models-${e.id}`,defaultValue:f,onBlur:g=>{g.target.value.trim()!==""&&g.target.value.trim()!==f&&y({model:g.target.value.trim()})}}),s.jsx("datalist",{id:`models-${e.id}`,children:v.map(g=>s.jsx("option",{value:g},g))})]})]}),i?null:s.jsxs("p",{className:"ui-card-meta",children:[(n==null?void 0:n.credentialKind)??e.provider.credentialKind," from"," ",s.jsx("span",{className:"mono",children:(n==null?void 0:n.credentialEnv)??e.provider.credentialEnv}),h&&!h.usable?` · default model ${h.defaultModel} (${h.defaultFrom})`:""]}),n!=null&&n.restartRequired?s.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),s.jsx(K,{title:"Behaviour",aside:"saved as you change them",children:s.jsxs(Bs,{children:[s.jsx(X,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:s.jsx("input",{type:"number",min:1,value:p,onChange:g=>x(g.target.value),onBlur:()=>{const g=Number(p);Number.isInteger(g)&&g>=1&&g!==((n==null?void 0:n.maxTurns)??e.maxTurns)&&y({maxTurns:g})}})}),s.jsx(X,{label:"Language",hint:"Mirror answers in whatever language you write.",children:s.jsx("select",{value:(n==null?void 0:n.language)??e.language,onChange:g=>y({language:g.target.value}),children:MF.map(g=>s.jsx("option",{value:g,children:g},g))})}),b0(k0(n??{id:e.id,provider:u},i))?s.jsx(X,{label:"Thinking",hint:"Reasoning before the answer. Off is faster and cheaper.",children:s.jsxs("select",{"aria-label":"Thinking",value:(n==null?void 0:n.thinking)??"default",onChange:g=>y({thinking:g.target.value==="default"?null:g.target.value}),children:[s.jsx("option",{value:"default",children:"Model default"}),s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})}):s.jsx(X,{label:"Thinking",hint:$T,children:s.jsx("span",{className:"ui-card-meta",children:"Up to the model"})})]})})]})})]})}),s.jsx("div",{hidden:o!=="access",children:s.jsxs(V,{gap:"lg",children:[s.jsx(DF,{agent:e,all:t,onSaved:c}),s.jsx(WF,{agent:e,all:t,onSaved:c}),s.jsx(Et,{summary:"Built-in context",boxed:!0,children:s.jsx("p",{className:"ui-card-meta",children:"Every agent receives current time, owner timezone and server-host information. system.time and system.info are always available, without grants or approval. Host and browser access still require their own permissions."})})]})})]})}function n1({dirty:e,busy:t,failure:n,label:r,onSave:i}){return s.jsxs(s.Fragment,{children:[n?s.jsx("span",{className:"critical save-error",role:"alert",children:n}):s.jsx("span",{className:e?"warning":"muted",children:e?"Not saved yet.":"Saved. Applies to new runs."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:!e||t,onClick:i,children:r})]})}const s1=s.jsx(H,{tone:"warning",children:"This agent ships with buddi, so its file is read-only here. Ask Agent Father to make it yours, then these fields can change."});function OF({agent:e,onSaved:t}){var B;const[n,r]=d.useState(e.name),[i,o]=d.useState(e.handle),[a,l]=d.useState(e.description),[c,u]=d.useState(e.avatar??""),[h,f]=d.useState(!1),p=ne(()=>T.agentFile(e.id),[e.id]),[x,y]=d.useState(null),w=((B=p.data)==null?void 0:B.persona.trim())??"",b=x??w,v=p.data!==void 0&&x!==null&&x.trim()!==w,[m,j]=d.useState(!1),[g,S]=d.useState(null),[k,N]=d.useState(null),C=n.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||a.trim()!==e.description||c.trim()!==(e.avatar??"")||v,A=c.trim()!==""&&(c.trim()!==(e.avatar??"")||!e.picture),E=sp(A?{...e,avatar:c.trim()}:e),_={...E?{avatar:E}:{},...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...!A&&e.picture?{picture:e.picture}:{}},L=async()=>{j(!0),S(null),N(null);try{const R=await T.updateAgentFile(e.id,{name:n.trim(),handle:i.trim().replace(/^@/,""),description:a.trim(),...c.trim()===""?{}:{avatar:c.trim()},...v&&b.trim()!==""?{persona:b.trim()}:{}});e.picture&&c.trim()!==""&&c.trim()!==(e.avatar??"")&&(await T.removeAgentPicture(e.id),window.dispatchEvent(new Event(ka))),y(null),p.reload(),N(R.message),t()}catch(R){S(R instanceof Error?R.message:String(R))}finally{j(!1)}};return s.jsx(K,{title:"Who it is",aside:s.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:s.jsx(n1,{dirty:C,busy:m,failure:g,label:"Save who it is",onSave:()=>void L()}),children:s.jsxs(V,{children:[e.isExample?s1:null,k?s.jsx(H,{tone:"good",role:"status",children:k}):null,s.jsxs(Bs,{children:[s.jsx(X,{label:"Name",hint:"What it is called, everywhere.",children:s.jsx("input",{value:n,disabled:m||e.isExample,onChange:R=>r(R.target.value)})}),s.jsx(X,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:s.jsx("input",{value:i,disabled:m||e.isExample,onChange:R=>o(R.target.value)})})]}),s.jsxs(q,{children:[s.jsx(vs,{id:e.id,name:n.trim()||e.name,size:"xl",face:_}),s.jsx(P,{"aria-expanded":h,onClick:()=>f(R=>!R),children:h?"Hide faces":"Change face"})]}),h?s.jsx(LF,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:m}):null,s.jsx(X,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:s.jsx("textarea",{rows:2,value:a,disabled:m||e.isExample,onChange:R=>l(R.target.value)})}),s.jsx(X,{label:"Persona",hint:s.jsxs(s.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",s.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:p.error?s.jsx(re,{message:p.error}):p.data?s.jsx("textarea",{className:"setup-persona",value:b,rows:Math.max(6,b.split(`
|
|
110
|
-
`).length+1),disabled:m||e.isExample,onChange:R=>y(R.target.value)}):s.jsx(ie,{children:"Reading its file…"})})]})})}function DF({agent:e,all:t,onSaved:n}){var A;const r=ne(()=>T.agentTools(e.id),[e.id]),[i,o]=d.useState(null),[a,l]=d.useState(()=>new Set((e.roles??[]).filter(Fv))),[c,u]=d.useState((e.roles??[]).filter(E=>!Fv(E)).join(", ")),[h,f]=d.useState(!1),[p,x]=d.useState(null),[y,w]=d.useState(null),b=(E,_)=>E.split(_).map(L=>L.trim()).filter(L=>L!==""),v=((A=r.data)==null?void 0:A.granted)??e.tools,m=i??v,j=r.data!==void 0&&!SF(m,v),g=Uv(a,b(c,/[\n,]/)),S=E=>l(_=>{const L=new Set(_);return L.has(E)?L.delete(E):L.add(E),L}),N=j||!((E,_)=>E.join(",")===_.join(","))(g,Uv(new Set(e.roles??[]),e.roles??[])),C=async()=>{f(!0),x(null),w(null);try{const E=await T.updateAgentFile(e.id,{...j&&r.data?{tools:kF(r.data.groups,m)}:{},roles:g});w(E.message),o(null),r.reload(),n()}catch(E){x(E instanceof Error?E.message:String(E))}finally{f(!1)}};return s.jsx(K,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:s.jsx(n1,{dirty:N,busy:h,failure:p,label:"Save roles and tools",onSave:()=>void C()}),children:s.jsxs(V,{children:[e.isExample?s1:null,y?s.jsx(H,{tone:"good",role:"status",children:y}):null,s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",id:`roles-${e.id}`,children:"Roles"}),s.jsx("div",{className:"role-chips",role:"group","aria-labelledby":`roles-${e.id}`,children:zm.map(E=>{const _=TI(t,E.id),L=_&&_.id!==e.id?_:void 0;return s.jsxs("button",{type:"button",className:"role-chip","aria-pressed":a.has(E.id),"data-on":a.has(E.id)?"true":void 0,disabled:h||e.isExample,onClick:()=>S(E.id),children:[s.jsx("span",{className:"role-chip-label",children:E.label}),s.jsx("span",{className:"role-chip-meaning",children:E.meaning}),L?s.jsxs("span",{className:"role-chip-holder",children:["Held by ",L.name,". If both claim it, the one listed first keeps it."]}):null]},E.id)})}),s.jsx("span",{className:"ui-field-hint",children:"Where buddi sends things when you do not say who. Tools are granted below."})]}),s.jsx(X,{label:"Other roles",hint:"Only a plugin that asks for a role by name reads these. Comma separated.",children:s.jsx("input",{value:c,disabled:h||e.isExample,onChange:E=>u(E.target.value)})}),s.jsxs("div",{className:"ui-field",children:[s.jsxs("span",{className:"ui-field-label",children:["Tools · ",v.length," granted"]}),r.error?s.jsx(re,{message:r.error}):r.data?s.jsx(CF,{view:r.data,chosen:m,onChange:o,disabled:h||e.isExample}):s.jsx(ie,{children:"Loading the installed tools…"})]})]})})}function sp(e){if(e.avatar)return/^[A-Za-z0-9_-]+\.(png|jpe?g|gif|webp)$/i.test(e.avatar)?{kind:"image",url:`/api/agents/${encodeURIComponent(e.id)}/avatar`}:{kind:"emoji",value:e.avatar.slice(0,8)}}function LF({agent:e,avatar:t,onEmoji:n,onChanged:r,disabled:i}){const[o,a]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(null),f=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),p=o??(f?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),x=async y=>{if(h(null),y.kind==="emoji"){n(y.value);return}if(y.kind==="kept"){n(e.avatar??"");return}a(y),c(!0);try{await T.uploadAgentPicture(e.id,await ZS(y.role)),n(e.avatar??""),r(),window.dispatchEvent(new Event(ka))}catch(w){h(w instanceof Error?w.message:String(w))}finally{a(null),c(!1)}};return s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Face"}),s.jsx(e1,{face:p,label:"Face",kept:e.picture,disabled:i||l,disableEmoji:e.isExample,onPick:y=>void x(y),children:s.jsx(FF,{agent:e,onChanged:r})}),u?s.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function FF({agent:e,onChanged:t}){const[n,r]=d.useState(null),[i,o]=d.useState(null),[a,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[p,x]=d.useState(0);d.useEffect(()=>{if(!n)return o(null);const N=URL.createObjectURL(n);return o(N),()=>URL.revokeObjectURL(N)},[n]);const y=N=>{r(null),x(C=>C+1),f(N),t(),window.dispatchEvent(new Event(ka))},w=async N=>{l(!0),u(null),f(null);try{y(await N())}catch(C){u(C instanceof Error?C.message:String(C))}finally{l(!1)}},b=()=>w(async()=>(await T.uploadAgentPicture(e.id,n)).note??null),v=()=>w(async()=>(await T.removeAgentPicture(e.id),null)),m={avatar:sp(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[j,g]=d.useState(!1),S=d.useRef(null),k=N=>{u(null),f(null),r(N??null)};return s.jsxs("div",{className:"setup-upload","data-dragging":j?"true":void 0,onDragOver:N=>{N.preventDefault(),a||g(!0)},onDragLeave:()=>g(!1),onDrop:N=>{var C;N.preventDefault(),g(!1),a||k((C=N.dataTransfer.files)==null?void 0:C[0])},children:[s.jsxs(q,{children:[s.jsx(vs,{id:e.id,name:e.name,size:"xl",face:m}),s.jsx("input",{ref:S,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:a,onChange:N=>{var C;return k((C=N.target.files)==null?void 0:C[0])}},p),s.jsx(P,{disabled:a,onClick:()=>{var N;return(N=S.current)==null?void 0:N.click()},children:"Upload a picture"}),s.jsx("span",{className:"setup-upload-name",children:n?n.name:"or drop one here"}),s.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!n?s.jsx(P,{variant:"ghost",disabled:a,onClick:()=>void v(),children:"Remove picture"}):null,s.jsx(P,{variant:"accent",disabled:!n||a,onClick:()=>void b(),children:"Save picture"})]}),c?s.jsx("span",{className:"critical save-error",role:"alert",children:c}):s.jsx("span",{className:"ui-field-hint",children:h??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function UF({agentId:e,accounts:t,onRun:n}){const r=t.bindings.find(x=>x.agentId===e),[i,o]=d.useState((r==null?void 0:r.accountId)??""),[a,l]=d.useState((r==null?void 0:r.model)??""),[c,u]=d.useState(!1),h=t.accounts.find(x=>x.id===i),f=i!==((r==null?void 0:r.accountId)??"")||a!==((r==null?void 0:r.model)??""),p=t.accounts.find(x=>x.id===(r==null?void 0:r.accountId));return s.jsxs("div",{className:"ui-stack",children:[s.jsxs(q,{valign:"end",children:[s.jsx(X,{label:"Account",children:s.jsxs("select",{value:i,disabled:c,onChange:x=>{var y;o(x.target.value),l(((y=t.accounts.find(w=>w.id===x.target.value))==null?void 0:y.defaultModel)??"")},children:[s.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(x=>s.jsxs("option",{value:x.id,disabled:!x.enabled,children:[x.label,x.enabled?x.configured?"":" (needs credential)":" (disabled)"]},x.id))]})}),s.jsx(hg,{accountId:h!=null&&h.configured?i:void 0,label:"Model",value:a,onChange:l,disabled:c},`${i}:${h==null?void 0:h.revision}`)]}),s.jsxs(q,{children:[f&&i&&a.trim()?s.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",p?`${p.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):s.jsx("span",{className:"muted",children:p?`Running on ${p.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:c||!i||!a.trim()||!f,onClick:()=>{u(!0),n(T.assignProviderAccount(e,i,a).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const BF=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],zF=e=>e.tools.some(t=>BF.includes(t));function WF({agent:e,all:t,onSaved:n}){const[r,i]=d.useState(e.delegates),[o,a]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(!1),[f,p]=d.useState(e.delegates),x=t.filter(m=>m.id!==e.id),y=[...r].sort().join(",")!==[...f].sort().join(","),w=t.filter(m=>m.id!==e.id&&m.delegates.includes(e.id)),b=m=>i(j=>j.includes(m)?j.filter(g=>g!==m):[...j,m]),v=async()=>{a(!0),c(null),h(!1);try{const m=await T.setDelegates(e.id,r);p(m.delegates),i(m.delegates),h(!0),n()}catch(m){c(m instanceof Error?m.message:String(m))}finally{a(!1)}};return s.jsx(K,{title:"Delegation",aside:e.tools.includes("agent.delegate")?"holds agent.delegate":"no agent.delegate tool: it cannot ask anyone until granted",panel:!0,foot:e.isExample?void 0:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:y?"warning":"muted",children:y?"Not saved yet.":u?"Saved. Applies to the next run.":r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(P,{variant:"accent",disabled:!y||o,onClick:()=>void v(),children:"Save who it can ask"})]}),children:s.jsxs(V,{divided:!0,children:[s.jsxs(K,{title:"Can ask",children:[e.isExample?s.jsx(H,{tone:"warning",children:"This agent ships with buddi, so its allowlist is read-only here. Ask Agent Father to make it yours, then it can change."}):null,s.jsx(re,{message:l}),x.length===0?s.jsx(ie,{children:"Nobody else is installed."}):s.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:x.map(m=>{const j=zF(m);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${m.id}`,checked:r.includes(m.id),disabled:j||e.isExample||o,onChange:()=>b(m.id)}),s.jsxs("label",{htmlFor:`can-ask-${e.id}-${m.id}`,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[m.name," ",s.jsxs("span",{className:"mono muted",children:["@",m.handle]})]}),s.jsx("span",{className:"ui-list-sub",children:j?"Makes and changes agents. Never reachable by delegation.":m.description})]})]},m.id)})})]}),s.jsx(K,{title:"Asked by",children:w.length===0?s.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):s.jsx(DM,{children:w.map(m=>s.jsx(ve,{children:m.name},m.id))})})]})})}const HF=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],VF=[{id:"conversations",label:"Conversations"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"},{id:"memory",label:"Memory"},{id:"skills",label:"Skills"},{id:"setup",label:"Setup"}];function KF({hash:e,timezone:t,navigate:n,agents:r,attention:i,defaultAgentId:o}){var b,v,m,j,g;const a=vI(e),l=((b=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:b[1])??"team",c=S=>k=>{k.preventDefault(),n(S)},u=ne(()=>T.agents(),[]),h=sg(),f=ne(()=>T.offers(),[],2e4),p=gS(),x=(((v=f.data)==null?void 0:v.offers.length)??0)+p.offers.length,y=((j=(m=u.data)==null?void 0:m.default)==null?void 0:j.defaultAgentId)??o??null,w=r.find(S=>S.roles.includes(Wm));return s.jsxs("div",{className:"ui-page",children:[s.jsx(Gm,{title:"Agents",lede:`Your team. Each one is a file on ${h} — what it can reach is listed on its page.`,actions:w?s.jsx(cn,{variant:"accent",href:Ue(w.id),onClick:c(Ue(w.id)),children:"Add an agent"}):null}),s.jsx(Fu,{children:HF.map(S=>s.jsx(Uu,{href:S.id==="team"?it:`${it}?tab=${S.id}`,active:l===S.id,count:S.id==="offers"?x:void 0,onClick:c(S.id==="team"?it:`${it}?tab=${S.id}`),children:S.label},S.id))}),l==="missions"?s.jsx(KS,{timezone:t,embedded:!0}):null,l==="offers"?s.jsx(xS,{offers:p.offers,reload:p.reload}):null,l==="offers"?s.jsx(YS,{embedded:!0}):null,l==="reminders"?s.jsx(JS,{timezone:t,embedded:!0}):null,l==="team"?s.jsx(GF,{data:u.data,error:u.error,reload:u.reload}):null,l==="team"?r.length===0?s.jsx(Ct,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):s.jsx("div",{className:"agents-grid",children:yk(r,y).map(S=>{const k=Ou(i.get(S.id));return s.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...Wa(za(S)),"data-unavailable":S.available?void 0:"true",children:[s.jsx("div",{className:"agent-card-top"}),s.jsx("div",{className:"agent-card-face",children:s.jsx(vs,{id:S.id,name:S.name,size:"xl",unavailable:!S.available,face:S})}),s.jsxs("div",{children:[s.jsxs("div",{className:"ui-card-title",children:[s.jsx("a",{className:"agent-card-link",href:xt(S.id,"conversations"),onClick:c(xt(S.id,"conversations")),children:S.name}),s.jsxs("span",{className:"agent-card-handle mono faint",children:["@",S.handle]})]}),s.jsx("p",{className:"ui-card-meta agent-card-desc",children:S.description})]}),s.jsxs("div",{className:"ui-row",children:[S.id===y?s.jsx(cc,{children:"front desk"}):null,k?s.jsx(ve,{tone:"critical",dot:!0,children:"waiting for you"}):S.available?s.jsx(ve,{tone:"good",dot:!0,children:"ready"}):s.jsx(ve,{tone:"warning",children:ms(S.unavailableReason??"cannot run",60)}),s.jsx(ve,{mono:!0,children:S.model}),s.jsx(cn,{className:"agent-card-talk",size:"sm",href:Ue(S.id),onClick:c(Ue(S.id)),"aria-label":`Talk to ${S.name}`,children:"Talk"})]})]},S.id)})}):null,a?s.jsx(Qt,{title:((g=r.find(S=>S.id===a.agentId))==null?void 0:g.name)??a.agentId,size:"wide",onClose:()=>n(it),children:s.jsx(YF,{agentId:a.agentId,agent:r.find(S=>S.id===a.agentId),agents:r,tab:a.tab??"conversations",...a.section?{section:a.section}:{},timezone:t,navigate:n,attention:i})}):null]})}function GF({data:e,error:t,reload:n}){const r=e==null?void 0:e.default,[i,o]=d.useState(null),[a,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null);if(t)return s.jsx(re,{message:t});if(!r||r.choices.length===0)return null;const p=r.defaultAgentId,x=i??p??"",y=x!==""&&x!==p,w=r.problem,b=m=>m.map(j=>{var g;return((g=r.choices.find(S=>S.id===j))==null?void 0:g.name)??j}).join(" and "),v=async()=>{l(!0),u(null),f(null);try{const m=await T.setDefaultAgent(x);f(m.note),o(null),n()}catch(m){u(m instanceof Error?m.message:String(m))}finally{l(!1)}};return s.jsx(ct,{children:s.jsxs("div",{className:"ui-stack",children:[s.jsx(re,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?s.jsx(H,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${b(w.agents)}. The one chosen here wins.`}):(w==null?void 0:w.code)==="no-default-agent"?s.jsx(H,{tone:"warning",role:"status",children:"No agent file claims the default and this installation has not recorded one. Choose who answers when you name nobody."}):null,h?s.jsx(H,{tone:"good",role:"status",children:h}):null,s.jsxs(q,{children:[s.jsxs("div",{className:"default-agent-text",children:[s.jsx("h3",{className:"default-agent-title",children:"Default agent"}),s.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("select",{"aria-label":"Default agent",value:x,disabled:a,onChange:m=>o(m.target.value),children:[x===""?s.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(m=>s.jsxs("option",{value:m.id,disabled:!m.available,children:[m.name," @",m.handle,m.available?"":" (cannot run)"]},m.id))]}),s.jsx(P,{variant:"accent",disabled:a||!y,onClick:()=>void v(),children:"Save"})]})]})})}function YF({agentId:e,agent:t,agents:n,tab:r,section:i,timezone:o,navigate:a,attention:l}){const c=f=>p=>{p.preventDefault(),a(f)},u=Ou(l.get(e)),h=(t==null?void 0:t.name)??e;return s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[s.jsxs("header",{className:"agent-head",children:[s.jsx(vs,{id:e,name:h,size:"xl",unavailable:t?!t.available:!1,face:t}),s.jsxs("div",{className:"agent-head-text",children:[s.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),s.jsxs("div",{className:"ui-row",children:[t?s.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?s.jsx("span",{className:"muted",children:t.model}):null,u?s.jsx(ve,{tone:"critical",children:u}):t&&!t.available?s.jsx(ve,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),s.jsx("div",{className:"ui-page-actions",children:s.jsxs(cn,{variant:"accent",href:Ue(e),onClick:c(Ue(e)),children:["Talk to ",h]})})]}),t&&!t.available?s.jsxs(H,{tone:"warning",role:"status",children:[bk(t)," ",s.jsx("a",{href:lt(Rh(t).section),children:Rh(t).label})]}):null,s.jsx(Fu,{children:VF.map(f=>s.jsx(Uu,{href:xt(e,f.id),active:r===f.id,onClick:c(xt(e,f.id)),children:f.label},f.id))}),r==="conversations"?s.jsx(qF,{agentId:e,navigate:a}):null,r==="missions"?s.jsx(KS,{timezone:o,embedded:!0,agentId:e}):null,r==="offers"?s.jsx(YS,{embedded:!0,agentId:e,agentName:h}):null,r==="reminders"?s.jsx(JS,{timezone:o,embedded:!0,agentId:e}):null,r==="memory"?s.jsx(qS,{embedded:!0,agents:n,timezone:o,agentId:e}):null,r==="skills"?s.jsx(jF,{agentId:e,agentName:h}):null,r==="setup"?s.jsx($F,{agentId:e,section:i,navigate:a}):null]})}function qF({agentId:e,navigate:t}){const{data:n,error:r}=ne(()=>_e.conversations(e,50),[e]);if(r)return s.jsx(ie,{children:r});const i=(n==null?void 0:n.conversations)??[];return s.jsx(ct,{flush:!0,children:n?i.length===0?s.jsx(Ct,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):s.jsx(Ut,{children:i.map(o=>s.jsx(Gt,{href:Ue(e,o.id),onClick:()=>t(Ue(e,o.id)),title:ms(o.preview||o.opening||"Untitled conversation",90),sub:`${o.messageCount} message${o.messageCount===1?"":"s"}`,side:Ee(o.lastMessageAt??o.startedAt??o.createdAt??null)},o.id))}):s.jsx(ie,{children:"Loading…"})})}const pg="(max-width: 900px)";function Ia(e){const[t,n]=d.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return d.useEffect(()=>{var o;let r;try{r=window.matchMedia(e)}catch{return}const i=a=>n(a.matches);return(o=r.addEventListener)==null||o.call(r,"change",i),()=>{var a;return(a=r.removeEventListener)==null?void 0:a.call(r,"change",i)}},[e]),t}const My=3;function QF({agent:e,navigate:t}){var y;const n=d.useRef(null),[r,i]=d.useState(!1),[o,a]=d.useState(null),[l,c]=d.useState(null),u=ne(()=>_e.conversations(e.id,My),[e.id],3e4),h=Ia(pg),f=Ia("(pointer: coarse)");d.useEffect(()=>{var w;!h&&!f&&((w=n.current)==null||w.focus())},[]);const p=(w,b)=>{i(!0),a(null),(async()=>{try{const{conversationId:v}=await _e.startConversation(e.id),m=await _e.send(e.id,{conversationId:v,text:w,...b.length>0?{attachmentIds:b.map(j=>j.artifactId)}:{}});t(Ue(e.id,m.conversationId))}catch(v){a(v instanceof oe?v.message:String(v)),c({text:w,at:Date.now()}),i(!1)}})()},x=(((y=u.data)==null?void 0:y.conversations)??[]).slice(0,My);return s.jsxs("div",{className:"home-ask",children:[o?s.jsx(re,{message:o}):null,s.jsx(uS,{ref:n,disabled:r||!e.available,running:!1,onSend:p,onStop:()=>{},agentName:e.name,placeholder:`Message ${e.name}…`,draft:l,threadKey:`home.${e.id}`}),x.length>0?s.jsx("ul",{className:"home-ask-recent","aria-label":`Recent conversations with ${e.name}`,children:x.map(w=>{const b=Ue(e.id,w.id),v=w.opening??w.preview??"Untitled conversation",m=Ee(w.lastMessageAt??w.createdAt??w.startedAt??null);return s.jsx("li",{children:s.jsxs("a",{href:b,onClick:j=>{j.preventDefault(),t(b)},children:["Continue: ",ms(v,60),m?` · ${m}`:""]})},w.id)})}):null]})}function XF({timezone:e,navigate:t,agents:n,defaultAgentId:r,attention:i,update:o}){var Ce,J,ge,xe,je,Pe,ze,te,se,we,be,We,fe;const a=ne(()=>T.overview(),[],15e3),l=ne(()=>T.approvals(),[],1e4),c=ne(()=>T.missions(),[],6e4),u=ne(()=>T.reminders(),[],6e4),h=ne(()=>T.conversations(),[],3e4),f=ne(()=>T.offers(),[],3e4),p=ne(()=>T.proposals(),[],6e4),x=ne(()=>T.agentOffers(),[],6e4),y=ne(()=>T.owner(),[]),w=ne(()=>T.notifications(20),[],3e4),b=d.useMemo(()=>yk(n,r??null),[n,r]),{busy:v,note:m,failure:j,decide:g}=rg(()=>{l.reload(),a.reload()}),S=a.data,k=n.find(D=>D.id===r)??null,N=D=>{var de;return((de=n.find(Ke=>Ke.id===D))==null?void 0:de.name)??D},C=D=>de=>{de.preventDefault(),t(D)},A=((Ce=l.data)==null?void 0:Ce.pending)??[],E=((J=S==null?void 0:S.jobs)==null?void 0:J.failed)??0,_=((ge=S==null?void 0:S.sentinels)==null?void 0:ge.openUrgent)??0,L=((xe=p.data)==null?void 0:xe.open.length)??0,B=(((je=x.data)==null?void 0:je.offers)??[]).filter(D=>!A.some(de=>mS(de,D.plugin,D.agent))),R=e4(((Pe=w.data)==null?void 0:Pe.notifications)??[],A),[O,Y]=d.useState(new Set),G=A.length+(E>0?1:0)+(_>0?1:0)+(S!=null&&S.paused?1:0)+(L>0?1:0)+B.length+R.length,M=d.useMemo(()=>{var D,de;return r4(((D=c.data)==null?void 0:D.missions)??[],((de=u.data)==null?void 0:de.reminders)??[])},[c.data,u.data]),W=(((ze=h.data)==null?void 0:ze.conversations)??[]).slice(0,5),$=((te=f.data)==null?void 0:te.offers)??[],ee=$.slice(0,t4),ce=$.length-ee.length;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"home-band",children:s.jsxs("header",{className:"home-hero",children:[s.jsxs("div",{className:"home-hero-text",children:[s.jsx("p",{className:"home-date",children:a4(S==null?void 0:S.now,e)}),s.jsx("h1",{className:"home-greeting",children:o4(S==null?void 0:S.now,e,((se=y.data)==null?void 0:se.preferredName)||((we=y.data)==null?void 0:we.displayName))}),s.jsx("p",{className:"home-lede",children:c4(G,A.length,E,_,(S==null?void 0:S.paused)??!1,L,B.length,R.length)})]}),s.jsx(Ck,{size:"lg"})]})}),s.jsxs("div",{className:"home",children:[k?s.jsx(QF,{agent:k,navigate:t},k.id):null,o&&o.updateAvailable&&!o.checkout&&o.latest?s.jsxs(H,{tone:"accent",children:["A newer buddi is ready: ",s.jsx("span",{className:"mono",children:o.latest}),"."," ",s.jsx("a",{href:lt("system"),onClick:C(lt("system")),children:"Upgrade from Settings → Version."})]}):null,s.jsx(re,{message:a.error??l.error??j}),m?s.jsx(H,{tone:"good",role:"status",children:m}):null,G>0?s.jsx(K,{title:"Needs you",children:s.jsxs(V,{children:[S!=null&&S.paused?s.jsxs(H,{tone:"warning",title:"The installation is paused.",children:["Nothing is being claimed until you resume it."," ",s.jsx(P,{size:"sm",onClick:()=>{T.setPaused(!1).then(()=>a.reload())},children:"Resume"})]}):null,A.map(D=>s.jsx(ig,{action:D,timezone:e,busy:v===D.id,onDecide:g,agentName:N(D.agentId)},D.id)),R.length>0?s.jsx(ct,{flush:!0,children:s.jsx(Ut,{children:R.filter(D=>!O.has(D.id)).map(D=>s.jsx(Gt,{href:D.link??void 0,onClick:()=>{Y(de=>new Set(de).add(D.id)),T.notificationSeen(D.id).catch(()=>{}),D.link&&t(D.link)},lead:D.agentId?s.jsx(tn,{agents:n,id:D.agentId,size:"sm"}):void 0,title:D.title,sub:D.agentId?N(D.agentId):D.pluginId??ZF[D.kind],side:D.state==="held"?"today":Ee(D.createdAt)},D.id))})}):null,E>0?s.jsx(H,{tone:"critical",children:s.jsxs("a",{href:`${rt}/jobs?state=failed`,onClick:C(`${rt}/jobs?state=failed`),children:[E," failed job",E===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,_>0?s.jsx(H,{tone:"critical",children:s.jsxs("a",{href:`${rt}/alerts`,onClick:C(`${rt}/alerts`),children:[_," urgent alert",_===1?"":"s"," from your watchers."]})}):null,B.map(D=>s.jsx(ct,{children:s.jsx(og,{plugin:D.plugin,agent:D.agent,text:D.text,label:`Create @${D.handle}`,handle:D.handle,onDismiss:()=>{T.dismissAgentOffer(D.plugin,D.agent).then(()=>x.reload())}})},`${D.plugin}/${D.agent}`)),L>0?s.jsx(H,{tone:"accent",children:s.jsxs("a",{href:lt("proposals"),onClick:C(lt("proposals")),children:[L," proposal",L===1?"":"s"," from your agents to keep or discard."]})}):null,(((be=S==null?void 0:S.sentinels)==null?void 0:be.errors)??[]).map(D=>s.jsxs(H,{tone:"warning",children:["Watcher ",D.sentinelId," failed: ",D.error]},D.sentinelId)),((S==null?void 0:S.mail)??[]).filter(D=>D.lastError).map(D=>s.jsxs(H,{tone:"warning",children:["Source ",D.sourceId,": ",D.lastError]},D.sourceId))]})}):null,s.jsx(K,{title:"Your team",aside:s.jsx("a",{href:it,onClick:C(it),children:"All agents"}),children:n.length===0?s.jsx(ie,{mascot:!0,children:"No agents yet. Add one under Agents."}):s.jsx("div",{className:"home-team",children:b.map(D=>{const de=Ou(i.get(D.id));return s.jsxs("a",{className:"home-face",...Wa(za(D)),href:Ue(D.id),onClick:C(Ue(D.id)),"data-waiting":de?"true":void 0,"data-unavailable":D.available?void 0:"true",children:[s.jsx(vs,{id:D.id,name:D.name,size:"lg",unavailable:!D.available,face:D}),s.jsxs("span",{className:"home-face-text",children:[s.jsx("span",{className:"home-face-name",children:D.name}),s.jsx("span",{className:"home-face-status",children:de?r1(de):D.available?ms(D.description,60):D.unavailableReason??"Cannot run right now."})]})]},D.id)})})}),ee.length>0?s.jsx(K,{title:"On offer",aside:s.jsxs("span",{className:"ui-row",children:[ce>0?s.jsxs("a",{href:`${it}?tab=offers`,onClick:C(`${it}?tab=offers`),children:[ce," more"]}):null,s.jsx(GS,{ids:$.map(D=>D.id),onDone:()=>f.reload()})]}),children:s.jsx("div",{className:"home-offers",children:ee.map(D=>s.jsx(s4,{offer:D,agents:n,open:C(xt(D.agentId,"offers")),onDismissed:()=>f.reload()},D.id))})}):null,(fe=(We=p.data)==null?void 0:We.digest)!=null&&fe.latest?s.jsx(l4,{digest:p.data.digest.latest,go:C}):null,s.jsxs("div",{className:"home-columns",children:[s.jsx(K,{title:"Coming up",aside:s.jsx("a",{href:`${it}?tab=missions`,onClick:C(`${it}?tab=missions`),children:"All missions"}),children:s.jsx(ct,{flush:!0,children:M.length===0?s.jsx(ie,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):s.jsx(Ut,{children:M.map(D=>s.jsx(Gt,{href:D.route,onClick:()=>t(D.route),lead:s.jsx(tn,{agents:n,id:D.agentId,size:"sm"}),title:D.title,sub:`${D.kind} for ${N(D.agentId)}`,side:Ee(D.at)},D.key))})})}),s.jsx(K,{title:"Lately",aside:s.jsx("a",{href:rt,onClick:C(rt),children:"All activity"}),children:s.jsx(ct,{flush:!0,children:W.length===0?s.jsx(ie,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):s.jsx(Ut,{children:W.map(D=>s.jsx(Gt,{href:Ue(D.agentId,D.id),onClick:()=>t(Ue(D.agentId,D.id)),lead:s.jsx(tn,{agents:n,id:D.agentId,size:"sm"}),title:D.opening?ms(D.opening,80):"Untitled conversation",sub:`${N(D.agentId)}, ${D.messageCount} message${D.messageCount===1?"":"s"}`,side:Ee(D.lastMessageAt??D.createdAt)},D.id))})})})]}),((S==null?void 0:S.home)??[]).map(D=>s.jsx(u4,{block:D},D.id)),S!=null&&S.jobs&&S.missions?s.jsxs("p",{className:"home-foot muted",children:[vt(S.jobs.pending??0)," queued, ",vt(S.jobs.leased??0)," running, ",vt(S.missions.enabled)," of ",vt(S.missions.total)," missions on."," ",S.paused?s.jsx(ve,{tone:"warning",children:"paused"}):s.jsx(ve,{tone:"good",children:"running"})," ",s.jsx("a",{href:Zi("").replace(/\/conversations\/$/,""),onClick:C(rt),children:"Activity"})," · ",s.jsx("a",{href:lt("system"),onClick:C(lt("system")),children:"System"})]}):null]})]})}const JF=new Set(["watcher","reminder","failure","recap","plugin"]),ZF={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin"};function e4(e,t){const n=new Set(t.map(r=>r.id));return e.filter(r=>JF.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&n.has(r.actionId)))}const t4=6,n4=500;function s4({offer:e,agents:t,open:n,onDismissed:r}){const[i,o]=d.useState(!1),a=d.useRef(null),l=d.useRef(!1),c=()=>{i||(o(!0),T.dismissOffer(e.id).then(r).finally(()=>o(!1)))},u=()=>{a.current!==null&&clearTimeout(a.current),a.current=null};return s.jsxs("span",{className:"home-offer-chip",children:[s.jsxs("a",{className:"home-offer",href:xt(e.agentId,"offers"),onClick:h=>{if(l.current){l.current=!1,h.preventDefault();return}n(h)},title:e.prompt,onTouchStart:()=>{l.current=!1,u(),a.current=setTimeout(()=>{l.current=!0,c()},n4)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[s.jsx(tn,{agents:t,id:e.agentId,size:"sm"}),s.jsx("span",{children:e.label})]}),s.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function r4(e,t){const n=[];for(const r of e)r.enabled&&r.nextRun&&n.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:xt(r.agentId,"missions")});for(const r of t)r.state==="pending"&&n.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:xt(r.agentId,"reminders")});return n.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function i4(e,t){try{const n=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(n)}catch{return new Date().getHours()}}function o4(e,t,n){const r=i4(e,t),i=n!=null&&n.trim()?`, ${n.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function a4(e,t){try{const n=e?new Date(e):new Date,r=new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:t}).format(n),i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",timeZone:t}).format(n);return`${r}, ${i}`}catch{return De(e??null,t)}}function Ll(e,t,n){return e.count===0?null:`${e.count} ${e.count===1?t:n}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function l4({digest:e,go:t}){const n=[Ll(e.memory,"memory note","memory notes"),Ll(e.skills,"skill kept","skills kept"),Ll(e.rules,"rule kept","rules kept"),Ll(e.changes,"change to an agent kept","changes to agents kept")].filter(i=>i!==null),r=e.stopped===null?"Not measured yet.":e.stopped.total>0?`Rules you kept acted ${e.stopped.total} time${e.stopped.total===1?"":"s"} (${Object.entries(e.stopped.byPlugin).filter(([,i])=>i>0).map(([i,o])=>`${i} ${o}`).join(", ")}).`:"No rule you kept acted this week.";return s.jsx(K,{title:"What buddi learned this week",aside:s.jsx("span",{className:"muted",children:Ee(e.at)}),children:s.jsx(ct,{children:s.jsxs(V,{divided:!0,children:[s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Learned"}),n.length===0?s.jsx("p",{children:"Nothing new."}):s.jsx("ul",{className:"home-digest-list",children:n.map(i=>s.jsx("li",{children:i},i))})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Proposes"}),s.jsx("p",{children:e.open>0?s.jsxs("a",{href:lt("proposals"),onClick:t(lt("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),s.jsx("p",{children:r})]})]})})})}function c4(e,t,n,r,i,o=0,a=0,l=0){if(e===0)return"Nothing needs you. Your agents are on it.";const c=[];t>0&&c.push(`${t} approval${t===1?"":"s"} waiting`),n>0&&c.push(`${n} failed job${n===1?"":"s"}`),r>0&&c.push(`${r} urgent alert${r===1?"":"s"}`),i&&c.push("the installation is paused"),o>0&&c.push(`${o} proposal${o===1?"":"s"} to review`),a>0&&c.push(`${a===1?"an agent":`${a} agents`} to set up`),l>0&&c.push(`${l} message${l===1?"":"s"} for you`);const u=c.length<=1?c.join(""):`${c.slice(0,-1).join(", ")} and ${c[c.length-1]}`;return`${r1(u)}.`}function r1(e){return e.charAt(0).toUpperCase()+e.slice(1)}function u4({block:e}){const[t,n]=d.useState(!1),r=e.sensitive===!0&&!t;d.useEffect(()=>{if(!e.sensitive||!t)return;const o=()=>{document.visibilityState==="hidden"&&n(!1)};return document.addEventListener("visibilitychange",o),window.addEventListener("blur",o),()=>{document.removeEventListener("visibilitychange",o),window.removeEventListener("blur",o)}},[e.sensitive,t]);const i=s.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?s.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?s.jsx(P,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>n(o=>!o),children:r?"Show":"Hide"}):null]});return s.jsxs(K,{title:e.title,aside:i,children:[e.note?s.jsx(H,{tone:"warning",children:e.note}):null,e.stats.length>0?s.jsx(Lu,{children:e.stats.map(o=>s.jsx(ls,{label:o.label,value:r?"••••":o.value,note:r?void 0:o.note,tone:r?void 0:o.tone},o.label))}):null,e.rows.length>0?r?s.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):s.jsx(ct,{flush:!0,children:s.jsx(Ut,{children:e.rows.map((o,a)=>s.jsx(Gt,{title:o.title,sub:o.sub,side:o.side?s.jsx("span",{className:o.tone==="critical"?"critical":o.tone==="good"?"good":void 0,children:o.side}):void 0},`${o.title}-${a}`))})}):null]})}const d4=3e4;function i1(){const{data:e,reload:t}=ne(()=>T.recovery(),[],d4);return{data:e,reload:t}}const f4="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function h4({active:e,onNavigate:t}){return e?s.jsxs("div",{className:"recovery-banner",role:"status",children:[s.jsx("span",{children:f4}),s.jsx("a",{href:Lv,onClick:n=>{n.preventDefault(),t(Lv)},children:"Finish the checklist"})]}):null}function p4({view:e,onLeft:t}){const{secrets:n,plugins:r,pending:i,grants:o}=e.checklist,[a,l]=d.useState(!0),[c,u]=d.useState([]),[h,f]=d.useState(!1),[p,x]=d.useState(null),[y,w]=d.useState(!1),b=r.filter(g=>!g.installed),v=i.jobs+i.missions+i.approvals+i.telegramChats,m=g=>{u(S=>S.includes(g)?S.filter(k=>k!==g):[...S,g])},j=()=>{f(!0),x(null),T.leaveRecovery({dropPending:a,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(g=>x(g instanceof oe?g.message:String(g))).finally(()=>f(!1))};return s.jsx(ct,{title:"Back from a backup",children:s.jsxs(V,{divided:!0,children:[s.jsxs(K,{children:[s.jsx(Pt,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:s.jsx("span",{className:"mono",children:e.archive??"—"})}]}),s.jsx("p",{className:"ui-card-meta",children:"Nothing runs on its own yet: no schedules, no watchers, no phone. Chat works. Go through what is below, then turn this buddi back on."})]}),s.jsx(K,{title:"Keys to paste again",children:n.length===0?s.jsx(ie,{children:"Nothing is missing."}):s.jsx("ul",{className:"recovery-list",children:n.map(g=>s.jsxs("li",{children:[g.settingsRoute?s.jsx("a",{href:g.settingsRoute,children:g.name}):g.name," ",s.jsx("span",{className:"ui-card-meta",children:g.kind})]},`${g.kind}:${g.name}`))})}),s.jsx(K,{title:"Add-ons to install again",children:b.length===0?s.jsx(ie,{children:"Everything the backup named is installed."}):s.jsx("ul",{className:"recovery-list",children:b.map(g=>s.jsxs("li",{children:[s.jsx("span",{className:"mono",children:g.name})," ",g.version," ",s.jsx("span",{className:"ui-card-meta",children:g.source})]},g.name))})}),s.jsx(K,{title:"Work that was waiting",children:v===0?s.jsx(ie,{children:"Nothing was in flight when the backup was taken."}):s.jsxs(V,{gap:"sm",children:[s.jsx(Pt,{items:[{label:"Jobs",value:String(i.jobs)},{label:"Missions",value:String(i.missions)},{label:"Waiting for an answer",value:String(i.approvals)},{label:"Phones",value:String(i.telegramChats)}]}),s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:g=>l(g.target.checked)}),s.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),s.jsx(K,{title:"Standing permissions",children:o.length===0?s.jsx(ie,{children:"No agent had a standing permission."}):s.jsxs(V,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),s.jsx("ul",{className:"recovery-list",children:o.map(g=>s.jsx("li",{children:s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:c.includes(g.id),onChange:()=>m(g.id),"aria-label":`Keep ${g.tool} for ${g.agent}`}),s.jsxs("span",{children:[s.jsx("span",{className:"mono",children:g.tool})," for ",g.agent," ",s.jsx("span",{className:"ui-card-meta",children:g.scope}),g.description?s.jsxs("span",{className:"ui-card-meta",children:[" — ",g.description]}):null]})]})},g.id))})]})}),s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:p}),y?s.jsx(H,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):s.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),s.jsx(q,{align:"end",children:s.jsx(P,{variant:"accent",disabled:h||y,onClick:j,children:"Leave recovery mode"})})]})})]})})}const m4=2e3,g4={queued:"Getting started.",stopping:"Stopping the gateway. The database stays up.",snapshot:"Taking a copy of what is here now, first.",database:"Putting the database back.",recovery:"Marking this installation as restored.",files:"Putting the files back.",starting:"Starting back up.",encrypt:"Locking it with your passphrase.",done:"Done.",failed:"That did not work.","rolled-back":"That did not work, so everything was put back as it was."};function $y(e){return g4[e.phase]??e.detail??e.phase}const x4=new Set(["done","failed","rolled-back"]);function o1(e){return e!==void 0&&(x4.has(e.phase)||!!e.finishedAt)}function v4(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(!1),[o,a]=d.useState(null),l=d.useRef(!1);return d.useEffect(()=>{if(!e){n(void 0),i(!1),l.current=!1;return}let c=!1;const u=()=>{T.backupJob(e).then(f=>{if(!c){if(l.current){window.location.reload();return}n(f),a(null),o1(f)&&(c=!0)}}).catch(f=>{if(!c){if(f instanceof oe&&f.status!==0&&f.status<500){a(f.message);return}l.current=!0,i(!0)}})};u();const h=window.setInterval(u,m4);return()=>{c=!0,window.clearInterval(h)}},[e]),{job:t,away:r,error:o}}function y4({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.jsx(H,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="rolled-back"||e.phase==="failed"?s.jsxs(H,{tone:"critical",role:"alert",children:[$y(e)," ",e.error??""]}):s.jsxs(H,{tone:e.phase==="done"?"good":void 0,role:"status",children:[$y(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function j4(){var b,v,m,j,g,S,k;const e=ne(()=>T.backups(),[],3e4),t=i1(),n=ne(()=>T.service(),[]),[r,i]=d.useState(null),o=v4(r),[a,l]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),p=((b=e.data)==null?void 0:b.supervised)??((v=n.data)==null?void 0:v.supervised),x=h!==null||p===!1,y=((m=e.data)==null?void 0:m.archives)??[],w=N=>{u(!0),l(null),N.then(C=>{var A;return i(((A=C.job)==null?void 0:A.id)??null)}).catch(C=>{C instanceof oe&&C.status===409?f(C.message):l(C instanceof oe?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return d.useEffect(()=>{o1(o.job)&&e.reload()},[(j=o.job)==null?void 0:j.phase]),s.jsxs(V,{gap:"lg",children:[(g=t.data)!=null&&g.active?s.jsx(p4,{view:t.data,onLeft:t.reload}):null,s.jsx(re,{message:e.error??a}),s.jsx(y4,{...o}),s.jsx(b4,{onSaved:()=>e.reload()}),s.jsx(K,{title:"Backups",panel:!0,actions:s.jsx(P,{variant:"accent",size:"sm",disabled:c,onClick:()=>w(T.startBackup(!0)),children:"Back up now"}),children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsxs("p",{className:"ui-card-meta",children:["Kept in ",s.jsx("span",{className:"mono",children:((S=e.data)==null?void 0:S.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),s.jsx(K,{children:e.data&&y.length===0?s.jsx(Ct,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?s.jsxs(un,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Taken"}),s.jsx("th",{children:"Size"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:y.map(N=>{var C;return s.jsx(k4,{archive:N,busy:c,database:(C=e.data)==null?void 0:C.database,checkout:x,onVerify:()=>w(T.verifyArchive(N.name)),onRestore:(A,E)=>w(T.restoreArchive({name:N.name,...A?{passphrase:A}:{},...E?{confirm:E}:{}}))},N.name)})})]}):s.jsx(ie,{children:"Loading…"})})]})}),s.jsx(S4,{}),s.jsx(N4,{busy:c,checkout:x,checkoutSaid:h,database:(k=e.data)==null?void 0:k.database,onRestore:(N,C,A)=>w(T.restoreUpload(N,{passphrase:C,confirm:A}))})]})}const w4={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function b4({onSaved:e}){var x;const t=ne(()=>T.backupSchedule(),[]),[n,r]=d.useState(null),[i,o]=d.useState(!1),[a,l]=d.useState(null),[c,u]=d.useState(!1);d.useEffect(()=>{t.data&&r(t.data)},[t.data]);const h={...w4,...n??t.data??{}};if(((x=t.data)==null?void 0:x.supervised)===!1)return s.jsx(K,{title:"Every night",panel:!0,children:s.jsx(K,{children:s.jsx(H,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const f=y=>{u(!1),r({...h,...y})},p=()=>{o(!0),l(null),T.setBackupSchedule(h).then(y=>{r(y),u(!0),e()}).catch(y=>l(y instanceof oe?y.message:String(y))).finally(()=>o(!1))};return s.jsx(K,{title:"Every night",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:i,onClick:p,children:"Save"}),children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:a}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:h.enabled,onChange:y=>f({enabled:y.target.checked})}),s.jsx("span",{children:"Back this buddi up on its own"})]}),s.jsxs(Bs,{children:[s.jsx(X,{label:"At",children:s.jsx("input",{type:"time",value:h.time,onChange:y=>f({time:y.target.value})})}),s.jsx(X,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:s.jsx("input",{type:"number",min:1,max:365,value:h.keep,onChange:y=>f({keep:Number(y.target.value)||1})})})]}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:h.encryptLocal,onChange:y=>f({encryptLocal:y.target.checked})}),s.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(X,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:s.jsx("input",{type:"text",value:h.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:y=>f({copyTo:y.target.value===""?null:y.target.value})})}),c?s.jsxs(H,{tone:"good",role:"status",children:["Saved.",h.lastRunAt?` Last run ${Ee(h.lastRunAt)}.`:""]}):null]})})]})})}function k4({archive:e,busy:t,database:n,checkout:r,onVerify:i,onRestore:o}){const[a,l]=d.useState(!1),[c,u]=d.useState(""),[h,f]=d.useState("");return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:e.name}),s.jsx("td",{children:Ee(e.createdAt)}),s.jsx("td",{children:dn(e.bytes)}),s.jsxs("td",{children:[e.encrypted?s.jsx(ve,{tone:"good",children:"locked"}):s.jsx(ve,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?s.jsx(ve,{tone:"critical",children:"damaged"}):null]}),s.jsx("td",{children:s.jsxs(q,{align:"end",children:[s.jsx(P,{size:"sm",disabled:t,onClick:i,children:"Verify"}),s.jsx(P,{size:"sm",variant:"ghost",onClick:()=>l(!a),children:"Restore…"})]})})]}),a?s.jsx("tr",{children:s.jsx("td",{colSpan:5,children:r?s.jsx(H,{tone:"warning",children:a1}):s.jsx(l1,{what:`${e.name}, taken ${Ee(e.createdAt)}, ${dn(e.bytes)}`,database:n,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:h,onConfirm:f,busy:t,onCancel:()=>l(!1),onGo:()=>o(c,h)})})}):null]})}const a1="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function l1({what:e,database:t,needsPassphrase:n,passphrase:r,onPassphrase:i,confirm:o,onConfirm:a,busy:l,onCancel:c,onGo:u}){const h=t??"",f=h===""?o.trim()!=="":o.trim()===h;return s.jsxs(V,{gap:"sm",children:[s.jsxs(H,{tone:"warning",children:["This replaces everything in this buddi with ",e,". What is here now is copied first, so a restore that fails puts it back."]}),n?s.jsx(X,{label:"The passphrase this one was locked with",children:s.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:p=>i(p.target.value)})}):null,s.jsx(X,{label:h?`Type ${h} to confirm`:"Type the name of this database to confirm",hint:h?void 0:"The same name buddi shows on the System tab.",children:s.jsx("input",{value:o,onChange:p=>a(p.target.value)})}),s.jsxs(q,{align:"end",children:[s.jsx(P,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(P,{variant:"danger",disabled:l||!f||n&&r==="",onClick:u,children:"Restore"})]})]})}function S4(){const[e,t]=d.useState(null),[n,r]=d.useState(""),[i,o]=d.useState(!1),[a,l]=d.useState(null),[c,u]=d.useState(!1),h=()=>{o(!0),l(null),T.backupPassphrase().then(p=>t(p.passphrase)).catch(p=>l(p instanceof oe?p.message:String(p))).finally(()=>o(!1))},f=()=>{o(!0),l(null),T.setBackupPassphrase(n.trim()).then(p=>{t(p.passphrase),r(""),u(!0)}).catch(p=>l(p instanceof oe?p.message:String(p))).finally(()=>o(!1))};return s.jsx(K,{title:"The passphrase",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:a}),s.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?s.jsx("p",{className:"backup-phrase mono",children:e}):s.jsx(q,{align:"end",children:s.jsx(P,{disabled:i,onClick:h,children:"Show it"})}),c?s.jsx(H,{tone:"good",role:"status",children:"Saved. Backups made from now on use it; older ones keep the one they were made with."}):null]})}),s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(X,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:s.jsx("input",{type:"text",autoComplete:"off",value:n,onChange:p=>{u(!1),r(p.target.value)}})}),s.jsx(q,{align:"end",children:s.jsx(P,{variant:"accent",disabled:i||n.trim()==="",onClick:f,children:"Use this one"})})]})})]})})}function N4({busy:e,checkout:t,checkoutSaid:n,database:r,onRestore:i}){const[o,a]=d.useState(null),[l,c]=d.useState(""),[u,h]=d.useState(""),[f,p]=d.useState(!1);return t?s.jsx(K,{title:"Restore from a file",panel:!0,children:s.jsx(K,{children:s.jsx(H,{tone:"warning",children:n??a1})})}):s.jsx(K,{title:"Restore from a file",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),s.jsxs(Bs,{children:[s.jsx(X,{label:"The backup file",children:s.jsx("input",{type:"file",onChange:x=>{var y;p(!1),a(((y=x.target.files)==null?void 0:y[0])??null)}})}),s.jsx(X,{label:"Its passphrase",hint:"Only if it was locked with one.",children:s.jsx("input",{type:"password",autoComplete:"off",value:l,onChange:x=>c(x.target.value)})})]}),f?null:s.jsx(q,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||!o,onClick:()=>p(!0),children:"Restore"})})]})}),f&&o?s.jsx(K,{children:s.jsx(l1,{what:`${o.name}, ${dn(o.size)}`,database:r,needsPassphrase:!1,passphrase:l,onPassphrase:c,confirm:u,onConfirm:h,busy:e,onCancel:()=>p(!1),onGo:()=>i(o,l,u)})}):null]})})}const c1="gemini-2.5-pro";function C4(e){return e.replace(/^models\//,"")}const E4=/(image|tts|audio|live|embedding|vision|robotics|transcribe)/;function u1(e){const t=e.map(C4);let n;for(const r of t){const i=/^gemini-(\d+(?:\.\d+)*)-pro(?:-(.+))?$/.exec(r);if(!i||E4.test(i[2]??""))continue;const o=i[1].split(".").map(Number),a=(i[2]??"")!=="";(!n||_y(o,n.version)>0||_y(o,n.version)===0&&n.preview&&!a)&&(n={id:r,version:o,preview:a})}return(n==null?void 0:n.id)??t.find(r=>r.startsWith("gemini-"))}function _y(e,t){for(let n=0;n<Math.max(e.length,t.length);n+=1){const r=(e[n]??0)-(t[n]??0);if(r!==0)return r}return 0}function A4(e,t){if(!t||e.kind!=="openai-compatible")return!1;const n=r=>r.replace(/\/+$/,"");return n(e.baseUrl)===n(t)}function d1({code:e,label:t="Your code"}){const[n,r]=d.useState(!1),i=async()=>{var o;try{await((o=navigator.clipboard)==null?void 0:o.writeText(e)),r(!0)}catch{}};return s.jsxs(q,{valign:"end",children:[s.jsx(X,{label:t,grow:!0,children:s.jsx("input",{readOnly:!0,value:e,spellCheck:!1,onFocus:o=>o.currentTarget.select()})}),s.jsx(P,{onClick:()=>void i(),children:n?"Copied":"Copy"})]})}function R4({embedded:e}={}){const{data:t,error:n,reload:r,loading:i}=ne(()=>T.providerAccounts(),[]),[o,a]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(""),[f,p]=d.useState(!1),[x,y]=d.useState(!1),[w,b]=d.useState(null),v=t==null?void 0:t.accounts.some(S=>{var k;return((k=S.login)==null?void 0:k.state)==="pending"&&S.login.expiresAt&&Date.parse(S.login.expiresAt)>Date.now()});d.useEffect(()=>{if(!v)return;const S=setInterval(r,2e3);return()=>clearInterval(S)},[v,r]);const m=async(S,k)=>{a(!0),c(null),h(""),y(!1);try{const N=await S();return h((N==null?void 0:N.warning)??k),r(),!0}catch(N){return c(N instanceof Error?N.message:"Could not apply change."),r(),!1}finally{a(!1)}},j=(t==null?void 0:t.accounts)??[],g=j.find(S=>S.id===w)??j[0];return s.jsxs(fn,{embedded:e,title:"Model accounts",lede:"Give each API key or subscription a name, then pick one per agent. An account never falls back to another credential on its own.",children:[s.jsx(re,{message:n??l}),u&&s.jsx(H,{tone:"good",role:"status",children:u}),x&&s.jsx(H,{role:"status",children:i?"Refreshing account status…":n?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!t&&!n&&s.jsx(ie,{children:"Loading accounts…"}),n&&s.jsx(q,{children:s.jsx(P,{onClick:r,children:"Retry"})}),t&&s.jsxs(s.Fragment,{children:[(t.vault.locked||t.vault.kind==="none")&&s.jsx(H,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),f&&s.jsx(Qt,{title:"Add an account",onClose:()=>p(!1),children:s.jsx("div",{id:"new-provider-account",children:s.jsx(_4,{accounts:j,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,gemini:t.gemini,busy:o,run:m,onDone:S=>{p(!1),S&&b(S)}})})}),s.jsx(K,{title:"Accounts",aside:`Secrets live in the ${T4(t.vault.kind)}; Postgres holds names and assignments only.`,actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",size:"sm",disabled:o||i,onClick:()=>{c(null),h(""),y(!0),r()},children:i?"Refreshing…":"Refresh status"}),s.jsx(P,{variant:"accent",size:"sm",disabled:o,"aria-expanded":f,"aria-controls":"new-provider-account",onClick:()=>p(!f),children:"Add account"})]}),panel:!0,flush:!0,children:j.length===0?s.jsx(Ct,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):s.jsxs("div",{className:"accounts",children:[s.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:j.map(S=>s.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(g==null?void 0:g.id)===S.id,onClick:()=>b(S.id),children:[s.jsx(P4,{kind:S.kind,auth:S.auth}),s.jsxs("span",{className:"accounts-row-text",children:[s.jsx("span",{className:"accounts-row-name",children:S.label}),s.jsxs("span",{className:"accounts-row-sub",children:[mg(S)," · ",S.assignedAgents.length===0?"no agents":`${S.assignedAgents.length} agent${S.assignedAgents.length===1?"":"s"}`]})]}),s.jsx(h1,{account:S})]},S.id))}),g?s.jsx(M4,{account:g,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:o,run:m},`${g.id}:${g.revision}`):null]})})]})]})}function T4(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function mg(e){return e.kind==="codex"?"ChatGPT subscription":e.kind==="anthropic"?e.auth==="anthropic-oauth"?"Claude subscription":e.auth==="legacy-subscription-token"?"Claude setup token":"Anthropic API":e.kind==="openai"?"OpenAI API":e.auth==="device-key"?"Ollama Cloud":"OpenAI-compatible"}function f1(e){return e.detectedContextWindowSource!=="provider"?"assumed":e.kind==="codex"?"from ChatGPT":"from the provider"}function P4({kind:e,auth:t}){const n=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return s.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:n})}function I4(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function h1({account:e}){const t=e.enabled?e.configured?"good":"warning":void 0,n=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return s.jsx(ve,{tone:t,children:n})}function p1(e){return{id:e.id,revision:e.revision,label:e.label,kind:e.kind,auth:e.auth,baseUrl:e.baseUrl,defaultModel:e.defaultModel,enabled:e.enabled,contextWindowTokens:e.contextWindowTokens??null}}function M4({account:e,busy:t,run:n,anthropicOAuthEnabled:r}){const[i,o]=d.useState(!1),[a,l]=d.useState(!1);return s.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:e.label}),s.jsx(h1,{account:e})]}),s.jsx(Pt,{items:[{label:"Provider",value:mg(e)},{label:"Default model",value:s.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:s.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":` (${f1(e)})`}`})},...e.baseUrl?[{label:"Endpoint",value:s.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?s.jsx("span",{className:"ui-row",children:e.assignedAgents.map(c=>s.jsx("a",{href:xt(c,"setup","brain"),children:c},c))}):s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:"No agents"}),s.jsx("a",{href:it,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${new Date(e.tokenExpiresAt).toLocaleString()} (not your subscription renewal date)`}]:[]]}),e.removalPending&&s.jsx(H,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&s.jsxs(H,{tone:"warning",children:["Token refresh did not finish. Reconnect this ",e.kind==="codex"?"ChatGPT":"Claude"," account."]}),e.auth==="anthropic-oauth"&&s.jsx(x1,{account:e,enabled:!!r,busy:t,run:n}),e.kind==="codex"&&s.jsx(m1,{account:e,busy:t,run:n}),e.auth==="device-key"&&s.jsx(g1,{account:e,busy:t,run:n}),s.jsxs(q,{children:[s.jsx(P,{disabled:t||e.removalPending,onClick:()=>o(!0),children:"Edit account"}),s.jsx(P,{disabled:t||e.removalPending,onClick:()=>void n(()=>T.saveProviderAccount({...p1(e),enabled:!e.enabled}),e.enabled?"Account disabled. Subsequent model calls will stop; already-sent requests cannot be recalled.":"Account enabled."),children:e.enabled?"Disable":"Enable"}),e.kind!=="codex"&&s.jsx(P,{disabled:t||!e.enabled||!e.configured,onClick:()=>void n(()=>T.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),s.jsx(P,{variant:"danger",disabled:t||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>l(!0),children:"Remove account"})]}),e.test&&s.jsxs(s.Fragment,{children:[s.jsxs(H,{role:"status",tone:I4(e.test.state),children:[s.jsx("p",{children:e.test.message}),e.test.retryAt?s.jsxs("p",{children:["Provider suggested retry time: ",new Date(e.test.retryAt).toLocaleString(),". This is retry advice, not a guaranteed quota reset."]}):["rate-limited","quota-exhausted"].includes(e.test.state)&&s.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),s.jsxs("p",{className:"muted",children:["Tested at ",new Date(e.test.checkedAt).toLocaleString(),e.test.httpStatus?` · HTTP ${e.test.httpStatus}`:"",". This is not a quota reset or subscription renewal date."]})]}),i&&s.jsx(Qt,{title:`Edit ${e.label}`,onClose:()=>o(!1),children:s.jsx($4,{account:e,busy:t,run:n,onDone:()=>o(!1)})}),a&&s.jsxs(H,{tone:"critical",children:[s.jsxs("p",{children:["Remove “",e.label,"” and its stored credential from Buddi? This does not revoke it at the provider or remove it from backups."]}),s.jsxs(q,{children:[s.jsx(P,{variant:"danger",disabled:t,onClick:()=>void n(()=>T.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),s.jsx(P,{disabled:t,onClick:()=>l(!1),children:"Cancel"})]})]}),s.jsx(Et,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[e.auth==="legacy-subscription-token"&&s.jsx("p",{children:"Legacy subscription token: not refreshable, token expiry and subscription renewal date unknown."}),e.kind==="codex"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Talks to OpenAI’s Codex backend directly with your ChatGPT sign-in. The credential stays in buddi’s vault; buddi refreshes it and never reads your own Codex login."}),s.jsx("p",{children:"Native tool-step usage reporting is incomplete. Do not use Buddi’s token or API-cost estimates as subscription billing or remaining quota."}),s.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):s.jsx("p",{children:"Testing sends a small fixed prompt and may incur a charge. No conversation or files are sent. Configured does not mean verified."}),e.auth==="device-key"&&s.jsx("p",{children:"Ollama Cloud with a device key: buddi made a key pair and keeps it in the vault; ollama.com only ever saw the public half and this computer’s name. Each request to ollama.com is signed with the key, and nothing else is sent with it. Disconnect asks ollama.com to forget the device and removes the key from buddi either way."}),e.auth==="anthropic-oauth"&&s.jsx("p",{children:"Claude subscription sign-in. Tokens remain in Buddi’s vault and refresh before use. Uses your plan’s monthly Agent SDK credits; after them, an API key. Remaining credits are unknown here."}),s.jsx("p",{children:"Subscription login is separate from API-key access. Existing Claude setup tokens remain legacy accounts, without automatic refresh or a known expiry."})]})})]})}function m1({account:e,busy:t,run:n}){var r,i,o;return s.jsxs(s.Fragment,{children:[s.jsxs(q,{children:[s.jsx(P,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void n(()=>T.codexAccountAction(e.id,"login",e.revision),"Complete device sign-in below."),children:e.configured?"Reconnect ChatGPT":"Connect ChatGPT"}),((i=e.login)==null?void 0:i.state)==="pending"&&s.jsx(P,{disabled:t,onClick:()=>void n(()=>T.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),s.jsx(P,{disabled:t||!e.configured,onClick:()=>void n(()=>T.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((o=e.login)==null?void 0:o.state)==="pending"&&s.jsxs(H,{tone:"accent",role:"status",children:[s.jsxs("p",{children:["Here is your code: ",s.jsx("strong",{children:e.login.userCode}),". Open the link, enter it, and approve buddi on openai.com."]}),e.login.userCode&&s.jsx(d1,{code:e.login.userCode}),e.login.verificationUrl&&s.jsx(q,{children:s.jsx(cn,{variant:"accent",href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open openai.com"})}),e.login.expiresAt&&s.jsxs("p",{className:"muted",children:["The code works until ",new Date(e.login.expiresAt).toLocaleTimeString(),". Start again after that; this is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&s.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function $4({account:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:o}){const[a,l]=d.useState((e==null?void 0:e.label)??""),[c,u]=d.useState((e==null?void 0:e.kind)??"anthropic"),[h,f]=d.useState((e==null?void 0:e.auth)??"api-key"),[p,x]=d.useState((e==null?void 0:e.baseUrl)??""),[y,w]=d.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[b,v]=d.useState(""),[m,j]=d.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),g=k=>{u(k),f(k==="codex"?"chatgpt":"api-key"),v(""),x(k==="openai-compatible"?"http://localhost:11434/v1":""),w(k==="anthropic"?"claude-sonnet-5":k==="openai"?"gpt-5":"")},S=!a.trim()||!y.trim();return s.jsxs("form",{className:"ui-stack",onSubmit:k=>{k.preventDefault();const N=b;v(""),n(()=>T.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:a,kind:c,auth:h,baseUrl:p,defaultModel:y,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:m.trim()?Number(m):null,...N.trim()?{secret:N}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(X,{label:"Account name",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:a,onChange:k=>l(k.target.value),placeholder:"Anthropic — Personal"})}),s.jsx(X,{label:"Provider",children:s.jsxs("select",{disabled:!!e,value:h==="anthropic-oauth"?"anthropic-oauth":h==="device-key"?"ollama-cloud":c,onChange:k=>{k.target.value==="anthropic-oauth"?(g("anthropic"),f("anthropic-oauth")):g(k.target.value)},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(e==null?void 0:e.auth)==="device-key"&&s.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),(o||(e==null?void 0:e.auth)==="anthropic-oauth")&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),(i||(e==null?void 0:e.kind)==="codex")&&s.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),c==="openai-compatible"&&h!=="device-key"&&s.jsxs(s.Fragment,{children:[s.jsx(X,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:p,onChange:k=>x(k.target.value)})}),s.jsx(X,{label:"Authentication",children:s.jsxs("select",{disabled:!!e,value:h,onChange:k=>{f(k.target.value),v("")},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),s.jsx(q,{valign:"end",children:s.jsx(hg,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:y,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),s.jsx(X,{label:"Context window",hint:"Tokens this endpoint actually serves. Leave blank unless you run the model yourself and set a window of your own — a conversation is ended once its history would fill half of this.",children:s.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:m,placeholder:e!=null&&e.detectedContextWindowTokens?`${e.detectedContextWindowTokens} (${f1(e)})`:"assumed from the model",onChange:k=>j(k.target.value)})}),c==="codex"&&s.jsx("p",{className:"muted",children:"Pick a model from the list once the account is connected."}),h==="anthropic-oauth"&&s.jsx("p",{className:"muted",children:"Save this account, then choose Connect Claude. You will approve in your browser and paste the authorization code here, not in chat. No existing agent assignment changes."}),h==="api-key"&&s.jsx(X,{label:e?"Replacement API key (leave blank to keep)":"API key",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:b,onChange:k=>v(k.target.value)})}),e&&s.jsx("p",{className:"muted",children:"Saving changes stops an active run at its next model call. Start a new turn afterward. Changing the default model does not change existing agent assignments."}),s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:r,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:S,children:"Save account"})]})]}),S&&s.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function g1({account:e,busy:t,run:n}){var l;const r=((l=e.login)==null?void 0:l.state)==="pending"&&e.login.attemptId?e.login:null,i=d.useRef(n);i.current=n,d.useEffect(()=>{if(!(r!=null&&r.attemptId))return;let c=!1,u=!1;const h=setInterval(()=>{c||u||(u=!0,T.ollamaPoll(e.id,r.attemptId).then(f=>{c||f.state==="waiting"||(c=!0,f.state==="connected"?i.current(async()=>{},`Connected as ${f.username}, device ${f.deviceName}.`):i.current(async()=>{throw new Error(f.message)},""))}).catch(()=>{}).finally(()=>{u=!1}))},2e3);return()=>{c=!0,clearInterval(h)}},[e.id,r==null?void 0:r.attemptId]);const o=()=>{const c=typeof window.open=="function"?window.open("","_blank"):null;n(async()=>{try{const u=await T.ollamaConnect(e.id,e.revision);return c&&(c.location.href=u.verificationUrl),u}catch(u){throw c==null||c.close(),u}},"Press Connect on the ollama.com page. This card notices on its own.")},a=e.device;return s.jsxs(s.Fragment,{children:[a&&s.jsx("p",{className:"muted",role:"status",children:a.connectedAt?`Connected as ${a.username||"an ollama.com account"}, device ${a.deviceName}.`:`Not connected yet. Device ${a.deviceName}.`}),s.jsxs(q,{children:[s.jsx(P,{disabled:t||!e.enabled||e.removalPending||!!r,onClick:o,children:e.configured?"Reconnect Ollama":"Connect Ollama"}),s.jsx(P,{disabled:t||!a||e.removalPending,onClick:()=>void n(async()=>({warning:(await T.ollamaDisconnect(e.id,e.revision)).note}),"Disconnected."),children:"Disconnect"})]}),r&&s.jsxs(H,{tone:"accent",role:"status",children:[s.jsxs("p",{children:[s.jsx("a",{href:r.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open the ollama.com page"})," and press Connect. Sign in there first if it asks."]}),s.jsxs("p",{className:"muted",children:["buddi stops waiting at ",r.expiresAt&&new Date(r.expiresAt).toLocaleTimeString(),"."]})]})]})}function x1({account:e,enabled:t,busy:n,run:r}){var a,l,c,u,h;const[i,o]=d.useState("");return d.useEffect(()=>{o("")},[(a=e.login)==null?void 0:a.attemptId,(l=e.login)==null?void 0:l.state]),s.jsxs(s.Fragment,{children:[!t&&s.jsx(H,{tone:"warning",children:"Claude subscription sign-in is turned off on this host."}),s.jsxs(q,{children:[s.jsx(P,{disabled:n||!t||!e.enabled||e.removalPending||((c=e.login)==null?void 0:c.state)==="pending",onClick:()=>void r(()=>T.anthropicAccountAction(e.id,"login",e.revision),"Open the Claude consent link below. Existing credentials remain until sign-in succeeds."),children:e.configured?"Reconnect Claude":"Connect Claude"}),((u=e.login)==null?void 0:u.state)==="pending"&&s.jsx(P,{disabled:n,onClick:()=>{o(""),r(()=>T.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),s.jsx(P,{disabled:n||!e.configured||e.removalPending,onClick:()=>{o(""),r(()=>T.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((h=e.login)==null?void 0:h.state)==="pending"&&s.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:f=>{f.preventDefault();const p=i;o(""),r(()=>T.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:p}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[s.jsx("p",{children:s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),s.jsxs("p",{className:"muted",children:["Use the Claude account you want to connect. Paste the entire code including #state. This attempt expires at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),"; restarting Buddi also ends it."]}),s.jsx(X,{label:"Claude authorization code",children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:f=>o(f.target.value),disabled:n})}),s.jsx(q,{align:"end",children:s.jsx(P,{type:"submit",variant:"accent",disabled:n||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const af={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5.5"};function lf(e,t,n){return v1(e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":t==="device-key"?"Ollama Cloud":"Local endpoint",n)}function v1(e,t){const n=new Set(t.map(r=>r.trim().toLowerCase()));if(!n.has(e.toLowerCase()))return e;for(let r=2;r<100;r+=1)if(!n.has(`${e} ${r}`.toLowerCase()))return`${e} ${r}`;return e}function _4({accounts:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:o,gemini:a}){const l=e.map(te=>te.label),[c,u]=d.useState(null),[h,f]=d.useState("anthropic"),[p,x]=d.useState("api-key"),[y,w]=d.useState(()=>lf("anthropic","api-key",l)),[b,v]=d.useState(!1),[m,j]=d.useState(""),[g,S]=d.useState(""),[k,N]=d.useState(null),[C,A]=d.useState(!1),[E,_]=d.useState(""),[L,B]=d.useState(""),[R,O]=d.useState(!1),[Y,G]=d.useState(!1),[M,W]=d.useState(!1),$=(te,se,we=!1)=>{f(te),x(se),S(""),N(null),_(""),B(""),O(!1),G(we),W(!1),j(we?"":te==="openai-compatible"?"http://localhost:11434/v1":""),b||w(we?lf(te,"device-key",l):lf(te,se,l))},ee=te=>{$("openai-compatible",te?"api-key":"device-key",!0),te&&T.ollama().then(se=>j(se.cloudBaseUrl)).catch(()=>{})},ce=()=>{a&&($("openai-compatible","api-key"),W(!0),j(a.baseUrl),b||w(v1("Gemini",l)))},Ce=c?e.find(te=>te.id===c):void 0;if(c)return Ce?s.jsx(O4,{account:Ce,busy:t,run:n,anthropicOAuthEnabled:o,onDone:()=>r(Ce.id)}):s.jsx(ie,{children:"Saving…"});const J=h==="openai-compatible"&&p!=="device-key",ge=h==="codex"||p==="anthropic-oauth"||p==="device-key",xe=!ge&&(p==="none"||g.trim()!=="")&&(!J||m.trim()!==""),je=async()=>{var te,se;A(!0),_("");try{const we=await T.probeModels({kind:h,auth:p,...J?{baseUrl:m}:{},...g.trim()?{secret:g}:{}});N(we),L||B(((te=we.models.find(be=>be.isDefault))==null?void 0:te.id)??((se=we.models[0])==null?void 0:se.id)??"")}catch(we){_(we instanceof Error?we.message:"Could not load models. You can still enter a custom model.")}finally{A(!1)}},Pe=L.trim(),ze=!y.trim()||J&&!m.trim()||J&&!M&&!Pe||M&&!g.trim();return s.jsxs("form",{className:"ui-stack",onSubmit:te=>{te.preventDefault();const se=g;S("");let we=Pe||(p==="device-key"?ic:af[h])||"claude-sonnet-5";(async()=>{if(M){we=c1;try{const fe=await T.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:m,secret:se});we=u1(fe.models.map(D=>D.id))??we}catch{}}let be;!await n(async()=>(be=await T.saveProviderAccount({label:y,kind:h,auth:p,baseUrl:m,defaultModel:we,enabled:!0,...se.trim()?{secret:se}:{}}),be),"Account saved.")||!be||(M?u(be.id):Pe||!ge?r(be.id):u(be.id))})()},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(X,{label:"Provider",children:s.jsxs("select",{value:p==="anthropic-oauth"?"anthropic-oauth":Y?"ollama-cloud":M?"gemini":h,onChange:te=>{if(te.target.value==="anthropic-oauth")$("anthropic","anthropic-oauth");else if(te.target.value==="gemini")ce();else if(te.target.value==="ollama-cloud")$("openai-compatible","device-key",!0);else{const se=te.target.value;$(se,se==="codex"?"chatgpt":"api-key")}},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),a&&s.jsx("option",{value:"gemini",children:"Gemini (Google AI key)"}),s.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),o&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),i&&s.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),s.jsx(X,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:y,onChange:te=>{w(te.target.value),v(!0)},placeholder:"Anthropic — Personal"})}),Y&&s.jsxs("label",{className:"ui-row",children:[s.jsx("input",{type:"checkbox",checked:p==="api-key",onChange:te=>ee(te.target.checked)}),s.jsx("span",{children:"Use a key instead"})]}),J&&s.jsxs(s.Fragment,{children:[s.jsx(X,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:s.jsx("input",{required:!0,type:"url",value:m,onChange:te=>{j(te.target.value),N(null)}})}),!M&&s.jsx(X,{label:"Authentication",children:s.jsxs("select",{value:p,onChange:te=>{x(te.target.value),S(""),N(null)},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),p==="api-key"&&s.jsx(X,{label:"API key",hint:"Stored in the vault, never shown again.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:g,onChange:te=>{S(te.target.value),N(null)}})}),M&&a?s.jsxs("p",{className:"muted",children:[s.jsx("a",{href:a.keyUrl,target:"_blank",rel:"noreferrer",children:"Get a key at aistudio.google.com"}),". buddi picks the newest Gemini Pro your key can reach; the next step lists the rest."]}):ge?s.jsx("p",{className:"muted",children:h==="codex"?"You will connect your ChatGPT subscription on the next step, with a code you enter on openai.com, and pick a model then.":p==="device-key"?"You will connect on the next step: ollama.com opens, you press Connect, and no key is typed. Free to start.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Model"}),k?s.jsxs("div",{className:"ui-row",children:[s.jsxs("select",{"aria-label":"Model",value:R?"__custom__":L,onChange:te=>{te.target.value==="__custom__"?(O(!0),B("")):(O(!1),B(te.target.value))},children:[k.models.map(te=>s.jsxs("option",{value:te.id,children:[te.name===te.id?te.id:`${te.name} — ${te.id}`,te.isDefault?" (provider default)":"",te.thinks?" · thinks":""]},te.id)),s.jsx("option",{value:"__custom__",children:"Custom model…"})]}),s.jsx(P,{size:"sm",disabled:C||!xe,onClick:()=>void je(),children:C?"Loading…":"Reload"})]}):s.jsxs("div",{className:"ui-row",children:[s.jsx(P,{disabled:C||!xe,onClick:()=>void je(),children:C?"Loading models…":"Load models"}),J?s.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):s.jsxs("span",{className:"muted",children:["Optional now: ",af[h]," is used until you pick one."]})]}),R||J&&!k?s.jsx("input",{"aria-label":"Custom model",required:J,maxLength:150,value:L,onChange:te=>B(te.target.value),placeholder:J?"qwen3:8b":af[h]}):null,E?s.jsx("span",{className:"ui-field-hint critical",role:"alert",children:E}):null,k!=null&&k.truncated?s.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:()=>r(),children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:ze,children:"Save account"})]})]}),ze&&s.jsxs("p",{className:"muted",children:["Enter an account name",M?" and a key":J?", an endpoint and a model":""," to enable Save account."]})]})}function O4({account:e,busy:t,run:n,anthropicOAuthEnabled:r,onDone:i}){const[o,a]=d.useState(e.defaultModel),l=e.configured;return s.jsxs(V,{gap:"lg",children:[s.jsxs(H,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!l?s.jsx(x1,{account:e,enabled:!!r,busy:t,run:n}):null,e.kind==="codex"&&!l?s.jsx(m1,{account:e,busy:t,run:n}):null,e.auth==="device-key"&&!l?s.jsx(g1,{account:e,busy:t,run:n}):null,l?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-page-lede",children:"Pick the model this account offers by default. An agent can still choose another when you assign it."}),s.jsx(q,{valign:"end",children:s.jsx(hg,{accountId:e.enabled?e.id:void 0,label:"Default model",value:o,onChange:a,disabled:t},`${e.id}:${e.revision}`)}),s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:i,children:"Skip for now"}),s.jsx(P,{variant:"accent",disabled:t||!o.trim(),onClick:()=>{if(o===e.defaultModel){i();return}n(()=>T.saveProviderAccount({...p1(e),defaultModel:o}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):s.jsx(q,{children:s.jsx(P,{onClick:i,children:"Finish later"})})]})}const Oy=new Set(["co.uk","org.uk","me.uk","ltd.uk","plc.uk","net.uk","sch.uk","ac.uk","gov.uk","nhs.uk","police.uk","mod.uk","gov.ie","co.at","or.at","ac.at","gv.at","com.pl","net.pl","org.pl","info.pl","biz.pl","edu.pl","gov.pl","waw.pl","com.es","org.es","nom.es","gob.es","edu.es","com.pt","org.pt","gov.pt","edu.pt","com.gr","org.gr","net.gr","edu.gr","gov.gr","com.cy","org.cy","net.cy","gov.cy","ac.cy","com.mt","org.mt","net.mt","edu.mt","gov.mt","co.hu","org.hu","info.hu","com.ro","org.ro","info.ro","nom.ro","co.rs","org.rs","edu.rs","gov.rs","in.rs","com.ua","org.ua","net.ua","gov.ua","edu.ua","in.ua","kiev.ua","com.ru","org.ru","net.ru","msk.ru","spb.ru","co.no","priv.no","com.hr","from.hr","iz.hr","name.hr","co.it","gov.it","edu.it","asso.fr","com.fr","gouv.fr","nom.fr","prd.fr","tm.fr","co.je","net.je","org.je","co.gg","net.gg","org.gg","co.im","net.im","org.im","gc.ca","on.ca","qc.ca","bc.ca","ab.ca","com.mx","org.mx","net.mx","edu.mx","gob.mx","ny.us","ca.us","tx.us","fl.us","wa.us","k12.ca.us","lib.ca.us","com.br","net.br","org.br","gov.br","edu.br","art.br","blog.br","eco.br","emp.br","ind.br","inf.br","tv.br","app.br","dev.br","com.ar","org.ar","net.ar","gob.ar","edu.ar","int.ar","tur.ar","com.co","org.co","net.co","edu.co","gov.co","nom.co","com.pe","org.pe","net.pe","gob.pe","edu.pe","nom.pe","com.ve","org.ve","net.ve","gob.ve","co.ve","com.uy","org.uy","net.uy","gub.uy","edu.uy","com.ec","org.ec","net.ec","gob.ec","edu.ec","fin.ec","com.bo","org.bo","net.bo","gob.bo","edu.bo","com.py","org.py","net.py","gov.py","edu.py","gob.cl","gov.cl","co.cl","com.do","org.do","net.do","gob.do","edu.do","com.gt","org.gt","net.gt","gob.gt","edu.gt","co.cr","or.cr","fi.cr","go.cr","ac.cr","com.pa","org.pa","net.pa","gob.pa","com.sv","org.sv","gob.sv","edu.sv","com.ni","org.ni","gob.ni","com.hn","org.hn","net.hn","gob.hn","com.cu","org.cu","net.cu","gob.cu","com.jm","org.jm","net.jm","gov.jm","com.tt","org.tt","net.tt","gov.tt","co.tt","com.pr","org.pr","net.pr","gov.pr","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","co.nz","net.nz","org.nz","ac.nz","govt.nz","school.nz","geek.nz","gen.nz","kiwi.nz","maori.nz","co.jp","ne.jp","or.jp","ac.jp","ad.jp","ed.jp","go.jp","gr.jp","lg.jp","com.cn","net.cn","org.cn","gov.cn","edu.cn","ac.cn","com.hk","net.hk","org.hk","edu.hk","gov.hk","idv.hk","com.tw","net.tw","org.tw","edu.tw","gov.tw","idv.tw","co.kr","or.kr","ne.kr","go.kr","ac.kr","re.kr","pe.kr","co.in","net.in","org.in","firm.in","gen.in","ind.in","ac.in","edu.in","gov.in","res.in","nic.in","com.sg","net.sg","org.sg","edu.sg","gov.sg","per.sg","com.my","net.my","org.my","edu.my","gov.my","name.my","co.id","or.id","ac.id","go.id","web.id","my.id","biz.id","net.id","sch.id","co.th","in.th","ac.th","go.th","or.th","net.th","com.vn","net.vn","org.vn","edu.vn","gov.vn","com.ph","net.ph","org.ph","edu.ph","gov.ph","com.pk","net.pk","org.pk","edu.pk","gov.pk","com.bd","org.bd","net.bd","gov.bd","edu.bd","com.lk","org.lk","gov.lk","edu.lk","com.np","org.np","gov.np","edu.np","com.kh","org.kh","gov.kh","com.mm","org.mm","gov.mm","com.fj","org.fj","gov.fj","ac.fj","com.pg","org.pg","gov.pg","ac.pg","com.kz","org.kz","gov.kz","edu.kz","com.tr","net.tr","org.tr","gov.tr","edu.tr","gen.tr","biz.tr","info.tr","av.tr","bel.tr","k12.tr","co.il","org.il","net.il","ac.il","gov.il","muni.il","com.sa","net.sa","org.sa","gov.sa","edu.sa","med.sa","co.ae","net.ae","org.ae","gov.ae","ac.ae","com.qa","org.qa","net.qa","gov.qa","edu.qa","com.kw","org.kw","net.kw","gov.kw","edu.kw","com.bh","org.bh","net.bh","gov.bh","edu.bh","com.om","org.om","net.om","gov.om","co.om","com.jo","org.jo","net.jo","gov.jo","edu.jo","com.lb","org.lb","net.lb","gov.lb","edu.lb","com.eg","org.eg","net.eg","gov.eg","edu.eg","eun.eg","co.ir","ac.ir","gov.ir","org.ir","net.ir","co.za","org.za","net.za","gov.za","ac.za","web.za","edu.za","nom.za","com.ng","org.ng","net.ng","gov.ng","edu.ng","name.ng","co.ke","or.ke","ne.ke","go.ke","ac.ke","sc.ke","co.tz","or.tz","ne.tz","go.tz","ac.tz","co.ug","or.ug","ne.ug","go.ug","ac.ug","com.gh","org.gh","gov.gh","edu.gh","co.ma","net.ma","org.ma","gov.ma","ac.ma","press.ma","com.tn","org.tn","gov.tn","ens.tn","fin.tn","com.dz","org.dz","net.dz","gov.dz","edu.dz","com.et","org.et","gov.et","edu.et","co.zw","org.zw","gov.zw","ac.zw","co.zm","org.zm","gov.zm","ac.zm","co.bw","org.bw","ac.bw","com.na","org.na","co.na","co.mz","org.mz","gov.mz","com.cm","co.cm","net.cm","gov.cm","com.sn","org.sn","edu.sn","gouv.sn","com.ci","co.ci","or.ci","go.ci","ac.ci","com.tg","gouv.tg","co.rw","gov.rw","ac.rw","*.ck","*.er","*.fk","*.jm","*.kh","*.mm","*.np","*.pg","*.bd","github.io","githubusercontent.com","gitlab.io","bitbucket.io","pages.dev","workers.dev","trycloudflare.com","vercel.app","vercel.dev","now.sh","netlify.app","netlify.com","herokuapp.com","herokussl.com","cloudfront.net","amazonaws.com","s3.amazonaws.com","elasticbeanstalk.com","awsapprunner.com","amplifyapp.com","azurewebsites.net","azurestaticapps.net","cloudapp.net","azureedge.net","azurefd.net","blob.core.windows.net","trafficmanager.net","appspot.com","firebaseapp.com","web.app","run.app","cloudfunctions.net","blogspot.com","fly.dev","onrender.com","up.railway.app","deno.dev","deno.net","glitch.me","repl.co","replit.dev","replit.app","ngrok.io","ngrok.app","ngrok-free.app","ngrok.dev","ngrok-free.dev","surge.sh","readthedocs.io","myshopify.com","wixsite.com","webflow.io","framer.app","framer.website","ondigitalocean.app","digitaloceanspaces.com","supabase.co","fastly.net","global.ssl.fastly.net","edgecompute.app","duckdns.org","dyndns.org","ddns.net","no-ip.org","hopto.org","zapto.org","eu.org","us.org","neocities.org","codeberg.page","sourceforge.io","pythonanywhere.com","streamlit.app","hf.space"]);function D4(e){const t=e.toLowerCase().replace(/\.$/,"");if(!t.includes(".")||Oy.has(t))return!0;const n=t.slice(t.indexOf(".")+1);return Oy.has(`*.${n}`)}function L4(e){return typeof e=="string"&&e.includes("*")}function F4(e){const t=/^(https?):\/\/([^/?#@\s]+)(?:[/?#]\S*)?$/i.exec(e.trim());if(t===null)return{ok:!1,reason:"invalid"};const[,n,r]=t;if(!r.startsWith("*.")||r.slice(2).includes("*"))return{ok:!1,reason:"placement"};let i;try{i=new URL(`${n.toLowerCase()}://${r.slice(2)}`)}catch{return{ok:!1,reason:"invalid"}}const o=i.hostname;return o===""||o.startsWith("[")||/^[\d.]+$/.test(o)||o.startsWith(".")||o.includes("..")?{ok:!1,reason:"invalid"}:D4(o)?{ok:!1,reason:"public-suffix"}:{ok:!0,value:{pattern:`${i.protocol}//*.${i.host}`,protocol:i.protocol,suffix:o,port:i.port}}}const Dy=["every-time","first-time","pre-approved"],y1={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function U4(e){const t=Dy.indexOf(e);return Dy.slice(0,t<0?1:t+1)}function j1(e){return e.endsWith(".account")}const B4="This account’s process holds the value for as long as its connection lives.",gg="Stored, not usable until it has a binding.";function z4(e){return e==="browser.field"?"the origin of the site that holds the field, e.g. https://en.wikipedia.org or *.wikimedia.org":e==="browser.form.data"?"the origin, then the field name — e.g. https://localhost:8443 card-number":e==="browser.native.type"?"the app’s bundle id, e.g. com.bank.app":e==="http.header"?"the host, then the header name — e.g. localhost:9200 Authorization":e==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":j1(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const w1={"browser.form.data":{hint:"an origin, then the field name",build:(e,t)=>({origin:e,field:t})},"http.header":{hint:"a host, then the header name",build:(e,t)=>({host:e,header:t})},"developer.env":{hint:"a workspace, then the variable name",build:(e,t)=>({workspace:e,variable:t})}},W4="A wildcard may only stand for the leftmost part of a site, like *.wikimedia.org.",H4=e=>`That is a public suffix; ${e} would match every site.`,Ly="Give the site as an origin, like https://en.wikipedia.org.";function Fy(e){const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:["https:","//",e].join("");if(L4(e)){const n=F4(t);if(n.ok)return{ok:!0,target:n.value.pattern};if(n.reason==="placement")return{ok:!1,error:W4};if(n.reason==="public-suffix"){const r=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/[/?#:].*$/,"").toLowerCase();return{ok:!1,error:H4(r)}}return{ok:!1,error:Ly}}try{const n=new URL(t);if(n.origin==="null"||n.protocol!=="https:"&&n.protocol!=="http:")throw new Error("not an origin");return{ok:!0,target:n.origin}}catch{return{ok:!1,error:Ly}}}function V4(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const n=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&n?[r,n]:null}function b1(e,t){const n=t.trim();if(n==="")return{ok:!1,error:"Give the exact place this value may go."};if(n.startsWith("{"))try{const o=JSON.parse(n);return o!==null&&typeof o=="object"&&!Array.isArray(o)?{ok:!0,target:o}:{ok:!1,error:'A target in JSON is an object, like {"host":"localhost","header":"Authorization"}.'}}catch{return{ok:!1,error:"That opens like JSON but does not parse."}}if(e==="browser.field")return Fy(n);if(e==="browser.native.type"||j1(e))return{ok:!0,target:n};const r=w1[e];if(r===void 0)return{ok:!0,target:n};const i=V4(n);if(i===null)return{ok:!1,error:`${e} needs both: ${r.hint}.`};if(e==="browser.form.data"){const o=Fy(i[0]);return o.ok?{ok:!0,target:r.build(o.target,i[1])}:o}return{ok:!0,target:r.build(i[0],i[1])}}function K4(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function G4(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const n=t,r=w1[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),o=i.map(a=>n[a]);if(i.every(a=>typeof n[a]=="string"))return o.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const k1="accounts.provider";function Y4(e,t){for(const n of e)if(n.kind===k1&&typeof n.target=="string"){const r=t.get(n.target);if(r)return r}}function rp(e,t,n){if(e===k1&&typeof t=="string"){const r=n.get(t);if(r)return r.label}return G4(e,t)}function S1(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function N1(e,t){if(typeof e!="object"||e===null)return[];const n=e[t];return Array.isArray(n)?n.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,o=r.count;return typeof i!="string"||typeof o!="number"||!(o>0)?[]:[{place:i,count:o}]}):[]}function C1(e){const t=e.map(({place:n,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?n.replace(/s$/,""):n}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function q4(e){const t=N1(e,"found");return t.length?`The value already sits in ${C1(t)}.`:""}function Q4(e){const t=N1(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${C1(t)}.`:""}async function Xr(e,t,n,r){n(!0),r(null);try{return(await T.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{n(!1)}}function X4({embedded:e,timezone:t}={}){const n=ne(()=>T.secrets(),[]),r=ne(()=>T.providerAccounts(),[]),i=d.useMemo(()=>{var c;return new Map((((c=r.data)==null?void 0:c.accounts)??[]).map(u=>[u.id,{label:u.label,provider:mg(u)}]))},[r.data]),[o,a]=d.useState(!1),l=n.data;return s.jsxs(fn,{embedded:e,title:"Keys and secrets",lede:"What the agents may use and never see: a name, a value buddi keeps, and the exact places the value may go.",children:[s.jsxs(V,{gap:"lg",children:[!l&&!n.error?s.jsx(ie,{children:"Opening the vault…"}):null,n.error?s.jsx(q,{children:s.jsx(P,{onClick:n.reload,children:"Retry"})}):null,l?s.jsx(K,{title:"Secrets",aside:"A value the agents use and never see: bound to where it may go, never shown again.",actions:s.jsx(P,{variant:"accent",size:"sm",onClick:()=>a(!0),children:"Add a secret"}),panel:!0,children:s.jsx(V,{divided:!0,children:l.secrets.length===0?s.jsx(Ct,{icon:"key",title:"Nothing stored yet",children:"Add one — a site password, an API token — and bind it to the places an agent may use it."}):l.secrets.map(c=>s.jsx(J4,{secret:c,accounts:i,destinations:l.destinations,timezone:t,onChanged:n.reload},c.name))})}):null,l?s.jsx(K,{title:"buddi’s own keys",aside:"Read-only.",children:s.jsxs(V,{gap:"sm",children:[l.ownKeys.length===0?s.jsx(ie,{children:"No keys of buddi’s own right now."}):s.jsx("div",{className:"ui-list",children:l.ownKeys.map(c=>s.jsx("div",{className:"ui-list-row",children:s.jsx("span",{className:"ui-list-main",children:s.jsx("span",{className:"mono",children:c})})},c))}),s.jsx("p",{className:"ui-card-meta",children:"These are the keys buddi itself runs on. They cannot be bound or replaced here, and the scrubber replaces them in what buddi sends out, exactly like your own secrets."})]})}):null]}),o&&l?s.jsx(e3,{destinations:l.destinations,onClose:()=>a(!1),onChanged:n.reload}):null]})}function J4({secret:e,accounts:t,destinations:n,timezone:r,onChanged:i}){const[o,a]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(!1),[x,y]=d.useState(!1),w=async()=>{await Xr("secrets.delete",{name:e.name},a,c)!==null&&(p(!1),i())},b=e.lastUse,v=Y4(e.bindings,t);return s.jsxs(V,{gap:"sm",children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:v?v.label:e.name}),v?s.jsx(cc,{children:v.provider}):null,e.totp?s.jsx(cc,{children:"TOTP"}):null,b?s.jsx(ve,{tone:S1(b.outcome),children:b.outcome}):null]}),v?s.jsx("p",{className:"ui-card-meta mono",children:e.name}):null,e.bindings.length===0?s.jsx("p",{className:"ui-card-meta",children:gg}):s.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((m,j)=>s.jsxs("div",{className:"ui-row",children:[s.jsx(cc,{children:m.kind}),s.jsx("span",{className:"mono",children:rp(m.kind,m.target,t)}),s.jsx(ve,{tone:"muted",children:y1[m.rule]??m.rule})]},j))}),e.bindings.some(m=>m.heldByPlugin)?s.jsx("p",{className:"ui-card-meta",children:B4}):null,s.jsx("p",{className:"ui-card-meta",children:b?`Last used ${Ee(b.at)}${b.agentId?` by ${b.agentId}`:""} — ${b.kind}, ${rp(b.kind,b.target,t)}.`:"Never used."}),s.jsx(re,{message:l}),f?s.jsxs(H,{tone:"critical",role:"alert",children:[s.jsxs("p",{children:["Delete “",e.name,"”? The value and its bindings go; the use log stays, under the name."]}),s.jsxs(q,{children:[s.jsx(P,{variant:"danger",disabled:o,onClick:()=>void w(),children:"Delete it"}),s.jsx(P,{disabled:o,onClick:()=>p(!1),children:"Cancel"})]})]}):null,s.jsxs(q,{children:[s.jsx(P,{size:"sm",disabled:o,onClick:()=>h("replace"),children:"Replace value"}),s.jsx(P,{size:"sm",disabled:o,onClick:()=>h("rename"),children:"Rename"}),s.jsx(P,{size:"sm",disabled:o,onClick:()=>h("rebind"),children:e.bindings.length===0?"Add a binding":"Rebind"}),s.jsx(P,{size:"sm",variant:"danger",disabled:o,onClick:()=>p(!0),children:"Delete"}),s.jsx(P,{size:"sm",variant:"ghost","aria-expanded":x,onClick:()=>y(!x),children:"Use log"})]}),x?s.jsx(Z4,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?s.jsx(t3,{secret:e,onClose:()=>h(null),onChanged:i}):null,u==="rename"?s.jsx(n3,{secret:e,onClose:()=>h(null),onChanged:i}):null,u==="rebind"?s.jsx(s3,{secret:e,destinations:n,onClose:()=>h(null),onChanged:i}):null]})}function Z4({name:e,accounts:t,timezone:n}){const r=ne(()=>T.secretUses(e,50),[e]);if(r.error)return s.jsx(re,{message:r.error});if(!r.data)return s.jsx(ie,{children:"Reading the log…"});const i=r.data.uses;return i.length===0?s.jsx(ie,{children:"No uses yet."}):s.jsx("div",{className:"ui-list",children:i.map((o,a)=>s.jsxs("div",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[De(o.at,n??"UTC")," — ",o.kind,", ",rp(o.kind,o.target,t)]}),s.jsxs("span",{className:"ui-list-sub",children:[o.agent?o.agent:"the owner",o.plugin?` · ${o.plugin}`:"",o.detail?` · ${o.detail}`:""]})]}),s.jsx("span",{className:"ui-list-side",children:s.jsx(ve,{tone:S1(o.outcome),children:o.outcome})})]},a))})}function E1({name:e,result:t,scrubbed:n,busy:r,failure:i,onScrub:o,onDone:a}){const l=q4(t);return s.jsxs(V,{gap:"sm",children:[s.jsxs(H,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),s.jsx("p",{className:"ui-card-meta",children:l||"Nothing of the value sits where buddi already holds text."}),s.jsx(re,{message:i}),l?s.jsx(q,{children:s.jsx(P,{variant:"accent",disabled:r||n!==null,onClick:o,children:n===null?"Scrub the history":Q4(n)||"Nothing of it was left to replace."})}):null,s.jsx(q,{align:"end",children:s.jsx(P,{onClick:a,children:"Done"})})]})}function A1({destinations:e,bindings:t,disabled:n,onChange:r}){const i=(o,a)=>{r(t.map((l,c)=>c===o?{...l,...a}:l))};return s.jsx(V,{gap:"sm",children:t.map((o,a)=>{const l=e.find(u=>u.kind===o.kind),c=(l==null?void 0:l.maxRule)??o.rule;return s.jsxs(q,{valign:"end",children:[s.jsx(X,{label:"Kind",inline:!0,children:s.jsx("select",{value:o.kind,disabled:n,onChange:u=>{var f;const h=u.target.value;i(a,{kind:h,rule:((f=e.find(p=>p.kind===h))==null?void 0:f.maxRule)??o.rule})},children:(l?e:[...e,{kind:o.kind,plugin:"",maxRule:o.rule}]).map(u=>s.jsx("option",{value:u.kind,children:u.kind},u.kind))})}),s.jsx(X,{label:"Target",inline:!0,grow:!0,children:s.jsx("input",{type:"text",spellCheck:!1,disabled:n,value:o.target,placeholder:z4(o.kind),onChange:u=>i(a,{target:u.target.value})})}),s.jsx(X,{label:"Rule",inline:!0,children:s.jsx("select",{value:o.rule,disabled:n,onChange:u=>i(a,{rule:u.target.value}),children:U4(c).map(u=>s.jsx("option",{value:u,children:y1[u]},u))})}),s.jsx(P,{size:"sm",variant:"ghost",disabled:n,onClick:()=>r(t.filter((u,h)=>h!==a)),children:"Remove"})]},a)})})}function e3({destinations:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[o,a]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:e[0].maxRule}]:[]),[f,p]=d.useState(!1),[x,y]=d.useState(null),[w,b]=d.useState(null),[v,m]=d.useState(null),j=async()=>{const S=u.map(A=>b1(A.kind,A.target)),k=S.findIndex(A=>!A.ok);if(k!==-1){y(`Binding ${k+1}: ${S[k].error}`);return}const N=o;a("");const C=await Xr("secrets.put",{name:r.trim(),value:N,totp:l,bindings:u.map((A,E)=>({kind:A.kind,target:S[E].target,rule:A.rule}))},p,y);C!==null&&(b({name:r.trim(),result:C}),n())},g=async()=>{const S=await Xr("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},p,y);S!==null&&(m(S),n())};return s.jsx(Qt,{title:"Add a secret",onClose:t,children:w?s.jsx(E1,{name:w.name,result:w.result,scrubbed:v,busy:f,failure:x,onScrub:()=>void g(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:S=>{S.preventDefault(),j()},children:s.jsxs("fieldset",{disabled:f,className:"ui-stack","data-gap":"sm",children:[s.jsx(X,{label:"Name",hint:"What an agent calls it. Saving a name that exists replaces that secret’s value.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:S=>i(S.target.value),placeholder:"PNC password"})}),s.jsx(X,{label:"Value",hint:"Kept in the vault, never shown again — not even here.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:o,onChange:S=>a(S.target.value)})}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked)}),s.jsx("span",{children:"The code comes from this secret"})]}),s.jsx("p",{className:"ui-field-hint",children:"The seed and the code are one thing buddi holds — the owner’s explicit choice per secret."}),s.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[s.jsx("span",{className:"ui-field-label",children:"Bindings — the places this value may go"}),s.jsx(A1,{destinations:e,bindings:u,disabled:f,onChange:h}),u.length===0?s.jsx("p",{className:"ui-field-hint",children:gg}):null,e.length?s.jsx(q,{children:s.jsx(P,{size:"sm",onClick:()=>h([...u,{kind:e[0].kind,target:"",rule:e[0].maxRule}]),children:"Add a binding"})}):s.jsx("p",{className:"ui-field-hint",children:"No destination is registered on this installation yet, so there is nothing to bind to."})]}),x?s.jsx(H,{tone:"critical",role:"alert",children:x}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save secret"})]})]})})})}function t3({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[o,a]=d.useState(!1),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(null),x=async()=>{const w=r;i("");const b=await Xr("secrets.put",{name:e.name,value:w,totp:e.totp,bindings:e.bindings.map(({kind:v,target:m,rule:j})=>({kind:v,target:m,rule:j}))},a,c);b!==null&&(h(b),n())},y=async()=>{const w=await Xr("secrets.scrub_history",{name:e.name},a,c);w!==null&&(p(w),n())};return s.jsx(Qt,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?s.jsx(E1,{name:e.name,result:u,scrubbed:f,busy:o,failure:l,onScrub:()=>void y(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:w=>{w.preventDefault(),x()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(X,{label:"New value",hint:"Replaces what is stored. The bindings stay as they are.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,value:r,onChange:w=>i(w.target.value)})}),l?s.jsx(H,{tone:"critical",role:"alert",children:l}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save value"})]})]})})})}function n3({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(e.name),[o,a]=d.useState(!1),[l,c]=d.useState(null),u=async()=>{await Xr("secrets.rename",{name:e.name,to:r.trim()},a,c)!==null&&(n(),t())};return s.jsx(Qt,{title:`Rename “${e.name}”`,onClose:t,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:h=>{h.preventDefault(),u()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(X,{label:"New name",hint:"The vault entry never moves; only the name the agents ask for does.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:h=>i(h.target.value)})}),l?s.jsx(H,{tone:"critical",role:"alert",children:l}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:t,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",disabled:!r.trim()||r.trim()===e.name,children:"Save name"})]})]})})})}function s3({secret:e,destinations:t,onClose:n,onChanged:r}){const[i,o]=d.useState(()=>e.bindings.map(f=>({kind:f.kind,target:K4(f.target),rule:f.rule}))),[a,l]=d.useState(!1),[c,u]=d.useState(null),h=async()=>{const f=i.map(y=>b1(y.kind,y.target)),p=f.findIndex(y=>!y.ok);if(p!==-1){u(`Binding ${p+1}: ${f[p].error}`);return}await Xr("secrets.rebind",{name:e.name,bindings:i.map((y,w)=>({kind:y.kind,target:f[w].target,rule:y.rule}))},l,u)!==null&&(r(),n())};return s.jsx(Qt,{title:`Rebind “${e.name}”`,onClose:n,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:f=>{f.preventDefault(),h()},children:s.jsxs("fieldset",{disabled:a,className:"ui-stack","data-gap":"sm",children:[s.jsx(A1,{destinations:t,bindings:i,disabled:a,onChange:o}),i.length===0?s.jsx("p",{className:"ui-field-hint",children:gg}):null,t.length?s.jsx(q,{children:s.jsx(P,{size:"sm",onClick:()=>o([...i,{kind:t[0].kind,target:"",rule:t[0].maxRule}]),children:"Add a binding"})}):null,c?s.jsx(H,{tone:"critical",role:"alert",children:c}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{onClick:n,children:"Cancel"}),s.jsx(P,{type:"submit",variant:"accent",children:"Save bindings"})]})]})})})}function r3({timezone:e,embedded:t}){const{data:n,error:r,reload:i}=ne(()=>T.sentinels(),[],3e4),[o,a]=d.useState(null),[l,c]=d.useState(null),u=(n==null?void 0:n.installed)??[],h=((n==null?void 0:n.runs)??[]).filter(x=>x.lastError),f=u.filter(x=>!x.enabled),p=(x,y)=>{a(x),c(null),T.setSentinelEnabled(x,y).catch(w=>c(w instanceof oe?w.message:String(w))).finally(()=>{a(null),i()})};return s.jsxs(fn,{embedded:t,title:"Watchers",children:[s.jsx(re,{message:r??l}),s.jsx(H,{children:"Watchers are small checks that run on their own, with no model involved. An urgent finding wakes an agent, which verifies it before it tells you. The rest waits for the weekly recap."}),h.length>0?s.jsx(H,{tone:"warning",children:h.length===1?"One watcher failed on its last run.":`${h.length} watchers failed on their last run.`}):null,f.length>0?s.jsxs(H,{tone:"warning",children:[f.length===1?"One watcher is off.":`${f.length} watchers are off.`," A watcher that is off does not run, and what it already found stays as it was."]}):null,s.jsx(K,{title:"Installed",aside:s.jsx("a",{href:`${rt}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:n?u.length===0?s.jsx(Ct,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):s.jsx(Ut,{children:u.map(x=>{const y=n.runs.find(w=>w.sentinelId===x.id);return s.jsx(Gt,{lead:s.jsx(ve,{tone:x.enabled?y!=null&&y.lastError?"critical":y?"good":void 0:"muted",children:x.enabled?y!=null&&y.lastError?"failed":y?"ok":"never ran":"off"}),title:x.description,sub:`${x.id}, every ${i3(x.every)}${y!=null&&y.lastError?`. ${y.lastError}`:""}`,side:s.jsxs(s.Fragment,{children:[s.jsx("span",{title:y?De(y.lastRunAt,e):void 0,children:y?Ee(y.lastRunAt):"never ran"}),s.jsx(P,{size:"sm",disabled:o===x.id,onClick:()=>p(x.id,!x.enabled),children:x.enabled?"Turn off":"Turn on"})]})},x.id)})}):s.jsx(ie,{children:"Loading…"})})]})}function i3(e){if(e%86400===0){const n=e/86400;return n===1?"day":`${n} days`}if(e%3600===0){const n=e/3600;return n===1?"hour":`${n} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}function o3({embedded:e}){const{data:t,error:n,reload:r}=ne(()=>T.owner(),[]);return s.jsxs(fn,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[s.jsx(re,{message:n}),t?s.jsx(a3,{initial:t,onSaved:r}):null]})}function a3({initial:e,onSaved:t}){const[n,r]=d.useState(e.preferredName??""),[i,o]=d.useState(e.timezone??""),[a,l]=d.useState(e.language??""),[c,u]=d.useState(e.about??""),[h,f]=d.useState(!1),[p,x]=d.useState(!1),[y,w]=d.useState(null);d.useEffect(()=>{r(e.preferredName??""),o(e.timezone??""),l(e.language??""),u(e.about??"")},[e]);const b=n.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||a.trim()!==(e.language??"")||c.trim()!==(e.about??""),v=async()=>{f(!0),w(null);try{await T.setOwner({preferredName:n.trim()===""?null:n.trim(),timezone:i===""?null:i,language:a.trim()===""?null:a.trim(),about:c.trim()===""?null:c.trim()}),x(!0),t()}catch(j){w(j instanceof oe?j.message:String(j))}finally{f(!1)}},m=e.zones.length>0?e.zones:[e.detectedTimezone];return s.jsx(K,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:s.jsxs(s.Fragment,{children:[p&&!b?s.jsx("span",{className:"muted",children:"Saved"}):null,s.jsx(P,{variant:"accent",disabled:!b||h,onClick:()=>void v(),children:h?"Saving…":"Save"})]}),children:s.jsxs(V,{divided:!0,gap:"lg",children:[s.jsx(K,{title:"Name and place",children:s.jsxs(Bs,{children:[s.jsx(X,{label:"What the agents call you",children:s.jsx("input",{value:n,maxLength:80,placeholder:e.displayName??"Your name",onChange:j=>{x(!1),r(j.target.value)}})}),s.jsx(X,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:s.jsxs("select",{value:i,onChange:j=>{x(!1),o(j.target.value)},children:[s.jsx("option",{value:"",children:"Not set (use the host's)"}),m.map(j=>s.jsx("option",{value:j,children:j},j))]})}),s.jsx(X,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:s.jsx("input",{value:a,maxLength:40,placeholder:"English, français…",onChange:j=>{x(!1),l(j.target.value)}})})]})}),s.jsxs(K,{title:"About you",children:[s.jsx(X,{label:"In your own words",hint:"Who you are, how you like answers, anything every agent should keep in mind. A few lines is plenty.",children:s.jsx("textarea",{rows:4,maxLength:1e3,value:c,placeholder:"I run a small studio and prefer short answers with the numbers first. Call me by my first name.",onChange:j=>{x(!1),u(j.target.value)}})}),y?s.jsx(H,{tone:"critical",children:y}):null]})]})})}const l3=2e6;function Uy(e,t){const n=e.replace(/\r\n/g,`
|
|
111
|
-
`).replace(/\n+$/,"").split(`
|
|
112
|
-
`),r=t.replace(/\r\n/g,`
|
|
113
|
-
`).replace(/\n+$/,"").split(`
|
|
114
|
-
`);if(e.trim()===t.trim())return"(no change)";if(n.length*r.length>l3)return[...n.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
|
|
115
|
-
`);const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let c=n.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=n[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const o=[];let a=0,l=0;for(;a<n.length&&l<r.length;)n[a]===r[l]?(o.push(` ${n[a]}`),a++,l++):i[a+1][l]>=i[a][l+1]?o.push(`-${n[a++]}`):o.push(`+${r[l++]}`);for(;a<n.length;)o.push(`-${n[a++]}`);for(;l<r.length;)o.push(`+${r[l++]}`);return o.join(`
|
|
116
|
-
`)}const c3={skill:"skill",policy:"rule",change:"change to itself"};function u3(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,n])=>!/Id$/.test(t)&&n!==null&&n!==void 0&&n!=="").map(([t,n])=>`${t} ${typeof n=="object"?JSON.stringify(n):String(n)}`).join(" · ")}function ip(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function d3(e,t){const n=e.change;if(!n||n.part!=="tools")return[];if(t===e.editable)return n.added;const r=new Set(ip(n.current??""));return ip(t).filter(i=>!r.has(i))}function By(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function f3({embedded:e,plugin:t}){const{data:n,error:r,reload:i}=ne(()=>T.proposals(),[],3e4),[o,a]=d.useState(null),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState({}),x=async(v,m,j=!1)=>{a(null),c(null),h(v),p(({[v]:g,...S})=>S);try{c(await m()),i()}catch(g){const S=g instanceof Error?g.message:String(g);j?p(k=>({...k,[v]:S})):a(S)}finally{h(null)}},y=gS(),w=((n==null?void 0:n.open)??[]).filter(v=>By(v,t)),b=((n==null?void 0:n.closed)??[]).filter(v=>By(v,t));return s.jsxs(fn,{embedded:e,title:"Proposals",lede:"What your agents learned and would like to keep: a procedure, a rule, a change to their own instructions. Nothing here applies itself. Keep what is right, correct what is nearly right, discard the rest.",children:[s.jsx(re,{message:r??o}),t?s.jsxs(H,{role:"status",children:["Showing the rules ",t," proposes. ",s.jsx("a",{href:lt("proposals"),children:"Show every proposal"})]}):null,l?s.jsx(H,{tone:"good",role:"status",children:l}):null,t?null:s.jsx(xS,{offers:y.offers,reload:y.reload}),!n||w.length===0?s.jsx(K,{title:"Waiting",panel:!0,children:n?t?s.jsx(Ct,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):s.jsx(Ct,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):s.jsx(ie,{children:"Loading…"})}):s.jsx(K,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(v=>s.jsx(g3,{proposal:v,busy:u===v.id,refusal:f[v.id]??null,onKeep:m=>void x(v.id,async()=>{const j=await T.keepProposal(v.id,m);return`${v.title}: ${j.note}`},!0),onDiscard:m=>void x(v.id,async()=>(await T.discardProposal(v.id,m),`Discarded: ${v.title}. ${v.agent} will be told once and will not propose it again for 90 days.`))},v.id))}),b.length>0?s.jsx(K,{title:`Kept, discarded and expired (${b.length})`,aside:"These stop being shown a week after they were decided.",panel:!0,flush:!0,children:s.jsx(Ut,{children:b.map(v=>{var m;return s.jsx(Gt,{title:v.title,sub:`${v.agent}: ${h3(v)}`,side:v.kind==="skill"&&v.state==="kept"&&((m=v.skill)!=null&&m.live)?s.jsxs(q,{align:"end",children:[s.jsx("span",{className:"muted",children:Ee(v.decidedAt??v.createdAt)}),s.jsx(P,{size:"sm",variant:"ghost",disabled:u===v.id,onClick:()=>void x(v.id,async()=>{const j=v.skill;return await T.removeSkill(v.agent,j.name),`Removed ${j.name} from ${v.agent}. Its versions are kept, and ${v.agent} will not propose it again for 90 days.`}),children:"Remove this skill"})]}):Ee(v.decidedAt??v.createdAt)},v.id)})})}):null,!t&&(n!=null&&n.digest)?s.jsx(m3,{schedule:n.digest.schedule,onSaved:i}):null]})}function h3(e){switch(e.state){case"kept":return e.kind==="skill"&&e.skill?e.skill.live?`Kept as ${e.skill.name}, version ${e.skill.version}; it loads on the agent's next run.`:`Kept; ${e.skill.name} has a newer version now (${e.skill.version}).`:e.note??"Kept.";case"discarded":return e.reason?`Discarded: ${e.reason}`:"Discarded.";case"expired":return`Expired: ${e.reason??"not decided in 30 days"}.`;default:return"Waiting."}}const p3=Array.from({length:24},(e,t)=>t),zy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function m3({schedule:e,onSaved:t}){const[n,r]=d.useState(e.day),[i,o]=d.useState(e.hour),[a,l]=d.useState(!1),[c,u]=d.useState(null),h=n!==e.day||i!==e.hour,f=async()=>{l(!0),u(null);try{await T.setDigestSchedule(n,i),u({tone:"good",text:`The digest now runs on ${zy[n]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(p){u({tone:"critical",text:p instanceof Error?p.message:String(p)})}finally{l(!1)}};return s.jsx(K,{title:"Weekly digest",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:a||!h,onClick:()=>void f(),children:"Save"}),children:s.jsxs(V,{children:[s.jsxs("p",{className:"muted",children:["Once a week, one message on Telegram and a card on Home: what your agents learned, what waits here, and what the rules you kept stopped them doing. No message when nothing was learned and nothing waits.",e.next?` Next: ${Ee(e.next)}.`:""]}),s.jsxs(q,{children:[s.jsx(X,{label:"Day",children:s.jsx("select",{value:n,disabled:a,onChange:p=>r(Number(p.target.value)),children:zy.map((p,x)=>s.jsx("option",{value:x,children:p},p))})}),s.jsx(X,{label:`Hour (${e.timezone})`,children:s.jsx("select",{value:i,disabled:a,onChange:p=>o(Number(p.target.value)),children:p3.map(p=>s.jsxs("option",{value:p,children:[String(p).padStart(2,"0"),":00"]},p))})})]}),c?s.jsx(H,{tone:c.tone,role:"status",children:c.text}):null]})})}function Wy(e,t){return e==="tools"?ip(t).join(`
|
|
117
|
-
`):t}function g3({proposal:e,busy:t,refusal:n,onKeep:r,onDiscard:i}){const[o,a]=d.useState(e.editable??""),[l,c]=d.useState(""),u=e.editable!==null&&o!==e.editable,h=e.payload,f=e.echoes??[],p=e.kind==="change"?e.change??null:null,x=d3(e,o);return s.jsx(Yr,{tone:e.untrusted?"warning":"accent",title:e.title,meta:s.jsxs(s.Fragment,{children:[s.jsx(ve,{children:c3[e.kind]}),s.jsx(ve,{mono:!0,children:e.agent}),e.untrusted?s.jsx(ve,{tone:"warning",children:"untrusted text in view"}):null,x.length>0?s.jsx(ve,{tone:"warning",children:"widens its tools"}):null]}),foot:s.jsxs(q,{align:"end",children:[n?s.jsx("span",{className:"proposal-refusal",role:"alert",children:n}):null,s.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:l,maxLength:300,disabled:t,onChange:y=>c(y.target.value)}),s.jsx(P,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(l.trim()||void 0),children:"Discard"}),s.jsx(P,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&o.trim()==="",onClick:()=>r(u?o:void 0),children:u?"Keep my version":"Keep"})]}),children:s.jsxs(V,{gap:"sm",children:[e.why?s.jsx("p",{children:e.why}):null,s.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",Ee(e.createdAt),e.conversationId?s.jsxs(s.Fragment,{children:[" in ",s.jsx("a",{href:Zi(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?s.jsxs(H,{tone:"warning",title:e.kind==="policy"?"Learned from mail you received.":"Made with untrusted text in view.",children:[e.kind==="policy"?"The plugin counted this rule from your own triage decisions; no instruction in that mail can change what it does.":"Something written by someone other than you was in the agent's context when it proposed this. Read it for instructions that came from there rather than from you.",s.jsx("ul",{className:"proposal-sources",children:e.sources.map(y=>s.jsx("li",{className:"mono",children:y},y))}),f.length>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),s.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:f.map(y=>s.jsx("li",{children:s.jsx("mark",{className:"wb-diff-mark",children:y})},y))})]}):null]}):null,e.kind==="skill"?s.jsxs(s.Fragment,{children:[typeof h.when=="string"?s.jsxs("p",{className:"ui-card-meta",children:["When: ",h.when]}):null,e.skill?s.jsxs(V,{gap:"sm",children:[s.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",s.jsxs("a",{href:xt(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),s.jsx(Yc,{text:Uy(e.skill.steps,o),marks:f,label:`Version ${e.skill.version} against this proposal`})]}):null,s.jsx(X,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:s.jsx("textarea",{rows:8,value:o,disabled:t,onChange:y=>a(y.target.value)})})]}):null,e.kind==="change"?s.jsxs(s.Fragment,{children:[x.length>0?s.jsxs(H,{tone:"warning",title:`Adds: ${x.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,p!=null&&p.refusal&&!u?s.jsx(H,{tone:"warning",title:"Keeping this as proposed will be refused.",children:p.refusal}):null,p&&p.current!==null?s.jsx(Yc,{text:Uy(Wy(p.part,p.current),Wy(p.part,o)),marks:f,label:`${e.agent}'s ${p.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof h.before=="string"?s.jsx(Et,{summary:`What its ${h.part==="tools"?"tool list":"instructions"} said when proposed`,children:s.jsx(ft,{children:h.before})}):null,s.jsx(X,{label:h.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:s.jsx("textarea",{rows:8,value:o,disabled:t,onChange:y=>a(y.target.value)})})]}):null,e.kind==="policy"?s.jsx(Pt,{items:[{label:"Plugin",value:s.jsx("span",{className:"mono",children:String(h.plugin??"")})},{label:"Matches",value:s.jsx("span",{className:"mono",children:u3(h.matcher??{})})},{label:"Does",value:String(h.action??"")},{label:"Learned from",value:(()=>{const y=Array.isArray(h.verdicts)?h.verdicts.length:0;return`${y} ${y===1?"decision":"decisions"}`})()}]}):null]})})}const x3=1500,v3={fetching:"Fetching the package.","installing-dependencies":"Installing its dependencies. Nothing of the plugin has run.",reading:"Reading what it says it is.",done:"Read. Nothing has been imported yet.",failed:"That did not work."},y3="Restart buddi to load it. In a checkout, stop it and run: buddi serve",R1=[{id:"npm",label:"From npm"},{id:"file",label:"A file"},{id:"directory",label:"A directory I built"}],T1="buddi.plugins.install-mode";function j3(){try{const e=window.localStorage.getItem(T1);if(R1.some(t=>t.id===e))return e}catch{}return"npm"}function w3(e){try{window.localStorage.setItem(T1,e)}catch{}}const Fl=".tgz";function b3(e){const t=[],n=(r,i,o)=>{r>0&&t.push(`${r} ${r===1?i:o}`)};return n(e.tools,"tool","tools"),n(e.sentinels,"watcher","watchers"),n(e.views,"view","views"),n(e.agents,"agent","agents"),t.length===0?"nothing on its own":t.join(", ")}function P1(e){return e.kind==="registry"?`npm · ${e.name}@${e.version}`:e.kind==="tarball"?`a file on this machine · ${e.path}`:`a directory on this machine · ${e.path}`}function k3(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function S3(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(null);return d.useEffect(()=>{if(!e){n(void 0),i(null);return}let o=!1;const a=()=>{T.pluginJob(e).then(c=>{o||(n(c),(c.phase==="done"||c.phase==="failed")&&(o=!0))}).catch(c=>{o||(i(c instanceof oe?c.message:String(c)),o=!0)})};a();const l=window.setInterval(a,x3);return()=>{o=!0,window.clearInterval(l)}},[e]),{job:t,error:r}}function N3(){const e=ne(()=>T.plugins(),[],2e4),[t,n]=d.useState(null),{job:r,error:i}=S3(t),[o,a]=d.useState(null),[l,c]=d.useState(null);d.useEffect(()=>{((r==null?void 0:r.phase)==="done"||(r==null?void 0:r.phase)==="failed")&&e.reload()},[r==null?void 0:r.phase]);const u=e.data,h=(u==null?void 0:u.checkout)??!0;return s.jsxs(V,{gap:"lg",children:[s.jsx(re,{message:e.error??o??i}),u!=null&&u.unavailable?s.jsx(H,{tone:"warning",children:u.unavailable}):null,s.jsx(K,{title:"Plugins",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsx(H,{tone:"warning",children:(u==null?void 0:u.trust)??""})}),s.jsx(K,{children:s.jsx(E3,{busy:r!==void 0&&r.phase!=="done"&&r.phase!=="failed",onStaged:f=>{a(null),c(null),n(f)},onFailed:a})}),r?s.jsx(K,{children:s.jsxs(H,{tone:r.phase==="failed"?"critical":r.phase==="done"?"good":void 0,role:"status",children:[v3[r.phase]," ",r.error??""]})}):null]})}),((u==null?void 0:u.staged)??[]).map(f=>s.jsx(R3,{staged:f,onInstalled:p=>{c(p),n(null),e.reload()},onGone:()=>e.reload()},f.id)),l||u!=null&&u.restartNeeded?s.jsx(T3,{checkout:h,name:l}):null,s.jsx(K,{title:"Installed",panel:!0,children:u?u.installed.length===0?s.jsx(Ct,{icon:"plug",title:"Nothing installed yet",children:"Only what buddi ships with is here."}):s.jsx(V,{divided:!0,children:u.installed.map(f=>s.jsx(K,{children:s.jsx(I3,{plugin:f,onChanged:()=>e.reload(),onFailed:a})},f.name))}):s.jsx(ie,{children:"Loading…"})}),((u==null?void 0:u.builtIn)??[]).length>0?s.jsx(K,{title:"Ships with buddi",panel:!0,children:s.jsx(V,{divided:!0,children:((u==null?void 0:u.builtIn)??[]).map(f=>s.jsx(K,{children:s.jsx(C3,{plugin:f})},f.name))})}):null]})}function C3({plugin:e}){return s.jsxs(V,{gap:"sm",children:[s.jsx(Pt,{items:[{label:s.jsx("span",{children:e.name}),value:s.jsxs("span",{children:[e.version," · ",b3(e.contribution)]})}]}),e.description?s.jsx("p",{className:"ui-card-meta",children:e.description}):null]})}function E3({busy:e,onStaged:t,onFailed:n}){const[r,i]=d.useState(j3),[o,a]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState(null),[f,p]=d.useState(null),[x,y]=d.useState(!1),w=d.useRef(null),b=g=>n(g instanceof oe?g.message:String(g)),v=g=>{i(g),w3(g),p(null)},m=()=>{c(!0),T.stagePlugin(o.trim()).then(g=>{t(g.job.id),a("")}).catch(b).finally(()=>c(!1))},j=g=>{if(g){if(!g.name.toLowerCase().endsWith(Fl)){h(null),p(`${g.name} is not a ${Fl}. A packed plugin is the file npm pack writes.`);return}p(null),h(g.name),c(!0),T.uploadPlugin(g).then(S=>t(S.job.id)).catch(b).finally(()=>c(!1))}};return s.jsxs(V,{gap:"sm",children:[s.jsx("div",{className:"plugin-modes",role:"radiogroup","aria-label":"Where it comes from",children:R1.map(g=>s.jsx("button",{type:"button",role:"radio","aria-checked":r===g.id,className:"plugin-mode","data-chosen":r===g.id?"true":void 0,onClick:()=>v(g.id),children:g.label},g.id))}),r==="file"?s.jsxs("div",{className:"plugin-drop",role:"group","aria-label":"A plugin file","data-state":x?"over":f?"refused":u?"chosen":void 0,onDragOver:g=>{g.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:g=>{var S,k;g.preventDefault(),y(!1),j((k=(S=g.dataTransfer)==null?void 0:S.files)==null?void 0:k[0])},children:[s.jsx("p",{className:"ui-card-meta",children:f??(u?`${u} — reading it.`:`Drop a ${Fl} here, or choose one.`)}),s.jsx(q,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||l,onClick:()=>{var g;return(g=w.current)==null?void 0:g.click()},children:"Choose a file"})}),s.jsx("input",{ref:w,type:"file",accept:Fl,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:g=>{var S;j((S=g.target.files)==null?void 0:S[0]),g.target.value=""}})]}):s.jsxs(s.Fragment,{children:[s.jsx(X,{label:r==="npm"?"Install a plugin":"The directory it is in",hint:r==="npm"?"A package name, or a name@version.":"The folder with its package.json, already built.",children:s.jsx("input",{type:"text",value:o,placeholder:r==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:g=>a(g.target.value)})}),s.jsx(q,{align:"end",children:s.jsx(P,{variant:"accent",disabled:e||l||o.trim()==="",onClick:m,children:"Read it first"})})]})]})}function A3({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],n=((i=e.uses)==null?void 0:i.dropped)??[];return s.jsx(K,{title:"What it reaches in buddi",children:s.jsxs(V,{gap:"sm",children:[t.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nothing beyond its own tables, its own folder and its own tools' approvals."}):s.jsx("ul",{className:"plugin-uses",children:t.map(o=>s.jsxs("li",{children:["It ",o.words,"."," ",o.added?s.jsxs(ve,{tone:"warning",children:["new in ",e.version]}):null]},o.use))}),n.length>0?s.jsxs("p",{className:"ui-card-meta",children:["No longer: ",n.map(o=>o.words).join("; "),"."]}):null]})})}function R3({staged:e,onInstalled:t,onGone:n}){const[r,i]=d.useState(e.plan??null),[o,a]=d.useState(!1),[l,c]=d.useState(null),u=p=>{a(!0),c(null),T.approveStaged(e.id,{integrity:e.integrity??"",...p?{acknowledgeDrift:!0}:{}}).then(x=>{x.installed?t(e.name):x.plan&&i(x.plan)}).catch(x=>c(x instanceof oe?x.message:String(x))).finally(()=>a(!1))},h=()=>{a(!0),c(null),T.rejectStaged(e.id).then(()=>n()).catch(p=>c(p instanceof oe?p.message:String(p))).finally(()=>a(!1))},f=(r==null?void 0:r.drift)??[];return s.jsxs(V,{gap:"lg",children:[s.jsx(Yr,{tone:"accent",title:`${e.name} ${e.version}`,meta:s.jsx(ve,{tone:"muted",children:"read, not installed"}),children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:l}),s.jsx(Pt,{items:[{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:P1(e.source)},{label:"Published by",value:e.publisher??"nobody npm will name"},{label:"Integrity",value:s.jsx("span",{className:"mono",children:e.integrity===void 0||e.integrity===""?"none — this came off a disk":e.integrity})},...e.stagedHash?[{label:"Files on disk",value:s.jsx("span",{className:"mono",children:e.stagedHash})}]:[],{label:"Dependencies",value:e.dependencies.count===0?"none":`${e.dependencies.count}${e.dependencies.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${e.dependencies.withScripts.join(", ")}`}`}]}),s.jsx(A3,{staged:e}),s.jsx(K,{title:"What the package says about itself",children:s.jsxs(V,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"This is its claim, taken from its own buddi.md. Nothing has checked it yet."}),s.jsx(Pt,{items:[{label:"Schema it owns",value:e.claims.schema??"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":e.claims.hosts.join(", ")}]}),e.claims.missing?s.jsx("p",{className:"ui-card-meta",children:"It ships no buddi.md, so it says nothing about itself at all."}):s.jsx("p",{className:"ui-card-meta",children:e.claims.text})]})}),s.jsxs(q,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:o,onClick:h,children:"Not this one"}),s.jsx(P,{variant:"accent",disabled:o||f.length>0,onClick:()=>u(!1),children:"Install"})]})]})}),f.length>0?s.jsx(Yr,{tone:"warning",title:"What it said, and what it does",meta:s.jsx(ve,{tone:"warning",children:"read this first"}),children:s.jsxs(V,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),s.jsx("ul",{className:"plugin-drift",children:f.map(p=>s.jsx("li",{children:p},p))}),s.jsx(I1,{unlocks:(r==null?void 0:r.agents)??[]}),s.jsxs(q,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:o,onClick:h,children:"Not this one"}),s.jsx(P,{variant:"danger",disabled:o,onClick:()=>u(!0),children:"Install anyway"})]})]})}):null]})}function T3({checkout:e,name:t}){const[n,r]=d.useState(!1),[i,o]=d.useState(null),a=t?`${t} is installed.`:"Something is installed that this buddi has not loaded.";return s.jsx(K,{title:"Restart to load it",panel:!0,children:s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:i}),s.jsxs(H,{tone:e?"warning":void 0,role:"status",children:[a," ",e?y3:"Its tools appear once buddi restarts. That closes this dashboard for a few seconds."]}),e?null:s.jsx(q,{align:"end",children:s.jsx(P,{variant:"accent",disabled:n,onClick:()=>{r(!0),o(null),T.serviceAction("restart").catch(l=>o(l instanceof oe?l.message:String(l))).finally(()=>r(!1))},children:"Restart to load it"})})]})})})}function I1({plugin:e,unlocks:t}){return t.length===0?null:s.jsx(K,{title:"Agents it would unlock",children:s.jsxs(V,{gap:"sm",divided:!0,children:[t.map(n=>s.jsx(P3,{plugin:e,unlock:n},n.id)),s.jsxs("p",{className:"ui-card-meta",children:["Nothing here is created by installing. Accept creates the agent with the tools listed. You can change or remove it ",s.jsx("a",{href:it,children:"on the Agents page"}),"."]})]})})}function P3({plugin:e,unlock:t}){const n=hS(e,t.id),r=t.drift.state!=="not-accepted";return s.jsxs(V,{gap:"sm",children:[s.jsxs(q,{children:[s.jsxs("span",{className:"mono",children:["@",t.handle]}),s.jsx(ve,{tone:t.drift.state==="up-to-date"?"good":"warning",children:t.drift.state}),s.jsx("span",{className:"ui-card-meta",children:t.drift.message}),s.jsx(xo,{}),e&&!r&&!n.created?s.jsx(P,{size:"sm",disabled:n.busy,onClick:n.accept,children:"Accept"}):null]}),s.jsx(re,{message:n.failure}),n.created?s.jsx(pS,{agent:n.created}):null]})}function I3({plugin:e,onChanged:t,onFailed:n}){const[r,i]=d.useState(!1),[o,a]=d.useState(!1),[l,c]=d.useState(""),[u,h]=d.useState(!1),f=x=>{h(!0),x.then(()=>{i(!1),a(!1),c(""),t()}).catch(y=>n(y instanceof oe?y.message:String(y))).finally(()=>h(!1))},p=e.contribution;return s.jsxs(V,{gap:"sm",children:[s.jsx(Yr,{tone:e.loaded?void 0:"critical",title:`${e.name} ${e.version}`,meta:e.loaded?s.jsx(ve,{tone:"good",children:"loaded"}):s.jsx(ve,{tone:"critical",children:"did not load"}),actions:s.jsxs(q,{align:"end",children:[s.jsx(P,{size:"sm",variant:"ghost",disabled:u,onClick:()=>i(!r),children:"Remove…"}),s.jsx(P,{size:"sm",disabled:u,onClick:()=>f(T.updatePlugin(e.name)),children:"Update"})]}),children:s.jsxs(V,{gap:"sm",children:[e.error?s.jsx(H,{tone:"critical",children:e.error}):null,s.jsx(Pt,{items:[{label:"From",value:P1(e.source)},{label:"Published by",value:k3(e.source,e.publisher)},{label:"Installed",value:Ee(e.installedAt)},{label:"Contributes",value:`${p.tools} tool${p.tools===1?"":"s"}, ${p.sentinels} on a timer, ${p.views} view${p.views===1?"":"s"}, ${p.agents} agent${p.agents===1?"":"s"} proposed`}]}),s.jsx(I1,{plugin:e.name,unlocks:e.unlocks})]})}),r?s.jsxs(V,{gap:"sm",children:[s.jsx(H,{tone:"warning",children:"Removing it stops its code loading and leaves its tables exactly where they are, so installing it again picks up where it left off."}),s.jsxs("label",{className:"plugin-check",children:[s.jsx("input",{type:"checkbox",checked:o,onChange:x=>{a(x.target.checked),c("")}}),s.jsx("span",{children:"Also drop its data. Its tables are not recoverable afterwards."})]}),o?s.jsx(X,{label:`Type ${e.name} to confirm`,children:s.jsx("input",{value:l,onChange:x=>c(x.target.value)})}):null,s.jsxs(q,{align:"end",children:[s.jsx(P,{variant:"ghost",disabled:u,onClick:()=>{i(!1),a(!1),c("")},children:"Cancel"}),s.jsx(P,{variant:"danger",disabled:u||o&&l.trim()!==e.name,onClick:()=>f(T.uninstallPlugin(e.name,o?{purge:!0,confirm:l.trim()}:{})),children:o?"Remove and drop its data":"Remove"})]})]}):null]})}var Ga={},M3=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},M1={},kn={};let xg;const $3=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];kn.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};kn.getSymbolTotalCodewords=function(t){return $3[t]};kn.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};kn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');xg=t};kn.isKanjiModeEnabled=function(){return typeof xg<"u"};kn.toSJIS=function(t){return xg(t)};var Bu={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(Bu);function $1(){this.buffer=[],this.length=0}$1.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var _3=$1;function Ya(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Ya.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};Ya.prototype.get=function(e,t){return this.data[e*this.size+t]};Ya.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Ya.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var O3=Ya,_1={};(function(e){const t=kn.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,o=t(r),a=o===145?26:Math.ceil((o-13)/(2*i-2))*2,l=[o-7];for(let c=1;c<i-1;c++)l[c]=l[c-1]-a;return l.push(6),l.reverse()},e.getPositions=function(r){const i=[],o=e.getRowColCoords(r),a=o.length;for(let l=0;l<a;l++)for(let c=0;c<a;c++)l===0&&c===0||l===0&&c===a-1||l===a-1&&c===0||i.push([o[l],o[c]]);return i}})(_1);var O1={};const D3=kn.getSymbolSize,Hy=7;O1.getPositions=function(t){const n=D3(t);return[[0,0],[n-Hy,0],[0,n-Hy]]};var D1={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const o=i.size;let a=0,l=0,c=0,u=null,h=null;for(let f=0;f<o;f++){l=c=0,u=h=null;for(let p=0;p<o;p++){let x=i.get(f,p);x===u?l++:(l>=5&&(a+=t.N1+(l-5)),u=x,l=1),x=i.get(p,f),x===h?c++:(c>=5&&(a+=t.N1+(c-5)),h=x,c=1)}l>=5&&(a+=t.N1+(l-5)),c>=5&&(a+=t.N1+(c-5))}return a},e.getPenaltyN2=function(i){const o=i.size;let a=0;for(let l=0;l<o-1;l++)for(let c=0;c<o-1;c++){const u=i.get(l,c)+i.get(l,c+1)+i.get(l+1,c)+i.get(l+1,c+1);(u===4||u===0)&&a++}return a*t.N2},e.getPenaltyN3=function(i){const o=i.size;let a=0,l=0,c=0;for(let u=0;u<o;u++){l=c=0;for(let h=0;h<o;h++)l=l<<1&2047|i.get(u,h),h>=10&&(l===1488||l===93)&&a++,c=c<<1&2047|i.get(h,u),h>=10&&(c===1488||c===93)&&a++}return a*t.N3},e.getPenaltyN4=function(i){let o=0;const a=i.data.length;for(let c=0;c<a;c++)o+=i.data[c];return Math.abs(Math.ceil(o*100/a/5)-10)*t.N4};function n(r,i,o){switch(r){case e.Patterns.PATTERN000:return(i+o)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(i+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return i*o%2+i*o%3===0;case e.Patterns.PATTERN110:return(i*o%2+i*o%3)%2===0;case e.Patterns.PATTERN111:return(i*o%3+(i+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,o){const a=o.size;for(let l=0;l<a;l++)for(let c=0;c<a;c++)o.isReserved(c,l)||o.xor(c,l,n(i,c,l))},e.getBestMask=function(i,o){const a=Object.keys(e.Patterns).length;let l=0,c=1/0;for(let u=0;u<a;u++){o(u),e.applyMask(u,i);const h=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),h<c&&(c=h,l=u)}return l}})(D1);var zu={};const nr=Bu,Ul=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Bl=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];zu.getBlocksCount=function(t,n){switch(n){case nr.L:return Ul[(t-1)*4+0];case nr.M:return Ul[(t-1)*4+1];case nr.Q:return Ul[(t-1)*4+2];case nr.H:return Ul[(t-1)*4+3];default:return}};zu.getTotalCodewordsCount=function(t,n){switch(n){case nr.L:return Bl[(t-1)*4+0];case nr.M:return Bl[(t-1)*4+1];case nr.Q:return Bl[(t-1)*4+2];case nr.H:return Bl[(t-1)*4+3];default:return}};var L1={},Wu={};const na=new Uint8Array(512),su=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)na[n]=t,su[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)na[n]=na[n-255]})();Wu.log=function(t){if(t<1)throw new Error("log("+t+")");return su[t]};Wu.exp=function(t){return na[t]};Wu.mul=function(t,n){return t===0||n===0?0:na[su[t]+su[n]]};(function(e){const t=Wu;e.mul=function(r,i){const o=new Uint8Array(r.length+i.length-1);for(let a=0;a<r.length;a++)for(let l=0;l<i.length;l++)o[a+l]^=t.mul(r[a],i[l]);return o},e.mod=function(r,i){let o=new Uint8Array(r);for(;o.length-i.length>=0;){const a=o[0];for(let c=0;c<i.length;c++)o[c]^=t.mul(i[c],a);let l=0;for(;l<o.length&&o[l]===0;)l++;o=o.slice(l)}return o},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let o=0;o<r;o++)i=e.mul(i,new Uint8Array([1,t.exp(o)]));return i}})(L1);const F1=L1;function vg(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}vg.prototype.initialize=function(t){this.degree=t,this.genPoly=F1.generateECPolynomial(this.degree)};vg.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=F1.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r};var L3=vg,U1={},Nr={},yg={};yg.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var js={};const B1="[0-9]+",F3="[A-Z $%*+\\-./:]+";let Ma="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ma=Ma.replace(/u/g,"\\u");const U3="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ma+`)(?:.|[\r
|
|
118
|
-
]))+`;js.KANJI=new RegExp(Ma,"g");js.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");js.BYTE=new RegExp(U3,"g");js.NUMERIC=new RegExp(B1,"g");js.ALPHANUMERIC=new RegExp(F3,"g");const B3=new RegExp("^"+Ma+"$"),z3=new RegExp("^"+B1+"$"),W3=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");js.testKanji=function(t){return B3.test(t)};js.testNumeric=function(t){return z3.test(t)};js.testAlphanumeric=function(t){return W3.test(t)};(function(e){const t=yg,n=js;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(o,a){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?o.ccBits[0]:a<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return n.testNumeric(o)?e.NUMERIC:n.testAlphanumeric(o)?e.ALPHANUMERIC:n.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(o,a){if(e.isValid(o))return o;try{return r(o)}catch{return a}}})(Nr);(function(e){const t=kn,n=zu,r=Bu,i=Nr,o=yg,a=7973,l=t.getBCHDigit(a);function c(p,x,y){for(let w=1;w<=40;w++)if(x<=e.getCapacity(w,y,p))return w}function u(p,x){return i.getCharCountIndicator(p,x)+4}function h(p,x){let y=0;return p.forEach(function(w){const b=u(w.mode,x);y+=b+w.getBitsLength()}),y}function f(p,x){for(let y=1;y<=40;y++)if(h(p,y)<=e.getCapacity(y,x,i.MIXED))return y}e.from=function(x,y){return o.isValid(x)?parseInt(x,10):y},e.getCapacity=function(x,y,w){if(!o.isValid(x))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=i.BYTE);const b=t.getSymbolTotalCodewords(x),v=n.getTotalCodewordsCount(x,y),m=(b-v)*8;if(w===i.MIXED)return m;const j=m-u(w,x);switch(w){case i.NUMERIC:return Math.floor(j/10*3);case i.ALPHANUMERIC:return Math.floor(j/11*2);case i.KANJI:return Math.floor(j/13);case i.BYTE:default:return Math.floor(j/8)}},e.getBestVersionForData=function(x,y){let w;const b=r.from(y,r.M);if(Array.isArray(x)){if(x.length>1)return f(x,b);if(x.length===0)return 1;w=x[0]}else w=x;return c(w.mode,w.getLength(),b)},e.getEncodedBits=function(x){if(!o.isValid(x)||x<7)throw new Error("Invalid QR Code version");let y=x<<12;for(;t.getBCHDigit(y)-l>=0;)y^=a<<t.getBCHDigit(y)-l;return x<<12|y}})(U1);var z1={};const op=kn,W1=1335,H3=21522,Vy=op.getBCHDigit(W1);z1.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;op.getBCHDigit(i)-Vy>=0;)i^=W1<<op.getBCHDigit(i)-Vy;return(r<<10|i)^H3};var H1={};const V3=Nr;function no(e){this.mode=V3.NUMERIC,this.data=e.toString()}no.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};no.prototype.getLength=function(){return this.data.length};no.prototype.getBitsLength=function(){return no.getBitsLength(this.data.length)};no.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const o=this.data.length-n;o>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,o*3+1))};var K3=no;const G3=Nr,cf=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function so(e){this.mode=G3.ALPHANUMERIC,this.data=e}so.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};so.prototype.getLength=function(){return this.data.length};so.prototype.getBitsLength=function(){return so.getBitsLength(this.data.length)};so.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=cf.indexOf(this.data[n])*45;r+=cf.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(cf.indexOf(this.data[n]),6)};var Y3=so;const q3=Nr;function ro(e){this.mode=q3.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}ro.getBitsLength=function(t){return t*8};ro.prototype.getLength=function(){return this.data.length};ro.prototype.getBitsLength=function(){return ro.getBitsLength(this.data.length)};ro.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var Q3=ro;const X3=Nr,J3=kn;function io(e){this.mode=X3.KANJI,this.data=e}io.getBitsLength=function(t){return t*13};io.prototype.getLength=function(){return this.data.length};io.prototype.getBitsLength=function(){return io.getBitsLength(this.data.length)};io.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=J3.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
119
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var Z3=io,V1={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var o={},a={};a[r]=0;var l=t.PriorityQueue.make();l.push(r,0);for(var c,u,h,f,p,x,y,w,b;!l.empty();){c=l.pop(),u=c.value,f=c.cost,p=n[u]||{};for(h in p)p.hasOwnProperty(h)&&(x=p[h],y=f+x,w=a[h],b=typeof a[h]>"u",(b||w>y)&&(a[h]=y,l.push(h,y),o[h]=u))}if(typeof i<"u"&&typeof a[i]>"u"){var v=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(v)}return o},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],o=r;o;)i.push(o),n[o],o=n[o];return i.reverse(),i},find_path:function(n,r,i){var o=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(o,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},o;n=n||{};for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(V1);var e6=V1.exports;(function(e){const t=Nr,n=K3,r=Y3,i=Q3,o=Z3,a=js,l=kn,c=e6;function u(v){return unescape(encodeURIComponent(v)).length}function h(v,m,j){const g=[];let S;for(;(S=v.exec(j))!==null;)g.push({data:S[0],index:S.index,mode:m,length:S[0].length});return g}function f(v){const m=h(a.NUMERIC,t.NUMERIC,v),j=h(a.ALPHANUMERIC,t.ALPHANUMERIC,v);let g,S;return l.isKanjiModeEnabled()?(g=h(a.BYTE,t.BYTE,v),S=h(a.KANJI,t.KANJI,v)):(g=h(a.BYTE_KANJI,t.BYTE,v),S=[]),m.concat(j,g,S).sort(function(N,C){return N.index-C.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function p(v,m){switch(m){case t.NUMERIC:return n.getBitsLength(v);case t.ALPHANUMERIC:return r.getBitsLength(v);case t.KANJI:return o.getBitsLength(v);case t.BYTE:return i.getBitsLength(v)}}function x(v){return v.reduce(function(m,j){const g=m.length-1>=0?m[m.length-1]:null;return g&&g.mode===j.mode?(m[m.length-1].data+=j.data,m):(m.push(j),m)},[])}function y(v){const m=[];for(let j=0;j<v.length;j++){const g=v[j];switch(g.mode){case t.NUMERIC:m.push([g,{data:g.data,mode:t.ALPHANUMERIC,length:g.length},{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.ALPHANUMERIC:m.push([g,{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.KANJI:m.push([g,{data:g.data,mode:t.BYTE,length:u(g.data)}]);break;case t.BYTE:m.push([{data:g.data,mode:t.BYTE,length:u(g.data)}])}}return m}function w(v,m){const j={},g={start:{}};let S=["start"];for(let k=0;k<v.length;k++){const N=v[k],C=[];for(let A=0;A<N.length;A++){const E=N[A],_=""+k+A;C.push(_),j[_]={node:E,lastCount:0},g[_]={};for(let L=0;L<S.length;L++){const B=S[L];j[B]&&j[B].node.mode===E.mode?(g[B][_]=p(j[B].lastCount+E.length,E.mode)-p(j[B].lastCount,E.mode),j[B].lastCount+=E.length):(j[B]&&(j[B].lastCount=E.length),g[B][_]=p(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,m))}}S=C}for(let k=0;k<S.length;k++)g[S[k]].end=0;return{map:g,table:j}}function b(v,m){let j;const g=t.getBestModeForData(v);if(j=t.from(m,g),j!==t.BYTE&&j.bit<g.bit)throw new Error('"'+v+'" cannot be encoded with mode '+t.toString(j)+`.
|
|
120
|
-
Suggested mode is: `+t.toString(g));switch(j===t.KANJI&&!l.isKanjiModeEnabled()&&(j=t.BYTE),j){case t.NUMERIC:return new n(v);case t.ALPHANUMERIC:return new r(v);case t.KANJI:return new o(v);case t.BYTE:return new i(v)}}e.fromArray=function(m){return m.reduce(function(j,g){return typeof g=="string"?j.push(b(g,null)):g.data&&j.push(b(g.data,g.mode)),j},[])},e.fromString=function(m,j){const g=f(m,l.isKanjiModeEnabled()),S=y(g),k=w(S,j),N=c.find_path(k.map,"start","end"),C=[];for(let A=1;A<N.length-1;A++)C.push(k.table[N[A]].node);return e.fromArray(x(C))},e.rawSplit=function(m){return e.fromArray(f(m,l.isKanjiModeEnabled()))}})(H1);const Hu=kn,uf=Bu,t6=_3,n6=O3,s6=_1,r6=O1,ap=D1,lp=zu,i6=L3,ru=U1,o6=z1,a6=Nr,df=H1;function l6(e,t){const n=e.size,r=r6.getPositions(t);for(let i=0;i<r.length;i++){const o=r[i][0],a=r[i][1];for(let l=-1;l<=7;l++)if(!(o+l<=-1||n<=o+l))for(let c=-1;c<=7;c++)a+c<=-1||n<=a+c||(l>=0&&l<=6&&(c===0||c===6)||c>=0&&c<=6&&(l===0||l===6)||l>=2&&l<=4&&c>=2&&c<=4?e.set(o+l,a+c,!0,!0):e.set(o+l,a+c,!1,!0))}}function c6(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function u6(e,t){const n=s6.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],o=n[r][1];for(let a=-2;a<=2;a++)for(let l=-2;l<=2;l++)a===-2||a===2||l===-2||l===2||a===0&&l===0?e.set(i+a,o+l,!0,!0):e.set(i+a,o+l,!1,!0)}}function d6(e,t){const n=e.size,r=ru.getEncodedBits(t);let i,o,a;for(let l=0;l<18;l++)i=Math.floor(l/3),o=l%3+n-8-3,a=(r>>l&1)===1,e.set(i,o,a,!0),e.set(o,i,a,!0)}function ff(e,t,n){const r=e.size,i=o6.getEncodedBits(t,n);let o,a;for(o=0;o<15;o++)a=(i>>o&1)===1,o<6?e.set(o,8,a,!0):o<8?e.set(o+1,8,a,!0):e.set(r-15+o,8,a,!0),o<8?e.set(8,r-o-1,a,!0):o<9?e.set(8,15-o-1+1,a,!0):e.set(8,15-o-1,a,!0);e.set(r-8,8,1,!0)}function f6(e,t){const n=e.size;let r=-1,i=n-1,o=7,a=0;for(let l=n-1;l>0;l-=2)for(l===6&&l--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,l-c)){let u=!1;a<t.length&&(u=(t[a]>>>o&1)===1),e.set(i,l-c,u),o--,o===-1&&(a++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function h6(e,t,n){const r=new t6;n.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),a6.getCharCountIndicator(c.mode,e)),c.write(r)});const i=Hu.getSymbolTotalCodewords(e),o=lp.getTotalCodewordsCount(e,t),a=(i-o)*8;for(r.getLengthInBits()+4<=a&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const l=(a-r.getLengthInBits())/8;for(let c=0;c<l;c++)r.put(c%2?17:236,8);return p6(r,e,t)}function p6(e,t,n){const r=Hu.getSymbolTotalCodewords(t),i=lp.getTotalCodewordsCount(t,n),o=r-i,a=lp.getBlocksCount(t,n),l=r%a,c=a-l,u=Math.floor(r/a),h=Math.floor(o/a),f=h+1,p=u-h,x=new i6(p);let y=0;const w=new Array(a),b=new Array(a);let v=0;const m=new Uint8Array(e.buffer);for(let N=0;N<a;N++){const C=N<c?h:f;w[N]=m.slice(y,y+C),b[N]=x.encode(w[N]),y+=C,v=Math.max(v,C)}const j=new Uint8Array(r);let g=0,S,k;for(S=0;S<v;S++)for(k=0;k<a;k++)S<w[k].length&&(j[g++]=w[k][S]);for(S=0;S<p;S++)for(k=0;k<a;k++)j[g++]=b[k][S];return j}function m6(e,t,n,r){let i;if(Array.isArray(e))i=df.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const h=df.rawSplit(e);u=ru.getBestVersionForData(h,n)}i=df.fromString(e,u||40)}else throw new Error("Invalid data");const o=ru.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`
|
|
121
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
122
|
-
Minimum version required to store current data is: `+o+`.
|
|
123
|
-
`);const a=h6(t,n,i),l=Hu.getSymbolSize(t),c=new n6(l);return l6(c,t),c6(c),u6(c,t),ff(c,n,0),t>=7&&d6(c,t),f6(c,a),isNaN(r)&&(r=ap.getBestMask(c,ff.bind(null,c,n))),ap.applyMask(r,c),ff(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}M1.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=uf.M,i,o;return typeof n<"u"&&(r=uf.from(n.errorCorrectionLevel,uf.M),i=ru.from(n.version),o=ap.from(n.maskPattern),n.toSJISFunc&&Hu.setToSJISFunction(n.toSJISFunc)),m6(t,i,r,o)};var K1={},jg={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(o){return[o,o]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,o=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:o,scale:o?4:a,margin:i,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},e.getImageWidth=function(r,i){const o=e.getScale(r,i);return Math.floor((r+i.margin*2)*o)},e.qrToImageData=function(r,i,o){const a=i.modules.size,l=i.modules.data,c=e.getScale(a,o),u=Math.floor((a+o.margin*2)*c),h=o.margin*c,f=[o.color.light,o.color.dark];for(let p=0;p<u;p++)for(let x=0;x<u;x++){let y=(p*u+x)*4,w=o.color.light;if(p>=h&&x>=h&&p<u-h&&x<u-h){const b=Math.floor((p-h)/c),v=Math.floor((x-h)/c);w=f[l[b*a+v]?1:0]}r[y++]=w.r,r[y++]=w.g,r[y++]=w.b,r[y]=w.a}}})(jg);(function(e){const t=jg;function n(i,o,a){i.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=a,o.width=a,o.style.height=a+"px",o.style.width=a+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,a,l){let c=l,u=a;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),a||(u=r()),c=t.getOptions(c);const h=t.getImageWidth(o.modules.size,c),f=u.getContext("2d"),p=f.createImageData(h,h);return t.qrToImageData(p.data,o,c),n(f,u,h),f.putImageData(p,0,0),u},e.renderToDataURL=function(o,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const u=e.render(o,a,c),h=c.type||"image/png",f=c.rendererOpts||{};return u.toDataURL(h,f.quality)}})(K1);var G1={};const g6=jg;function Ky(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function hf(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function x6(e,t,n){let r="",i=0,o=!1,a=0;for(let l=0;l<e.length;l++){const c=Math.floor(l%t),u=Math.floor(l/t);!c&&!o&&(o=!0),e[l]?(a++,l>0&&c>0&&e[l-1]||(r+=o?hf("M",c+n,.5+u+n):hf("m",i,0),i=0,o=!1),c+1<t&&e[l+1]||(r+=hf("h",a),a=0)):i++}return r}G1.render=function(t,n,r){const i=g6.getOptions(n),o=t.modules.size,a=t.modules.data,l=o+i.margin*2,c=i.color.light.a?"<path "+Ky(i.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",u="<path "+Ky(i.color.dark,"stroke")+' d="'+x6(a,o,i.margin)+'"/>',h='viewBox="0 0 '+l+" "+l+'"',p='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+h+' shape-rendering="crispEdges">'+c+u+`</svg>
|
|
124
|
-
`;return typeof r=="function"&&r(null,p),p};const v6=M3,cp=M1,Y1=K1,y6=G1;function wg(e,t,n,r,i){const o=[].slice.call(arguments,1),a=o.length,l=typeof o[a-1]=="function";if(!l&&!v6())throw new Error("Callback required as last argument");if(l){if(a<2)throw new Error("Too few arguments provided");a===2?(i=n,n=t,t=r=void 0):a===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(n=t,t=r=void 0):a===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(c,u){try{const h=cp.create(n,r);c(e(h,t,r))}catch(h){u(h)}})}try{const c=cp.create(n,r);i(null,e(c,t,r))}catch(c){i(c)}}Ga.create=cp.create;Ga.toCanvas=wg.bind(null,Y1.render);Ga.toDataURL=wg.bind(null,Y1.renderToDataURL);Ga.toString=wg.bind(null,function(e,t,n){return y6.render(e,n)});async function j6(e){const t=await Ga.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const Gy=10*6e4,w6=2e3;function q1(e,t){const[n,r]=d.useState(null),[i,o]=d.useState(null),[a,l]=d.useState(!1),[c,u]=d.useState(!1),h=d.useRef(e);h.current=e;const f=d.useRef(t);f.current=t;const p=d.useCallback(async()=>{const x=await T.telegramPairing();r(x),u(!1),l(!1),o(await j6(x.link).catch(()=>""))},[]);return d.useEffect(()=>{if(!n||a||c)return;let x=!1;const y=Math.min(Date.parse(n.expiresAt)||Date.now()+Gy,Date.now()+Gy),w=window.setInterval(()=>{if(Date.now()>=y){u(!0);return}h.current().then(b=>{var v;x||!b||(l(!0),(v=f.current)==null||v.call(f))}).catch(()=>{})},w6);return()=>{x=!0,window.clearInterval(w)}},[n,a,c]),{offer:n,square:i,paired:a,stale:c,ask:p}}function Q1({offer:e,square:t,children:n}){return s.jsxs("div",{className:"meet-pair",children:[t?s.jsx("img",{className:"meet-qr",src:t,alt:e.link}):null,s.jsx("a",{className:"meet-link",href:e.link,target:"_blank",rel:"noreferrer",children:e.link}),n]})}const X1=new Set(["approval","question"]),zl={approval:{label:"Approvals",hint:"A run nobody is watching wants to do something gated."},question:{label:"Questions",hint:"A run asked you something and waits."},watcher:{label:"Watchers",hint:"A watcher or a source found something."},reminder:{label:"Reminders",hint:"A reminder an agent promised you came due."},failure:{label:"Failures",hint:"Background jobs died and will not be retried."},recap:{label:"Reports",hint:"Mission reports, the weekly recap, answers to actions you tapped."},plugin:{label:"Plugins",hint:"A plugin that may send you messages has something to say."}};function b6({timezone:e}){var w,b;const t=ne(()=>T.notificationSettings(),[]),n=ne(()=>T.notifications(20),[],3e4),[r,i]=d.useState(null),[o,a]=d.useState(!1),[l,c]=d.useState(!1),[u,h]=d.useState(null),f=((w=t.data)==null?void 0:w.channels)??[],p=r??((b=t.data)==null?void 0:b.settings),x=v=>{p&&(c(!1),i({...p,...v}))},y=()=>{p&&(a(!0),c(!1),h(null),T.saveNotificationSettings(p).then(()=>{c(!0),i(null),t.reload()}).catch(v=>h(v instanceof oe?v.message:String(v))).finally(()=>a(!1)))};return s.jsxs(V,{gap:"lg",children:[s.jsx(k6,{timezone:e,onChange:t.reload}),s.jsx(K,{title:"Notifications",aside:"What buddi tells you when you are not looking at this page.",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:o||!p,onClick:y,children:"Save"}),children:s.jsxs(V,{divided:!0,children:[s.jsx(re,{message:t.error??u}),s.jsx(K,{title:"Where buddi reaches you",children:p?f.length===0?s.jsx("p",{className:"ui-card-meta",children:"No channel yet, so everything waits for you here. Pair Telegram and buddi can reach you on your phone."}):s.jsx(V,{gap:"sm",children:f.map(v=>{var m;return s.jsx(C6,{channel:v,checked:(p.defaultChannel??((m=f[0])==null?void 0:m.kind))===v.kind,onPick:()=>x({defaultChannel:v.kind})},v.kind)})}):s.jsx(ie,{children:"Loading…"})}),s.jsx(K,{title:"By kind",children:p?s.jsxs(V,{gap:"sm",children:[MT.map(v=>s.jsxs("div",{className:"pref-row nt-kind",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:zl[v].label}),s.jsx("span",{className:"ui-field-hint",children:zl[v].hint})]}),s.jsxs("select",{"aria-label":zl[v].label,value:E6(p,v,f),onChange:m=>{const j={...p.perKind};m.target.value==="default"?delete j[v]:j[v]=m.target.value,x({perKind:j})},children:[s.jsx("option",{value:"default",children:"Default"}),f.map(m=>s.jsx("option",{value:m.kind,children:m.label},m.kind)),X1.has(v)?null:s.jsx("option",{value:"off",children:"Off"})]})]},v)),s.jsx("p",{className:"ui-field-hint",children:"Off keeps it in the list below and never sends it."})]}):null}),s.jsx(K,{title:"Quiet hours",children:p?s.jsxs(V,{gap:"sm",children:[s.jsxs("div",{className:"nt-times",children:[s.jsx(X,{label:"From",children:s.jsx("input",{type:"time",value:p.quietStart??"",onChange:v=>x({quietStart:v.target.value||null})})}),s.jsx(X,{label:"Until",children:s.jsx("input",{type:"time",value:p.quietEnd??"",onChange:v=>x({quietEnd:v.target.value||null})})}),s.jsx(X,{label:"End of the day",children:s.jsx("input",{type:"time",value:p.endOfDay,onChange:v=>x({endOfDay:v.target.value})})})]}),s.jsxs("p",{className:"ui-field-hint",children:["Messages wait until quiet hours end. Approvals and questions still come through. At the end of the day, what could wait goes out as one message. Times are on your clock (",e,")."]})]}):null}),l?s.jsx(H,{tone:"good",role:"status",children:"Saved."}):null]})}),s.jsxs(K,{title:"The last twenty",panel:!0,flush:!0,children:[s.jsx(re,{message:n.error}),n.data?n.data.notifications.length===0?s.jsx(ie,{children:"Nothing yet. What buddi tells you will be listed here."}):s.jsx(Ut,{children:n.data.notifications.map(v=>s.jsx(Gt,{title:v.title,sub:`${De(v.createdAt,e)} · ${zl[v.kind].label.toLowerCase()} · ${A6(v,f)}`,side:s.jsx(R6,{row:v})},v.id))}):s.jsx(ie,{children:"Loading…"})]})]})}function k6({timezone:e,onChange:t}){var C,A;const n=ne(()=>T.telegramBot(),[]),r=ne(()=>T.telegramDevices(),[]),[i,o]=d.useState(!1),[a,l]=d.useState(""),[c,u]=d.useState(!1),[h,f]=d.useState(null),[p,x]=d.useState(null),y=d.useRef(new Set),w=q1(()=>T.telegramDevices().then(E=>E.devices.some(_=>!y.current.has(_.id))),()=>{r.reload(),t()}),b=((C=n.data)==null?void 0:C.configured)??!1,v=!b||i,m=()=>{var _;if(a.trim()===""||c)return;u(!0),f(null);const E=i&&(((_=n.data)==null?void 0:_.running)??!1);T.saveTelegramToken(a.trim()).then(L=>{l(""),o(!1),f(L.restartNeeded?{ok:!1,text:L.note??"Saved. It will be ready the next time buddi starts."}:E?{ok:!0,text:"Saved. The new bot takes over the next time buddi starts."}:{ok:!0,text:"Saved."}),n.reload(),t()}).catch(L=>f({ok:!1,text:L instanceof oe?L.message:String(L)})).finally(()=>u(!1))},j=()=>{var E;x(null),y.current=new Set((((E=r.data)==null?void 0:E.devices)??[]).map(_=>_.id)),w.ask().catch(_=>x(_ instanceof oe?_.message:String(_)))},{offer:g,square:S,paired:k,stale:N}=w;return s.jsx(K,{title:"Telegram",aside:"Talk to buddi from your phone.",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{title:"The bot",foot:v?s.jsxs(s.Fragment,{children:[i?s.jsx(P,{variant:"ghost",onClick:()=>{o(!1),l("")},children:"Cancel"}):null,s.jsx(P,{variant:"accent",disabled:c||a.trim()==="",onClick:m,children:"Save token"})]}):void 0,children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:n.error}),!n.data&&!n.error?s.jsx(ie,{children:"Loading…"}):b&&!i?s.jsxs("div",{className:"nt-channel",children:[s.jsx("span",{className:"pref-label",children:(A=n.data)!=null&&A.username?`Bot: @${n.data.username}`:"A bot token is saved."}),s.jsx(P,{variant:"ghost",size:"sm",onClick:()=>{o(!0),f(null)},children:"Replace token"})]}):null,v?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-card-meta",children:"Ask @BotFather for a bot and paste its token here."}),s.jsx(X,{label:"Bot token",grow:!0,children:s.jsx("input",{type:"password",value:a,autoComplete:"off",spellCheck:!1,onChange:E=>l(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),m())}})})]}):null,h?s.jsx(H,{tone:h.ok?"good":"warning",role:"status",children:h.text}):null]})}),s.jsxs(K,{title:"Your devices",children:[s.jsx(re,{message:r.error}),r.data?r.data.devices.length===0?s.jsx("p",{className:"ui-card-meta",children:"No phone is paired yet."}):s.jsx(Ut,{children:r.data.devices.map(E=>s.jsx(Gt,{title:E.name??`Telegram user ${E.userId}`,sub:`Paired ${De(E.pairedAt,e)} · ${E.lastSeenAt?`last spoke ${Ee(E.lastSeenAt)}`:"has not spoken yet"}`,side:s.jsx(S6,{id:E.id,onGone:()=>{r.reload(),t()}})},E.id))}):r.error?null:s.jsx(ie,{children:"Loading…"})]}),s.jsx(K,{title:"Pair a device",foot:b&&(!g||k)?s.jsx(P,{variant:g?void 0:"accent",onClick:j,children:"Pair a phone"}):b&&N?s.jsx(P,{variant:"accent",onClick:j,children:"New code"}):void 0,children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:p}),b?k?s.jsx(H,{tone:"good",role:"status",children:"Paired."}):g&&N?s.jsx("p",{className:"ui-card-meta",children:"That code has run out."}):g?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-card-meta",children:"Open this on your phone, then send /start to the bot."}),s.jsx(Q1,{offer:g,square:S,children:s.jsx(N6,{text:g.link})}),s.jsxs("p",{className:"ui-field-hint",children:["The code works until ",De(g.expiresAt,e),"."]})]}):s.jsx("p",{className:"ui-card-meta",children:"Pair another phone, or the first one if you skipped it."}):s.jsx("p",{className:"ui-card-meta",children:"Save a bot token first."})]})})]})})}function S6({id:e,onGone:t}){const[n,r]=d.useState(!1),[i,o]=d.useState(!1),[a,l]=d.useState(null);if(!n)return s.jsx(P,{size:"sm",onClick:()=>r(!0),children:"Unpair"});const c=()=>{o(!0),l(null),T.unpairTelegramDevice(e).then(t).catch(u=>l(u instanceof oe?u.message:String(u))).finally(()=>o(!1))};return s.jsxs("span",{className:"nt-channel",children:[s.jsx("span",{className:"ui-field-hint",role:a?"alert":void 0,children:a??"It will no longer reach your agents."}),s.jsx(P,{size:"sm",variant:"ghost",disabled:i,onClick:()=>r(!1),children:"Keep"}),s.jsx(P,{size:"sm",variant:"danger",disabled:i,onClick:c,children:"Unpair"})]})}function N6({text:e}){const[t,n]=d.useState(null),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("Select the link to copy it.");return}navigator.clipboard.writeText(e).then(()=>n("Copied."),()=>n("Select the link to copy it."))};return s.jsxs("span",{className:"nt-channel",children:[s.jsx(P,{size:"sm",onClick:r,children:"Copy"}),t?s.jsx("span",{className:"ui-field-hint",role:"status",children:t}):null]})}function C6({channel:e,checked:t,onPick:n}){const[r,i]=d.useState(!1),[o,a]=d.useState(null),l=()=>{i(!0),a(null),T.testChannel(e.kind).then(()=>a({ok:!0,text:"Sent. Check that it arrived."})).catch(c=>a({ok:!1,text:c instanceof oe?c.message:String(c)})).finally(()=>i(!1))};return s.jsxs("div",{className:"nt-channel",children:[s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"nt-default-channel",checked:t,onChange:n}),s.jsxs("span",{className:"nt-channel-text",children:[s.jsxs("span",{className:"pref-label",children:[e.label,e.where?`, ${e.where}`:""]}),s.jsxs("span",{className:"ui-field-hint",children:["The title and a few lines of each message go to ",e.label,"."]}),o?s.jsx("span",{className:"nt-channel-sent","data-tone":o.ok?void 0:"critical",role:"status",children:o.text}):null]})]}),s.jsx(P,{size:"sm",disabled:r,onClick:l,children:"Send a test"})]})}function E6(e,t,n){const r=e.perKind[t];return r==="off"?X1.has(t)?"default":"off":r&&n.some(i=>i.kind===r)?r:"default"}function A6(e,t){var n;return e.channel&&e.channel!=="dashboard"?((n=t.find(r=>r.kind===e.channel))==null?void 0:n.label)??e.channel:"dashboard"}function R6({row:e}){return e.state==="failed"?s.jsxs("span",{className:"nt-state","data-tone":"critical",children:["Failed: ",e.error??"no reason given"]}):e.actedAt?s.jsx("span",{className:"nt-state",children:"Acted on"}):e.seenAt?s.jsx("span",{className:"nt-state",children:"Seen"}):e.state==="held"?s.jsx("span",{className:"nt-state",children:"Waiting"}):e.state==="stored"?s.jsx("span",{className:"nt-state",children:"Kept"}):e.state==="sent"?s.jsx("span",{className:"nt-state",children:"Sent"}):s.jsx("span",{className:"nt-state",children:"Not seen"})}const T6={you:"person",appearance:"sun",notifications:"bell",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function P6(e){const t=CI.map(r=>({id:r.id,route:lt(r.id),label:r.label,icon:T6[r.id],group:r.group})),n=[...e].sort((r,i)=>r.title.localeCompare(i.title,void 0,{sensitivity:"base"})||r.plugin.localeCompare(i.plugin)||r.id.localeCompare(i.id)).map(r=>({id:mk(r.plugin,r.id),route:Um(r.plugin,r.id),label:r.title,icon:OS(r.icon),group:"plugins"}));return[...t,...n]}function J1(e){return NI.map(t=>({id:t.id,label:t.label,entries:e.filter(n=>n.group===t.id)})).filter(t=>t.entries.length>0)}function Z1(e,t,n){return t?`${e}, ${t} open`:n?`${e}, ${n}`:void 0}function I6({entries:e,active:t,counts:n={},dots:r={},navigate:i}){var u;const o=d.useRef(null),a=J1(e),l=e.some(h=>h.id===t)?t:(u=e[0])==null?void 0:u.id,c=h=>{var y;const f=[...((y=o.current)==null?void 0:y.querySelectorAll("a.settings-nav-link"))??[]],p=f.indexOf(document.activeElement);if(p===-1)return;const x=w=>{var b;h.preventDefault(),(b=f[Math.max(0,Math.min(f.length-1,w))])==null||b.focus()};if(h.key==="ArrowDown")x(p+1);else if(h.key==="ArrowUp")x(p-1);else if(h.key==="Home")x(0);else if(h.key==="End")x(f.length-1);else if(h.key==="Enter"||h.key===" "){h.preventDefault();const w=f[p].getAttribute("href");w&&i(w)}};return s.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:o,onKeyDown:c,children:a.map(h=>s.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${h.id}`,children:[s.jsx("div",{className:"settings-nav-label",id:`settings-nav-${h.id}`,children:h.label}),h.entries.map(f=>{const p=f.id===t,x=n[f.id],y=r[f.id];return s.jsxs("a",{className:"settings-nav-link",href:f.route,"data-active":p?"true":void 0,"aria-current":p?"page":void 0,"aria-label":Z1(f.label,x,y),tabIndex:f.id===l?0:-1,onClick:w=>{w.preventDefault(),i(f.route)},children:[s.jsx(Ae,{name:f.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:f.label}),x?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:x>99?"99+":x}):y?s.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","data-testid":"settings-nav-dot","aria-hidden":"true"}):null]},f.id)})]},h.id))})}function M6({entries:e,active:t,counts:n={},dots:r={},navigate:i}){const o=J1(e),a=e.find(l=>l.id===t)??e[0];return s.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:s.jsxs(Tm,{modal:!1,children:[s.jsx(Pm,{asChild:!0,children:s.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(a==null?void 0:a.label)??""}`,children:[a?s.jsx(Ae,{name:a.icon,className:"settings-nav-icon"}):null,s.jsx("span",{className:"settings-nav-text",children:a==null?void 0:a.label}),s.jsx(Ae,{name:"chevron-down",className:"settings-menu-chevron"})]})}),s.jsx(Im,{children:s.jsx(Mm,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:s.jsx(BP,{value:t,onValueChange:l=>{const c=e.find(u=>u.id===l);c&&i(c.route)},children:o.map((l,c)=>s.jsxs(UP,{children:[c>0?s.jsx(lc,{className:"ui-menu-sep"}):null,s.jsx($m,{className:"ui-menu-label",children:l.label}),l.entries.map(u=>{const h=n[u.id],f=r[u.id];return s.jsxs(zP,{value:u.id,className:"ui-menu-item settings-menu-item","data-active":u.id===t?"true":void 0,"aria-label":Z1(u.label,h,f),children:[s.jsxs("span",{className:"settings-menu-entry",children:[s.jsx(Ae,{name:u.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:u.label})]}),h?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:h>99?"99+":h}):f?s.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","aria-hidden":"true"}):null]},u.id)})]},l.id))})})})]})})}function $6({hash:e,timezone:t,navigate:n,agents:r,pluginPages:i}){var v,m;const o=EI(e),a=$S(i!==void 0),l=i??a,c=wI(e),u=c?l.find(c.plugin,c.page):void 0,h=Ia(pg),f=P6(l.settings),x={proposals:((m=(v=ne(()=>Promise.resolve().then(()=>T.proposals()),[],3e4).data)==null?void 0:v.open)==null?void 0:m.length)??0},y=ne(()=>T.version(),[]),w=y.data&&!y.data.checkout&&y.data.updateAvailable?{system:"a newer buddi is ready"}:{},b={entries:f,active:o,counts:x,dots:w,navigate:j=>n(j)};return s.jsxs("div",{className:"settings",children:[h?null:s.jsx(I6,{...b}),s.jsx("div",{className:"settings-body",children:s.jsxs("div",{className:"ui-page",children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Settings"}),s.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),h?s.jsx(M6,{...b}):null,u?s.jsx(OL,{page:u,navigate:n,timezone:t,siblings:l.all.filter(j=>j.plugin===u.plugin)}):null,o==="you"?s.jsx(o3,{embedded:!0}):null,o==="appearance"?s.jsx(_6,{}):null,o==="notifications"?s.jsx(b6,{timezone:t}):null,o==="memory"?s.jsx(qS,{embedded:!0,agents:r,timezone:t}):null,o==="proposals"?s.jsx(f3,{embedded:!0,plugin:kI(e)}):null,o==="accounts"?s.jsx(R4,{embedded:!0}):null,o==="computer"?s.jsx(HO,{embedded:!0,timezone:t}):null,o==="secrets"?s.jsx(X4,{embedded:!0,timezone:t}):null,o==="watchers"?s.jsx(r3,{timezone:t,embedded:!0}):null,o==="backup"?s.jsx(j4,{}):null,o==="plugins"?s.jsx(N3,{}):null,o==="system"?s.jsx(O6,{timezone:t}):null]})})]})}function _6(){const[e,t]=zS();return s.jsx(K,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:s.jsxs(V,{divided:!0,gap:"lg",children:[s.jsx(pf,{label:"Theme",hint:"System follows your Mac.",children:s.jsx(uc,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:e.theme,onChange:n=>t({theme:n})})}),s.jsx(pf,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:s.jsx(uc,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:e.ground,onChange:n=>t({ground:n})})}),s.jsx(pf,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:s.jsx(uc,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:e.width,onChange:n=>t({width:n})})})]})})}function pf({label:e,hint:t,children:n}){return s.jsxs("div",{className:"pref-row ui-section",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:e}),s.jsx("span",{className:"ui-field-hint",children:t})]}),n]})}function O6({timezone:e}){const t=ne(()=>T.overview(),[],15e3),n=ne(()=>T.session(),[]),r=ne(()=>T.providerAccounts(),[]),i=t.data;return s.jsxs(V,{gap:"lg",children:[s.jsx(re,{message:t.error}),s.jsx(Q6,{}),i?s.jsx(K,{title:"The queue",panel:!0,actions:s.jsx(P,{size:"sm",variant:i.paused?"accent":void 0,onClick:()=>{T.setPaused(!i.paused).then(()=>t.reload())},children:i.paused?"Resume the queue":"Pause the queue"}),children:s.jsxs("p",{className:"ui-card-meta",children:[i.paused?"Paused. Nothing is being claimed until you resume.":"Running. Jobs are claimed as they come due."," ",i.paused?s.jsx(ve,{tone:"warning",children:"paused"}):s.jsx(ve,{tone:"good",children:"running"})]})}):null,s.jsxs(K,{title:"This host",panel:!0,children:[s.jsx(Pt,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?De(i.now,e):"…"},{label:"Bound to",value:n.data?`${n.data.host}:${n.data.port}`:"…"},{label:"Credential vault",value:r.data?U6(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?s.jsx(H,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),s.jsx(F6,{}),s.jsx(D6,{}),s.jsx(K,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?s.jsx(ie,{children:"No sources are installed."}):s.jsx(Pt,{items:i.mail.map(o=>({key:o.sourceId,label:s.jsx("span",{className:"mono",children:o.sourceId}),value:o.lastError?s.jsx("span",{className:"critical",children:o.lastError}):s.jsxs("span",{children:["polled ",Ee(o.lastRunAt)]})}))}):s.jsx(ie,{children:"Loading…"})})]})}function D6(){var x;const e=ne(()=>T.tailscale(),[]),[t,n]=d.useState(null),[r,i]=d.useState(!1),[o,a]=d.useState(null),[l,c]=d.useState(!1),u=e.data,h=t??((u==null?void 0:u.login)||((x=u==null?void 0:u.self)==null?void 0:x.login)||""),f=(u==null?void 0:u.proxied)===!0,p=y=>{i(!0),a(null),c(!1),T.setTailscale({enabled:y,login:h.trim()}).then(()=>{c(!0)}).catch(w=>a(w instanceof oe?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return s.jsx(K,{title:"Sign in through Tailscale",panel:!0,foot:s.jsx(P,{variant:"accent",disabled:r||!u||f,onClick:()=>p((u==null?void 0:u.enabled)??!1),children:"Save"}),children:s.jsx(V,{divided:!0,children:s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:e.error??o}),s.jsx("p",{className:"ui-card-meta",children:u?u.available&&u.self?`Tailscale is running on this machine as ${u.self.login}.`:u.available?"Tailscale is running on this machine.":"Tailscale is not running here.":"…"}),f?s.jsxs(s.Fragment,{children:[s.jsx(H,{tone:"warning",children:"Change this from the computer buddi runs on."}),s.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${h}`:"Off"})]}):null,s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||f,onChange:y=>p(y.target.checked)}),s.jsx("span",{children:"Let this Tailscale login sign in"})]}),s.jsx(X,{label:"Tailscale login",children:s.jsx("input",{type:"text",value:h,placeholder:"you@example.com",disabled:r||!u||f,onChange:y=>n(y.target.value)})}),s.jsx("p",{className:"ui-card-meta",children:"Anyone signed in to Tailscale as this login, on any device in your tailnet, is signed in to buddi. The proxy must run on this machine:"}),s.jsxs("div",{className:"tailscale-command",children:[s.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),s.jsx(P,{size:"sm",disabled:r||!u,onClick:()=>{L6((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),s.jsx("p",{className:"ui-card-meta",children:"This gives your tailnet the trust this machine already has: buddi cannot tell the Tailscale proxy from another program running here, and any program that can reach the dashboard on this machine can already read buddi’s files."}),l?s.jsx(H,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function L6(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function F6(){var u;const e=ne(()=>T.service(),[],1e4),[t,n]=d.useState(null),[r,i]=d.useState(!1),[o,a]=d.useState(null),l=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!l)return null;const c=h=>{i(!0),a(null),T.serviceAction(h).then(()=>{n(null)}).catch(f=>{a(f.message)}).finally(()=>{i(!1),e.reload()})};return s.jsx(K,{title:"Service",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsx(Pt,{items:[{label:"Database",value:s.jsx(Yy,{state:l.database,pid:l.databasePid})},{label:"Gateway",value:s.jsx(Yy,{state:l.gateway,pid:l.gatewayPid})},{label:"Supervisor",value:s.jsxs("span",{className:"mono",children:["pid ",l.supervisorPid]})}]})}),s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:o}),t?s.jsx(H,{tone:"warning",role:"alert",children:t==="stop"?"Stopping the gateway closes this dashboard. The database keeps running; run buddi in a terminal to bring the dashboard back.":"Restarting the gateway closes this dashboard for a few seconds. If it does not come back on its own, run buddi in a terminal."}):s.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),s.jsx(q,{align:"end",children:t?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",disabled:r,onClick:()=>{n(null),a(null)},children:"Cancel"}),s.jsx(P,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>{n("stop")},children:"Stop gateway"}),s.jsx(P,{variant:"accent",onClick:()=>{n("restart")},children:"Restart gateway"})]})})]})})]})})}function Yy({state:e,pid:t}){return s.jsxs("span",{children:[s.jsx(ve,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?s.jsx("span",{className:"ui-card-meta",children:"no process"}):s.jsxs("span",{className:"mono",children:["pid ",t]})]})}function U6(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const B6=2e3,qy={starting:"Getting started.",backup:"Taking a backup first, so there is a way back.",stopping:"Stopping the gateway. The database stays up.",installing:"Installing the new version.",restarting:"Restarting buddi on the new version.",migrating:"Bringing the database up to date.",done:"Done.",failed:"That did not work."},z6=new Set(["done","failed","rolled-back"]),W6="The check asks the npm registry for the newest version and sends nothing else.",H6="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",V6="A checkout upgrades with git pull, then buddi upgrade in a terminal.",K6=10*6e4,G6="buddi did not come back. Run buddi doctor in a terminal.";function Y6(e){const t=e.step==="starting"?"while starting":`at ${e.step??"an unknown step"}`;return`The upgrade to ${e.to} failed ${t}: ${e.error??"no reason given"}. The backup taken first is ${e.backup??"not available"}. Run buddi doctor in a terminal; it prints the way back.`}function q6(e,t,n,r){const[i,o]=d.useState(void 0),[a,l]=d.useState(!1),[c,u]=d.useState(null),h=d.useRef(!1),f=d.useRef(n),p=d.useRef(r);return f.current=n,p.current=r,d.useEffect(()=>{if(!e){o(void 0),l(!1),h.current=!1;return}let x=!1,y=0;const w=()=>{h.current=!0,y=Date.now()+K6,l(!0)},b=()=>{if(Date.now()<y){T.session().then(j=>{x||j.version!==void 0&&j.version===t||(x=!0,f.current())}).catch(()=>{}),T.version().then(j=>{const g=j.history[j.history.length-1];x||(g==null?void 0:g.outcome)!=="failed"||(x=!0,l(!1),u(Y6(g)))}).catch(()=>{});return}x=!0,l(!1),u(G6)},v=()=>{if(!x){if(h.current)return b();T.upgradeJob(e).then(j=>{var g;x||(o(j),u(null),(z6.has(j.phase)||j.finishedAt)&&(x=!0,j.phase==="failed"&&((g=p.current)==null||g.call(p,j))))}).catch(j=>{x||(j instanceof oe&&j.status!==0&&j.status<500?u(j.message):w())})}};v();const m=window.setInterval(v,B6);return()=>{x=!0,window.clearInterval(m)}},[e,t]),{job:i,away:a,error:c}}function Q6({reload:e}){var g;const t=ne(()=>T.version(),[]),[n,r]=d.useState(null),[i,o]=d.useState(!1),[a,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),p=(g=t.data)==null?void 0:g.current,x=e??(()=>window.location.reload()),y=d.useCallback(S=>{r(null),f(S)},[]),w=q6(n,p,x,y),b=t.data,v=()=>{l(!0),u(null),T.checkVersion().catch(S=>u(S instanceof oe?S.message:String(S))).finally(()=>{l(!1),t.reload()})},m=S=>{l(!0),u(null),T.setVersionCheck(S).catch(k=>u(k instanceof oe?k.message:String(k))).finally(()=>{l(!1),t.reload()})},j=()=>{l(!0),u(null),f(null),T.startUpgrade(b==null?void 0:b.latest).then(S=>{var k;o(!1),r(((k=S.job)==null?void 0:k.id)??null)}).catch(S=>u(S instanceof oe?S.message:String(S))).finally(()=>l(!1))};return b!=null&&b.checkout?s.jsx(K,{title:"Version",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsx(Pt,{items:[{label:"Running",value:s.jsx("span",{className:"mono",children:b.current})}]})}),s.jsx(K,{children:s.jsx("p",{className:"ui-card-meta",children:V6})})]})}):s.jsx(K,{title:"Version",panel:!0,children:s.jsxs(V,{divided:!0,children:[s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(re,{message:t.error??c}),s.jsx(Pt,{items:[{label:"Running",value:b?s.jsx("span",{className:"mono",children:b.current}):"…"},{label:"Newest",value:b?b.updateAvailable&&b.latest?s.jsxs("span",{children:["A newer buddi is available: ",s.jsx("span",{className:"mono",children:b.latest})]}):b.checkedAt?s.jsxs("span",{children:["This is the latest, as of ",Ee(b.checkedAt),"."]}):s.jsx("span",{children:"Not checked yet."}):"…"}]}),b!=null&&b.error?s.jsxs(H,{tone:"warning",children:["The last check did not get an answer: ",b.error]}):null,s.jsx(q,{align:"end",children:s.jsx(P,{disabled:a,onClick:v,children:"Check now"})})]})}),s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(b==null?void 0:b.checkEnabled)??!1,disabled:a||!b,onChange:S=>m(S.target.checked)}),s.jsx("span",{children:"Check once a day"})]}),s.jsx("p",{className:"ui-card-meta",children:W6})]})}),b!=null&&b.updateAvailable&&b.latest&&b.latestNotes?s.jsx(K,{title:`What changes in ${b.latest}`,children:s.jsx(vr,{text:b.latestNotes})}):null,s.jsx(K,{children:s.jsxs(V,{gap:"sm",children:[s.jsx(X6,{...w,job:w.job??h??void 0}),i?s.jsx(H,{tone:"warning",role:"alert",children:H6}):null,s.jsx(q,{align:"end",children:i?s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",disabled:a,onClick:()=>o(!1),children:"Cancel"}),s.jsxs(P,{variant:"accent",disabled:a,onClick:j,children:["Upgrade to ",b==null?void 0:b.latest]})]}):s.jsx(P,{variant:"accent",disabled:a||n!==null||!(b!=null&&b.updateAvailable),onClick:()=>o(!0),children:b!=null&&b.updateAvailable&&b.latest?`Upgrade to ${b.latest}`:"Upgrade"})})]})}),b&&b.history.length>0?s.jsx(K,{title:"Upgrades so far",children:s.jsx(Pt,{items:b.history.slice().reverse().map(S=>({key:S.startedAt,label:s.jsxs("span",{className:"mono",children:[S.from," → ",S.to]}),value:s.jsx(J6,{attempt:S})}))})}):null]})})}function X6({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.jsx(H,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="failed"?s.jsxs(H,{tone:"critical",role:"alert",children:[qy.failed," ",e.error??""," buddi is still running on the version it had."]}):s.jsx(H,{tone:e.phase==="done"?"good":void 0,role:"status",children:qy[e.phase]??e.detail??e.phase}):null}function J6({attempt:e}){return s.jsxs("span",{children:[s.jsx(ve,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",Ee(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?s.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",s.jsx("span",{className:"mono",children:e.backup})]}):null]})}const up=["name","clock","brain","browser","assistant","handover"],eN={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function Z6(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function eU(e){var o,a,l;const t=Z6(e.accounts),n=e.assistant?(((o=e.accounts)==null?void 0:o.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(n==null?void 0:n.accountId)??((l=(a=e.onboarding)==null?void 0:a.details)==null?void 0:l.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(n==null?void 0:n.model)??i.defaultModel}}function tN(e){var r,i,o;const t=eU(e),n=e.onboarding&&!e.onboarding.needs.agent?e.assistant:void 0;return{...(r=e.owner)!=null&&r.preferredName?{name:e.owner.preferredName}:{},...(i=e.owner)!=null&&i.timezone?{clock:e.owner.timezone}:{},...t?{brain:t}:{},...(o=e.onboarding)!=null&&o.stepsDone.includes("browser")||n?{browser:e.browser??"other"}:{},...n?{assistant:n}:{}}}function tU(e,t){return t==="name"?typeof e.name=="string"&&e.name!=="":t==="clock"?typeof e.clock=="string"&&e.clock!=="":t==="brain"?e.brain!==void 0:t==="browser"?e.browser!==void 0:t==="assistant"?e.assistant!==void 0:!1}function dp(e){return up.find(t=>!tU(e,t))??"handover"}function nU(e,t){const n=up.indexOf(t);return up.filter((r,i)=>i<n||r===t)}function sU(e,t){const n={...e};return delete n[t],n}const fp="buddi.firstRun.restore";function mf(e){try{e===null?window.sessionStorage.removeItem(fp):window.sessionStorage.setItem(fp,e)}catch{}}function nN(){try{return window.sessionStorage.getItem(fp)}catch{return null}}function rU(e){const t=tN(e),n=dp(t);return{answers:t,open:n,stay:n!=="handover"}}function iU(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function oU(e){const t=e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,20).replace(/-+$/,"");return t===""?"assistant":t}const aU=550,lU=6e4,cU=5*6e4,sN=1500,uU=3e3;function jo(){const e=d.useRef(null);return d.useEffect(()=>{let t=0,n=0;const r=a=>{const l=a.ownerDocument.activeElement;return l===null||l===a.ownerDocument.body||l===a.ownerDocument.documentElement},i=()=>{const a=e.current;a&&r(a)&&a.focus()},o=()=>{i(),n=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(o):o(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(n),window.removeEventListener("focus",i)}},[]),e}function rN(){const[e,t]=d.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}});return d.useEffect(()=>{var i;let n;try{n=window.matchMedia("(prefers-reduced-motion: reduce)")}catch{return}const r=o=>t(o.matches);return(i=n.addEventListener)==null||i.call(n,"change",r),()=>{var o;return(o=n.removeEventListener)==null?void 0:o.call(n,"change",r)}},[]),e}function Me({children:e,at:t=0}){const n=rN(),[r,i]=d.useState(n||t===0);return d.useEffect(()=>{if(n){i(!0);return}const o=window.setTimeout(()=>i(!0),aU*t);return()=>window.clearTimeout(o)},[n,t]),r?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:e})}):s.jsx(Gn,{})}function Gn({line:e}){return s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[e,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})})}function Re({children:e}){return s.jsxs("div",{className:"meet-turn",children:[s.jsxs("div",{className:"wb-msg-who",children:[s.jsx("img",{className:"meet-turn-mark",src:Ka("core"),alt:"","aria-hidden":"true"}),s.jsx("span",{children:"buddi"})]}),e]})}const iN=d.createContext({body:null,actions:null});function oN({children:e,actions:t}){const n=d.useContext(iN),r=e==null?null:n.body?Qi.createPortal(e,n.body):e,i=t==null?null:n.actions?Qi.createPortal(t,n.actions):t;return s.jsxs(s.Fragment,{children:[r,i]})}function Wl({text:e,onChange:t}){return s.jsxs("div",{className:"wb-msg","data-role":"user",children:[s.jsx("div",{className:"wb-bubble",children:e}),s.jsx("button",{type:"button",className:"meet-change",onClick:t,children:F.change})]})}function ht({children:e,actions:t}){return s.jsx(oN,{actions:t?s.jsx("span",{className:"meet-actions",children:t}):null,children:e?s.jsx("div",{className:"meet-ask",children:e}):null})}function ii({onClick:e,disabled:t}){return s.jsxs(P,{variant:"ghost",onClick:e,disabled:t,children:[s.jsx(Ae,{name:"chevron-left"}),F.brain.back]})}function dU({navigate:e,timezone:t}){var te;const[n,r]=d.useState(void 0);d.useEffect(()=>{T.session().then(se=>r(se.platform)).catch(()=>{})},[]);const[i,o]=d.useState({}),[a,l]=d.useState(null),[c,u]=d.useState(void 0),[h,f]=d.useState(void 0),[p,x]=d.useState([]),[y,w]=d.useState(null),[b,v]=d.useState(null),[m,j]=d.useState(!1),[g,S]=d.useState(null),[k,N]=d.useState(null),[C,A]=d.useState(null),[E,_]=d.useState(null),L=d.useMemo(()=>({body:C,actions:E}),[C,E]),[B,R]=d.useState(null),[O,Y]=d.useState(!1),G=d.useCallback(()=>Y(!0),[]),[M,W]=d.useState(()=>nN()?"running":"idle"),$=d.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),ee=d.useRef(e);ee.current=e;const ce=d.useCallback(async(se=!0,we=!1)=>{var Gs,Xn,ws,bs,oi,hn,Cn,ks;const[be,We,fe,D,de,Ke]=await Promise.all([T.onboarding().catch(()=>{}),T.owner().catch(()=>{}),T.providerAccounts().catch(()=>{}),_e.agents().catch(()=>{}),T.browser().catch(()=>{}),T.providers().catch(()=>{})]);u(fe);const nt=(Xn=(Gs=Ke==null?void 0:Ke.providers.find(Le=>Le.kind==="anthropic"))==null?void 0:Gs.defaultModel)==null?void 0:Xn.trim();f(nt||void 0),x((We==null?void 0:We.zones)??[]),S(((ws=be==null?void 0:be.details)==null?void 0:ws.conversationId)??null);const $e=(D==null?void 0:D.agents.find(Le=>Le.id===D.defaultAgentId))??(D==null?void 0:D.agents[0]);$e&&w($e),N(be&&!be.needs.agent&&$e?{id:$e.id,name:$e.name,avatar:((bs=$e.avatar)==null?void 0:bs.kind)==="emoji"?$e.avatar.value:"",description:$e.description,...$e.picture?{picture:$e.picture}:{}}:null);const Sn={onboarding:be,owner:We,accounts:fe,browser:(oi=de==null?void 0:de.browser)==null?void 0:oi.engine,...$e?{assistant:{id:$e.id,name:$e.name,avatar:((hn=$e.avatar)==null?void 0:hn.kind)==="emoji"?$e.avatar.value:""}}:{}},Nn=tN(Sn);if(we){const Le=rU(Sn);if(o(Le.answers),l(Le.open),!Le.stay){const Jn=(Cn=be==null?void 0:be.details)==null?void 0:Cn.conversationId;ee.current(Jn&&$e?Ue($e.id,Jn):Ft,!0)}return}if(se&&(be==null?void 0:be.state)==="done"){const Le=(ks=be.details)==null?void 0:ks.conversationId;ee.current(Le&&$e?Ue($e.id,Le):Ft,!0);return}se&&(o(Nn),l(Le=>Le??dp(Nn)))},[]);d.useEffect(()=>{ce()},[ce]);const Ce=(se,we={})=>{T.onboardingStep(eN[se],we).catch(()=>{})},J=(se,we)=>{v(null),o(we),Ce(se,se==="brain"&&we.brain?{accountId:we.brain.accountId}:{}),l(dp(we))},ge=se=>{v(null),o(we=>sU(we,se)),l(se)},xe=()=>{j(!0),T.skipOnboarding().then(()=>e(Ft)).catch(se=>v(se instanceof oe?se.message:String(se))).finally(()=>j(!1))},je=M==="form"||M==="running"?[]:a?nU(i,a):[],Pe=ne(()=>T.version().catch(()=>({current:""})),[]),ze=d.useRef(null);return d.useEffect(()=>{const se=ze.current;if(!se)return;const we=()=>{se.scrollTop=se.scrollHeight};we();let be;try{be=new ResizeObserver(we),se.firstElementChild&&be.observe(se.firstElementChild)}catch{}return()=>be==null?void 0:be.disconnect()},[je.length,a,i,b]),s.jsx(iN.Provider,{value:L,children:s.jsx("div",{className:"meet",children:s.jsxs("div",{className:"meet-stack",children:[s.jsxs("header",{className:"meet-head",children:[s.jsx("img",{className:"meet-head-mascot",src:Ka("core"),alt:"","aria-hidden":"true"}),s.jsxs("span",{className:"meet-head-who",children:[s.jsx("span",{className:"meet-head-name",children:"buddi"}),s.jsx("span",{className:"meet-head-line",children:n===void 0||n==="darwin"?F.tagline:F.taglineElsewhere}),(te=Pe.data)!=null&&te.current?s.jsxs("span",{className:"meet-head-version mono",children:["buddi ",Pe.data.current]}):null]})]}),s.jsxs("div",{className:"meet-board",children:[s.jsx("div",{className:"meet-scroll thin-scroll",ref:ze,children:s.jsxs("div",{className:"meet-thread","data-testid":"meet-thread",children:[s.jsx(Re,{children:F.opening.map((se,we)=>s.jsx(Me,{at:we,children:se},se))}),s.jsx(fU,{state:M,offered:a==="name"&&i.name===void 0,name:i.name,onState:W,onDone:()=>{W("idle"),ce(!0,!0)},onTrouble:v}),je.map(se=>s.jsx(hU,{id:se,openNow:a===se,answers:i,accounts:c,claudeModel:h,zones:p,browserZone:$,assistantAgent:y,met:g,onMet:S,existing:k,navigate:e,onCarriesOn:R,onClosed:G,onSettled:we=>J(se,we),onChange:()=>ge(se),onTrouble:v,onReload:()=>void ce(!1),onPickAnotherBrain:()=>ge("brain")},se)),b?s.jsx(Re,{children:s.jsx(Me,{children:b})}):null]})}),s.jsxs("footer",{className:"meet-dock",children:[s.jsx("div",{className:"meet-dock-ask",ref:A}),s.jsxs("div",{className:"meet-dock-row",children:[O?s.jsx("span",{}):B?s.jsx("a",{className:"meet-later",href:B,onClick:se=>{se.preventDefault(),e(B,!0)},children:F.done.open}):s.jsx("button",{className:"meet-later",type:"button",disabled:m,onClick:xe,children:F.later}),s.jsx("div",{className:"meet-dock-actions",ref:_})]})]})]})]})})})}function fU({state:e,offered:t,name:n,onState:r,onDone:i,onTrouble:o}){const[a,l]=d.useState(()=>nN()),[c,u]=d.useState([]),[h,f]=d.useState(!1),[p,x]=d.useState(null),[y,w]=d.useState(""),[b,v]=d.useState(!1);d.useEffect(()=>{if(!a)return;let g=!1;const S=()=>{T.backupJob(a).then(N=>{g||(u(C=>C.includes(N.phase)?C:[...C,N.phase]),N.phase==="done"?(g=!0,mf(null),f(!0),i()):(N.phase==="rolled-back"||N.phase==="failed")&&(g=!0,mf(null),l(null),o(N.error??F.restore.phases[N.phase]),r("idle")))}).catch(()=>{})};S();const k=window.setInterval(S,sN);return()=>{g=!0,window.clearInterval(k)}},[a]);const m=()=>{!p||b||(v(!0),o(null),T.firstRunRestore(p,y.trim()).then(g=>{mf(g.job.id),l(g.job.id),r("running")}).catch(g=>o(g instanceof oe?g.message:String(g))).finally(()=>v(!1)))},j=c.filter(g=>g in F.restore.phases);return s.jsxs(s.Fragment,{children:[t&&e==="idle"&&!h?s.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:F.restore.offer}):null,e==="form"?s.jsxs(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>r("idle"),children:F.restore.cancel}),s.jsx(P,{variant:"accent",disabled:b||!p,onClick:m,children:F.restore.submit})]}),children:[s.jsx(X,{label:F.restore.file,grow:!0,children:s.jsx("input",{type:"file",onChange:g=>{var S;return x(((S=g.target.files)==null?void 0:S[0])??null)}})}),s.jsx(X,{label:F.restore.passphrase,hint:F.restore.passphraseHint,children:s.jsx("input",{type:"password",autoComplete:"off",value:y,onChange:g=>w(g.target.value)})})]}):null,e==="running"||h?s.jsxs(Re,{children:[s.jsx(Me,{children:F.restore.started}),j.map(g=>s.jsx(Me,{children:F.restore.phases[g]},g))]}):null,h?s.jsxs(Re,{children:[n?s.jsx(Me,{children:F.restore.welcome(n)}):null,s.jsx(Me,{children:F.restore.keys})]}):null]})}function hU(e){var o,a,l,c;const{id:t,openNow:n,answers:r,onChange:i}=e;if(t==="name")return s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{at:1,children:F.name.ask})}),n?s.jsx(pU,{...e}):s.jsx(Wl,{text:r.name??"",onChange:i})]});if(t==="clock")return s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{at:1,children:F.clock.ask(r.name??"",r.clock??e.browserZone)})}),n?s.jsx(mU,{...e}):s.jsx(Wl,{text:F.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{at:1,children:F.brain.ask})}),n?s.jsx(gU,{...e}):s.jsxs(s.Fragment,{children:[s.jsx(Wl,{text:F.brain.answer(((o=r.brain)==null?void 0:o.label)??""),onChange:i}),s.jsxs(Re,{children:[s.jsx(Me,{children:F.brain.works(((a=r.brain)==null?void 0:a.model)??"")}),s.jsx(RU,{...e})]})]})]});if(t==="browser"){if(n)return s.jsx(OU,{...e});const u=_U(r.browser);return u?s.jsx(Re,{children:s.jsx(Me,{children:u})}):null}return t==="assistant"?s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{at:1,children:F.assistant.ask})}),n?s.jsx(LU,{...e}):s.jsx(Wl,{text:`${((l=r.assistant)==null?void 0:l.avatar)??""} ${((c=r.assistant)==null?void 0:c.name)??""}`.trim(),onChange:i})]}):s.jsx(FU,{...e})}function pU({answers:e,onSettled:t,onTrouble:n}){const r=jo(),[i,o]=d.useState(e.name??""),[a,l]=d.useState(!1),c=()=>{const u=i.trim();u===""||a||(l(!0),T.setOwner({preferredName:u}).then(()=>t({...e,name:u})).catch(h=>n(h instanceof oe?h.message:String(h))).finally(()=>l(!1)))};return s.jsx(ht,{actions:s.jsx(P,{variant:"accent",disabled:a||i.trim()==="",onClick:c,children:F.name.submit}),children:s.jsx("input",{ref:r,className:"meet-input","aria-label":F.name.placeholder,placeholder:F.name.placeholder,maxLength:80,value:i,onChange:u=>o(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function mU({answers:e,zones:t,browserZone:n,onSettled:r,onTrouble:i}){const[o,a]=d.useState(!1),[l,c]=d.useState(n),[u,h]=d.useState(!1),f=p=>{h(!0),T.setOwner({timezone:p}).then(()=>r({...e,clock:p})).catch(x=>i(x instanceof oe?x.message:String(x))).finally(()=>h(!1))};return o?s.jsx(ht,{actions:s.jsx(P,{variant:"accent",disabled:u,onClick:()=>f(l),children:F.clock.yes}),children:s.jsx("select",{className:"meet-input","aria-label":F.clock.label,value:l,onChange:p=>c(p.target.value),children:(t.includes(l)?t:[l,...t]).map(p=>s.jsx("option",{value:p,children:p},p))})}):s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>a(!0),children:F.clock.another}),s.jsx(P,{variant:"accent",disabled:u,onClick:()=>f(n),children:F.clock.yes})]})})}function gU(e){const{accounts:t,answers:n,onSettled:r,onReload:i}=e,[o,a]=d.useState(null),[l,c]=d.useState(null),[u,h]=d.useState(!1),[f,p]=d.useState(null),[x,y]=d.useState(null),w=(t==null?void 0:t.anthropicOAuthEnabled)===!0,b=(t==null?void 0:t.codexEnabled)===!0,v=t==null?void 0:t.gemini,[m,j]=d.useState(null);d.useEffect(()=>{let N=!1;const C=()=>{T.ollama().then(E=>{N||p(E)}).catch(()=>{})};C();const A=window.setInterval(C,4e3);return()=>{N=!0,window.clearInterval(A)}},[]);const g=async N=>{if(n.assistant)try{await T.bindBrain({accountId:N.accountId,model:N.model})}catch(A){return A instanceof oe?A.message:String(A)}return i(),r({...n,brain:N}),null},S=async(N,C)=>{h(!0),c(null);try{const A=await T.saveProviderAccount(N),E=await T.testProviderAccount(A.id);if(E.state!=="connected"){try{const L=(await T.providerAccounts()).accounts.find(B=>B.id===A.id);L&&await T.removeProviderAccount(A.id,L.revision)}catch{}c(E.message);return}const _=await g({accountId:A.id,label:C,model:N.defaultModel});_&&c(_)}catch(A){c(A instanceof oe?A.message:String(A))}finally{h(!1)}},k=(N,C,A)=>{if(N.length<=1){S(C(N[0]??""),A);return}y({models:N,make:C,label:A})};return x?s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{children:F.brain.model.ask})}),u?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.service})}):l?s.jsx(Re,{children:s.jsx(Me,{children:l})}):null,s.jsx(bU,{busy:u,models:x.models,onUse:N=>void S(x.make(N),x.label)})]}):o==="gemini"&&v?s.jsx(SU,{busy:u,problem:l,preset:v,onBack:()=>a(null),onUse:S}):o==="key"?s.jsx(kU,{busy:u,problem:l,onBack:()=>a(null),onUse:S}):o==="service"?s.jsx(CU,{busy:u,problem:l,address:(f==null?void 0:f.cloudBaseUrl)??"",onBack:()=>a(null),onOffer:k}):o==="ollama"?s.jsx(NU,{busy:u,problem:l,probe:f,onBack:()=>a(null),onOffer:k}):o==="cloud"?s.jsx(AU,{busy:u,consent:m,onBack:()=>{m==null||m.close(),j(null),a(null)},onConnected:g,...e}):o==="chatgpt"?s.jsx(PU,{busy:u,consent:m,onBack:()=>{m==null||m.close(),j(null),a(null)},onConnected:g,...e}):o==="claude"?s.jsx(MU,{busy:u,problem:l,onBack:()=>a(null),onConnected:g,...e}):s.jsx(oN,{children:s.jsxs("div",{className:"meet-cards",role:"group","aria-label":F.brain.ask,children:[w?s.jsx(Tr,{mark:s.jsx(xU,{}),card:F.brain.cards.claude,onPick:()=>a("claude")}):null,b?s.jsx(Tr,{mark:s.jsx(vU,{}),card:F.brain.cards.chatgpt,onPick:()=>{j(typeof window.open=="function"?window.open("","_blank"):null),a("chatgpt")}}):null,v?s.jsx(Tr,{mark:s.jsx(wU,{}),card:F.brain.cards.gemini,onPick:()=>a("gemini")}):null,s.jsx(Tr,{mark:s.jsx(yU,{}),card:F.brain.cards.key,onPick:()=>a("key")}),s.jsx(Tr,{mark:s.jsx(jU,{}),card:F.brain.cards.ollama,note:f===null?F.brain.ollama.looking:f.running?F.brain.ollama.found:F.brain.ollama.missing,onPick:()=>a("ollama")}),s.jsx(Tr,{mark:s.jsx(Qy,{}),card:F.brain.cards.cloud,onPick:()=>{j(typeof window.open=="function"?window.open("","_blank"):null),a("cloud")}}),s.jsx(Tr,{mark:s.jsx(Qy,{}),card:F.brain.cards.service,onPick:()=>a("service")})]})})}function Tr({mark:e,card:t,note:n,onPick:r}){return s.jsxs("button",{type:"button",className:"meet-card",onClick:r,children:[s.jsx("span",{className:"meet-card-mark","aria-hidden":"true",children:e}),s.jsxs("span",{className:"meet-card-words",children:[s.jsx("span",{className:"meet-card-title",children:t.title}),s.jsx("span",{className:"meet-card-line",children:n??t.line}),t.know?s.jsx("span",{className:"meet-card-know",children:t.know}):null]})]})}function xU(){const e=[0,45,90,135,180,225,270,315];return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",children:e.map(t=>s.jsx("rect",{x:"11.1",y:"2.6",width:"1.8",height:"8.6",rx:"0.9",fill:"currentColor",transform:`rotate(${t} 12 12)`},t))})}function vU(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M5.4 4.6h13.2a2 2 0 0 1 2 2v8.2a2 2 0 0 1-2 2h-7.4l-4.4 3.4v-3.4H5.4a2 2 0 0 1-2-2V6.6a2 2 0 0 1 2-2Z"}),s.jsx("path",{d:"M8 9.4h8"}),s.jsx("path",{d:"M8 12.6h5"})]})}function yU(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"8",cy:"8",r:"3.6"}),s.jsx("path",{d:"M10.6 10.6 19.4 19.4"}),s.jsx("path",{d:"M13.8 13.8 11.9 15.7"}),s.jsx("path",{d:"M16.6 16.6 14.7 18.5"})]})}function jU(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3.2",y:"4.6",width:"17.6",height:"11.2",rx:"2"}),s.jsx("path",{d:"M9.4 19.4h5.2"}),s.jsx("path",{d:"M12 15.8v3.6"})]})}function wU(){return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 3c.6 4.6 3.9 8.4 9 9-5.1.6-8.4 4.4-9 9-.6-4.6-3.9-8.4-9-9 5.1-.6 8.4-4.4 9-9Z"})})}function Qy(){return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7.2 18.3h9.6a3.8 3.8 0 0 0 .5-7.6 5.4 5.4 0 0 0-10.3-1.2 3.9 3.9 0 0 0 .2 8.8Z"})})}function bU({busy:e,models:t,onUse:n}){const[r,i]=d.useState(t[0]??"");return s.jsx(ht,{actions:s.jsx(P,{variant:"accent",disabled:e||r==="",onClick:()=>n(r),children:F.brain.model.submit}),children:s.jsx(X,{label:F.brain.model.label,grow:!0,children:s.jsx("select",{value:r,onChange:o=>i(o.target.value),children:t.map(o=>s.jsx("option",{value:o,children:o},o))})})})}function kU({busy:e,problem:t,onBack:n,onUse:r}){const i=jo(),[o,a]=d.useState(""),[l,c]=d.useState(null),[u,h]=d.useState(!1),f=e||u,p=l??iU(o),x=()=>{const y=o.trim();y===""||f||(h(!0),(async()=>{var b;let w=p==="anthropic"?"claude-sonnet-5":"gpt-5";try{w=((b=(await T.probeModels({kind:p,auth:"api-key",secret:y})).models.find(m=>m.isDefault))==null?void 0:b.id)??w}catch{}h(!1),await r({label:p==="anthropic"?F.brain.key.anthropic:F.brain.key.openai,kind:p,auth:"api-key",baseUrl:"",defaultModel:w,enabled:!0,secret:y},p==="anthropic"?F.brain.key.anthropic:F.brain.key.openai)})())};return s.jsxs(s.Fragment,{children:[f?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.key})}):t?s.jsx(Re,{children:s.jsx(Me,{children:F.brain.key.refused})}):null,s.jsxs(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ii,{onClick:n,disabled:f}),s.jsx(P,{variant:"accent",disabled:f||o.trim()==="",onClick:x,children:F.brain.key.submit})]}),children:[s.jsx(X,{label:F.brain.key.field,grow:!0,children:s.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:F.brain.key.placeholder,value:o,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),x())}})}),s.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(p==="anthropic"?"openai":"anthropic"),children:[p==="anthropic"?F.brain.key.anthropic:F.brain.key.openai," · ",F.brain.key.which]})]})]})}function SU({busy:e,problem:t,preset:n,onBack:r,onUse:i}){const o=jo(),[a,l]=d.useState(""),[c,u]=d.useState(!1),h=e||c,f=()=>{const p=a.trim();p===""||h||(u(!0),(async()=>{let x=c1;try{const y=await T.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:n.baseUrl,secret:p});x=u1(y.models.map(w=>w.id))??x}catch{}u(!1),await i({label:F.brain.gemini.label,kind:"openai-compatible",auth:"api-key",baseUrl:n.baseUrl,defaultModel:x,enabled:!0,secret:p},F.brain.gemini.label)})())};return s.jsxs(s.Fragment,{children:[h?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.gemini})}):t?s.jsx(Re,{children:s.jsx(Me,{children:t})}):null,s.jsxs(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ii,{onClick:r,disabled:h}),s.jsx(P,{variant:"accent",disabled:h||a.trim()==="",onClick:f,children:F.brain.gemini.submit})]}),children:[s.jsx(X,{label:F.brain.gemini.field,grow:!0,children:s.jsx("input",{ref:o,type:"password",autoComplete:"off",spellCheck:!1,placeholder:F.brain.gemini.placeholder,value:a,onChange:p=>l(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),f())}})}),s.jsx("a",{className:"meet-quiet",href:n.keyUrl,target:"_blank",rel:"noreferrer",children:F.brain.gemini.get})]})]})}function NU({busy:e,problem:t,probe:n,onBack:r,onOffer:i}){const o=(n==null?void 0:n.models)??[],a=()=>{n&&i(o,l=>({label:F.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:n.baseUrl,defaultModel:l,enabled:!0}),F.brain.cards.ollama.title)};return s.jsxs(s.Fragment,{children:[e?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.ollama})}):t?s.jsx(Re,{children:s.jsx(Me,{children:t})}):null,s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ii,{onClick:r,disabled:e}),n!=null&&n.running?s.jsx(P,{variant:"accent",disabled:e||o.length===0,onClick:a,children:F.brain.ollama.connect}):n?s.jsx(cn,{variant:"accent",href:n.downloadUrl,target:"_blank",rel:"noreferrer",children:F.brain.ollama.download}):null]}),children:s.jsx("span",{className:"meet-line",children:n===null?F.brain.ollama.looking:n.running?F.brain.ollama.found:F.brain.ollama.missing})})]})}function CU({busy:e,problem:t,address:n,onBack:r,onOffer:i}){const o=jo(),[a,l]=d.useState(n),[c,u]=d.useState(""),[h,f]=d.useState(!1),p=e||h,x=()=>{a.trim()===""||p||(f(!0),(async()=>{var m;const y=c.trim()?"api-key":"none",w=j=>({label:F.brain.cards.service.title,kind:"openai-compatible",auth:y,baseUrl:a.trim(),defaultModel:j,enabled:!0,...c.trim()?{secret:c.trim()}:{}});let b=[],v;try{const j=await T.probeModels({kind:"openai-compatible",auth:y,baseUrl:a.trim(),...c.trim()?{secret:c.trim()}:{}});b=j.models.map(g=>g.id),v=(m=j.models.find(g=>g.isDefault))==null?void 0:m.id}catch{}f(!1),i(v?[v]:b,w,F.brain.cards.service.title)})())};return s.jsxs(s.Fragment,{children:[p?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.service})}):t?s.jsx(Re,{children:s.jsx(Me,{children:t})}):null,s.jsxs(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ii,{onClick:r,disabled:p}),s.jsx(P,{variant:"accent",disabled:p||a.trim()==="",onClick:x,children:F.brain.service.submit})]}),children:[s.jsx(X,{label:F.brain.service.address,grow:!0,children:s.jsx("input",{ref:o,value:a,placeholder:F.brain.service.addressPlaceholder,onChange:y=>l(y.target.value)})}),s.jsx(X,{label:F.brain.service.key,children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:c,onChange:y=>u(y.target.value)})})]})]})}const EU=2e3;function AU({busy:e,consent:t,onBack:n,onConnected:r,accounts:i}){const[o,a]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(0),x=d.useRef(-1),y=d.useRef(null),w=F.brain.cloud.label;d.useEffect(()=>{if(x.current===f)return;x.current=f,a(!0),c(null);const v=f===0?t:y.current;(async()=>{try{const m=((i==null?void 0:i.accounts)??[]).find(k=>k.auth==="device-key"),j=m?{id:m.id}:await T.saveProviderAccount({label:w,kind:"openai-compatible",auth:"device-key",baseUrl:"",defaultModel:ic,enabled:!0}),g=(await T.providerAccounts()).accounts.find(k=>k.id===j.id),S=await T.ollamaConnect(g.id,g.revision);h({id:g.id,attemptId:S.attemptId,url:S.verificationUrl}),v&&(v.location.href=S.verificationUrl)}catch(m){v==null||v.close(),c(m instanceof oe?m.message:String(m))}finally{a(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let v=!1,m=!1;const j=async()=>{if(!(v||m)){m=!0;try{const S=await T.ollamaPoll(u.id,u.attemptId);if(v||S.state==="waiting")return;if(v=!0,h(null),S.state==="failed"){c(S.message);return}a(!0),c(await b(u.id)),a(!1)}catch{}finally{m=!1}}},g=window.setInterval(()=>void j(),EU);return()=>{v=!0,window.clearInterval(g)}},[u]);const b=async v=>{try{const m=(await T.accountModels(v).catch(()=>({models:[]}))).models.map(k=>k.id),j=m.length===0||m.includes(ic)?ic:m[0],g=(await T.providerAccounts()).accounts.find(k=>k.id===v);g&&g.defaultModel!==j&&await T.saveProviderAccount({id:g.id,revision:g.revision,label:g.label,kind:g.kind,auth:g.auth,baseUrl:g.baseUrl,defaultModel:j,enabled:g.enabled});const S=await T.testProviderAccount(v);return S.state!=="connected"?S.message:await r({accountId:v,label:w,model:j})}catch(m){return m instanceof oe?m.message:String(m)}};return s.jsxs(s.Fragment,{children:[o||e?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.cloud})}):l?s.jsx(Re,{children:s.jsx(Me,{children:l})}):u?s.jsx(Re,{children:s.jsx(Me,{children:F.brain.cloud.waiting})}):null,s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ii,{onClick:n,disabled:o||e}),u?s.jsx(cn,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:F.brain.cloud.open}):l?s.jsx(P,{variant:"accent",disabled:o||e,onClick:()=>{y.current=typeof window.open=="function"?window.open("","_blank"):null,p(v=>v+1)},children:F.brain.cloud.again}):null]})})]})}function RU({answers:e,accounts:t,onSettled:n,onTrouble:r}){var p;const i=e.brain,o=i?((t==null?void 0:t.accounts)??[]).find(x=>x.id===i.accountId):void 0,[a,l]=d.useState([]),[c,u]=d.useState(!1),h=(o==null?void 0:o.auth)==="device-key"||(o==null?void 0:o.kind)==="codex"||!!o&&A4(o,(p=t==null?void 0:t.gemini)==null?void 0:p.baseUrl);if(d.useEffect(()=>{if(!h||!o)return;let x=!1;return T.accountModels(o.id).then(y=>{x||l(y.models.map(w=>w.id))}).catch(()=>{}),()=>{x=!0}},[h,o==null?void 0:o.id]),!h||!o||!i||a.length<2)return null;const f=x=>{x===i.model||c||(u(!0),r(null),(async()=>{try{await T.saveProviderAccount({id:o.id,revision:o.revision,label:o.label,kind:o.kind,auth:o.auth,baseUrl:o.baseUrl,defaultModel:x,enabled:o.enabled}),e.assistant&&await T.bindBrain({accountId:o.id,model:x}),n({...e,brain:{...i,model:x}})}catch(y){r(y instanceof oe?y.message:String(y))}finally{u(!1)}})())};return s.jsx(Me,{children:s.jsx(X,{label:F.brain.model.change,children:s.jsx("select",{value:i.model,disabled:c,onChange:x=>f(x.target.value),children:(a.includes(i.model)?a:[i.model,...a]).map(x=>s.jsx("option",{value:x,children:x},x))})})})}const Xy="gpt-5.5",TU=2e3;function PU({busy:e,consent:t,onBack:n,onConnected:r,accounts:i}){const[o,a]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(null),[f,p]=d.useState(0),x=d.useRef(-1),y=d.useRef(null),w=d.useRef(null),b=F.brain.chatgpt.label;d.useEffect(()=>()=>{const j=w.current;w.current=null,j&&T.codexAccountAction(j.id,"cancel-login",j.revision).catch(()=>{})},[]),d.useEffect(()=>{if(x.current===f)return;x.current=f,a(!0),c(null);const j=f===0?t:y.current;(async()=>{try{const g=((i==null?void 0:i.accounts)??[]).find(C=>C.kind==="codex"),S=g?{id:g.id}:await T.saveProviderAccount({label:b,kind:"codex",auth:"chatgpt",baseUrl:"",defaultModel:Xy,enabled:!0}),k=(await T.providerAccounts()).accounts.find(C=>C.id===S.id),N=await T.codexAccountAction(k.id,"login",k.revision);if(!(N!=null&&N.verificationUrl)||!N.userCode)throw new Error((N==null?void 0:N.message)??F.brain.chatgpt.failed);w.current={id:k.id,revision:k.revision},h({id:k.id,revision:k.revision,url:N.verificationUrl,code:N.userCode}),j&&(j.location.href=N.verificationUrl)}catch(g){j==null||j.close(),c(g instanceof oe||g instanceof Error?g.message:String(g))}finally{a(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let j=!1,g=!1;const S=async()=>{if(!(j||g)){g=!0;try{const N=(await T.providerAccounts()).accounts.find(A=>A.id===u.id);if(j)return;const C=N==null?void 0:N.login;if(!C||C.state==="pending")return;if(j=!0,w.current=null,h(null),C.state!=="connected"){c(C.message??F.brain.chatgpt.failed);return}a(!0),c(await v(u.id)),a(!1)}catch{}finally{g=!1}}},k=window.setInterval(()=>void S(),TU);return()=>{j=!0,window.clearInterval(k)}},[u]);const v=async j=>{var g,S;try{const k=(await T.accountModels(j).catch(()=>({models:[]}))).models,N=((g=k.find(A=>A.isDefault))==null?void 0:g.id)??((S=k[0])==null?void 0:S.id)??Xy,C=(await T.providerAccounts()).accounts.find(A=>A.id===j);return C&&C.defaultModel!==N&&await T.saveProviderAccount({id:C.id,revision:C.revision,label:C.label,kind:C.kind,auth:C.auth,baseUrl:C.baseUrl,defaultModel:N,enabled:C.enabled}),await r({accountId:j,label:b,model:N})}catch(k){return k instanceof oe?k.message:String(k)}},m=()=>{const j=w.current;w.current=null,j&&T.codexAccountAction(j.id,"cancel-login",j.revision).catch(()=>{}),n()};return s.jsxs(s.Fragment,{children:[o||e?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.chatgpt})}):l?s.jsx(Re,{children:s.jsx(Me,{children:l})}):u?s.jsx(Re,{children:s.jsxs(Me,{children:[F.brain.chatgpt.codeBefore,s.jsx("strong",{children:u.code}),F.brain.chatgpt.codeAfter]})}):null,s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ii,{onClick:m,disabled:o||e}),u?s.jsx(cn,{variant:"accent",href:u.url,target:"_blank",rel:"noreferrer",children:F.brain.chatgpt.open}):l?s.jsx(P,{variant:"accent",disabled:o||e,onClick:()=>{y.current=typeof window.open=="function"?window.open("","_blank"):null,p(j=>j+1)},children:F.brain.chatgpt.again}):null]}),children:u?s.jsx(d1,{code:u.code,label:F.brain.chatgpt.code}):null})]})}const IU="claude-sonnet-5";function MU({busy:e,problem:t,onBack:n,onConnected:r,accounts:i,claudeModel:o}){const[a,l]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[p,x]=d.useState(""),y=o??IU,w=()=>{l(!0),u(null);const v=typeof window.open=="function"?window.open("","_blank"):null;(async()=>{try{const m=((i==null?void 0:i.accounts)??[]).find(N=>N.auth==="anthropic-oauth"),j=m?{id:m.id}:await T.saveProviderAccount({label:F.brain.cards.claude.title,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:y,enabled:!0}),S=(await T.providerAccounts()).accounts.find(N=>N.id===j.id),k=await T.anthropicAccountAction(S.id,"login",S.revision);f({id:S.id,revision:S.revision+1,url:k.verificationUrl??"",attemptId:k.attemptId??""}),v&&k.verificationUrl?v.location.href=k.verificationUrl:v==null||v.close()}catch(m){v==null||v.close(),u(m instanceof oe?m.message:String(m))}finally{l(!1)}})()},b=()=>{!h||p.trim()===""||(l(!0),(async()=>{try{await T.anthropicAccountAction(h.id,"complete-login",h.revision,{attemptId:h.attemptId,code:p.trim()});const v=await T.testProviderAccount(h.id);if(v.state!=="connected"){u(v.message);return}u(await r({accountId:h.id,label:F.brain.cards.claude.title,model:y}))}catch(v){u(v instanceof oe?v.message:String(v))}finally{l(!1)}})())};return s.jsxs(s.Fragment,{children:[a||e?s.jsx(Re,{children:s.jsx(Gn,{line:F.brain.checking.claude})}):t??c?s.jsx(Re,{children:s.jsx(Me,{children:t??c})}):null,h?s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{children:F.brain.claude.waiting})}),s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(cn,{href:h.url,target:"_blank",rel:"noreferrer",children:F.brain.claude.open}),s.jsx(P,{variant:"accent",disabled:a||p.trim()==="",onClick:b,children:F.brain.claude.finish})]}),children:s.jsx(X,{label:F.brain.claude.paste,grow:!0,children:s.jsx($U,{value:p,onChange:x})})})]}):s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ii,{onClick:n,disabled:e||a}),s.jsx(P,{variant:"accent",disabled:e||a,onClick:w,children:F.brain.claude.start})]})})]})}function $U({value:e,onChange:t}){const n=jo();return s.jsx("input",{ref:n,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function _U(e){switch(e){case"chrome":return F.browser.chrome;case"chromium":return F.browser.chromium;case"installed":return F.browser.installed;case"skipped":return F.browser.skipped;case"none":return F.browser.missing;default:return null}}function OU({answers:e,onSettled:t}){const[n,r]=d.useState("checking"),[i,o]=d.useState(null),[a,l]=d.useState(null),[c,u]=d.useState(void 0),[h,f]=d.useState(0),p=d.useRef(!1),x=d.useRef(!1),y=d.useRef(()=>{});if(y.current=b=>{x.current||(x.current=!0,t({...e,browser:b}))},d.useEffect(()=>{let b=!1,v;const m=k=>{b||y.current(k)},j=(k,N)=>{b||(p.current=!1,r("failed"),o(k),l(N??null))},g=async k=>{r("launching");let N;try{N=await T.browserCheck()}catch(C){return j(C instanceof oe?C.message:String(C))}if(!b)return N.ok?m(p.current?"installed":k):j(N.message,N.command)},S=async()=>{var C,A;let k;try{k=await T.browser()}catch{return m("other")}if(b)return;const N=k.browser;if(!N)return m("other");if(((C=N.install)==null?void 0:C.state)==="running"){r("installing"),u(N.install.progress),v=window.setTimeout(()=>void S(),1e3);return}if(N.engine!=="none")return g(N.engine);if(p.current)return j(((A=N.install)==null?void 0:A.line)??"");p.current=!0,r("installing"),u(void 0);try{await T.browserInstall()}catch(E){return j(E instanceof oe?E.message:String(E))}b||(v=window.setTimeout(()=>void S(),1e3))};return S(),()=>{b=!0,window.clearTimeout(v)}},[h]),n==="checking")return s.jsx(Gn,{});const w=n==="installing"||n==="launching";return s.jsxs(s.Fragment,{children:[s.jsxs(Re,{children:[p.current||n==="installing"?s.jsx(Me,{children:F.browser.needs}):null,n==="installing"?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:s.jsx(aS,{progress:c})})}):n==="launching"?s.jsx(Gn,{line:F.browser.launching}):s.jsx(Me,{children:F.browser.failed(i??"")})]}),s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:()=>y.current("skipped"),children:F.browser.skip}),s.jsx(P,{variant:"accent",disabled:w,onClick:()=>{r("launching"),l(null),f(b=>b+1)},children:w?F.browser.installing:F.browser.retry})]}),children:n==="failed"&&a?s.jsx(DU,{command:a}):null})]})}function DU({command:e}){const[t,n]=d.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("failed");return}navigator.clipboard.writeText(e).then(()=>n("done"),()=>n("failed"))};return s.jsxs(V,{gap:"sm",children:[s.jsx(ft,{label:"The command to run",children:e}),s.jsxs(q,{align:"end",children:[t==="failed"?s.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,s.jsx(P,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function LU({answers:e,existing:t,onSettled:n,onTrouble:r,onReload:i}){const[o,a]=d.useState(()=>(t==null?void 0:t.name)??AF),[l,c]=d.useState(()=>t!=null&&t.picture?{kind:"kept",url:t.picture}:t!=null&&t.avatar?{kind:"emoji",value:t.avatar}:{kind:"mascot",role:"core"}),[u,h]=d.useState(t?null:F.assistant.purposeValue),[f,p]=d.useState(t?"":F.assistant.purposeValue);d.useEffect(()=>{if(!t)return;let b=!1;return T.firstAgentPersona().then(v=>{b||(h(v.persona),p(v.persona))},v=>{b||r(v instanceof oe?v.message:String(v))}),()=>{b=!0}},[t==null?void 0:t.id]);const[x,y]=d.useState(!1),w=()=>{if(o.trim()===""||x)return;y(!0);const b=l.kind==="emoji"?{avatar:l.value}:{},v=!t||u!==null&&f.trim()!==""&&f.trim()!==u.trim()?{instructions:f.trim()}:{},m=t?T.updateFirstAgent({name:o.trim(),...v,...b}):T.createFirstAgent({name:o.trim(),handle:oU(o),description:"",...v,...b,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let j;try{j=await m}catch(S){r(S instanceof oe?S.message:String(S)),y(!1);return}let g=null;try{l.kind==="mascot"?await T.uploadAgentPicture(j.id,await ZS(l.role)):l.kind==="emoji"&&(t!=null&&t.picture)&&await T.removeAgentPicture(j.id)}catch(S){g=S instanceof oe?S.message:String(S)}y(!1),i(),n({...e,assistant:{id:j.id,name:o.trim(),avatar:l.kind==="emoji"?l.value:""}}),g&&r(g)})()};return s.jsxs(ht,{actions:s.jsx(P,{variant:"accent",disabled:x||o.trim()===""||u===null,onClick:w,children:F.assistant.submit}),children:[s.jsx("span",{className:"meet-chosen-face","data-kind":l.kind==="emoji"?"emoji":"image","aria-hidden":"true",children:l.kind==="emoji"?l.value:s.jsx("img",{src:l.kind==="mascot"?Ka(l.role):l.url,alt:""})}),s.jsx(X,{label:F.assistant.name,children:s.jsx("input",{value:o,maxLength:60,onChange:b=>a(b.target.value)})}),s.jsx(e1,{face:l,onPick:c}),s.jsx(X,{label:F.assistant.purpose,wide:!0,children:s.jsx("textarea",{className:"meet-purpose",value:f,maxLength:8e3,rows:Math.max(4,f.split(`
|
|
125
|
-
`).length+1),onChange:b=>p(b.target.value)})})]})}function FU({answers:e,assistantAgent:t,met:n,onMet:r,onCarriesOn:i,onClosed:o,navigate:a,onPickAnotherBrain:l}){const c=e.assistant,[u,h]=d.useState(n),[f,p]=d.useState([]),[x,y]=d.useState(!1),[w,b]=d.useState(!1),[v,m]=d.useState(!0),[j,g]=d.useState("open"),[S,k]=d.useState(!1),N=rN(),C=d.useRef(!1),A=d.useMemo(()=>t?[t]:[],[t]);d.useEffect(()=>{if(!c||C.current)return;if(C.current=!0,n){h(n);return}let B=!1;return(async()=>{try{const R=await _e.startConversation(c.id);if(B)return;h(R.conversationId),r(R.conversationId),await T.onboardingStep(eN.handover,{conversationId:R.conversationId}).catch(()=>{}),await _e.send(c.id,{conversationId:R.conversationId,text:PF,opening:!0})}catch{B||(m(!1),y(!0))}})(),()=>{B=!0}},[c==null?void 0:c.id,n]),d.useEffect(()=>{if(!u)return;let B=!1;const R=Date.now(),O=()=>{_e.conversation(u).then(G=>{if(B)return;p(G.messages);const M=Date.now()-R;if(G.messages.some(Jy)){m(!1),y(!1),b(!1);return}const W=G.runs??[],$=W.some(ce=>ce.finishedAt===null),ee=W.length>0&&!$;b($&&M>=lU),(ee||M>=cU)&&(m(!1),y(!0))}).catch(()=>{})};O();const Y=window.setInterval(O,sN);return()=>{B=!0,window.clearInterval(Y)}},[u]);const E=c&&u?Ue(c.id,u):null,_=f.some(Jy);d.useEffect(()=>{_&&E&&i(E)},[_,E,i]),d.useEffect(()=>{if(!S||!E||N)return;const B=window.setTimeout(()=>a(E,!0),uU);return()=>window.clearTimeout(B)},[S,E,N,a]);const L=S&&E!==null;return d.useEffect(()=>{L&&o()},[L,o]),s.jsxs(s.Fragment,{children:[s.jsx(rS,{messages:f,live:[],now:Date.now(),onOpen:()=>{},working:v,agents:A,agentName:(c==null?void 0:c.name)??"",emptyHint:F.handover.waiting,plain:!0,workingLine:F.handover.looking((c==null?void 0:c.name)??"")}),w&&!x?s.jsx(Re,{children:s.jsx(Me,{children:F.handover.slow})}):null,x?s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{children:F.handover.silent})}),s.jsx(ht,{actions:s.jsx(P,{variant:"accent",onClick:l,children:F.handover.again})})]}):null,S?s.jsx(Re,{children:s.jsx(Me,{children:F.done.said})}):null,_&&j==="open"?s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{onClick:()=>g("phone"),children:F.offers.phone}),s.jsx(P,{variant:"accent",onClick:()=>{g("gone"),k(!0)},children:F.offers.notNow})]})}):null,_&&j==="phone"?s.jsx(UU,{onPaired:()=>k(!0),onDismiss:()=>{g("gone"),k(!0)}}):null,L&&E?s.jsx(ht,{actions:s.jsx(cn,{variant:"accent",href:E,onClick:B=>{B.preventDefault(),a(E,!0)},children:F.done.open}),children:s.jsx("span",{className:"meet-line",children:N?F.done.ready:F.done.leaving})}):null]})}function Jy(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function UU({onPaired:e,onDismiss:t}){const n=jo(),[r,i]=d.useState(""),[o,a]=d.useState(!1),[l,c]=d.useState(null),{offer:u,square:h,paired:f,stale:p,ask:x}=q1(()=>T.telegram().then(b=>b.paired),e),y=()=>{r.trim()===""||o||(a(!0),c(null),(async()=>{try{const b=await T.saveTelegramToken(r.trim());if(i(""),b.restartNeeded){c(b.note??F.telegram.restart);return}await x()}catch(b){c(b instanceof oe?b.message:String(b))}finally{a(!1)}})())},w=()=>{c(null),x().catch(b=>c(b instanceof oe?b.message:String(b)))};return f?s.jsx(Re,{children:s.jsx(Me,{children:F.telegram.paired})}):u?s.jsxs(s.Fragment,{children:[s.jsx(Re,{children:s.jsx(Me,{children:p?F.telegram.expired:F.telegram.scan})}),s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:t,children:F.offers.notNow}),p?s.jsx(P,{variant:"accent",onClick:w,children:F.telegram.newCode}):null]}),children:p?null:s.jsx(Q1,{offer:u,square:h})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Re,{children:[s.jsx(Me,{children:F.telegram.how}),l?s.jsx(Me,{children:l}):null]}),s.jsx(ht,{actions:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"ghost",onClick:t,children:F.offers.notNow}),s.jsx(P,{variant:"accent",disabled:o||r.trim()==="",onClick:y,children:F.telegram.submit})]}),children:s.jsx(X,{label:F.telegram.field,grow:!0,children:s.jsx("input",{ref:n,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),y())}})})})]})}const BU="(max-width: 1080px)";function zU(){const[e,t]=d.useState(()=>window.location.hash||Ft);d.useEffect(()=>{const r=()=>t(window.location.hash||Ft);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const n=d.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,n]}function WU(){const[e,t]=zS();d.useEffect(()=>{BS(e)},[e]);const n=d.useCallback(r=>t({theme:r}),[t]);return[e.theme,n]}function HU(){var be,We;const[e,t]=zU();KL(t,Od(e)===null);const[n,r]=d.useState("UTC"),[i,o]=d.useState({approvals:0,failed:0}),[a,l]=WU(),c=Ia(pg),[u,h]=d.useState(!1),[f,p]=d.useState([]),[x,y]=d.useState(null),[w,b]=d.useState(null),[v,m]=d.useState([]),[j,g]=d.useState(!1),[S,k]=d.useState(null),N=zI(),C=Ia(BU),A=i1(),E=$S(),_=ne(()=>Promise.resolve().then(()=>T.version()),[],60*6e4).data,L=_&&!_.checkout&&_.updateAvailable?_:null,[B,R]=d.useState(new Map);d.useEffect(()=>{const fe=()=>{T.conversations().then(de=>{const Ke=new Map;for(const nt of de.conversations){const $e=nt.lastMessageAt??nt.createdAt,Sn=Ke.get(nt.agentId);(!Sn||$e>Sn)&&Ke.set(nt.agentId,$e)}R(Ke)}).catch(()=>{})};fe();const D=window.setInterval(fe,3e4);return()=>window.clearInterval(D)},[e]);const[O,Y]=d.useState(!1);d.useEffect(()=>{if(O)return;let fe=!1;return T.onboarding().then(D=>{fe||(Y(!0),D.state==="pending"&&D.needs.model&&!Od(window.location.hash)&&t(mI,!0))}).catch(()=>{fe||Y(!0)}),()=>{fe=!0}},[O,t]),d.useEffect(()=>{const fe=AI(e);fe&&t(fe,!0)},[e,t]),d.useEffect(()=>{let fe=!1;const D=()=>{_e.agents().then(Ke=>{fe||(p(Ke.agents),$I(Ke.defaultAgentId??null),y(Ke.defaultAgentId??null),b(nt=>{var $e;return nt??Ke.defaultAgentId??(($e=Ke.agents[0])==null?void 0:$e.id)??null}))}).catch(()=>{})};D();const de=window.setInterval(D,15e3);return window.addEventListener("focus",D),window.addEventListener(ka,D),()=>{fe=!0,window.clearInterval(de),window.removeEventListener("focus",D),window.removeEventListener(ka,D)}},[e]),d.useEffect(()=>{let fe=!1;const D=()=>{_e.groups().then(Ke=>{fe||m(Ke.groups)}).catch(()=>{})};D();const de=window.setInterval(D,3e4);return()=>{fe=!0,window.clearInterval(de)}},[e]);const G=vk(f,x),M=xI(e),W=pk(e),$=W?v.find(fe=>fe.id===W.groupId)??null:null,ee=W?null:(M==null?void 0:M.agentId)??w;d.useEffect(()=>{M&&b(M.agentId)},[M==null?void 0:M.agentId]);const ce=fe=>{b(fe),t(Ue(fe))},Ce=fe=>t(Zo(fe)),J=d.useCallback((fe,D,de=!0)=>t(W?Zo(W.groupId,D):Ue(fe,D),de),[t,W==null?void 0:W.groupId]),[ge,xe]=d.useState(!1);d.useEffect(()=>{T.session().then(fe=>{r(fe.timezone),xe(!0)}).catch(()=>{})},[]);const je=VD(ge);QD(ge,je.refresh,()=>xe(!1)),d.useEffect(()=>{const fe=()=>{T.overview().then(de=>o({approvals:de.approvals.pending,failed:de.jobs.failed??0})).catch(()=>{})};fe();const D=window.setInterval(fe,2e4);return()=>window.clearInterval(D)},[]);const Pe=Od(e),ze=RI(e),te=ze===Ji,se=S?v.find(fe=>fe.id===S)??null:null,we=j?s.jsx(wy,{agents:f,onClose:()=>g(!1),onCreated:fe=>{m(D=>[...D,fe]),g(!1),t(Zo(fe.id))}}):se?s.jsx(wy,{agents:f,group:se,onClose:()=>k(null),onSaved:fe=>{m(D=>D.map(de=>de.id===fe.id?fe:de)),k(null)},onArchived:fe=>{m(D=>D.filter(de=>de.id!==fe)),k(null),t(Ji)}}):null;return Pe?s.jsx(Nv,{delayDuration:400,children:s.jsxs(fv,{swipeDirection:"right",children:[s.jsx(dU,{navigate:t,timezone:n}),s.jsx(hv,{className:"ui-toasts"})]})}):s.jsx(nM,{picture:(be=f.find(fe=>fe.id===x))==null?void 0:be.picture,children:s.jsx(Nv,{delayDuration:400,children:s.jsxs(fv,{swipeDirection:"right",children:[we,s.jsxs("div",{className:"wb-shell",children:[s.jsx(h4,{active:((We=A.data)==null?void 0:We.active)===!0,onNavigate:t}),s.jsxs("div",{className:"wb",children:[s.jsx(zL,{attention:i.approvals+i.failed,place:ze,onNavigate:t,theme:a,onTheme:l,plugins:E.rail,updateAvailable:L!==null,version:_&&!_.checkout?{current:_.current,latest:_.latest,updateAvailable:_.updateAvailable}:_?{current:_.current,updateAvailable:!1}:void 0}),te&&!C?s.jsx(Sk,{agents:G,currentId:ee,attention:N,onSelect:ce,lastActivity:B,groups:v,currentGroupId:($==null?void 0:$.id)??null,onSelectGroup:Ce,onNewGroup:()=>g(!0)}):null,te?s.jsx(ID,{timezone:n,agents:G,agentId:$?$.coordinator:ee,defaultAgentId:x,group:$,onEditGroup:$?()=>k($.id):void 0,requestedConversationId:(W==null?void 0:W.conversationId)??(M==null?void 0:M.conversationId),requestedTab:M==null?void 0:M.tab,onConversationOpened:J,onSelectAgent:ce,attention:N,agentsInHeader:C,narrow:c,canvasOpen:u,onOpenCanvas:()=>h(!0),onCloseCanvas:()=>h(!1)}):s.jsx("main",{"data-ground":VU(ze,e)?"plain":void 0,"data-layout":ze===Zt?"split":void 0,children:s.jsx(KU,{hash:e,place:ze,timezone:n,navigate:t,agents:f,defaultAgentId:x,attention:N,pluginPages:E,update:L})})]})]}),s.jsx(KD,{queue:je.queue,agents:f,navigate:t,onDismiss:je.dismiss}),s.jsx(hv,{className:"ui-toasts"})]})})})}function VU(e,t){return Fm(t)!==null}function KU({place:e,pluginPages:t,...n}){const r={...n,pluginPages:t},i=Fm(n.hash);if(i){const o=t.find(i.plugin,i.page);if(o)return s.jsx(MS,{page:o,item:i.item??null,navigate:n.navigate,timezone:n.timezone,siblings:t.all.filter(a=>a.plugin===i.plugin)});if(t.all.length===0)return s.jsx(s.Fragment,{})}switch(e){case it:return s.jsx(KF,{...n});case rt:return s.jsx(oF,{...n});case Zt:return s.jsx($6,{...r});case Gr:return s.jsx(LL,{...n});default:return s.jsx(XF,{...n})}}const Zy=document.getElementById("root");Zy&&fb(Zy).render(s.jsx(d.StrictMode,{children:s.jsx(HU,{})}));
|