synapse-orch-ai 0.1.0
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/LICENSE +661 -0
- package/README.md +501 -0
- package/backend/core/__init__.py +0 -0
- package/backend/core/agent_logger.py +195 -0
- package/backend/core/builder_tools.py +1482 -0
- package/backend/core/compaction.py +188 -0
- package/backend/core/config.py +89 -0
- package/backend/core/json_store.py +50 -0
- package/backend/core/llm_providers.py +2088 -0
- package/backend/core/mcp_client.py +548 -0
- package/backend/core/mcp_oauth_state.py +37 -0
- package/backend/core/memory.py +714 -0
- package/backend/core/messaging/__init__.py +5 -0
- package/backend/core/messaging/adapters/__init__.py +1 -0
- package/backend/core/messaging/adapters/discord.py +112 -0
- package/backend/core/messaging/adapters/slack.py +123 -0
- package/backend/core/messaging/adapters/teams.py +102 -0
- package/backend/core/messaging/adapters/telegram.py +118 -0
- package/backend/core/messaging/adapters/whatsapp.py +216 -0
- package/backend/core/messaging/base.py +209 -0
- package/backend/core/messaging/manager.py +291 -0
- package/backend/core/messaging/markdown.py +171 -0
- package/backend/core/messaging/store.py +95 -0
- package/backend/core/models.py +154 -0
- package/backend/core/models_orchestration.py +123 -0
- package/backend/core/models_schedule.py +56 -0
- package/backend/core/native_builder/__init__.py +60 -0
- package/backend/core/native_builder/agents/agent_creator.json +20 -0
- package/backend/core/native_builder/agents/orchestrator_builder.json +15 -0
- package/backend/core/native_builder/agents/requirements_analyst.json +21 -0
- package/backend/core/native_builder/agents/saver_create.json +28 -0
- package/backend/core/native_builder/agents/saver_update.json +29 -0
- package/backend/core/native_builder/orchestration.json +515 -0
- package/backend/core/native_builder/seed.py +135 -0
- package/backend/core/orchestration/__init__.py +5 -0
- package/backend/core/orchestration/context.py +630 -0
- package/backend/core/orchestration/engine.py +489 -0
- package/backend/core/orchestration/logger.py +278 -0
- package/backend/core/orchestration/state.py +79 -0
- package/backend/core/orchestration/steps.py +1017 -0
- package/backend/core/orchestration/summarizer.py +106 -0
- package/backend/core/personal_details.py +60 -0
- package/backend/core/profiling.py +160 -0
- package/backend/core/react_engine.py +1017 -0
- package/backend/core/routes/__init__.py +4 -0
- package/backend/core/routes/agents.py +303 -0
- package/backend/core/routes/auth.py +38 -0
- package/backend/core/routes/builder.py +491 -0
- package/backend/core/routes/chat.py +151 -0
- package/backend/core/routes/data.py +800 -0
- package/backend/core/routes/db_configs.py +105 -0
- package/backend/core/routes/import_export.py +370 -0
- package/backend/core/routes/logs.py +93 -0
- package/backend/core/routes/messaging.py +204 -0
- package/backend/core/routes/n8n.py +95 -0
- package/backend/core/routes/orchestrations.py +364 -0
- package/backend/core/routes/profiling.py +83 -0
- package/backend/core/routes/repos.py +212 -0
- package/backend/core/routes/schedules.py +158 -0
- package/backend/core/routes/sessions.py +48 -0
- package/backend/core/routes/settings.py +362 -0
- package/backend/core/routes/tools.py +416 -0
- package/backend/core/routes/usage.py +63 -0
- package/backend/core/routes/vault.py +254 -0
- package/backend/core/schedule_logger.py +226 -0
- package/backend/core/scheduler.py +376 -0
- package/backend/core/server.py +658 -0
- package/backend/core/session.py +206 -0
- package/backend/core/tools.py +344 -0
- package/backend/core/usage_tracker.py +417 -0
- package/backend/core/vault.py +265 -0
- package/backend/main.py +26 -0
- package/backend/requirements.txt +24 -0
- package/backend/services/__init__.py +0 -0
- package/backend/services/code_indexer.py +488 -0
- package/backend/services/google.py +343 -0
- package/backend/services/synthetic_data.py +140 -0
- package/backend/tools/__init__.py +0 -0
- package/backend/tools/bash.py +244 -0
- package/backend/tools/code_indexer.py +110 -0
- package/backend/tools/code_search.py +537 -0
- package/backend/tools/collect_data.py +134 -0
- package/backend/tools/pdf_parser.py +103 -0
- package/backend/tools/personal_details.py +52 -0
- package/backend/tools/sandbox.Dockerfile +24 -0
- package/backend/tools/sandbox.py +586 -0
- package/backend/tools/sql_agent.py +221 -0
- package/backend/tools/time.py +283 -0
- package/backend/tools/web_scraper.py +765 -0
- package/backend/tools/xlsx_parser.py +79 -0
- package/bin/synapse +16 -0
- package/bin/synapse.bat +36 -0
- package/bin/synapse.js +247 -0
- package/frontend-build/.next/BUILD_ID +1 -0
- package/frontend-build/.next/app-path-routes-manifest.json +22 -0
- package/frontend-build/.next/build-manifest.json +21 -0
- package/frontend-build/.next/package.json +1 -0
- package/frontend-build/.next/prerender-manifest.json +114 -0
- package/frontend-build/.next/required-server-files.json +352 -0
- package/frontend-build/.next/routes-manifest.json +194 -0
- package/frontend-build/.next/server/app/_global-error/page/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/_global-error/page/build-manifest.json +17 -0
- package/frontend-build/.next/server/app/_global-error/page/next-font-manifest.json +6 -0
- package/frontend-build/.next/server/app/_global-error/page/react-loadable-manifest.json +1 -0
- package/frontend-build/.next/server/app/_global-error/page/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/_global-error/page.js +9 -0
- package/frontend-build/.next/server/app/_global-error/page.js.map +5 -0
- package/frontend-build/.next/server/app/_global-error/page.js.nft.json +1 -0
- package/frontend-build/.next/server/app/_global-error/page_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/_global-error.html +1 -0
- package/frontend-build/.next/server/app/_global-error.meta +15 -0
- package/frontend-build/.next/server/app/_global-error.rsc +14 -0
- package/frontend-build/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +5 -0
- package/frontend-build/.next/server/app/_global-error.segments/_full.segment.rsc +14 -0
- package/frontend-build/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
- package/frontend-build/.next/server/app/_global-error.segments/_index.segment.rsc +5 -0
- package/frontend-build/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
- package/frontend-build/.next/server/app/_not-found/page/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/_not-found/page/build-manifest.json +17 -0
- package/frontend-build/.next/server/app/_not-found/page/next-font-manifest.json +14 -0
- package/frontend-build/.next/server/app/_not-found/page/react-loadable-manifest.json +1 -0
- package/frontend-build/.next/server/app/_not-found/page/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/_not-found/page.js +13 -0
- package/frontend-build/.next/server/app/_not-found/page.js.map +5 -0
- package/frontend-build/.next/server/app/_not-found/page.js.nft.json +1 -0
- package/frontend-build/.next/server/app/_not-found/page_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/_not-found.html +1 -0
- package/frontend-build/.next/server/app/_not-found.meta +16 -0
- package/frontend-build/.next/server/app/_not-found.rsc +18 -0
- package/frontend-build/.next/server/app/_not-found.segments/_full.segment.rsc +18 -0
- package/frontend-build/.next/server/app/_not-found.segments/_head.segment.rsc +6 -0
- package/frontend-build/.next/server/app/_not-found.segments/_index.segment.rsc +7 -0
- package/frontend-build/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
- package/frontend-build/.next/server/app/_not-found.segments/_not-found.segment.rsc +5 -0
- package/frontend-build/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -0
- package/frontend-build/.next/server/app/api/agent-types/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/agent-types/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/agent-types/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/agent-types/route.js +6 -0
- package/frontend-build/.next/server/app/api/agent-types/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/agent-types/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/agent-types/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/agents/generate-prompt/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/agents/generate-prompt/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/agents/generate-prompt/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/agents/generate-prompt/route.js +6 -0
- package/frontend-build/.next/server/app/api/agents/generate-prompt/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/agents/generate-prompt/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/agents/generate-prompt/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/builder/chat/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/builder/chat/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/builder/chat/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/builder/chat/route.js +6 -0
- package/frontend-build/.next/server/app/api/builder/chat/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/builder/chat/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/builder/chat/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/builder/resume/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/builder/resume/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/builder/resume/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/builder/resume/route.js +6 -0
- package/frontend-build/.next/server/app/api/builder/resume/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/builder/resume/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/builder/resume/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/chat/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/chat/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/chat/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/chat/route.js +6 -0
- package/frontend-build/.next/server/app/api/chat/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/chat/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/chat/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/chat/stream/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/chat/stream/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/chat/stream/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/chat/stream/route.js +6 -0
- package/frontend-build/.next/server/app/api/chat/stream/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/chat/stream/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/chat/stream/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/logs/[type]/[run_id]/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/logs/[type]/[run_id]/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/logs/[type]/[run_id]/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/logs/[type]/[run_id]/route.js +6 -0
- package/frontend-build/.next/server/app/api/logs/[type]/[run_id]/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/logs/[type]/[run_id]/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/logs/[type]/[run_id]/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/logs/[type]/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/logs/[type]/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/logs/[type]/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/logs/[type]/route.js +6 -0
- package/frontend-build/.next/server/app/api/logs/[type]/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/logs/[type]/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/logs/[type]/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/models/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/models/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/models/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/models/route.js +6 -0
- package/frontend-build/.next/server/app/api/models/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/models/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/models/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/orchestrations/[orch_id]/run/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/orchestrations/[orch_id]/run/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/orchestrations/[orch_id]/run/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/orchestrations/[orch_id]/run/route.js +6 -0
- package/frontend-build/.next/server/app/api/orchestrations/[orch_id]/run/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/orchestrations/[orch_id]/run/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/orchestrations/[orch_id]/run/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/human-input/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/human-input/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/human-input/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/human-input/route.js +6 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/human-input/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/human-input/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/human-input/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/resume/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/resume/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/resume/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/resume/route.js +6 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/resume/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/resume/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/orchestrations/runs/[run_id]/resume/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/route.js +6 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/run/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/run/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/run/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/run/route.js +6 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/run/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/run/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/schedules/[schedule_id]/run/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/api/schedules/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/api/schedules/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/api/schedules/route/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/api/schedules/route.js +6 -0
- package/frontend-build/.next/server/app/api/schedules/route.js.map +5 -0
- package/frontend-build/.next/server/app/api/schedules/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/api/schedules/route_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/icon.svg/route/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/icon.svg/route/build-manifest.json +9 -0
- package/frontend-build/.next/server/app/icon.svg/route.js +6 -0
- package/frontend-build/.next/server/app/icon.svg/route.js.map +5 -0
- package/frontend-build/.next/server/app/icon.svg/route.js.nft.json +1 -0
- package/frontend-build/.next/server/app/icon.svg.body +4 -0
- package/frontend-build/.next/server/app/icon.svg.meta +1 -0
- package/frontend-build/.next/server/app/index.html +1 -0
- package/frontend-build/.next/server/app/index.meta +14 -0
- package/frontend-build/.next/server/app/index.rsc +25 -0
- package/frontend-build/.next/server/app/index.segments/__PAGE__.segment.rsc +9 -0
- package/frontend-build/.next/server/app/index.segments/_full.segment.rsc +25 -0
- package/frontend-build/.next/server/app/index.segments/_head.segment.rsc +6 -0
- package/frontend-build/.next/server/app/index.segments/_index.segment.rsc +7 -0
- package/frontend-build/.next/server/app/index.segments/_tree.segment.rsc +8 -0
- package/frontend-build/.next/server/app/page/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/page/build-manifest.json +17 -0
- package/frontend-build/.next/server/app/page/next-font-manifest.json +14 -0
- package/frontend-build/.next/server/app/page/react-loadable-manifest.json +1 -0
- package/frontend-build/.next/server/app/page/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/page.js +14 -0
- package/frontend-build/.next/server/app/page.js.map +5 -0
- package/frontend-build/.next/server/app/page.js.nft.json +1 -0
- package/frontend-build/.next/server/app/page_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app/settings/[tab]/page/app-paths-manifest.json +3 -0
- package/frontend-build/.next/server/app/settings/[tab]/page/build-manifest.json +17 -0
- package/frontend-build/.next/server/app/settings/[tab]/page/next-font-manifest.json +14 -0
- package/frontend-build/.next/server/app/settings/[tab]/page/react-loadable-manifest.json +1 -0
- package/frontend-build/.next/server/app/settings/[tab]/page/server-reference-manifest.json +4 -0
- package/frontend-build/.next/server/app/settings/[tab]/page.js +16 -0
- package/frontend-build/.next/server/app/settings/[tab]/page.js.map +5 -0
- package/frontend-build/.next/server/app/settings/[tab]/page.js.nft.json +1 -0
- package/frontend-build/.next/server/app/settings/[tab]/page_client-reference-manifest.js +3 -0
- package/frontend-build/.next/server/app-paths-manifest.json +22 -0
- package/frontend-build/.next/server/chunks/0zjb_server_app_api_orchestrations_runs_[run_id]_human-input_route_actions_0oj9y8~.js +3 -0
- package/frontend-build/.next/server/chunks/0zjb_server_app_api_orchestrations_runs_[run_id]_resume_route_actions_0cdumha.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__00sljji._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__02je2si._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__03e7r3a._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__053~3b.._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0afb7iz._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0bc5iuk._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0bygctj._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0c7o1w_._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0cy6bl4._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0dmb8p1._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0gx4j6x._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0h2-vsq._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0j8-xkl._.js +13 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0kkdqe3._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0n1p1jk._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__0xccig4._.js +3 -0
- package/frontend-build/.next/server/chunks/[root-of-the-server]__13dxl3m._.js +3 -0
- package/frontend-build/.next/server/chunks/[turbopack]_runtime.js +903 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_agent-types_route_actions_11dsnho.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_agents_generate-prompt_route_actions_0sqc90~.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_builder_chat_route_actions_0mserwk.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_builder_resume_route_actions_10w~8ke.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_chat_route_actions_0tmcf6..js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_chat_stream_route_actions_0ef7us3.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_logs_[type]_[run_id]_route_actions_061uvw9.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_logs_[type]_route_actions_0jpmtla.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_models_route_actions_0vfccm4.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_orchestrations_[orch_id]_run_route_actions_019s..3.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_schedules_[schedule_id]_route_actions_0vtfp83.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_schedules_[schedule_id]_run_route_actions_04d41xi.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_api_schedules_route_actions_129kjsa.js +3 -0
- package/frontend-build/.next/server/chunks/_next-internal_server_app_icon_svg_route_actions_0-0ehc~.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__08gf6t7._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__09z7o2x._.js +19 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__0fql_-o._.js +33 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__0hfoz0-._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__0p3x1m7._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__0rj.gz.._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__0ssmzpx._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__0uo38ip._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__10unlca._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__10xgshr._.js +33 -0
- package/frontend-build/.next/server/chunks/ssr/[root-of-the-server]__12b-xga._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/[turbopack]_runtime.js +903 -0
- package/frontend-build/.next/server/chunks/ssr/_0ayz11y._.js +4 -0
- package/frontend-build/.next/server/chunks/ssr/_0df15zg._.js +48 -0
- package/frontend-build/.next/server/chunks/ssr/_0yv_lu6._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0k77kol.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0eq97pa.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/_next-internal_server_app_page_actions_09-gtaw.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/_next-internal_server_app_settings_[tab]_page_actions_0ltd7re.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_09w7yel._.js +33 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_0_ce7g1._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_0y8evf1._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_0zhhlrq._.js +6 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_1041ur2._.js +6 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_0ag5..o._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_loader-circle_0hcf_w-.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_0xdsm99._.js +6 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_client_components_0inhx6q._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_0ghu-f7.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0lgvd_..js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_unauthorized_0cjv-23.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_08ib7il.js +4 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0k.0n04.js +4 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0rc3ul_.js +4 -0
- package/frontend-build/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_13pf1l2.js +4 -0
- package/frontend-build/.next/server/chunks/ssr/src_app_page_tsx_0ss2.w7._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/src_app_settings_layout_tsx_0j6i0d.._.js +3 -0
- package/frontend-build/.next/server/chunks/ssr/src_app_settings_loading_tsx_0.wko.c._.js +3 -0
- package/frontend-build/.next/server/functions-config-manifest.json +29 -0
- package/frontend-build/.next/server/middleware-build-manifest.js +21 -0
- package/frontend-build/.next/server/middleware-manifest.json +6 -0
- package/frontend-build/.next/server/next-font-manifest.js +1 -0
- package/frontend-build/.next/server/next-font-manifest.json +28 -0
- package/frontend-build/.next/server/pages/404.html +1 -0
- package/frontend-build/.next/server/pages/500.html +1 -0
- package/frontend-build/.next/server/pages-manifest.json +4 -0
- package/frontend-build/.next/server/prefetch-hints.json +1 -0
- package/frontend-build/.next/server/server-reference-manifest.js +1 -0
- package/frontend-build/.next/server/server-reference-manifest.json +5 -0
- package/frontend-build/.next/static/2m6rYBnEW4xy8D-1wzwqJ/_buildManifest.js +18 -0
- package/frontend-build/.next/static/2m6rYBnEW4xy8D-1wzwqJ/_clientMiddlewareManifest.js +1 -0
- package/frontend-build/.next/static/2m6rYBnEW4xy8D-1wzwqJ/_ssgManifest.js +1 -0
- package/frontend-build/.next/static/chunks/02i7dfk78~t~2.js +4 -0
- package/frontend-build/.next/static/chunks/03~yq9q893hmn.js +1 -0
- package/frontend-build/.next/static/chunks/04v~lhs2c9fvw.js +1 -0
- package/frontend-build/.next/static/chunks/05dz57h.5fg3-.js +2 -0
- package/frontend-build/.next/static/chunks/078eei4f0ilb1.js +1 -0
- package/frontend-build/.next/static/chunks/0h4a4y-~puu.x.js +1 -0
- package/frontend-build/.next/static/chunks/0ipoy_nm8gvxg.js +1 -0
- package/frontend-build/.next/static/chunks/0j29xn-eqm8iz.css +5 -0
- package/frontend-build/.next/static/chunks/0js-43escs3uy.js +1 -0
- package/frontend-build/.next/static/chunks/0jvmviuftg5e2.css +1 -0
- package/frontend-build/.next/static/chunks/0mim5z5~_34t1.js +31 -0
- package/frontend-build/.next/static/chunks/0n_h7vo0a.b~e.js +46 -0
- package/frontend-build/.next/static/chunks/0obt-c9w~4_5f.js +1 -0
- package/frontend-build/.next/static/chunks/0uuygh822k98..css +1 -0
- package/frontend-build/.next/static/chunks/0v9xc_wrxht3o.js +1 -0
- package/frontend-build/.next/static/chunks/0vn.s1wic2p_8.js +1 -0
- package/frontend-build/.next/static/chunks/0x6cedgvid-.9.js +2 -0
- package/frontend-build/.next/static/chunks/11evimknhsnll.js +1 -0
- package/frontend-build/.next/static/chunks/127bqzm7d2i2u.js +1 -0
- package/frontend-build/.next/static/chunks/turbopack-1606efl0p3-k2.js +1 -0
- package/frontend-build/.next/static/media/03fc1b4a8d284b5e-s.p.09.f.n_ccld80.woff2 +0 -0
- package/frontend-build/.next/static/media/13bf9871fe164e7f-s.0s19wthhh_6~m.woff2 +0 -0
- package/frontend-build/.next/static/media/1bcd0e671759a44c-s.0vnh8.d8wxa2x.woff2 +0 -0
- package/frontend-build/.next/static/media/1bffadaabf893a1e-s.16ipb6fqu393i.woff2 +0 -0
- package/frontend-build/.next/static/media/2bbe8d2671613f1f-s.067x_6k0k23tk.woff2 +0 -0
- package/frontend-build/.next/static/media/2c55a0e60120577a-s.0bjc5tiuqdqro.woff2 +0 -0
- package/frontend-build/.next/static/media/3fe682a82f50d426-s.09q3q1i5159bl.woff2 +0 -0
- package/frontend-build/.next/static/media/4fa387ec64143e14-s.0q3udbd2bu5yp.woff2 +0 -0
- package/frontend-build/.next/static/media/5476f68d60460930-s.0wxq9webf.ew4.woff2 +0 -0
- package/frontend-build/.next/static/media/57215795b8570f5c-s.0vwgtotjdgnhr.woff2 +0 -0
- package/frontend-build/.next/static/media/70bc3e132a0a741e-s.p.1409xf.ylxg8g.woff2 +0 -0
- package/frontend-build/.next/static/media/7178b3e590c64307-s.11.cyxs5p-0z~.woff2 +0 -0
- package/frontend-build/.next/static/media/71b036adf157cdcf-s.03nf~dfjdkf~..woff2 +0 -0
- package/frontend-build/.next/static/media/797e433ab948586e-s.p.0.q-h669a_dqa.woff2 +0 -0
- package/frontend-build/.next/static/media/7fea77d1d19108bf-s.0xyeb7czu1stb.woff2 +0 -0
- package/frontend-build/.next/static/media/83afe278b6a6bb3c-s.p.0q-301v4kxxnr.woff2 +0 -0
- package/frontend-build/.next/static/media/89b21bb081cb7469-s.0gfhww.tctz1o.woff2 +0 -0
- package/frontend-build/.next/static/media/8a480f0b521d4e75-s.06d3mdzz5bre_.woff2 +0 -0
- package/frontend-build/.next/static/media/90c51ce8fb754fe8-s.00z~hoalba5dm.woff2 +0 -0
- package/frontend-build/.next/static/media/9c72aa0f40e4eef8-s.0m6w47a4e5dy9.woff2 +0 -0
- package/frontend-build/.next/static/media/ad66f9afd8947f86-s.11u06r12fd6v_.woff2 +0 -0
- package/frontend-build/.next/static/media/bbc41e54d2fcbd21-s.0gw~uztddq1df.woff2 +0 -0
- package/frontend-build/.next/static/media/caa3a2e1cccd8315-s.p.16t1db8_9y2o~.woff2 +0 -0
- package/frontend-build/.next/static/media/cc545e633e20c56d-s.0dza.stei.9v7.woff2 +0 -0
- package/frontend-build/.next/static/media/e15f58668ad64cb8-s.0~.8lt~vdqmc3.woff2 +0 -0
- package/frontend-build/.next/static/media/icon.08txep8y1sjlr.svg +4 -0
- package/frontend-build/node_modules/@img/colour/color.cjs +1594 -0
- package/frontend-build/node_modules/@img/colour/index.cjs +1 -0
- package/frontend-build/node_modules/@img/colour/package.json +45 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linux-x64/README.md +46 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include/glibconfig.h +221 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +1 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linux-x64/package.json +42 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linuxmusl-x64/README.md +46 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/glib-2.0/include/glibconfig.h +221 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/index.js +1 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linuxmusl-x64/package.json +42 -0
- package/frontend-build/node_modules/@img/sharp-libvips-linuxmusl-x64/versions.json +30 -0
- package/frontend-build/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
- package/frontend-build/node_modules/@img/sharp-linux-x64/package.json +46 -0
- package/frontend-build/node_modules/@img/sharp-linuxmusl-x64/lib/sharp-linuxmusl-x64.node +0 -0
- package/frontend-build/node_modules/@img/sharp-linuxmusl-x64/package.json +46 -0
- package/frontend-build/node_modules/@next/env/dist/index.js +1 -0
- package/frontend-build/node_modules/@next/env/package.json +36 -0
- package/frontend-build/node_modules/@swc/helpers/cjs/_interop_require_default.cjs +6 -0
- package/frontend-build/node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs +38 -0
- package/frontend-build/node_modules/@swc/helpers/package.json +471 -0
- package/frontend-build/node_modules/client-only/index.js +0 -0
- package/frontend-build/node_modules/client-only/package.json +19 -0
- package/frontend-build/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/frontend-build/node_modules/detect-libc/lib/elf.js +39 -0
- package/frontend-build/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/frontend-build/node_modules/detect-libc/lib/process.js +24 -0
- package/frontend-build/node_modules/detect-libc/package.json +44 -0
- package/frontend-build/node_modules/next/dist/build/adapter/setup-node-env.external.js +15 -0
- package/frontend-build/node_modules/next/dist/build/define-env.js +255 -0
- package/frontend-build/node_modules/next/dist/build/duration-to-string.js +99 -0
- package/frontend-build/node_modules/next/dist/build/get-supported-browsers.js +38 -0
- package/frontend-build/node_modules/next/dist/build/next-config-ts/require-hook.js +85 -0
- package/frontend-build/node_modules/next/dist/build/next-config-ts/transpile-config.js +251 -0
- package/frontend-build/node_modules/next/dist/build/output/format.js +84 -0
- package/frontend-build/node_modules/next/dist/build/output/log.js +135 -0
- package/frontend-build/node_modules/next/dist/build/segment-config/app/app-segment-config.js +162 -0
- package/frontend-build/node_modules/next/dist/build/segment-config/app/app-segments.js +137 -0
- package/frontend-build/node_modules/next/dist/build/segment-config/app/collect-root-param-keys.js +52 -0
- package/frontend-build/node_modules/next/dist/build/static-paths/app/extract-pathname-route-param-segments-from-loader-tree.js +137 -0
- package/frontend-build/node_modules/next/dist/build/static-paths/app.js +735 -0
- package/frontend-build/node_modules/next/dist/build/static-paths/pages.js +169 -0
- package/frontend-build/node_modules/next/dist/build/static-paths/utils.js +119 -0
- package/frontend-build/node_modules/next/dist/build/swc/helpers.js +15 -0
- package/frontend-build/node_modules/next/dist/build/swc/index.js +1348 -0
- package/frontend-build/node_modules/next/dist/build/swc/install-bindings.js +30 -0
- package/frontend-build/node_modules/next/dist/build/swc/jest-transformer.js +76 -0
- package/frontend-build/node_modules/next/dist/build/swc/loaderWorkerPool.js +40 -0
- package/frontend-build/node_modules/next/dist/build/swc/options.js +403 -0
- package/frontend-build/node_modules/next/dist/build/swc/types.js +6 -0
- package/frontend-build/node_modules/next/dist/build/utils.js +1215 -0
- package/frontend-build/node_modules/next/dist/cli/next-test.js +170 -0
- package/frontend-build/node_modules/next/dist/client/add-base-path.js +24 -0
- package/frontend-build/node_modules/next/dist/client/app-call-server.js +34 -0
- package/frontend-build/node_modules/next/dist/client/app-find-source-map-url.js +39 -0
- package/frontend-build/node_modules/next/dist/client/assign-location.js +29 -0
- package/frontend-build/node_modules/next/dist/client/components/app-router-announcer.js +78 -0
- package/frontend-build/node_modules/next/dist/client/components/app-router-headers.js +138 -0
- package/frontend-build/node_modules/next/dist/client/components/app-router-instance.js +397 -0
- package/frontend-build/node_modules/next/dist/client/components/app-router-utils.js +62 -0
- package/frontend-build/node_modules/next/dist/client/components/app-router.js +514 -0
- package/frontend-build/node_modules/next/dist/client/components/builtin/default.js +35 -0
- package/frontend-build/node_modules/next/dist/client/components/builtin/error-styles.js +165 -0
- package/frontend-build/node_modules/next/dist/client/components/builtin/global-error.js +100 -0
- package/frontend-build/node_modules/next/dist/client/components/dev-root-http-access-fallback-boundary.js +52 -0
- package/frontend-build/node_modules/next/dist/client/components/error-boundary.js +144 -0
- package/frontend-build/node_modules/next/dist/client/components/errors/graceful-degrade-boundary.js +86 -0
- package/frontend-build/node_modules/next/dist/client/components/errors/root-error-boundary.js +41 -0
- package/frontend-build/node_modules/next/dist/client/components/forbidden.js +48 -0
- package/frontend-build/node_modules/next/dist/client/components/handle-isr-error.js +30 -0
- package/frontend-build/node_modules/next/dist/client/components/hooks-server-context.js +42 -0
- package/frontend-build/node_modules/next/dist/client/components/http-access-fallback/error-boundary.js +125 -0
- package/frontend-build/node_modules/next/dist/client/components/http-access-fallback/http-access-fallback.js +72 -0
- package/frontend-build/node_modules/next/dist/client/components/is-next-router-error.js +23 -0
- package/frontend-build/node_modules/next/dist/client/components/links.js +299 -0
- package/frontend-build/node_modules/next/dist/client/components/match-segments.js +32 -0
- package/frontend-build/node_modules/next/dist/client/components/nav-failure-handler.js +61 -0
- package/frontend-build/node_modules/next/dist/client/components/navigation-devtools.js +126 -0
- package/frontend-build/node_modules/next/dist/client/components/navigation-untracked.js +67 -0
- package/frontend-build/node_modules/next/dist/client/components/navigation.js +225 -0
- package/frontend-build/node_modules/next/dist/client/components/navigation.react-server.js +75 -0
- package/frontend-build/node_modules/next/dist/client/components/not-found.js +42 -0
- package/frontend-build/node_modules/next/dist/client/components/readonly-url-search-params.js +41 -0
- package/frontend-build/node_modules/next/dist/client/components/redirect-boundary.js +107 -0
- package/frontend-build/node_modules/next/dist/client/components/redirect-error.js +43 -0
- package/frontend-build/node_modules/next/dist/client/components/redirect-status-code.js +24 -0
- package/frontend-build/node_modules/next/dist/client/components/redirect.js +91 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/compute-changed-path.js +201 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/create-href-from-url.js +21 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/create-initial-router-state.js +153 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/create-router-cache-key.js +32 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/fetch-server-response.js +457 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/is-navigating-to-new-root-layout.js +59 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/ppr-navigations.js +1341 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/committed-state.js +49 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/find-head-in-cache.js +63 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/has-interception-route-in-current-tree.js +38 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/hmr-refresh-reducer.js +23 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/navigate-reducer.js +56 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/refresh-reducer.js +83 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/restore-reducer.js +62 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/server-action-reducer.js +320 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/reducers/server-patch-reducer.js +58 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/router-reducer-types.js +70 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/router-reducer.js +66 -0
- package/frontend-build/node_modules/next/dist/client/components/router-reducer/set-cache-busting-search-param.js +60 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/bfcache.js +128 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/cache-key.js +28 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/cache-map.js +305 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/cache.js +1933 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/lru.js +152 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/navigation-testing-lock.js +194 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/navigation.js +597 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/optimistic-routes.js +543 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/prefetch.js +31 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/scheduler.js +1249 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/types.js +69 -0
- package/frontend-build/node_modules/next/dist/client/components/segment-cache/vary-path.js +278 -0
- package/frontend-build/node_modules/next/dist/client/components/static-generation-bailout.js +42 -0
- package/frontend-build/node_modules/next/dist/client/components/unauthorized.js +49 -0
- package/frontend-build/node_modules/next/dist/client/components/unrecognized-action-error.js +39 -0
- package/frontend-build/node_modules/next/dist/client/components/unresolved-thenable.js +23 -0
- package/frontend-build/node_modules/next/dist/client/components/unstable-rethrow.browser.js +28 -0
- package/frontend-build/node_modules/next/dist/client/components/unstable-rethrow.js +25 -0
- package/frontend-build/node_modules/next/dist/client/components/unstable-rethrow.server.js +32 -0
- package/frontend-build/node_modules/next/dist/client/components/use-action-queue.js +148 -0
- package/frontend-build/node_modules/next/dist/client/dev/debug-channel.js +72 -0
- package/frontend-build/node_modules/next/dist/client/flight-data-helpers.js +232 -0
- package/frontend-build/node_modules/next/dist/client/has-base-path.js +23 -0
- package/frontend-build/node_modules/next/dist/client/lib/console.js +177 -0
- package/frontend-build/node_modules/next/dist/client/lib/javascript-url.js +32 -0
- package/frontend-build/node_modules/next/dist/client/navigation-build-id.js +53 -0
- package/frontend-build/node_modules/next/dist/client/normalize-trailing-slash.js +36 -0
- package/frontend-build/node_modules/next/dist/client/remove-base-path.js +32 -0
- package/frontend-build/node_modules/next/dist/client/route-params.js +230 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js +339 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/cookies/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/ponyfill/index.js +46 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/ponyfill/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/abort-controller.js.text.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/console.js.text.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/events.js.text.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/index.js +5 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/load.js +18713 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/stream.js +44 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/timers.js.text.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@edge-runtime/primitives/url.js.text.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@hapi/accept/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@hapi/accept/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@mswjs/interceptors/ClientRequest/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@mswjs/interceptors/ClientRequest/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@napi-rs/triples/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@napi-rs/triples/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@opentelemetry/api/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/@opentelemetry/api/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/async-retry/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/async-retry/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/async-sema/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/async-sema/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/busboy/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/busboy/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/bytes/index.js +8 -0
- package/frontend-build/node_modules/next/dist/compiled/bytes/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/ci-info/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/ci-info/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/commander/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/commander/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/comment-json/index.js +7 -0
- package/frontend-build/node_modules/next/dist/compiled/comment-json/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/compression/index.js +58 -0
- package/frontend-build/node_modules/next/dist/compiled/compression/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/conf/index.js +15 -0
- package/frontend-build/node_modules/next/dist/compiled/conf/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/content-disposition/index.js +6 -0
- package/frontend-build/node_modules/next/dist/compiled/content-disposition/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/cookie/index.js +7 -0
- package/frontend-build/node_modules/next/dist/compiled/cookie/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/cross-spawn/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/cross-spawn/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/debug/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/debug/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/edge-runtime/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/edge-runtime/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/find-up/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/find-up/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/fresh/index.js +8 -0
- package/frontend-build/node_modules/next/dist/compiled/fresh/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/http-proxy/index.js +34 -0
- package/frontend-build/node_modules/next/dist/compiled/http-proxy/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/image-detector/detector.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/image-size/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/image-size/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/ipaddr.js/ipaddr.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/ipaddr.js/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/is-animated/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/is-animated/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/is-docker/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/is-docker/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/is-wsl/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/is-wsl/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/jsonwebtoken/index.js +11 -0
- package/frontend-build/node_modules/next/dist/compiled/jsonwebtoken/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/nanoid/index.cjs +1 -0
- package/frontend-build/node_modules/next/dist/compiled/nanoid/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +54 -0
- package/frontend-build/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +54 -0
- package/frontend-build/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +6 -0
- package/frontend-build/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +20 -0
- package/frontend-build/node_modules/next/dist/compiled/p-limit/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/p-limit/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/p-queue/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/p-queue/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/path-browserify/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/path-browserify/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/path-to-regexp/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/path-to-regexp/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/picomatch/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/picomatch/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/react-is/cjs/react-is.development.js +133 -0
- package/frontend-build/node_modules/next/dist/compiled/react-is/cjs/react-is.production.js +130 -0
- package/frontend-build/node_modules/next/dist/compiled/react-is/index.js +7 -0
- package/frontend-build/node_modules/next/dist/compiled/react-is/package.json +26 -0
- package/frontend-build/node_modules/next/dist/compiled/regenerator-runtime/package.json +19 -0
- package/frontend-build/node_modules/next/dist/compiled/regenerator-runtime/runtime.js +729 -0
- package/frontend-build/node_modules/next/dist/compiled/semver/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/semver/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/send/index.js +70 -0
- package/frontend-build/node_modules/next/dist/compiled/send/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/source-map/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/source-map/source-map.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/stacktrace-parser/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/stacktrace-parser/stack-trace-parser.cjs.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/string-hash/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/string-hash/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/strip-ansi/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/strip-ansi/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/superstruct/index.cjs +1 -0
- package/frontend-build/node_modules/next/dist/compiled/superstruct/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/tar/index.min.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/tar/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/text-table/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/text-table/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/watchpack/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/watchpack/watchpack.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/ws/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/ws/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/zod/index.cjs +1 -0
- package/frontend-build/node_modules/next/dist/compiled/zod/package.json +1 -0
- package/frontend-build/node_modules/next/dist/compiled/zod-validation-error/index.js +1 -0
- package/frontend-build/node_modules/next/dist/compiled/zod-validation-error/package.json +1 -0
- package/frontend-build/node_modules/next/dist/experimental/testmode/context.js +57 -0
- package/frontend-build/node_modules/next/dist/experimental/testmode/fetch.js +142 -0
- package/frontend-build/node_modules/next/dist/experimental/testmode/httpget.js +26 -0
- package/frontend-build/node_modules/next/dist/experimental/testmode/server-edge.js +32 -0
- package/frontend-build/node_modules/next/dist/experimental/testmode/server.js +62 -0
- package/frontend-build/node_modules/next/dist/export/helpers/create-incremental-cache.js +61 -0
- package/frontend-build/node_modules/next/dist/lib/batcher.js +65 -0
- package/frontend-build/node_modules/next/dist/lib/build-custom-route.js +46 -0
- package/frontend-build/node_modules/next/dist/lib/bundler.js +97 -0
- package/frontend-build/node_modules/next/dist/lib/client-and-server-references.js +54 -0
- package/frontend-build/node_modules/next/dist/lib/coalesced-function.js +39 -0
- package/frontend-build/node_modules/next/dist/lib/compile-error.js +14 -0
- package/frontend-build/node_modules/next/dist/lib/constants.js +420 -0
- package/frontend-build/node_modules/next/dist/lib/create-client-router-filter.js +67 -0
- package/frontend-build/node_modules/next/dist/lib/default-transpiled-packages.json +1 -0
- package/frontend-build/node_modules/next/dist/lib/detached-promise.js +32 -0
- package/frontend-build/node_modules/next/dist/lib/detect-typo.js +51 -0
- package/frontend-build/node_modules/next/dist/lib/download-swc.js +183 -0
- package/frontend-build/node_modules/next/dist/lib/error-telemetry-utils.js +42 -0
- package/frontend-build/node_modules/next/dist/lib/fallback.js +100 -0
- package/frontend-build/node_modules/next/dist/lib/fatal-error.js +14 -0
- package/frontend-build/node_modules/next/dist/lib/file-exists.js +53 -0
- package/frontend-build/node_modules/next/dist/lib/find-config.js +102 -0
- package/frontend-build/node_modules/next/dist/lib/find-pages-dir.js +65 -0
- package/frontend-build/node_modules/next/dist/lib/find-root.js +126 -0
- package/frontend-build/node_modules/next/dist/lib/format-cli-help-output.js +84 -0
- package/frontend-build/node_modules/next/dist/lib/format-dynamic-import-path.js +24 -0
- package/frontend-build/node_modules/next/dist/lib/format-server-error.js +75 -0
- package/frontend-build/node_modules/next/dist/lib/framework/boundary-components.js +62 -0
- package/frontend-build/node_modules/next/dist/lib/framework/boundary-constants.js +36 -0
- package/frontend-build/node_modules/next/dist/lib/fs/rename.js +87 -0
- package/frontend-build/node_modules/next/dist/lib/fs/write-atomic.js +28 -0
- package/frontend-build/node_modules/next/dist/lib/generate-interception-routes-rewrites.js +52 -0
- package/frontend-build/node_modules/next/dist/lib/get-files-in-dir.js +33 -0
- package/frontend-build/node_modules/next/dist/lib/get-network-host.js +44 -0
- package/frontend-build/node_modules/next/dist/lib/get-package-version.js +118 -0
- package/frontend-build/node_modules/next/dist/lib/get-project-dir.js +51 -0
- package/frontend-build/node_modules/next/dist/lib/has-necessary-dependencies.js +49 -0
- package/frontend-build/node_modules/next/dist/lib/helpers/get-cache-directory.js +66 -0
- package/frontend-build/node_modules/next/dist/lib/helpers/get-npx-command.js +29 -0
- package/frontend-build/node_modules/next/dist/lib/helpers/get-online.js +50 -0
- package/frontend-build/node_modules/next/dist/lib/helpers/get-pkg-manager.js +63 -0
- package/frontend-build/node_modules/next/dist/lib/helpers/get-registry.js +45 -0
- package/frontend-build/node_modules/next/dist/lib/helpers/get-reserved-port.js +116 -0
- package/frontend-build/node_modules/next/dist/lib/helpers/install.js +83 -0
- package/frontend-build/node_modules/next/dist/lib/import-next-warning.js +50 -0
- package/frontend-build/node_modules/next/dist/lib/inline-static-env.js +112 -0
- package/frontend-build/node_modules/next/dist/lib/install-dependencies.js +40 -0
- package/frontend-build/node_modules/next/dist/lib/interop-default.js +16 -0
- package/frontend-build/node_modules/next/dist/lib/is-api-route.js +15 -0
- package/frontend-build/node_modules/next/dist/lib/is-app-page-route.js +15 -0
- package/frontend-build/node_modules/next/dist/lib/is-app-route-route.js +15 -0
- package/frontend-build/node_modules/next/dist/lib/is-edge-runtime.js +16 -0
- package/frontend-build/node_modules/next/dist/lib/is-error.js +78 -0
- package/frontend-build/node_modules/next/dist/lib/is-interception-route-rewrite.js +18 -0
- package/frontend-build/node_modules/next/dist/lib/is-internal-component.js +36 -0
- package/frontend-build/node_modules/next/dist/lib/is-serializable-props.js +106 -0
- package/frontend-build/node_modules/next/dist/lib/known-edge-safe-packages.json +1 -0
- package/frontend-build/node_modules/next/dist/lib/load-custom-routes.js +594 -0
- package/frontend-build/node_modules/next/dist/lib/memory/gc-observer.js +53 -0
- package/frontend-build/node_modules/next/dist/lib/memory/shutdown.js +29 -0
- package/frontend-build/node_modules/next/dist/lib/memory/startup.js +47 -0
- package/frontend-build/node_modules/next/dist/lib/memory/trace.js +109 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/constants.js +40 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/default-metadata.js +82 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/generate/icon-mark.js +22 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/generate/utils.js +52 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/get-metadata-route.js +123 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/is-metadata-route.js +221 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/metadata-context.js +18 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/metadata.js +1686 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/resolve-metadata.js +884 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/resolvers/resolve-basics.js +232 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/resolvers/resolve-icons.js +56 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/resolvers/resolve-opengraph.js +199 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/resolvers/resolve-title.js +40 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/resolvers/resolve-url.js +135 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/alternative-urls-types.js +7 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/extra-types.js +9 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/icons.js +6 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/manifest-types.js +6 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/metadata-interface.js +18 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/metadata-types.js +10 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/opengraph-types.js +6 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/resolvers.js +6 -0
- package/frontend-build/node_modules/next/dist/lib/metadata/types/twitter-types.js +7 -0
- package/frontend-build/node_modules/next/dist/lib/mime-type.js +20 -0
- package/frontend-build/node_modules/next/dist/lib/mkcert.js +204 -0
- package/frontend-build/node_modules/next/dist/lib/multi-file-writer.js +75 -0
- package/frontend-build/node_modules/next/dist/lib/needs-experimental-react.js +16 -0
- package/frontend-build/node_modules/next/dist/lib/non-nullable.js +15 -0
- package/frontend-build/node_modules/next/dist/lib/normalize-path.js +21 -0
- package/frontend-build/node_modules/next/dist/lib/oxford-comma-list.js +15 -0
- package/frontend-build/node_modules/next/dist/lib/page-types.js +18 -0
- package/frontend-build/node_modules/next/dist/lib/patch-incorrect-lockfile.js +185 -0
- package/frontend-build/node_modules/next/dist/lib/pick.js +19 -0
- package/frontend-build/node_modules/next/dist/lib/picocolors.js +177 -0
- package/frontend-build/node_modules/next/dist/lib/pretty-bytes.js +74 -0
- package/frontend-build/node_modules/next/dist/lib/realpath.js +20 -0
- package/frontend-build/node_modules/next/dist/lib/recursive-copy.js +76 -0
- package/frontend-build/node_modules/next/dist/lib/recursive-delete.js +137 -0
- package/frontend-build/node_modules/next/dist/lib/recursive-readdir.js +124 -0
- package/frontend-build/node_modules/next/dist/lib/redirect-status.js +46 -0
- package/frontend-build/node_modules/next/dist/lib/require-instrumentation-client.js +26 -0
- package/frontend-build/node_modules/next/dist/lib/resolve-build-paths.js +154 -0
- package/frontend-build/node_modules/next/dist/lib/resolve-from.js +65 -0
- package/frontend-build/node_modules/next/dist/lib/route-pattern-normalizer.js +107 -0
- package/frontend-build/node_modules/next/dist/lib/scheduler.js +64 -0
- package/frontend-build/node_modules/next/dist/lib/semver-noop.js +18 -0
- package/frontend-build/node_modules/next/dist/lib/server-external-packages.jsonc +103 -0
- package/frontend-build/node_modules/next/dist/lib/setup-exception-listeners.js +11 -0
- package/frontend-build/node_modules/next/dist/lib/static-env.js +92 -0
- package/frontend-build/node_modules/next/dist/lib/try-to-parse-path.js +67 -0
- package/frontend-build/node_modules/next/dist/lib/turbopack-warning.js +185 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/diagnosticFormatter.js +243 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/getTypeScriptConfiguration.js +153 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/getTypeScriptIntent.js +52 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/missingDependencyError.js +27 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/runTypeCheck.js +149 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/type-paths.js +51 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/writeAppTypeDeclarations.js +75 -0
- package/frontend-build/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js +395 -0
- package/frontend-build/node_modules/next/dist/lib/url.js +75 -0
- package/frontend-build/node_modules/next/dist/lib/verify-partytown-setup.js +115 -0
- package/frontend-build/node_modules/next/dist/lib/verify-root-layout.js +165 -0
- package/frontend-build/node_modules/next/dist/lib/verify-typescript-setup.js +228 -0
- package/frontend-build/node_modules/next/dist/lib/wait.js +19 -0
- package/frontend-build/node_modules/next/dist/lib/with-promise-cache.js +24 -0
- package/frontend-build/node_modules/next/dist/lib/worker.js +234 -0
- package/frontend-build/node_modules/next/dist/server/ReactDOMServerPages.js +16 -0
- package/frontend-build/node_modules/next/dist/server/accept-header.js +132 -0
- package/frontend-build/node_modules/next/dist/server/after/after-context.js +140 -0
- package/frontend-build/node_modules/next/dist/server/after/after.js +26 -0
- package/frontend-build/node_modules/next/dist/server/after/awaiter.js +74 -0
- package/frontend-build/node_modules/next/dist/server/after/builtin-request-context.js +38 -0
- package/frontend-build/node_modules/next/dist/server/after/index.js +21 -0
- package/frontend-build/node_modules/next/dist/server/after/run-with-after.js +35 -0
- package/frontend-build/node_modules/next/dist/server/api-utils/get-cookie-parser.js +22 -0
- package/frontend-build/node_modules/next/dist/server/api-utils/index.js +201 -0
- package/frontend-build/node_modules/next/dist/server/api-utils/node/api-resolver.js +395 -0
- package/frontend-build/node_modules/next/dist/server/api-utils/node/parse-body.js +79 -0
- package/frontend-build/node_modules/next/dist/server/api-utils/node/try-get-preview-data.js +86 -0
- package/frontend-build/node_modules/next/dist/server/api-utils/web.js +17 -0
- package/frontend-build/node_modules/next/dist/server/app-render/action-async-storage-instance.js +14 -0
- package/frontend-build/node_modules/next/dist/server/app-render/action-async-storage.external.js +13 -0
- package/frontend-build/node_modules/next/dist/server/app-render/action-handler.js +1020 -0
- package/frontend-build/node_modules/next/dist/server/app-render/after-task-async-storage-instance.js +14 -0
- package/frontend-build/node_modules/next/dist/server/app-render/after-task-async-storage.external.js +13 -0
- package/frontend-build/node_modules/next/dist/server/app-render/app-render-prerender-utils.js +167 -0
- package/frontend-build/node_modules/next/dist/server/app-render/app-render-render-utils.js +76 -0
- package/frontend-build/node_modules/next/dist/server/app-render/app-render-scheduling.js +188 -0
- package/frontend-build/node_modules/next/dist/server/app-render/app-render.js +4469 -0
- package/frontend-build/node_modules/next/dist/server/app-render/async-local-storage.js +76 -0
- package/frontend-build/node_modules/next/dist/server/app-render/cache-signal.js +181 -0
- package/frontend-build/node_modules/next/dist/server/app-render/collect-segment-data.js +600 -0
- package/frontend-build/node_modules/next/dist/server/app-render/console-async-storage-instance.js +14 -0
- package/frontend-build/node_modules/next/dist/server/app-render/console-async-storage.external.js +13 -0
- package/frontend-build/node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js +33 -0
- package/frontend-build/node_modules/next/dist/server/app-render/create-component-tree.js +840 -0
- package/frontend-build/node_modules/next/dist/server/app-render/create-error-handler.js +189 -0
- package/frontend-build/node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.js +102 -0
- package/frontend-build/node_modules/next/dist/server/app-render/csrf-protection.js +86 -0
- package/frontend-build/node_modules/next/dist/server/app-render/debug-channel-server.js +30 -0
- package/frontend-build/node_modules/next/dist/server/app-render/debug-channel-server.web.js +71 -0
- package/frontend-build/node_modules/next/dist/server/app-render/dynamic-access-async-storage-instance.js +14 -0
- package/frontend-build/node_modules/next/dist/server/app-render/dynamic-access-async-storage.external.js +13 -0
- package/frontend-build/node_modules/next/dist/server/app-render/dynamic-rendering.js +1144 -0
- package/frontend-build/node_modules/next/dist/server/app-render/encryption-utils-server.js +114 -0
- package/frontend-build/node_modules/next/dist/server/app-render/encryption-utils.js +93 -0
- package/frontend-build/node_modules/next/dist/server/app-render/encryption.js +259 -0
- package/frontend-build/node_modules/next/dist/server/app-render/entry-base.js +256 -0
- package/frontend-build/node_modules/next/dist/server/app-render/flight-render-result.js +28 -0
- package/frontend-build/node_modules/next/dist/server/app-render/get-asset-query-string.js +29 -0
- package/frontend-build/node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js +49 -0
- package/frontend-build/node_modules/next/dist/server/app-render/get-layer-assets.js +65 -0
- package/frontend-build/node_modules/next/dist/server/app-render/get-preloadable-fonts.js +39 -0
- package/frontend-build/node_modules/next/dist/server/app-render/get-script-nonce-from-header.js +44 -0
- package/frontend-build/node_modules/next/dist/server/app-render/get-short-dynamic-param-type.js +25 -0
- package/frontend-build/node_modules/next/dist/server/app-render/has-loading-component-in-tree.js +19 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/boundary-constants.js +13 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/boundary-impl.js +103 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/boundary-tracking.js +18 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/instant-config.js +181 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/instant-samples-client.js +128 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/instant-samples.js +432 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/instant-validation-error.js +33 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/instant-validation.js +713 -0
- package/frontend-build/node_modules/next/dist/server/app-render/instant-validation/stream-utils.js +96 -0
- package/frontend-build/node_modules/next/dist/server/app-render/interop-default.js +17 -0
- package/frontend-build/node_modules/next/dist/server/app-render/make-get-server-inserted-html.js +92 -0
- package/frontend-build/node_modules/next/dist/server/app-render/manifests-singleton.js +264 -0
- package/frontend-build/node_modules/next/dist/server/app-render/metadata-insertion/create-server-inserted-metadata.js +28 -0
- package/frontend-build/node_modules/next/dist/server/app-render/module-loading/track-dynamic-import.js +57 -0
- package/frontend-build/node_modules/next/dist/server/app-render/module-loading/track-module-loading.external.js +32 -0
- package/frontend-build/node_modules/next/dist/server/app-render/module-loading/track-module-loading.instance.js +66 -0
- package/frontend-build/node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.js +49 -0
- package/frontend-build/node_modules/next/dist/server/app-render/postponed-state.js +157 -0
- package/frontend-build/node_modules/next/dist/server/app-render/prospective-render-utils.js +74 -0
- package/frontend-build/node_modules/next/dist/server/app-render/react-large-shell-error.js +17 -0
- package/frontend-build/node_modules/next/dist/server/app-render/react-server.node.js +39 -0
- package/frontend-build/node_modules/next/dist/server/app-render/render-css-resource.js +52 -0
- package/frontend-build/node_modules/next/dist/server/app-render/required-scripts.js +76 -0
- package/frontend-build/node_modules/next/dist/server/app-render/rsc/postpone.js +18 -0
- package/frontend-build/node_modules/next/dist/server/app-render/rsc/preloads.js +74 -0
- package/frontend-build/node_modules/next/dist/server/app-render/rsc/taint.js +79 -0
- package/frontend-build/node_modules/next/dist/server/app-render/segment-explorer-path.js +128 -0
- package/frontend-build/node_modules/next/dist/server/app-render/server-inserted-html.js +77 -0
- package/frontend-build/node_modules/next/dist/server/app-render/staged-rendering.js +343 -0
- package/frontend-build/node_modules/next/dist/server/app-render/stale-time.js +111 -0
- package/frontend-build/node_modules/next/dist/server/app-render/stream-ops.js +106 -0
- package/frontend-build/node_modules/next/dist/server/app-render/stream-ops.web.js +163 -0
- package/frontend-build/node_modules/next/dist/server/app-render/strip-flight-headers.js +18 -0
- package/frontend-build/node_modules/next/dist/server/app-render/types.js +65 -0
- package/frontend-build/node_modules/next/dist/server/app-render/use-flight-response.js +214 -0
- package/frontend-build/node_modules/next/dist/server/app-render/vary-params.js +336 -0
- package/frontend-build/node_modules/next/dist/server/app-render/walk-tree-with-flight-router-state.js +232 -0
- package/frontend-build/node_modules/next/dist/server/app-render/work-async-storage-instance.js +14 -0
- package/frontend-build/node_modules/next/dist/server/app-render/work-async-storage.external.js +13 -0
- package/frontend-build/node_modules/next/dist/server/app-render/work-unit-async-storage-instance.js +14 -0
- package/frontend-build/node_modules/next/dist/server/app-render/work-unit-async-storage.external.js +280 -0
- package/frontend-build/node_modules/next/dist/server/async-storage/draft-mode-provider.js +62 -0
- package/frontend-build/node_modules/next/dist/server/async-storage/request-store.js +144 -0
- package/frontend-build/node_modules/next/dist/server/async-storage/with-store.js +6 -0
- package/frontend-build/node_modules/next/dist/server/async-storage/work-store.js +91 -0
- package/frontend-build/node_modules/next/dist/server/base-http/helpers.js +36 -0
- package/frontend-build/node_modules/next/dist/server/base-http/index.js +54 -0
- package/frontend-build/node_modules/next/dist/server/base-http/node.js +147 -0
- package/frontend-build/node_modules/next/dist/server/base-http/web.js +124 -0
- package/frontend-build/node_modules/next/dist/server/base-server.js +1874 -0
- package/frontend-build/node_modules/next/dist/server/body-streams.js +114 -0
- package/frontend-build/node_modules/next/dist/server/cache-dir.js +26 -0
- package/frontend-build/node_modules/next/dist/server/capsize-font-metrics.json +181516 -0
- package/frontend-build/node_modules/next/dist/server/ci-info.js +41 -0
- package/frontend-build/node_modules/next/dist/server/client-component-renderer-logger.js +70 -0
- package/frontend-build/node_modules/next/dist/server/config-schema.js +718 -0
- package/frontend-build/node_modules/next/dist/server/config-shared.js +369 -0
- package/frontend-build/node_modules/next/dist/server/config-utils.js +185 -0
- package/frontend-build/node_modules/next/dist/server/config.js +1545 -0
- package/frontend-build/node_modules/next/dist/server/create-deduped-by-callsite-server-error-logger.js +96 -0
- package/frontend-build/node_modules/next/dist/server/crypto-utils.js +70 -0
- package/frontend-build/node_modules/next/dist/server/dev/browser-logs/file-logger.js +186 -0
- package/frontend-build/node_modules/next/dist/server/dev/browser-logs/receive-logs.js +558 -0
- package/frontend-build/node_modules/next/dist/server/dev/browser-logs/source-map.js +222 -0
- package/frontend-build/node_modules/next/dist/server/dev/debug-channel.js +87 -0
- package/frontend-build/node_modules/next/dist/server/dev/dev-indicator-server-state.js +15 -0
- package/frontend-build/node_modules/next/dist/server/dev/get-source-map-from-file.js +100 -0
- package/frontend-build/node_modules/next/dist/server/dev/hot-middleware.js +274 -0
- package/frontend-build/node_modules/next/dist/server/dev/hot-reloader-rspack.js +171 -0
- package/frontend-build/node_modules/next/dist/server/dev/hot-reloader-shared-utils.js +56 -0
- package/frontend-build/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +1480 -0
- package/frontend-build/node_modules/next/dist/server/dev/hot-reloader-types.js +58 -0
- package/frontend-build/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1386 -0
- package/frontend-build/node_modules/next/dist/server/dev/log-requests.js +149 -0
- package/frontend-build/node_modules/next/dist/server/dev/messages.js +74 -0
- package/frontend-build/node_modules/next/dist/server/dev/middleware-turbopack.js +403 -0
- package/frontend-build/node_modules/next/dist/server/dev/middleware-webpack.js +483 -0
- package/frontend-build/node_modules/next/dist/server/dev/node-stack-frames.js +72 -0
- package/frontend-build/node_modules/next/dist/server/dev/on-demand-entry-handler.js +773 -0
- package/frontend-build/node_modules/next/dist/server/dev/parse-version-info.js +108 -0
- package/frontend-build/node_modules/next/dist/server/dev/require-cache.js +79 -0
- package/frontend-build/node_modules/next/dist/server/dev/serialized-errors.js +67 -0
- package/frontend-build/node_modules/next/dist/server/dev/server-action-logger.js +37 -0
- package/frontend-build/node_modules/next/dist/server/dev/static-paths-worker.js +104 -0
- package/frontend-build/node_modules/next/dist/server/dev/turbopack-utils.js +687 -0
- package/frontend-build/node_modules/next/dist/server/dynamic-rendering-utils.js +108 -0
- package/frontend-build/node_modules/next/dist/server/font-utils.js +43 -0
- package/frontend-build/node_modules/next/dist/server/get-app-route-from-entrypoint.js +30 -0
- package/frontend-build/node_modules/next/dist/server/get-page-files.js +23 -0
- package/frontend-build/node_modules/next/dist/server/get-route-from-entrypoint.js +35 -0
- package/frontend-build/node_modules/next/dist/server/htmlescape.js +37 -0
- package/frontend-build/node_modules/next/dist/server/image-optimizer.js +1220 -0
- package/frontend-build/node_modules/next/dist/server/instrumentation/types.js +6 -0
- package/frontend-build/node_modules/next/dist/server/instrumentation/utils.js +21 -0
- package/frontend-build/node_modules/next/dist/server/internal-utils.js +39 -0
- package/frontend-build/node_modules/next/dist/server/is-private-ip.js +36 -0
- package/frontend-build/node_modules/next/dist/server/lib/app-dir-module.js +59 -0
- package/frontend-build/node_modules/next/dist/server/lib/app-info-log.js +132 -0
- package/frontend-build/node_modules/next/dist/server/lib/async-callback-set.js +29 -0
- package/frontend-build/node_modules/next/dist/server/lib/cache-control.js +22 -0
- package/frontend-build/node_modules/next/dist/server/lib/cache-handlers/default.external.js +18 -0
- package/frontend-build/node_modules/next/dist/server/lib/cache-handlers/default.js +160 -0
- package/frontend-build/node_modules/next/dist/server/lib/cache-handlers/types.js +8 -0
- package/frontend-build/node_modules/next/dist/server/lib/chrome-devtools-workspace.js +116 -0
- package/frontend-build/node_modules/next/dist/server/lib/clone-response.js +77 -0
- package/frontend-build/node_modules/next/dist/server/lib/cpu-profile.js +59 -0
- package/frontend-build/node_modules/next/dist/server/lib/decode-query-path-parameter.js +26 -0
- package/frontend-build/node_modules/next/dist/server/lib/dedupe-fetch.js +163 -0
- package/frontend-build/node_modules/next/dist/server/lib/dev-bundler-service.js +95 -0
- package/frontend-build/node_modules/next/dist/server/lib/disk-lru-cache.external.js +57 -0
- package/frontend-build/node_modules/next/dist/server/lib/etag.js +56 -0
- package/frontend-build/node_modules/next/dist/server/lib/experimental/create-env-definitions.js +48 -0
- package/frontend-build/node_modules/next/dist/server/lib/experimental/ppr.js +47 -0
- package/frontend-build/node_modules/next/dist/server/lib/find-page-file.js +147 -0
- package/frontend-build/node_modules/next/dist/server/lib/fix-mojibake.js +25 -0
- package/frontend-build/node_modules/next/dist/server/lib/format-hostname.js +16 -0
- package/frontend-build/node_modules/next/dist/server/lib/i18n-provider.js +129 -0
- package/frontend-build/node_modules/next/dist/server/lib/implicit-tags.js +77 -0
- package/frontend-build/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +335 -0
- package/frontend-build/node_modules/next/dist/server/lib/incremental-cache/index.js +501 -0
- package/frontend-build/node_modules/next/dist/server/lib/incremental-cache/memory-cache.external.js +57 -0
- package/frontend-build/node_modules/next/dist/server/lib/incremental-cache/shared-cache-controls.external.js +73 -0
- package/frontend-build/node_modules/next/dist/server/lib/incremental-cache/tags-manifest.external.js +55 -0
- package/frontend-build/node_modules/next/dist/server/lib/install-code-frame.js +22 -0
- package/frontend-build/node_modules/next/dist/server/lib/is-ipv6.js +41 -0
- package/frontend-build/node_modules/next/dist/server/lib/lazy-result.js +46 -0
- package/frontend-build/node_modules/next/dist/server/lib/lru-cache.js +191 -0
- package/frontend-build/node_modules/next/dist/server/lib/match-next-data-pathname.js +18 -0
- package/frontend-build/node_modules/next/dist/server/lib/mock-request.js +416 -0
- package/frontend-build/node_modules/next/dist/server/lib/module-loader/module-loader.js +8 -0
- package/frontend-build/node_modules/next/dist/server/lib/module-loader/node-module-loader.js +25 -0
- package/frontend-build/node_modules/next/dist/server/lib/module-loader/route-module-loader.js +26 -0
- package/frontend-build/node_modules/next/dist/server/lib/node-fs-methods.js +28 -0
- package/frontend-build/node_modules/next/dist/server/lib/parse-stack.js +46 -0
- package/frontend-build/node_modules/next/dist/server/lib/patch-fetch.js +978 -0
- package/frontend-build/node_modules/next/dist/server/lib/patch-set-header.js +38 -0
- package/frontend-build/node_modules/next/dist/server/lib/postponed-request-body.js +64 -0
- package/frontend-build/node_modules/next/dist/server/lib/render-server.js +155 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-server.js +696 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/block-cross-site-dev.js +110 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/build-data-route.js +48 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/build-prefetch-segment-data-route.js +50 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/cache-life-type-utils.js +211 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/decode-path-params.js +42 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/filesystem.js +591 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/instrumentation-globals.external.js +89 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/instrumentation-node-extensions.js +96 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/is-postpone.js +16 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/proxy-request.js +118 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/resolve-routes.js +629 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/route-types-utils.js +286 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/router-server-context.js +26 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/typegen.js +858 -0
- package/frontend-build/node_modules/next/dist/server/lib/router-utils/types.js +6 -0
- package/frontend-build/node_modules/next/dist/server/lib/server-action-request-meta.js +53 -0
- package/frontend-build/node_modules/next/dist/server/lib/server-ipc/utils.js +81 -0
- package/frontend-build/node_modules/next/dist/server/lib/source-maps.js +196 -0
- package/frontend-build/node_modules/next/dist/server/lib/start-server.js +494 -0
- package/frontend-build/node_modules/next/dist/server/lib/streaming-metadata.js +38 -0
- package/frontend-build/node_modules/next/dist/server/lib/to-route.js +37 -0
- package/frontend-build/node_modules/next/dist/server/lib/trace/constants.js +203 -0
- package/frontend-build/node_modules/next/dist/server/lib/trace/tracer.js +280 -0
- package/frontend-build/node_modules/next/dist/server/lib/trace/utils.js +16 -0
- package/frontend-build/node_modules/next/dist/server/lib/types.js +6 -0
- package/frontend-build/node_modules/next/dist/server/lib/utils.js +278 -0
- package/frontend-build/node_modules/next/dist/server/lib/worker-utils.js +36 -0
- package/frontend-build/node_modules/next/dist/server/load-components.js +179 -0
- package/frontend-build/node_modules/next/dist/server/load-default-error-components.js +41 -0
- package/frontend-build/node_modules/next/dist/server/load-manifest.external.js +117 -0
- package/frontend-build/node_modules/next/dist/server/match-bundle.js +25 -0
- package/frontend-build/node_modules/next/dist/server/mcp/get-mcp-middleware.js +49 -0
- package/frontend-build/node_modules/next/dist/server/mcp/get-or-create-mcp-server.js +41 -0
- package/frontend-build/node_modules/next/dist/server/mcp/mcp-telemetry-tracker.js +82 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/get-errors.js +114 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/get-logs.js +67 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/get-page-metadata.js +188 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/get-project-metadata.js +59 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/get-routes.js +136 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/get-server-action-by-id.js +121 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/next-instance-error-state.js +31 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/utils/browser-communication.js +90 -0
- package/frontend-build/node_modules/next/dist/server/mcp/tools/utils/format-errors.js +137 -0
- package/frontend-build/node_modules/next/dist/server/next-server.js +1429 -0
- package/frontend-build/node_modules/next/dist/server/next-typescript.js +13 -0
- package/frontend-build/node_modules/next/dist/server/next.js +455 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-baseline.js +25 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/console-dim.external.js +301 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/console-exit.js +49 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/console-file.js +56 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/date.js +52 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/error-inspect.js +8 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/fast-set-immediate.external.js +577 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/global-behaviors.js +33 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/io-utils.js +195 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/node-crypto.js +103 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/process-error-handlers.js +91 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/random.js +28 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/unhandled-rejection.external.js +508 -0
- package/frontend-build/node_modules/next/dist/server/node-environment-extensions/web-crypto.js +45 -0
- package/frontend-build/node_modules/next/dist/server/node-environment.js +19 -0
- package/frontend-build/node_modules/next/dist/server/node-polyfill-crypto.js +21 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/absolute-filename-normalizer.js +33 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/app/app-bundle-path-normalizer.js +54 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/app/app-filename-normalizer.js +22 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/app/app-page-normalizer.js +40 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/app/app-pathname-normalizer.js +55 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/app/index.js +42 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/pages/index.js +44 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/pages/pages-bundle-path-normalizer.js +55 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/pages/pages-filename-normalizer.js +22 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/pages/pages-page-normalizer.js +19 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/built/pages/pages-pathname-normalizer.js +19 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/locale-route-normalizer.js +26 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/normalizer.js +6 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/normalizers.js +23 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/prefixing-normalizer.js +26 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/request/base-path.js +25 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/request/next-data.js +38 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/request/pathname-normalizer.js +6 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/request/prefix.js +39 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/request/rsc.js +19 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/request/segment-prefix-rsc.js +33 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/request/suffix.js +27 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/underscore-normalizer.js +17 -0
- package/frontend-build/node_modules/next/dist/server/normalizers/wrap-normalizer-fn.js +17 -0
- package/frontend-build/node_modules/next/dist/server/og/image-response.js +53 -0
- package/frontend-build/node_modules/next/dist/server/patch-error-inspect.js +453 -0
- package/frontend-build/node_modules/next/dist/server/pipe-readable.js +140 -0
- package/frontend-build/node_modules/next/dist/server/post-process.js +39 -0
- package/frontend-build/node_modules/next/dist/server/render-result.js +204 -0
- package/frontend-build/node_modules/next/dist/server/render.js +1141 -0
- package/frontend-build/node_modules/next/dist/server/request/connection.js +133 -0
- package/frontend-build/node_modules/next/dist/server/request/cookies.js +235 -0
- package/frontend-build/node_modules/next/dist/server/request/draft-mode.js +230 -0
- package/frontend-build/node_modules/next/dist/server/request/fallback-params.js +69 -0
- package/frontend-build/node_modules/next/dist/server/request/headers.js +229 -0
- package/frontend-build/node_modules/next/dist/server/request/params.js +527 -0
- package/frontend-build/node_modules/next/dist/server/request/pathname.js +119 -0
- package/frontend-build/node_modules/next/dist/server/request/root-params.js +194 -0
- package/frontend-build/node_modules/next/dist/server/request/search-params.js +526 -0
- package/frontend-build/node_modules/next/dist/server/request/utils.js +51 -0
- package/frontend-build/node_modules/next/dist/server/request-meta.js +55 -0
- package/frontend-build/node_modules/next/dist/server/require-hook.js +82 -0
- package/frontend-build/node_modules/next/dist/server/require.js +109 -0
- package/frontend-build/node_modules/next/dist/server/response-cache/index.js +311 -0
- package/frontend-build/node_modules/next/dist/server/response-cache/types.js +41 -0
- package/frontend-build/node_modules/next/dist/server/response-cache/utils.js +104 -0
- package/frontend-build/node_modules/next/dist/server/response-cache/web.js +101 -0
- package/frontend-build/node_modules/next/dist/server/resume-data-cache/cache-store.js +96 -0
- package/frontend-build/node_modules/next/dist/server/resume-data-cache/resume-data-cache.js +124 -0
- package/frontend-build/node_modules/next/dist/server/revalidation-utils.js +157 -0
- package/frontend-build/node_modules/next/dist/server/route-definitions/app-page-route-definition.js +16 -0
- package/frontend-build/node_modules/next/dist/server/route-definitions/app-route-route-definition.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-definitions/locale-route-definition.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-definitions/pages-api-route-definition.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-definitions/pages-route-definition.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-definitions/route-definition.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-kind.js +32 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-managers/default-route-matcher-manager.js +239 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-managers/dev-route-matcher-manager.js +120 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-managers/route-matcher-manager.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/app-page-route-matcher-provider.js +55 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/app-route-route-matcher-provider.js +43 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.js +91 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/dev-app-route-route-matcher-provider.js +112 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.js +77 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/dev-pages-route-matcher-provider.js +77 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/file-cache-route-matcher-provider.js +28 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.js +106 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/default-file-reader.js +42 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/file-reader.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/helpers/cached-route-matcher-provider.js +30 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/manifest-loader.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.js +34 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.js +20 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/manifest-route-matcher-provider.js +21 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/pages-api-route-matcher-provider.js +55 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/pages-route-matcher-provider.js +64 -0
- package/frontend-build/node_modules/next/dist/server/route-matcher-providers/route-matcher-provider.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matchers/app-page-route-matcher.js +18 -0
- package/frontend-build/node_modules/next/dist/server/route-matchers/app-route-route-matcher.js +15 -0
- package/frontend-build/node_modules/next/dist/server/route-matchers/locale-route-matcher.js +68 -0
- package/frontend-build/node_modules/next/dist/server/route-matchers/pages-api-route-matcher.js +30 -0
- package/frontend-build/node_modules/next/dist/server/route-matchers/pages-route-matcher.js +30 -0
- package/frontend-build/node_modules/next/dist/server/route-matchers/route-matcher.js +54 -0
- package/frontend-build/node_modules/next/dist/server/route-matches/app-page-route-match.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matches/app-route-route-match.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matches/locale-route-match.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matches/pages-api-route-match.js +16 -0
- package/frontend-build/node_modules/next/dist/server/route-matches/pages-route-match.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-matches/route-match.js +6 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/helpers/prerender-manifest-matcher.js +51 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/module.compiled.js +36 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/module.js +162 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/module.render.js +24 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/normalize-request-url.js +25 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/app-router-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/entrypoints.js +87 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/head-manager-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/hooks-client-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/image-config-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/router-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/contexts/server-inserted-html.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/entrypoints.js +140 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-compiler-runtime.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-dom.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-jsx-dev-runtime.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-jsx-runtime.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-static.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-webpack-server.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react-server-dom-webpack-static.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/react.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/entrypoints.js +125 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-compiler-runtime.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-dom-server.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-dom.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-dev-runtime.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-runtime.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-server-dom-turbopack-client.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-server-dom-webpack-client.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/helpers/auto-implement-methods.js +85 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/helpers/clean-url.js +24 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.js +29 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/helpers/is-static-gen-enabled.js +15 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/helpers/parsed-url-query-to-params.js +20 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/module.compiled.js +36 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/module.js +914 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/app-route/shared-modules.js +56 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/checks.js +45 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/builtin/_error.js +100 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/module.compiled.js +20 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/module.js +92 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/module.render.js +24 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/pages-handler.js +545 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/app-router-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/entrypoints.js +102 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/head-manager-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/hooks-client-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/html-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/image-config-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/loadable-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/loadable.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/router-context.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages/vendored/contexts/server-inserted-html.js +4 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages-api/module.compiled.js +20 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/pages-api/module.js +58 -0
- package/frontend-build/node_modules/next/dist/server/route-modules/route-module.js +650 -0
- package/frontend-build/node_modules/next/dist/server/runtime-reacts.external.js +46 -0
- package/frontend-build/node_modules/next/dist/server/send-payload.js +88 -0
- package/frontend-build/node_modules/next/dist/server/send-response.js +70 -0
- package/frontend-build/node_modules/next/dist/server/serve-static.js +66 -0
- package/frontend-build/node_modules/next/dist/server/server-route-utils.js +30 -0
- package/frontend-build/node_modules/next/dist/server/server-utils.js +323 -0
- package/frontend-build/node_modules/next/dist/server/setup-http-agent-env.js +31 -0
- package/frontend-build/node_modules/next/dist/server/stream-utils/encoded-tags.js +122 -0
- package/frontend-build/node_modules/next/dist/server/stream-utils/node-web-streams-helper.js +918 -0
- package/frontend-build/node_modules/next/dist/server/stream-utils/uint8array-helpers.js +74 -0
- package/frontend-build/node_modules/next/dist/server/typescript/constant.js +98 -0
- package/frontend-build/node_modules/next/dist/server/typescript/index.js +199 -0
- package/frontend-build/node_modules/next/dist/server/typescript/rules/client-boundary.js +97 -0
- package/frontend-build/node_modules/next/dist/server/typescript/rules/config.js +512 -0
- package/frontend-build/node_modules/next/dist/server/typescript/rules/entry.js +149 -0
- package/frontend-build/node_modules/next/dist/server/typescript/rules/error.js +38 -0
- package/frontend-build/node_modules/next/dist/server/typescript/rules/metadata.js +234 -0
- package/frontend-build/node_modules/next/dist/server/typescript/rules/server-boundary.js +115 -0
- package/frontend-build/node_modules/next/dist/server/typescript/rules/server.js +79 -0
- package/frontend-build/node_modules/next/dist/server/typescript/utils.js +212 -0
- package/frontend-build/node_modules/next/dist/server/use-cache/cache-life.js +163 -0
- package/frontend-build/node_modules/next/dist/server/use-cache/cache-tag.js +52 -0
- package/frontend-build/node_modules/next/dist/server/use-cache/constants.js +28 -0
- package/frontend-build/node_modules/next/dist/server/use-cache/handlers.js +121 -0
- package/frontend-build/node_modules/next/dist/server/use-cache/use-cache-errors.js +36 -0
- package/frontend-build/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +1588 -0
- package/frontend-build/node_modules/next/dist/server/utils.js +73 -0
- package/frontend-build/node_modules/next/dist/server/web/adapter.js +392 -0
- package/frontend-build/node_modules/next/dist/server/web/edge-route-module-wrapper.js +123 -0
- package/frontend-build/node_modules/next/dist/server/web/error.js +54 -0
- package/frontend-build/node_modules/next/dist/server/web/exports/index.js +56 -0
- package/frontend-build/node_modules/next/dist/server/web/get-edge-preview-props.js +23 -0
- package/frontend-build/node_modules/next/dist/server/web/globals.js +128 -0
- package/frontend-build/node_modules/next/dist/server/web/http.js +39 -0
- package/frontend-build/node_modules/next/dist/server/web/internal-edge-wait-until.js +64 -0
- package/frontend-build/node_modules/next/dist/server/web/next-url.js +199 -0
- package/frontend-build/node_modules/next/dist/server/web/sandbox/context.js +462 -0
- package/frontend-build/node_modules/next/dist/server/web/sandbox/fetch-inline-assets.js +35 -0
- package/frontend-build/node_modules/next/dist/server/web/sandbox/index.js +28 -0
- package/frontend-build/node_modules/next/dist/server/web/sandbox/resource-managers.js +88 -0
- package/frontend-build/node_modules/next/dist/server/web/sandbox/sandbox.js +137 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/adapters/headers.js +192 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/adapters/next-request.js +142 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/adapters/reflect.js +30 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js +211 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/cookies.js +29 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/fetch-event.js +98 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/image-response.js +22 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/request.js +99 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/response.js +136 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/revalidate.js +214 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/unstable-cache.js +289 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/unstable-no-store.js +51 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/url-pattern.js +14 -0
- package/frontend-build/node_modules/next/dist/server/web/spec-extension/user-agent.js +46 -0
- package/frontend-build/node_modules/next/dist/server/web/types.js +6 -0
- package/frontend-build/node_modules/next/dist/server/web/utils.js +151 -0
- package/frontend-build/node_modules/next/dist/server/web/web-on-close.js +87 -0
- package/frontend-build/node_modules/next/dist/shared/lib/action-revalidation-kind.js +31 -0
- package/frontend-build/node_modules/next/dist/shared/lib/app-router-context.shared-runtime.js +50 -0
- package/frontend-build/node_modules/next/dist/shared/lib/app-router-types.js +46 -0
- package/frontend-build/node_modules/next/dist/shared/lib/constants.js +448 -0
- package/frontend-build/node_modules/next/dist/shared/lib/deep-freeze.js +30 -0
- package/frontend-build/node_modules/next/dist/shared/lib/deployment-id.js +63 -0
- package/frontend-build/node_modules/next/dist/shared/lib/dset.js +34 -0
- package/frontend-build/node_modules/next/dist/shared/lib/encode-uri-path.js +15 -0
- package/frontend-build/node_modules/next/dist/shared/lib/entry-constants.js +36 -0
- package/frontend-build/node_modules/next/dist/shared/lib/error-source.js +36 -0
- package/frontend-build/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +39 -0
- package/frontend-build/node_modules/next/dist/shared/lib/errors/code-frame.js +20 -0
- package/frontend-build/node_modules/next/dist/shared/lib/errors/constants.js +19 -0
- package/frontend-build/node_modules/next/dist/shared/lib/errors/empty-generate-static-params-error.js +24 -0
- package/frontend-build/node_modules/next/dist/shared/lib/errors/hard-deprecated-config-error.js +20 -0
- package/frontend-build/node_modules/next/dist/shared/lib/escape-regexp.js +22 -0
- package/frontend-build/node_modules/next/dist/shared/lib/get-hostname.js +23 -0
- package/frontend-build/node_modules/next/dist/shared/lib/hash.js +42 -0
- package/frontend-build/node_modules/next/dist/shared/lib/head-manager-context.shared-runtime.js +18 -0
- package/frontend-build/node_modules/next/dist/shared/lib/head.js +163 -0
- package/frontend-build/node_modules/next/dist/shared/lib/hooks-client-context.shared-runtime.js +60 -0
- package/frontend-build/node_modules/next/dist/shared/lib/html-context.shared-runtime.js +40 -0
- package/frontend-build/node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js +25 -0
- package/frontend-build/node_modules/next/dist/shared/lib/i18n/get-locale-redirect.js +59 -0
- package/frontend-build/node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js +54 -0
- package/frontend-build/node_modules/next/dist/shared/lib/image-blur-svg.js +22 -0
- package/frontend-build/node_modules/next/dist/shared/lib/image-config-context.shared-runtime.js +19 -0
- package/frontend-build/node_modules/next/dist/shared/lib/image-config.js +77 -0
- package/frontend-build/node_modules/next/dist/shared/lib/invariant-error.js +18 -0
- package/frontend-build/node_modules/next/dist/shared/lib/is-plain-object.js +42 -0
- package/frontend-build/node_modules/next/dist/shared/lib/is-thenable.js +20 -0
- package/frontend-build/node_modules/next/dist/shared/lib/isomorphic/path.js +14 -0
- package/frontend-build/node_modules/next/dist/shared/lib/lazy-dynamic/bailout-to-csr.js +37 -0
- package/frontend-build/node_modules/next/dist/shared/lib/loadable-context.shared-runtime.js +19 -0
- package/frontend-build/node_modules/next/dist/shared/lib/loadable.shared-runtime.js +246 -0
- package/frontend-build/node_modules/next/dist/shared/lib/match-local-pattern.js +46 -0
- package/frontend-build/node_modules/next/dist/shared/lib/match-remote-pattern.js +63 -0
- package/frontend-build/node_modules/next/dist/shared/lib/modern-browserslist-target.js +15 -0
- package/frontend-build/node_modules/next/dist/shared/lib/no-fallback-error.external.js +18 -0
- package/frontend-build/node_modules/next/dist/shared/lib/normalized-asset-prefix.js +28 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/absolute-path-to-page.js +26 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js +18 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js +18 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/get-page-paths.js +40 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/normalize-data-path.js +23 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/normalize-page-path.js +26 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/normalize-path-sep.js +19 -0
- package/frontend-build/node_modules/next/dist/shared/lib/page-path/remove-page-path-tail.js +20 -0
- package/frontend-build/node_modules/next/dist/shared/lib/promise-with-resolvers.js +26 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/adapters.js +136 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/routes/app.js +122 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/add-locale.js +28 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js +20 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js +20 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/app-paths.js +62 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/as-path-to-search-params.js +17 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/cache-busting-search-param.js +24 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/escape-path-delimiters.js +16 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js +27 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/format-url.js +111 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/get-dynamic-param.js +174 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js +52 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/get-route-from-asset-path.js +25 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/get-segment-param.js +90 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/html-bots.js +17 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/index.js +30 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/interception-prefix-from-param-type.js +33 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/interception-routes.js +108 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/is-bot.js +57 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/is-dynamic.js +26 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/middleware-route-matcher.js +31 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/parse-loader-tree.js +30 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/parse-path.js +33 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js +43 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/parse-url.js +38 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js +20 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/path-match.js +49 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/prepare-destination.js +292 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/querystring.js +79 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/relativize-url.js +40 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.js +39 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js +21 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/resolve-param-value.js +116 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/route-match-utils.js +113 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/route-matcher.js +45 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/route-regex.js +256 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js +244 -0
- package/frontend-build/node_modules/next/dist/shared/lib/router-context.shared-runtime.js +18 -0
- package/frontend-build/node_modules/next/dist/shared/lib/segment-cache/segment-value-encoding.js +99 -0
- package/frontend-build/node_modules/next/dist/shared/lib/segment-cache/vary-params-decoding.js +32 -0
- package/frontend-build/node_modules/next/dist/shared/lib/segment.js +102 -0
- package/frontend-build/node_modules/next/dist/shared/lib/server-inserted-html.shared-runtime.js +35 -0
- package/frontend-build/node_modules/next/dist/shared/lib/server-reference-info.js +56 -0
- package/frontend-build/node_modules/next/dist/shared/lib/side-effect.js +63 -0
- package/frontend-build/node_modules/next/dist/shared/lib/size-limit.js +40 -0
- package/frontend-build/node_modules/next/dist/shared/lib/turbopack/internal-error.js +53 -0
- package/frontend-build/node_modules/next/dist/shared/lib/utils/reflect-utils.js +69 -0
- package/frontend-build/node_modules/next/dist/shared/lib/utils/warn-once.js +22 -0
- package/frontend-build/node_modules/next/dist/shared/lib/utils.js +207 -0
- package/frontend-build/node_modules/next/dist/shared/lib/zod.js +101 -0
- package/frontend-build/node_modules/next/dist/telemetry/anonymous-meta.js +89 -0
- package/frontend-build/node_modules/next/dist/telemetry/detached-flush.js +56 -0
- package/frontend-build/node_modules/next/dist/telemetry/events/build.js +174 -0
- package/frontend-build/node_modules/next/dist/telemetry/events/index.js +41 -0
- package/frontend-build/node_modules/next/dist/telemetry/events/plugins.js +51 -0
- package/frontend-build/node_modules/next/dist/telemetry/events/swc-load-failure.js +55 -0
- package/frontend-build/node_modules/next/dist/telemetry/events/version.js +66 -0
- package/frontend-build/node_modules/next/dist/telemetry/flush-telemetry.js +19 -0
- package/frontend-build/node_modules/next/dist/telemetry/post-telemetry-payload.js +48 -0
- package/frontend-build/node_modules/next/dist/telemetry/project-id.js +48 -0
- package/frontend-build/node_modules/next/dist/telemetry/storage.js +301 -0
- package/frontend-build/node_modules/next/dist/trace/index.js +58 -0
- package/frontend-build/node_modules/next/dist/trace/report/index.js +37 -0
- package/frontend-build/node_modules/next/dist/trace/report/to-json-build.js +40 -0
- package/frontend-build/node_modules/next/dist/trace/report/to-json.js +165 -0
- package/frontend-build/node_modules/next/dist/trace/report/to-telemetry.js +36 -0
- package/frontend-build/node_modules/next/dist/trace/shared.js +39 -0
- package/frontend-build/node_modules/next/dist/trace/trace.js +211 -0
- package/frontend-build/node_modules/next/package.json +378 -0
- package/frontend-build/node_modules/react/cjs/react-compiler-runtime.production.js +16 -0
- package/frontend-build/node_modules/react/cjs/react-jsx-dev-runtime.production.js +14 -0
- package/frontend-build/node_modules/react/cjs/react-jsx-runtime.production.js +34 -0
- package/frontend-build/node_modules/react/cjs/react.development.js +1284 -0
- package/frontend-build/node_modules/react/cjs/react.production.js +542 -0
- package/frontend-build/node_modules/react/compiler-runtime.js +14 -0
- package/frontend-build/node_modules/react/index.js +7 -0
- package/frontend-build/node_modules/react/jsx-dev-runtime.js +7 -0
- package/frontend-build/node_modules/react/jsx-runtime.js +7 -0
- package/frontend-build/node_modules/react/package.json +51 -0
- package/frontend-build/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +6603 -0
- package/frontend-build/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.js +6692 -0
- package/frontend-build/node_modules/react-dom/cjs/react-dom-server.browser.production.js +7410 -0
- package/frontend-build/node_modules/react-dom/cjs/react-dom-server.edge.production.js +7512 -0
- package/frontend-build/node_modules/react-dom/cjs/react-dom-server.node.production.js +7707 -0
- package/frontend-build/node_modules/react-dom/cjs/react-dom.production.js +210 -0
- package/frontend-build/node_modules/react-dom/index.js +38 -0
- package/frontend-build/node_modules/react-dom/package.json +117 -0
- package/frontend-build/node_modules/react-dom/server.browser.js +16 -0
- package/frontend-build/node_modules/react-dom/server.edge.js +17 -0
- package/frontend-build/node_modules/react-dom/server.node.js +18 -0
- package/frontend-build/node_modules/react-dom/static.node.js +14 -0
- package/frontend-build/node_modules/sharp/lib/channel.js +177 -0
- package/frontend-build/node_modules/sharp/lib/colour.js +195 -0
- package/frontend-build/node_modules/sharp/lib/composite.js +212 -0
- package/frontend-build/node_modules/sharp/lib/constructor.js +499 -0
- package/frontend-build/node_modules/sharp/lib/index.js +16 -0
- package/frontend-build/node_modules/sharp/lib/input.js +809 -0
- package/frontend-build/node_modules/sharp/lib/is.js +143 -0
- package/frontend-build/node_modules/sharp/lib/libvips.js +207 -0
- package/frontend-build/node_modules/sharp/lib/operation.js +1016 -0
- package/frontend-build/node_modules/sharp/lib/output.js +1666 -0
- package/frontend-build/node_modules/sharp/lib/resize.js +595 -0
- package/frontend-build/node_modules/sharp/lib/sharp.js +121 -0
- package/frontend-build/node_modules/sharp/lib/utility.js +291 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/classes/comparator.js +143 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/classes/range.js +557 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/classes/semver.js +333 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/cmp.js +54 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/coerce.js +62 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/compare.js +7 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/eq.js +5 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/gt.js +5 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/gte.js +5 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/lt.js +5 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/lte.js +5 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/neq.js +5 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/parse.js +18 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/functions/satisfies.js +12 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/internal/constants.js +37 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/internal/debug.js +11 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/internal/identifiers.js +29 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/internal/lrucache.js +42 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/internal/parse-options.js +17 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/internal/re.js +223 -0
- package/frontend-build/node_modules/sharp/node_modules/semver/package.json +78 -0
- package/frontend-build/node_modules/sharp/package.json +202 -0
- package/frontend-build/node_modules/styled-jsx/dist/index/index.js +499 -0
- package/frontend-build/node_modules/styled-jsx/index.js +1 -0
- package/frontend-build/node_modules/styled-jsx/package.json +132 -0
- package/frontend-build/node_modules/styled-jsx/style.js +1 -0
- package/frontend-build/package.json +43 -0
- package/frontend-build/public/aws-bedrock-icon.svg +1 -0
- package/frontend-build/public/chatgpt-icon.svg +1 -0
- package/frontend-build/public/claude-ai-icon.svg +1 -0
- package/frontend-build/public/deepseek-logo-icon.svg +1 -0
- package/frontend-build/public/discord-round-color-icon.svg +1 -0
- package/frontend-build/public/file.svg +1 -0
- package/frontend-build/public/globe.svg +1 -0
- package/frontend-build/public/google-gemini-icon.svg +1 -0
- package/frontend-build/public/grok-icon.svg +1 -0
- package/frontend-build/public/next.svg +1 -0
- package/frontend-build/public/ollama-icon.svg +1 -0
- package/frontend-build/public/slack-icon.svg +6 -0
- package/frontend-build/public/teams.svg +2 -0
- package/frontend-build/public/telegram-icon.svg +1 -0
- package/frontend-build/public/vercel.svg +1 -0
- package/frontend-build/public/whatsapp-color-icon.svg +1 -0
- package/frontend-build/public/window.svg +1 -0
- package/frontend-build/server.js +38 -0
- package/package.json +34 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,55838,(e,t,n)=>{"use strict";var s=e.r(71645),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=s.useState,o=s.useEffect,a=s.useLayoutEffect,l=s.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var h="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),s=r({inst:{value:n,getSnapshot:t}}),i=s[0].inst,h=s[1];return a(function(){i.value=n,i.getSnapshot=t,c(i)&&h({inst:i})},[e,n,t]),o(function(){return c(i)&&h({inst:i}),e(function(){c(i)&&h({inst:i})})},[e]),l(n),n};n.useSyncExternalStore=void 0!==s.useSyncExternalStore?s.useSyncExternalStore:h},2239,(e,t,n)=>{"use strict";t.exports=e.r(55838)},52822,(e,t,n)=>{"use strict";var s=e.r(71645),i=e.r(2239),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=i.useSyncExternalStore,a=s.useRef,l=s.useEffect,c=s.useMemo,h=s.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,s,i){var d=a(null);if(null===d.current){var u={hasValue:!1,value:null};d.current=u}else u=d.current;var p=o(e,(d=c(function(){function e(e){if(!l){if(l=!0,o=e,e=s(e),void 0!==i&&u.hasValue){var t=u.value;if(i(t,e))return a=t}return a=e}if(t=a,r(o,e))return t;var n=s(e);return void 0!==i&&i(t,n)?(o=e,t):(o=e,a=n)}var o,a,l=!1,c=void 0===n?null:n;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,n,s,i]))[0],d[1]);return l(function(){u.hasValue=!0,u.value=p},[p]),h(p),p}},30224,(e,t,n)=>{"use strict";t.exports=e.r(52822)},72677,e=>{"use strict";let t,n,s;var i,r,o,a,l,c,h,d,u,p,f,m,g,x,b,v,y,w=e.i(18050),O=e.i(71645),k=e.i(98919),j=e.i(16019),N=e.i(66992),S=e.i(27927),z=e.i(58041),C=e.i(73264),_=e.i(31245),T=e.i(95116),A=e.i(18393),M=e.i(90272),P=e.i(40524),E=e.i(76516),R=e.i(86311),D=e.i(3116),$=e.i(15505),Q=e.i(61224),I=e.i(18566),L=e.i(55487),q=e.i(39731),B=e.i(31278);function W({agentName:e,setAgentName:t,vaultEnabled:n,setVaultEnabled:s,vaultThreshold:i,setVaultThreshold:r,autoCompactEnabled:o,setAutoCompactEnabled:a,autoCompactThreshold:l,setAutoCompactThreshold:c,allowDbWrite:h,setAllowDbWrite:d,embedCode:u,setEmbedCode:p,bashAllowedDirs:f,setBashAllowedDirs:m,onSave:g,isSaving:x}){let[b,v]=(0,O.useState)(!1),[y,k]=(0,O.useState)(""),[j,N]=(0,O.useState)(String(i)),[S,z]=(0,O.useState)(String(l));(0,O.useEffect)(()=>{N(String(i))},[i]),(0,O.useEffect)(()=>{z(String(l))},[l]);let[C,_]=(0,O.useState)(null),[T,A]=(0,O.useState)({host:"localhost",port:"5432",username:"postgres",password:"",dbName:"synapse"}),[M,P]=(0,O.useState)(!1),[E,R]=(0,O.useState)(null),D=async()=>{v(!0),_(null),R(null);try{let e=await fetch("/api/settings/check-embed"),t=await e.json();t.all_ok?(p(!0),_(null)):t.psql_available?t.db_url_configured&&!t.db_connection_ok?_({issue:"existing_url_broken",detail:`${t.db_url_hint}: ${t.db_error||"connection failed"}`}):t.db_connection_ok&&!t.pgvector_available?_({issue:"no_pgvector"}):_({issue:"no_db"}):_({issue:"no_psql"})}catch(e){_({issue:"connection_error",detail:String(e)})}finally{v(!1)}},$=async()=>{if(u){p(!1),_(null);return}await D()},Q=async()=>{P(!0),R(null);try{let e=await fetch("/api/settings/setup-embed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:T.host,port:parseInt(T.port)||5432,username:T.username,password:T.password,db_name:T.dbName})});if(!e.ok){let t=await e.json();R(t.detail||"Setup failed");return}await D()}catch(e){R(String(e))}finally{P(!1)}};return(0,w.jsxs)("div",{className:"space-y-8",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Global Agent Name"}),(0,w.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-sm focus:border-white focus:outline-none transition-colors text-white placeholder:text-zinc-700 font-medium",placeholder:"Enter Agent Name"}),(0,w.jsx)("p",{className:"text-xs text-zinc-600",children:"This name identifies your agent across the system."})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Large Response Handling"}),(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("div",{children:(0,w.jsx)("p",{className:"text-xs text-zinc-600 mt-0.5",children:"When enabled, tool outputs exceeding the threshold are saved to a vault file instead of flooding the context."})}),(0,w.jsx)("button",{onClick:()=>s(!n),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none ${n?"bg-white":"bg-zinc-700"}`,children:(0,w.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${n?"translate-x-6 bg-black":"translate-x-1 bg-zinc-400"}`})})]}),n&&(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Character Threshold"}),(0,w.jsxs)("p",{className:"text-xs text-zinc-500",children:["≈ ",(0,w.jsx)("span",{className:"text-zinc-300 font-semibold",children:Math.round(i/4).toLocaleString()})," tokens",(0,w.jsx)("span",{className:"text-zinc-600 ml-1",children:"(at ~4 chars / token)"})]}),(0,w.jsx)("input",{type:"number",value:j,onChange:e=>N(e.target.value),onBlur:()=>{let e=Math.max(1,parseInt(j)||1);r(e),N(String(e))},className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-sm focus:border-white focus:outline-none transition-colors text-white placeholder:text-zinc-700 font-medium",min:1}),(0,w.jsx)("p",{className:"text-xs text-zinc-600",children:"Responses longer than this many characters will be saved to a file."})]})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Auto Context Compaction"}),(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("div",{children:(0,w.jsx)("p",{className:"text-xs text-zinc-600 mt-0.5",children:"When the accumulated context exceeds the threshold, the agent summarises everything so far to ~30% of its size and archives the original to the vault so nothing is lost."})}),(0,w.jsx)("button",{onClick:()=>a(!o),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none flex-shrink-0 ml-4 ${o?"bg-white":"bg-zinc-700"}`,children:(0,w.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${o?"translate-x-6 bg-black":"translate-x-1 bg-zinc-400"}`})})]}),o&&(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Compaction Threshold (characters)"}),(0,w.jsxs)("p",{className:"text-xs text-zinc-500",children:["≈ ",(0,w.jsx)("span",{className:"text-zinc-300 font-semibold",children:Math.round(l/4).toLocaleString()})," tokens",(0,w.jsx)("span",{className:"text-zinc-600 ml-1",children:"(at ~4 chars / token)"})]}),(0,w.jsx)("input",{type:"number",value:S,onChange:e=>z(e.target.value),onBlur:()=>{let e=Math.max(1e4,parseInt(S)||1e4);c(e),z(String(e))},className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-sm focus:border-white focus:outline-none transition-colors text-white placeholder:text-zinc-700 font-medium",min:1e4}),(0,w.jsx)("p",{className:"text-xs text-zinc-600",children:"When context exceeds this, it is compacted using the current model. The full original is archived to the vault."})]})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Database Write Access"}),(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("div",{children:(0,w.jsx)("p",{className:"text-xs text-zinc-600 mt-0.5",children:"When disabled (default), agents are strictly limited to SELECT/SHOW/DESCRIBE queries. When enabled, INSERT/UPDATE/DELETE and other write queries are allowed — but agents must always ask for confirmation before executing them."})}),(0,w.jsx)("button",{onClick:()=>d(!h),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none flex-shrink-0 ml-4 ${h?"bg-amber-500":"bg-zinc-700"}`,children:(0,w.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${h?"translate-x-6 bg-black":"translate-x-1 bg-zinc-400"}`})})]}),h&&(0,w.jsxs)("div",{className:"p-3 bg-amber-500/10 border border-amber-500/20 text-amber-400 text-xs",children:[(0,w.jsx)("strong",{children:"Write mode active."})," Agents MUST ask for explicit user confirmation before running any INSERT, UPDATE, DELETE, DROP, or CREATE queries. This is enforced in the system prompt."]})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Code Repository Indexing"}),(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("div",{children:(0,w.jsx)("p",{className:"text-xs text-zinc-600 mt-0.5",children:"When enabled, agents can semantically search your indexed code repositories using vector embeddings. Requires PostgreSQL with the pgvector extension."})}),(0,w.jsx)("button",{onClick:$,disabled:b,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none flex-shrink-0 ml-4 ${u?"bg-white":"bg-zinc-700"} ${b?"opacity-50 cursor-not-allowed":""}`,children:(0,w.jsx)("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${u?"translate-x-6 bg-black":"translate-x-1 bg-zinc-400"}`})})]}),b&&(0,w.jsxs)("div",{className:"flex items-center gap-2 text-xs text-zinc-400",children:[(0,w.jsx)(B.Loader2,{className:"w-3.5 h-3.5 animate-spin"}),"Checking PostgreSQL setup…"]}),C?.issue==="no_psql"&&(0,w.jsxs)("div",{className:"p-3 bg-amber-500/10 border border-amber-500/20 text-amber-400 text-xs space-y-2",children:[(0,w.jsxs)("p",{children:[(0,w.jsx)("strong",{children:"PostgreSQL not found."})," Install it to enable code indexing."]}),(0,w.jsxs)("ul",{className:"space-y-0.5 text-amber-300/80",children:[(0,w.jsxs)("li",{children:[(0,w.jsx)("strong",{children:"Ubuntu/Debian:"})," ",(0,w.jsx)("code",{className:"bg-black/30 px-1",children:"sudo apt install postgresql postgresql-contrib"})]}),(0,w.jsxs)("li",{children:[(0,w.jsx)("strong",{children:"macOS:"})," ",(0,w.jsx)("code",{className:"bg-black/30 px-1",children:"brew install postgresql"})]}),(0,w.jsxs)("li",{children:[(0,w.jsx)("strong",{children:"Windows:"})," Download from ",(0,w.jsx)("span",{className:"underline",children:"postgresql.org/download/windows"})]})]}),(0,w.jsxs)("p",{className:"text-amber-300/60",children:["After installing, also install pgvector: ",(0,w.jsx)("code",{className:"bg-black/30 px-1",children:"sudo apt install postgresql-pgvector"})," (Ubuntu) or ",(0,w.jsx)("code",{className:"bg-black/30 px-1",children:"brew install pgvector"})," (macOS)."]}),(0,w.jsx)("button",{onClick:D,className:"mt-1 px-3 py-1 text-xs font-bold bg-amber-500/20 hover:bg-amber-500/30 text-amber-300 border border-amber-500/30 transition-colors",children:"Check again"})]}),C?.issue==="existing_url_broken"&&(0,w.jsxs)("div",{className:"p-3 bg-zinc-800/60 border border-zinc-700 text-xs space-y-3",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("p",{className:"text-zinc-300 font-semibold",children:"Existing connection is failing"}),(0,w.jsx)("p",{className:"text-zinc-500 font-mono break-all",children:C.detail}),(0,w.jsx)("p",{className:"text-zinc-500",children:"Please provide new connection details to reconfigure."})]}),(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Host"}),(0,w.jsx)("input",{type:"text",value:T.host,onChange:e=>A(t=>({...t,host:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Port"}),(0,w.jsx)("input",{type:"text",value:T.port,onChange:e=>A(t=>({...t,port:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Username"}),(0,w.jsx)("input",{type:"text",value:T.username,onChange:e=>A(t=>({...t,username:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs",autoComplete:"off"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Password"}),(0,w.jsx)("input",{type:"password",value:T.password,onChange:e=>A(t=>({...t,password:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs",autoComplete:"new-password"})]}),(0,w.jsxs)("div",{className:"col-span-2 space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Database Name"}),(0,w.jsx)("input",{type:"text",value:T.dbName,onChange:e=>A(t=>({...t,dbName:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs"})]})]}),E&&(0,w.jsx)("p",{className:"text-red-400 font-mono text-[11px]",children:E}),(0,w.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,w.jsxs)("button",{onClick:Q,disabled:M,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-bold bg-white text-black hover:bg-zinc-200 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[M&&(0,w.jsx)(B.Loader2,{className:"w-3 h-3 animate-spin"}),M?"Connecting…":"Save & Connect"]}),(0,w.jsx)("button",{onClick:()=>_(null),className:"px-3 py-2 text-xs text-zinc-500 hover:text-white transition-colors",children:"Cancel"})]})]}),C?.issue==="no_pgvector"&&(0,w.jsxs)("div",{className:"p-3 bg-amber-500/10 border border-amber-500/20 text-amber-400 text-xs space-y-2",children:[(0,w.jsxs)("p",{children:[(0,w.jsx)("strong",{children:"pgvector extension not installed."})," PostgreSQL is running but the vector extension is missing."]}),(0,w.jsx)("p",{children:"Connect to your database and run:"}),(0,w.jsx)("code",{className:"block bg-black/40 px-2 py-1.5 font-mono text-white/80",children:"CREATE EXTENSION vector;"}),(0,w.jsxs)("p",{className:"text-amber-300/60",children:["Or install the OS package first: ",(0,w.jsx)("code",{className:"bg-black/30 px-1",children:"sudo apt install postgresql-pgvector"})," (Ubuntu) / ",(0,w.jsx)("code",{className:"bg-black/30 px-1",children:"brew install pgvector"})," (macOS), then run the SQL above."]}),(0,w.jsx)("button",{onClick:D,className:"mt-1 px-3 py-1 text-xs font-bold bg-amber-500/20 hover:bg-amber-500/30 text-amber-300 border border-amber-500/30 transition-colors",children:"Check again"})]}),C?.issue==="no_db"&&(0,w.jsxs)("div",{className:"p-3 bg-zinc-800/60 border border-zinc-700 text-xs space-y-3",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("p",{className:"text-zinc-300 font-semibold",children:"Set up a PostgreSQL database for code indexing"}),(0,w.jsx)("p",{className:"text-zinc-500",children:"No database configured yet. Enter your PostgreSQL credentials and we'll create the database and enable pgvector."})]}),(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Host"}),(0,w.jsx)("input",{type:"text",value:T.host,onChange:e=>A(t=>({...t,host:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Port"}),(0,w.jsx)("input",{type:"text",value:T.port,onChange:e=>A(t=>({...t,port:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Username"}),(0,w.jsx)("input",{type:"text",value:T.username,onChange:e=>A(t=>({...t,username:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs",autoComplete:"off"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Password"}),(0,w.jsx)("input",{type:"password",value:T.password,onChange:e=>A(t=>({...t,password:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs",autoComplete:"new-password"})]}),(0,w.jsxs)("div",{className:"col-span-2 space-y-1",children:[(0,w.jsx)("label",{className:"text-zinc-500 uppercase tracking-wider text-[10px] font-bold",children:"Database Name"}),(0,w.jsx)("input",{type:"text",value:T.dbName,onChange:e=>A(t=>({...t,dbName:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 p-2 text-white focus:border-white focus:outline-none font-mono text-xs"})]})]}),E&&(0,w.jsx)("p",{className:"text-red-400 font-mono text-[11px]",children:E}),(0,w.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,w.jsxs)("button",{onClick:Q,disabled:M,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-bold bg-white text-black hover:bg-zinc-200 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[M&&(0,w.jsx)(B.Loader2,{className:"w-3 h-3 animate-spin"}),M?"Creating…":"Create Database"]}),(0,w.jsx)("button",{onClick:()=>_(null),className:"px-3 py-2 text-xs text-zinc-500 hover:text-white transition-colors",children:"Cancel"})]})]}),C?.issue==="connection_error"&&(0,w.jsxs)("div",{className:"p-3 bg-red-500/10 border border-red-500/20 text-red-400 text-xs space-y-2",children:[(0,w.jsxs)("p",{children:[(0,w.jsx)("strong",{children:"Check failed."})," ",C.detail]}),(0,w.jsx)("button",{onClick:D,className:"px-3 py-1 text-xs font-bold bg-red-500/20 hover:bg-red-500/30 text-red-300 border border-red-500/30 transition-colors",children:"Try again"})]})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Bash Command Directories"}),(0,w.jsx)("p",{className:"text-xs text-zinc-600",children:"Extra directories the bash tool can execute commands in. Linked repos and vault are always included automatically."}),f.length>0&&(0,w.jsx)("div",{className:"space-y-1",children:f.map((e,t)=>(0,w.jsxs)("div",{className:"flex items-center justify-between bg-zinc-900 border border-zinc-800 px-3 py-2",children:[(0,w.jsx)("span",{className:"text-xs font-mono text-zinc-300 truncate",children:e}),(0,w.jsx)("button",{onClick:()=>m(f.filter((e,n)=>n!==t)),className:"text-zinc-600 hover:text-red-400 transition-colors text-xs ml-2 flex-shrink-0",children:"Remove"})]},t))}),(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("input",{type:"text",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y.trim()&&(m([...f,y.trim()]),k(""))},placeholder:"/path/to/directory",className:"flex-1 bg-zinc-900 border border-zinc-800 p-2.5 text-sm focus:border-white focus:outline-none transition-colors text-white placeholder:text-zinc-700 font-mono"}),(0,w.jsx)("button",{onClick:()=>{y.trim()&&(m([...f,y.trim()]),k(""))},disabled:!y.trim(),className:"px-4 py-2.5 text-xs font-bold bg-zinc-800 hover:bg-zinc-700 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Add"})]})]}),(0,w.jsx)("div",{className:"pt-4 flex justify-end",children:(0,w.jsxs)("button",{onClick:g,disabled:x,className:"flex items-center gap-2 px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg disabled:opacity-50 disabled:cursor-not-allowed",children:[x&&(0,w.jsx)(B.Loader2,{className:"w-4 h-4 animate-spin"}),x?"Saving…":"Save Changes"]})})]})}let V=({pdFirstName:e,setPdFirstName:t,pdLastName:n,setPdLastName:s,pdEmail:i,setPdEmail:r,pdPhone:o,setPdPhone:a,pdAddress1:l,setPdAddress1:c,pdAddress2:h,setPdAddress2:d,pdCity:u,setPdCity:p,pdState:f,setPdState:m,pdZipcode:g,setPdZipcode:x,onSave:b})=>(0,w.jsxs)("div",{className:"space-y-8",children:[(0,w.jsxs)("div",{className:"mb-4",children:[(0,w.jsxs)("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:[(0,w.jsx)(k.Shield,{className:"h-5 w-5"}),"Personal Details"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm mt-1",children:"Saved details the agent can use when completing workflows."})]}),(0,w.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"First Name"}),(0,w.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors",placeholder:"First name"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Last Name"}),(0,w.jsx)("input",{type:"text",value:n,onChange:e=>s(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors",placeholder:"Last name"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Email"}),(0,w.jsx)("input",{type:"email",value:i,onChange:e=>r(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"name@company.com"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Phone Number"}),(0,w.jsx)("input",{type:"tel",value:o,onChange:e=>a(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"+1 555 555 5555"})]})]}),(0,w.jsxs)("div",{className:"border border-zinc-800 bg-zinc-900/20 p-6 space-y-6",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"text-sm font-bold text-white",children:"Address"}),(0,w.jsx)("div",{className:"text-xs text-zinc-500",children:"Used when a workflow needs a billing or mailing address."})]}),(0,w.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Address 1"}),(0,w.jsx)("input",{type:"text",value:l,onChange:e=>c(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors",placeholder:"Street address"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Address 2"}),(0,w.jsx)("input",{type:"text",value:h,onChange:e=>d(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors",placeholder:"Apt, suite, unit"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"City"}),(0,w.jsx)("input",{type:"text",value:u,onChange:e=>p(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors",placeholder:"City"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"State"}),(0,w.jsx)("input",{type:"text",value:f,onChange:e=>m(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors",placeholder:"State"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Zipcode"}),(0,w.jsx)("input",{type:"text",value:g,onChange:e=>x(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"Zipcode"})]})]})]}),(0,w.jsx)("div",{className:"pt-2 flex justify-end",children:(0,w.jsx)("button",{onClick:b,className:"px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg",children:"Save Changes"})})]});var F=e.i(27612),H=e.i(75254);let X=(0,H.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),U=(0,H.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),G=(0,H.default)("chart-no-axes-column",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]]);var Z=e.i(55716);let Y=(0,H.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]),K=({isOpen:e,title:t,message:n,confirmText:s="Yes, Delete It",cancelText:i="Cancel",onConfirm:r,onClose:o})=>e?(0,w.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-200 font-mono",children:(0,w.jsxs)("div",{className:"w-full max-w-sm border border-red-500/30 bg-black shadow-[0_0_50px_rgba(255,0,0,0.1)] p-6 relative overflow-hidden",children:[(0,w.jsx)("div",{className:"absolute top-0 inset-x-0 h-1 bg-gradient-to-r from-transparent via-red-500 to-transparent opacity-50"}),(0,w.jsxs)("h3",{className:"text-lg font-bold text-red-500 mb-4 flex items-center gap-2",children:[(0,w.jsx)(X,{className:"h-5 w-5"})," ",t.toUpperCase()]}),(0,w.jsx)("p",{className:"text-sm text-zinc-300 mb-8 leading-relaxed whitespace-pre-wrap",children:n}),(0,w.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,w.jsx)("button",{onClick:o,className:"px-4 py-2 text-xs font-medium border border-zinc-800 hover:bg-zinc-900 text-zinc-400 hover:text-white transition-colors",children:i}),(0,w.jsx)("button",{onClick:()=>{r(),o()},className:"px-4 py-2 text-xs bg-red-900/20 border border-red-900/50 text-red-500 hover:bg-red-900/40 hover:text-red-400 font-bold transition-colors",children:s})]})]})}):null,J=[{id:"chat_history",icon:R.MessageSquare,label:"Chat History",description:"All saved conversations across all sessions",detail:"All conversation messages and session state files"},{id:"orchestration_history",icon:Y,label:"Orchestration Run History",description:"Past orchestration run logs and checkpoints",detail:"All orchestration execution logs and run state files"},{id:"agent_logs",icon:_.Bot,label:"Agent Logs",description:"Per-run debug logs for individual agent executions",detail:"All agent run log files from chat and orchestration sources"},{id:"usage",icon:G,label:"Usage History",description:"Token usage and cost tracking records",detail:"All token/cost logs across all sessions"},{id:"repos",icon:Z.GitBranch,label:"Repositories",description:"All indexed code repositories and their vector indexes",detail:"All repo configurations and code search indexes"},{id:"db_configs",icon:A.Server,label:"Database Connections",description:"All saved database configurations",detail:"All DB connection strings and configuration data"}],ee={chat_history:!1,orchestration_history:!1,agent_logs:!1,usage:!1,repos:!1,db_configs:!1},et=()=>{let[e,t]=(0,O.useState)(ee),[n,s]=(0,O.useState)(!1),[i,r]=(0,O.useState)(!1),[o,a]=(0,O.useState)(null),l=J.filter(t=>e[t.id]),c=l.length,h=async()=>{r(!0),a(null);try{let n=Object.keys(e).filter(t=>e[t]),s=await fetch("/api/memory/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:n})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.detail||"Failed to clear data")}let i=l.map(e=>e.label).join(", ");a({type:"success",text:`Successfully cleared: ${i}`}),t(ee)}catch(e){a({type:"error",text:e instanceof Error?e.message:"An error occurred"})}finally{r(!1)}},d=`The following data will be permanently deleted:
|
|
2
|
+
|
|
3
|
+
`+l.map(e=>`• ${e.label}: ${e.detail}`).join("\n")+`
|
|
4
|
+
|
|
5
|
+
This action cannot be undone.`;return(0,w.jsxs)("div",{className:"space-y-6",children:[(0,w.jsx)("div",{className:"flex items-center justify-between border-b border-zinc-800/50 pb-4",children:(0,w.jsxs)("div",{children:[(0,w.jsx)("h3",{className:"text-lg font-bold text-zinc-100 flex items-center gap-2",children:"Data Categories"}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm mt-1",children:"Select the data pipelines you want to permanently clear."})]})}),(0,w.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:J.map(n=>{let s=n.icon,i=e[n.id];return(0,w.jsxs)("div",{onClick:()=>{var e;return e=n.id,void(t(t=>({...t,[e]:!t[e]})),a(null))},className:`flex items-start gap-4 p-4 border transition-all cursor-pointer group ${i?"bg-red-950/20 border-red-900/50":"bg-zinc-900/40 border-zinc-800/50 hover:border-zinc-700/50 hover:bg-zinc-900/80"}`,children:[(0,w.jsx)("div",{className:`mt-0.5 h-4 w-4 flex-shrink-0 flex items-center justify-center transition-colors border ${i?"bg-red-500 border-red-500":"bg-zinc-950 border-zinc-700 group-hover:border-zinc-500"}`,children:i&&(0,w.jsx)("svg",{className:"h-3 w-3 text-black",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,w.jsx)("polyline",{points:"2,6 5,9 10,3"})})}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,w.jsx)(s,{className:`h-4 w-4 flex-shrink-0 transition-colors ${i?"text-red-400":"text-zinc-500 group-hover:text-zinc-400"}`}),(0,w.jsx)("div",{className:`text-sm font-bold tracking-wide transition-colors ${i?"text-red-200":"text-zinc-200 group-hover:text-zinc-100"}`,children:n.label})]}),(0,w.jsx)("div",{className:`text-xs transition-colors mt-1.5 leading-relaxed ${i?"text-red-400/70":"text-zinc-500 group-hover:text-zinc-400"}`,children:n.description})]})]},n.id)})}),o&&(0,w.jsxs)("div",{className:`flex items-center gap-2 text-sm p-3 border ${"success"===o.type?"text-green-400 border-green-900/50 bg-green-950/10":"text-red-400 border-red-900/50 bg-red-950/10"}`,children:["success"===o.type?(0,w.jsx)(U,{className:"h-4 w-4 flex-shrink-0"}):(0,w.jsx)(X,{className:"h-4 w-4 flex-shrink-0"}),(0,w.jsx)("span",{children:o.text})]}),(0,w.jsx)("div",{className:"mt-8 pt-6 border-t border-zinc-800/50",children:(0,w.jsxs)("div",{className:"bg-transparent border border-red-900/30 p-5 md:p-6 flex flex-col md:flex-row md:items-center justify-between gap-4 md:gap-8 hover:border-red-900/50 transition-colors",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h3",{className:"text-sm uppercase tracking-wider font-bold text-red-500 flex items-center gap-2",children:[(0,w.jsx)(F.Trash2,{className:"h-4 w-4"})," Danger Zone"]}),(0,w.jsx)("p",{className:"text-xs text-red-400/70 mt-1.5 leading-relaxed",children:"Actions here are irreversible. Selecting items and clearing them will permanently wipe their corresponding data."})]}),(0,w.jsx)("button",{disabled:0===c||i,onClick:()=>s(!0),className:"flex-shrink-0 px-6 py-2.5 text-sm font-bold bg-red-950/40 border border-red-900/50 text-red-500 hover:bg-red-900/60 hover:text-red-400 hover:border-red-500/80 disabled:opacity-40 disabled:cursor-not-allowed transition-all",children:i?"Clearing...":0===c?"Clear Selected":`Clear Selected (${c})`})]})}),(0,w.jsx)(K,{isOpen:n,title:"Confirm Data Deletion",message:d,confirmText:"Yes, Clear Selected",onConfirm:h,onClose:()=>s(!1)})]})};var en=e.i(7233);let es=(0,H.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var ei=e.i(64659),er=e.i(63059);let eo=(0,H.default)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);var ea=e.i(83086);let el=(0,H.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),ec=(0,H.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var eh=e.i(78917);let ed=(0,H.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),eu=(0,H.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),ep=(0,H.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var ef=e.i(74080);let em=(0,H.default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),eg=(0,H.default)("file-braces",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]),ex=(0,H.default)("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);function eb({value:e,onChange:t,className:n,...s}){let i=(0,O.useRef)(null),[r,o]=(0,O.useState)(!1),[a,l]=(0,O.useState)(""),[c,h]=(0,O.useState)(-1),[d,u]=(0,O.useState)([]),[p,f]=(0,O.useState)(!1),[m,g]=(0,O.useState)(0),[x,b]=(0,O.useState)({bottom:0,left:0,width:0});(0,O.useEffect)(()=>{if(!r)return;let e=!1;return f(!0),fetch(`/api/vault/search?q=${encodeURIComponent(a)}`).then(e=>e.ok?e.json():{files:[]}).then(t=>{e||(u(Array.isArray(t.files)?t.files:[]),g(0),f(!1))}).catch(()=>{e||(u([]),f(!1))}),()=>{e=!0}},[r,a]);let v=(0,O.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.getBoundingClientRect();b({bottom:window.innerHeight-t.top+4,left:t.left,width:t.width})},[]),y=(0,O.useCallback)(()=>{o(!1),l(""),h(-1),u([]),g(0)},[]),k=(0,O.useCallback)(n=>{let s=i.current;if(!s||c<0)return;let r=s.selectionStart??e.length,o=e.slice(0,c),a=e.slice(r),l=`@[${n.path}]`,h=o+l+a,d=c+l.length,u=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value")?.set;u&&(u.call(s,h),s.dispatchEvent(new Event("input",{bubbles:!0}))),t({target:s}),setTimeout(()=>{s.setSelectionRange(d,d),s.focus()},0),y()},[c,e,t,y]),j=(0,O.useCallback)(e=>{r?"ArrowDown"===e.key?(e.preventDefault(),g(e=>Math.min(e+1,d.length-1))):"ArrowUp"===e.key?(e.preventDefault(),g(e=>Math.max(e-1,0))):"Enter"===e.key||"Tab"===e.key?d.length>0?(e.preventDefault(),k(d[m])):y():"Escape"===e.key?(e.preventDefault(),y()):s.onKeyDown?.(e):s.onKeyDown?.(e)},[r,d,m,k,y,s]),N=(0,O.useCallback)(e=>{let n=e.target.value,s=e.target.selectionStart??n.length,i=n.slice(0,s).match(/@([^@[\]\n]*)$/);if(i){let e=i[1],t=s-e.length-1;o(!0),l(e),h(t),g(0),v()}else r&&y();t(e)},[r,t,y,v]);(0,O.useEffect)(()=>{if(!r)return;let e=e=>{let t=i.current;if(t&&!t.contains(e.target)){let t=document.getElementById("vault-mention-dropdown");t&&t.contains(e.target)||y()}};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,y]),(0,O.useEffect)(()=>{if(!r)return;let e=()=>v();return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[r,v]);let S=r?(0,ef.createPortal)((0,w.jsxs)("div",{id:"vault-mention-dropdown",style:{bottom:x.bottom,left:x.left,width:Math.max(x.width,288)},className:"fixed z-[9999] bg-zinc-900 border border-zinc-700 shadow-2xl rounded overflow-hidden",children:[(0,w.jsxs)("div",{className:"px-3 py-1.5 text-[10px] text-zinc-500 border-b border-zinc-800 font-mono flex items-center gap-1.5",children:[(0,w.jsx)("span",{className:"text-emerald-400",children:"@"})," Vault file reference",a&&(0,w.jsxs)("span",{className:"text-zinc-600",children:["— “",a,"”"]})]}),p?(0,w.jsx)("div",{className:"px-3 py-3 text-xs text-zinc-500 text-center",children:"Searching…"}):0===d.length?(0,w.jsx)("div",{className:"px-3 py-3 text-xs text-zinc-600 text-center",children:"No vault files found"}):(0,w.jsx)("div",{className:"max-h-52 overflow-y-auto",children:d.map((e,t)=>(0,w.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),k(e)},className:`w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-zinc-800 transition-colors ${t===m?"bg-zinc-800":""}`,children:[".json"===e.ext?(0,w.jsx)(eg,{className:"h-3.5 w-3.5 text-amber-400 flex-shrink-0"}):".txt"===e.ext?(0,w.jsx)(ex,{className:"h-3.5 w-3.5 text-zinc-400 flex-shrink-0"}):(0,w.jsx)(em,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),(0,w.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,w.jsx)("div",{className:"text-xs font-medium text-zinc-200 truncate",children:e.name}),(0,w.jsx)("div",{className:"text-[10px] text-zinc-500 truncate font-mono",children:e.path})]}),(0,w.jsx)("span",{className:`text-[9px] px-1 py-0.5 rounded font-mono flex-shrink-0 ${".json"===e.ext?"bg-amber-900/40 text-amber-400":".txt"===e.ext?"bg-zinc-800 text-zinc-400":"bg-blue-900/40 text-blue-400"}`,children:e.ext.slice(1)})]},e.path))}),(0,w.jsx)("div",{className:"px-3 py-1.5 border-t border-zinc-800 text-[9px] text-zinc-600 font-mono",children:"↑↓ navigate · Enter/Tab select · Esc cancel"})]}),document.body):null;return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("textarea",{ref:i,value:e,onChange:N,onKeyDown:j,className:n,...s}),S]})}let ev={all_types:["sequentialthinking","read_file","read_multiple_files","search_files","list_directory","get_file_info","grep","glob","read_file_by_lines"],code:["search_codebase"],orchestrator:[]};var ey=e.i(77291);let ew={success:"bg-green-500/10 border border-green-500/30 text-green-400",warning:"bg-yellow-500/10 border border-yellow-500/30 text-yellow-300",error:"bg-red-500/10 border border-red-500/30 text-red-400"},eO={success:ed,warning:X,error:eu},ek=({show:e,message:t,type:n="success"})=>{if(!e)return null;let s=eO[n];return(0,w.jsxs)("div",{className:`fixed top-6 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-2.5 px-4 py-2.5 rounded shadow-2xl text-xs font-medium animate-in fade-in slide-in-from-top-4 duration-300 ${ew[n]}`,children:[(0,w.jsx)(s,{className:"h-4 w-4 shrink-0"}),(0,w.jsx)("span",{children:t})]})},ej=({agents:e,selectedAgentId:t,setSelectedAgentId:n,draftAgent:s,setDraftAgent:i,availableCapabilities:r,loadingCapabilities:o=!1,customTools:a,onDeleteAgent:l,providers:c,defaultModel:h,loadingAgents:d=!1})=>{let u,p,f=(0,L.useDispatch)(),[m,g]=(0,O.useState)([]),[x,b]=(0,O.useState)([]),[v,y]=(0,O.useState)([]),[k,N]=(0,O.useState)(new Set),[S,z]=(0,O.useState)(""),[C,T]=(0,O.useState)(!1),[A,M]=(0,O.useState)(!1),[P,E]=(0,O.useState)("config"),[D,$]=(0,O.useState)([]),[Q,I]=(0,O.useState)(!1),[W,V]=(0,O.useState)(null),F=(e,t)=>{V({show:!0,message:e,type:t}),setTimeout(()=>V(null),4e3)},H=async()=>{if(s){I(!0);try{let t=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.ok){let r=await t.json();e.some(e=>e.id===s.id)?f((0,q.updateAgent)(r)):(f((0,q.addAgent)(r)),n(r.id),i(r)),F("Agent saved successfully","success")}else F("Failed to save agent","error")}catch{F("Error saving agent","error")}finally{I(!1)}}};(0,O.useEffect)(()=>{E("config"),$([])},[t]),(0,O.useEffect)(()=>{fetch("/api/repos").then(e=>e.json()).then(e=>g(e)).catch(e=>console.error("Failed to fetch repos",e)),fetch("/api/db-configs").then(e=>e.json()).then(e=>b(e)).catch(e=>console.error("Failed to fetch DB configs",e)),fetch("/api/agent-types").then(e=>e.json()).then(e=>y(e.types||[])).catch(e=>console.error("Failed to fetch agent types",e))},[]);let X=e=>{let t=e.tools.every(e=>s.tools.includes(e));if(s.tools.includes("all")){let n=r.flatMap(e=>e.tools);if(t){let t=n.filter(t=>!e.tools.includes(t));i({...s,tools:t})}else i({...s,tools:[...s.tools,...e.tools]})}else if(t){let t=s.tools.filter(t=>!e.tools.includes(t));i({...s,tools:t})}else{let t=[...s.tools,...e.tools.filter(e=>!s.tools.includes(e))];i({...s,tools:t})}},U=async()=>{if(S.trim()){T(!0);try{let e=s.type||"conversational",t=[...ev.all_types||[],...ev[e]||[]],n=[];for(let e of r)for(let i of e.toolDetails||e.tools.map(e=>({name:e,description:""})))(t.includes(i.name)||s.tools.includes("all")||s.tools.includes(i.name))&&n.push(i.description?`${i.name} - ${i.description}`:i.name);let o=await fetch("/api/agents/generate-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:S,agent_type:e,tools:n,existing_prompt:s.system_prompt||""}),signal:AbortSignal.timeout(18e4)});if(!o.ok)throw Error("Failed to generate prompt");let a=await o.json();i({...s,system_prompt:a.system_prompt}),z("")}catch(e){console.error("Failed to generate prompt:",e)}finally{T(!1)}}};return(0,w.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-10",children:[W&&(0,w.jsx)(ek,{show:W.show,message:W.message,type:W.type}),(0,w.jsxs)("div",{className:"md:col-span-4 border-r border-zinc-800 pr-4 flex flex-col max-h-[calc(100vh-180px)] sticky top-0 self-start",children:[(0,w.jsxs)("div",{className:"mb-4 flex justify-between items-center",children:[(0,w.jsx)("h3",{className:"text-sm font-bold text-zinc-400",children:"YOUR AGENTS"}),(0,w.jsx)("button",{onClick:()=>{let e={id:`agent_${Date.now()}`,name:"New Agent",description:"A custom agent.",system_prompt:"You are a helpful assistant.",tools:[],repos:[],type:"conversational",avatar:"default",max_turns:30};i(e),n(e.id)},className:"p-1.5 hover:bg-zinc-800 text-white transition-colors border border-dashed border-zinc-600 hover:border-white",title:"Create New Agent",children:(0,w.jsx)(en.Plus,{className:"h-4 w-4"})})]}),(0,w.jsxs)("div",{className:"space-y-2 flex-1 overflow-y-auto modern-scrollbar",children:[d&&0===e.length&&(0,w.jsxs)("div",{className:"flex items-center gap-2 text-zinc-500 text-sm py-4",children:[(0,w.jsx)(B.Loader2,{className:"w-4 h-4 animate-spin"}),"Loading agents…"]}),Array.isArray(e)&&e.map(e=>(0,w.jsxs)("div",{onClick:()=>{n(e.id),i({...e})},className:`p-3 border cursor-pointer transition-all group relative
|
|
6
|
+
${t===e.id?"bg-zinc-900 border-white shadow-lg":"bg-black border-zinc-800 hover:border-zinc-600"}`,children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("div",{className:`h-8 w-8 rounded-full flex items-center justify-center text-xs font-bold
|
|
7
|
+
${t===e.id?"bg-white text-black":"bg-zinc-800 text-zinc-400"}
|
|
8
|
+
`,children:e.name.substring(0,2).toUpperCase()}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("div",{className:"text-xs font-bold text-white truncate",children:e.name}),(0,w.jsx)("div",{className:"text-[10px] text-zinc-500 truncate",children:e.description})]})]}),(0,w.jsx)("button",{onClick:t=>{t.stopPropagation(),l(e.id)},className:"absolute top-2 right-2 p-1 text-zinc-600 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,w.jsx)(j.Trash,{className:"h-3 w-3"})})]},e.id))]})]}),(0,w.jsx)("div",{className:"md:col-span-8 pl-4",children:s?(0,w.jsx)("div",{className:"space-y-6 h-full flex flex-col pb-4",children:"orchestrator"===s.type?(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center h-full min-h-[400px] gap-6 text-center",children:[(0,w.jsxs)("div",{className:"relative",children:[(0,w.jsx)("div",{className:"h-20 w-20 rounded-full bg-gradient-to-br from-purple-900/60 to-violet-900/40 border border-purple-700/50 flex items-center justify-center",children:(0,w.jsx)("svg",{className:"h-9 w-9 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,w.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"})})}),(0,w.jsx)("div",{className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-purple-600 flex items-center justify-center",children:(0,w.jsx)(eo,{className:"h-2.5 w-2.5 text-white"})})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("h4",{className:"text-sm font-bold text-white",children:s.name}),(0,w.jsxs)("p",{className:"text-[11px] text-zinc-500 max-w-[280px] leading-relaxed",children:["This is an ",(0,w.jsx)("span",{className:"text-purple-400 font-semibold",children:"Orchestration Agent"}),". Its workflow, steps, and configuration are managed in the dedicated Orchestrations editor."]})]}),(0,w.jsxs)("div",{className:"px-5 py-3 border border-dashed border-purple-800/60 bg-purple-950/20 rounded text-[10px] text-purple-300 flex items-center gap-2",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-3 w-3 flex-shrink-0"}),"Open the ",(0,w.jsx)("strong",{children:"Orchestrations"})," menu to edit this agent's workflow"]})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsxs)("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[(0,w.jsx)("div",{className:"h-2 w-2 rounded-full bg-purple-500"}),e.some(e=>e.id===s.id)?`EDITING: ${s.name.toUpperCase()}`:"NEW AGENT"]}),"config"===P&&(0,w.jsx)("button",{onClick:H,disabled:Q,className:"flex items-center gap-2 px-4 py-1.5 bg-white text-black text-xs font-bold hover:bg-zinc-200 disabled:opacity-60 disabled:cursor-not-allowed",children:Q?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(B.Loader2,{className:"h-3 w-3 animate-spin"})," SAVING…"]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(es,{className:"h-3 w-3"})," SAVE AGENT"]})})]}),(0,w.jsx)("div",{className:"flex gap-0 border-b border-zinc-800",children:[{id:"config",label:"Configuration"},{id:"messaging",label:"Messaging Channels"}].map(e=>(0,w.jsx)("button",{onClick:()=>{E(e.id),"messaging"===e.id&&s.id&&fetch(`/api/messaging/channels?agent_id=${s.id}`).then(e=>e.ok?e.json():[]).then(e=>$(Array.isArray(e)?e:[])).catch(()=>$([]))},className:`px-4 py-2 text-xs font-bold transition-all border-b-2 -mb-px
|
|
9
|
+
${P===e.id?"text-white border-white":"text-zinc-500 border-transparent hover:text-zinc-300"}`,children:e.label},e.id))}),"config"===P&&(0,w.jsxs)("div",{className:"space-y-6 flex-1 flex flex-col min-h-0",children:[(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Name"}),(0,w.jsx)("input",{type:"text",value:s.name,onChange:e=>i({...s,name:e.target.value}),className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Description"}),(0,w.jsx)("input",{type:"text",value:s.description,onChange:e=>i({...s,description:e.target.value}),className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Agent Type"}),(0,w.jsx)("select",{value:s.type||"conversational",onChange:e=>{let t=e.target.value,n=ev[s.type]||[],r=s.tools.filter(e=>!n.includes(e));i({...s,type:t,tools:r,max_turns:s.max_turns??("code"===t?50:30)})},className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none",children:v.map(e=>(0,w.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,w.jsx)("p",{className:"text-[9px] text-zinc-500 mt-1",children:v.find(e=>e.value===(s.type||"conversational"))?.description})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Model"}),(0,w.jsxs)("select",{value:s.model||"",onChange:e=>i({...s,model:e.target.value||null}),className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none",children:[(0,w.jsxs)("option",{value:"",children:["Use Default (",h||"not set",")"]}),c&&Object.entries(c).map(([e,t])=>{if(!t.available||0===t.models.length)return null;let n=e.charAt(0).toUpperCase()+e.slice(1);return(0,w.jsx)("optgroup",{label:n,children:t.models.map(e=>(0,w.jsx)("option",{value:e,children:e},e))},e)})]}),(0,w.jsx)("p",{className:"text-[9px] text-zinc-500 mt-1",children:"Override the default model for this agent. Leave empty to use the system default."})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Max Turns"}),(0,w.jsx)("input",{type:"number",min:1,max:200,value:s.max_turns??("code"===s.type?50:30),onChange:e=>i({...s,max_turns:parseInt(e.target.value)||30}),className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none"}),(0,w.jsx)("p",{className:"text-[9px] text-zinc-500 mt-1",children:"Max reasoning turns per request. Orchestration steps override this value."})]})]}),"code"===s.type&&(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Linked Repositories"}),(0,w.jsxs)("div",{className:"bg-zinc-950 border border-zinc-800 p-3 flex flex-wrap gap-2 min-h-[50px]",children:[0===m.length&&(0,w.jsx)("span",{className:"text-xs text-zinc-500",children:"No repositories indexed yet."}),m.map(e=>{let t=s.repos?.includes(e.id);return(0,w.jsxs)("button",{onClick:()=>{let n=s.repos||[];t?i({...s,repos:n.filter(t=>t!==e.id)}):i({...s,repos:[...n,e.id]})},className:`px-3 py-1.5 text-xs font-bold border transition-colors ${t?"bg-white text-black border-white":"bg-zinc-900 border-zinc-800 text-zinc-400 hover:border-zinc-500"}`,children:[e.name," ",t&&"✓"]},e.id)})]}),(0,w.jsx)("p",{className:"text-[9px] text-zinc-500 mt-1",children:"Select indexed repositories for semantic code search access."})]}),"code"===s.type&&(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Linked Databases"}),(0,w.jsxs)("div",{className:"bg-zinc-950 border border-zinc-800 p-3 flex flex-wrap gap-2 min-h-[50px]",children:[0===x.length&&(0,w.jsx)("span",{className:"text-xs text-zinc-500",children:"No databases configured yet."}),x.map(e=>{let t=s.db_configs?.includes(e.id);return(0,w.jsxs)("button",{onClick:()=>{let n=s.db_configs||[];t?i({...s,db_configs:n.filter(t=>t!==e.id)}):i({...s,db_configs:[...n,e.id]})},className:`px-3 py-1.5 text-xs font-bold border transition-colors ${t?"bg-white text-black border-white":"bg-zinc-900 border-zinc-800 text-zinc-400 hover:border-zinc-500"}`,children:[e.name," ",(0,w.jsx)("span",{className:"opacity-50",children:e.db_type})," ",t&&"✓"]},e.id)})]}),(0,w.jsx)("p",{className:"text-[9px] text-zinc-500 mt-1",children:"Select databases to inject schema context into the agent's system prompt."})]}),(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Capabilities (Tools)"}),o?(0,w.jsx)("div",{className:"grid grid-cols-2 gap-4",children:Array.from({length:8}).map((e,t)=>(0,w.jsxs)("div",{className:"border border-zinc-800 bg-black p-4 space-y-2 animate-pulse",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("div",{className:"w-3 h-3 rounded-sm bg-zinc-800"}),(0,w.jsx)("div",{className:"h-2.5 bg-zinc-800 rounded w-24"})]}),(0,w.jsx)("div",{className:"h-2 bg-zinc-800/70 rounded w-32 ml-5"})]},t))}):(u=s.type||"conversational",p=new Set([...ev.all_types||[],...ev[u]||[]]),(0,w.jsx)("div",{className:"grid grid-cols-2 gap-4",children:r.map(e=>{let t=e.toolDetails||e.tools.map(e=>({name:e,description:""})),n=t.length>1,o=k.has(e.id),a=e.tools.every(e=>p.has(e)),l=e.tools.filter(e=>a||s.tools.includes("all")||s.tools.includes(e)).length,c=l===e.tools.length,h=l>0&&!c;return(0,w.jsxs)("div",{className:`border transition-colors
|
|
10
|
+
${a?"bg-zinc-900/60 border-blue-900/40":c?"bg-zinc-900 border-zinc-600":h?"bg-zinc-900/50 border-zinc-700":"bg-black border-zinc-800 opacity-50"}`,children:[(0,w.jsxs)("div",{className:`p-4 flex items-center gap-2 transition-colors ${a?"cursor-default":"cursor-pointer hover:bg-zinc-800/30"}`,onClick:()=>{if(!a)if(n){var t;t=e.id,N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})}else X(e)},children:[a?(0,w.jsx)(eo,{className:"w-3 h-3 text-blue-400 flex-shrink-0"}):(0,w.jsx)("div",{onClick:t=>{n&&(t.stopPropagation(),X(e))},className:`w-3 h-3 border flex-shrink-0 flex items-center justify-center cursor-pointer
|
|
11
|
+
${c?"bg-green-500 border-green-500":h?"bg-yellow-500 border-yellow-500":"border-zinc-600"}`,children:h&&(0,w.jsx)("div",{className:"w-1.5 h-0.5 bg-white"})}),(0,w.jsx)("span",{className:"text-xs font-bold text-white truncate flex-1",children:e.label}),a&&(0,w.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 bg-blue-900/50 text-blue-400 border border-blue-900 rounded",children:"DEFAULT"}),!a&&"custom"===e.toolType&&(0,w.jsx)("span",{className:"text-[9px] px-1 bg-zinc-800 text-zinc-400 rounded",children:"CUSTOM"}),!a&&"mcp"===e.toolType&&(0,w.jsx)("span",{className:"text-[9px] px-1 bg-blue-900/50 text-blue-400 border border-blue-900 rounded",children:"MCP"}),!a&&n&&(0,w.jsxs)("span",{className:"text-[9px] text-zinc-500",children:[l,"/",e.tools.length]}),!a&&n&&(o?(0,w.jsx)(ei.ChevronDown,{className:"h-3 w-3 text-zinc-500 flex-shrink-0"}):(0,w.jsx)(er.ChevronRight,{className:"h-3 w-3 text-zinc-500 flex-shrink-0"}))]}),!o&&(0,w.jsx)("div",{className:"px-4 pb-3 -mt-1",children:(0,w.jsx)("p",{className:"text-[9px] text-zinc-500 pl-5 line-clamp-2",children:a?`Included by default for ${u} agents`:e.description})}),o&&n&&!a&&(0,w.jsx)("div",{className:"border-t border-zinc-800 px-3 py-2 space-y-1 max-h-[200px] overflow-y-auto",children:t.map(e=>{let t=p.has(e.name),n=t||s.tools.includes("all")||s.tools.includes(e.name);return(0,w.jsxs)("div",{onClick:()=>!t&&((e,t)=>{if(s.tools.includes("all")){let t=r.flatMap(e=>e.tools).filter(t=>t!==e);i({...s,tools:t})}else if(s.tools.includes(e)){let t=s.tools.filter(t=>t!==e);i({...s,tools:t})}else i({...s,tools:[...s.tools,e]})})(e.name,0),className:`flex gap-2.5 py-1.5 px-2 rounded transition-colors ${t?"cursor-default opacity-60":"cursor-pointer hover:bg-zinc-800/40"}`,children:[t?(0,w.jsx)(eo,{className:"w-2.5 h-2.5 text-blue-400 flex-shrink-0 mt-[3px]"}):(0,w.jsx)("div",{className:`w-2.5 h-2.5 border flex-shrink-0 mt-[3px]
|
|
12
|
+
${n?"bg-green-500 border-green-500":"border-zinc-600"}`}),(0,w.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,w.jsx)("div",{className:"text-[10px] font-mono text-zinc-300",children:e.name}),e.description&&(0,w.jsx)("p",{className:"text-[9px] text-zinc-600 mt-0.5 leading-tight line-clamp-2",children:e.description})]})]},e.name)})})]},e.id)})}))]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase flex items-center gap-1.5",children:[(0,w.jsx)(ea.Sparkles,{className:"h-3 w-3"})," AI Prompt Writer"]}),(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("input",{type:"text",value:S,onChange:e=>z(e.target.value),onKeyDown:e=>"Enter"===e.key&&!C&&U(),placeholder:"Describe what this agent should do... e.g. 'A customer support agent for a SaaS product'",className:"flex-1 bg-zinc-950 border border-zinc-800 px-3 py-2 text-xs text-white focus:border-purple-500 focus:outline-none placeholder:text-zinc-600"}),(0,w.jsx)("button",{onClick:U,disabled:C||!S.trim(),className:"px-4 py-2 bg-purple-600 hover:bg-purple-500 disabled:bg-zinc-800 disabled:text-zinc-600 text-white text-xs font-bold flex items-center gap-2 transition-colors",children:C?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(B.Loader2,{className:"h-3 w-3 animate-spin"})," GENERATING..."]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(ea.Sparkles,{className:"h-3 w-3"})," GENERATE"]})})]}),(0,w.jsx)("p",{className:"text-[9px] text-zinc-600",children:"Describe the agent's purpose and the AI will generate a comprehensive system prompt. Tools and date/time context are auto-injected at runtime."})]}),(0,w.jsxs)("div",{className:"space-y-1 flex-1 flex flex-col min-h-0",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"System Prompt (The Brain)"}),(0,w.jsxs)("button",{onClick:()=>M(!A),className:"flex items-center gap-1.5 text-[10px] font-bold text-zinc-500 hover:text-white transition-colors px-2 py-1",children:[A?(0,w.jsx)(ec,{className:"h-3 w-3"}):(0,w.jsx)(el,{className:"h-3 w-3"}),A?"EDIT":"PREVIEW"]})]}),A?(0,w.jsx)("div",{className:"w-full flex-1 min-h-[200px] max-h-[500px] overflow-y-auto bg-zinc-950 border border-zinc-800 p-4 text-sm text-zinc-300 leading-relaxed",children:(0,ey.renderTextContent)(s.system_prompt||"*No system prompt yet.*")}):(0,w.jsx)(eb,{value:s.system_prompt,onChange:e=>i({...s,system_prompt:e.target.value}),className:"w-full flex-1 min-h-[200px] bg-zinc-950 border border-zinc-800 p-3 text-xs font-mono text-zinc-300 focus:border-white focus:outline-none resize-none leading-relaxed",placeholder:"You are a helpful assistant. Type @ to reference a vault file..."})]})]})," ","messaging"===P&&(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("p",{className:"text-[10px] text-zinc-500",children:["Messaging channels bound to this agent. Configure them in full from ",(0,w.jsx)("strong",{className:"text-zinc-300",children:"Settings → Messaging"}),"."]}),0===D.length?(0,w.jsxs)("div",{className:"p-8 border border-dashed border-zinc-800 text-center text-zinc-600 space-y-3",children:[(0,w.jsx)(R.MessageSquare,{className:"h-8 w-8 mx-auto opacity-20"}),(0,w.jsx)("p",{className:"text-xs",children:"No messaging channels bound to this agent yet."}),(0,w.jsxs)("p",{className:"text-[10px]",children:["Go to ",(0,w.jsx)("strong",{className:"text-zinc-400",children:"Settings → Messaging"})," and select this agent when creating a channel."]})]}):(0,w.jsx)("div",{className:"space-y-2",children:D.map(e=>(0,w.jsxs)("div",{className:"flex items-center gap-3 p-3 border border-zinc-800 bg-zinc-950",children:[(0,w.jsx)("span",{className:"text-lg",children:{telegram:"✈️",discord:"🎮",slack:"💬",teams:"📘",whatsapp:"📱"}[e.platform]??"🤖"}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("div",{className:"text-xs font-bold text-white",children:e.name}),(0,w.jsxs)("div",{className:"text-[10px] text-zinc-500 capitalize",children:[e.platform,e.multi_agent_mode?" · multi-agent":""]})]}),"running"===e.status?(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-green-400",children:[(0,w.jsx)(ed,{className:"h-3 w-3"})," Running"]}):"error"===e.status?(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-red-400",children:[(0,w.jsx)(eu,{className:"h-3 w-3"})," Error"]}):(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-zinc-500",children:[(0,w.jsx)(ep,{className:"h-3 w-3"})," Stopped"]})]},e.id))})]})]})}):(0,w.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-zinc-600 space-y-4",children:[(0,w.jsx)(_.Bot,{className:"h-12 w-12 opacity-20"}),(0,w.jsx)("p",{className:"text-sm",children:"Select an agent to edit or create a new one."})]})})]})};var eN=e.i(37727);let eS=(0,H.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var ez=e.i(16715);let eC=(0,H.default)("container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]),e_=(0,H.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),eT=(0,H.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var eA=e.i(68054);let eM=(0,H.default)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),eP=[],eE=[],eR="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<eR.length;e++)(e%2?eE:eP).push(t+=eR[e]);function eD(e){return e>=127462&&e<=127487}function e$(e,t,n){if(t==e.length)return t;t&&eI(e.charCodeAt(t))&&eL(e.charCodeAt(t-1))&&t--;let s=eQ(e,t);for(t+=eq(s);t<e.length;){let i=eQ(e,t);if(8205==s||8205==i||n&&function(e){if(e<768)return!1;for(let t=0,n=eP.length;;){let s=t+n>>1;if(e<eP[s])n=s;else{if(!(e>=eE[s]))return!0;t=s+1}if(t==n)return!1}}(i))t+=eq(i),s=i;else if(eD(i)){let n=0,s=t-2;for(;s>=0&&eD(eQ(e,s));)n++,s-=2;if(n%2==0)break;t+=2}else break}return t}function eQ(e,t){let n=e.charCodeAt(t);if(!eL(n)||t+1==e.length)return n;let s=e.charCodeAt(t+1);return eI(s)?(n-55296<<10)+(s-56320)+65536:n}function eI(e){return e>=56320&&e<57344}function eL(e){return e>=55296&&e<56320}function eq(e){return e<65536?1:2}class eB{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=eZ(this,e,t);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(t,this.length,s,1),eV.from(s,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=eZ(this,e,t);let n=[];return this.decompose(e,t,n,0),eV.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new eH(this),i=new eH(e);for(let e=t,r=t;;){if(s.next(e),i.next(e),e=0,s.lineBreak!=i.lineBreak||s.done!=i.done||s.value!=i.value)return!1;if(r+=s.value.length,s.done||r>=n)return!0}}iter(e=1){return new eH(this,e)}iterRange(e,t=this.length){return new eX(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new eU(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(0==e.length)throw RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new eW(e):eV.from(eW.split(e,[])):eB.empty}}class eW extends eB{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,s){for(let i=0;;i++){let r=this.text[i],o=s+r.length;if((t?n:o)>=e)return new eG(s,o,n,r);s=o+1,n++}}decompose(e,t,n,s){var i;let r=e<=0&&t>=this.length?this:new eW((i=this.text,eF(i,[""],e,t)),Math.min(t,this.length)-Math.max(0,e));if(1&s){let e=n.pop(),t=eF(r.text,e.text.slice(),0,r.length);if(t.length<=32)n.push(new eW(t,e.length+r.length));else{let e=t.length>>1;n.push(new eW(t.slice(0,e)),new eW(t.slice(e)))}}else n.push(r)}replace(e,t,n){var s;if(!(n instanceof eW))return super.replace(e,t,n);[e,t]=eZ(this,e,t);let i=eF(this.text,eF(n.text,(s=this.text,eF(s,[""],0,e))),t),r=this.length+n.length-(t-e);return i.length<=32?new eW(i,r):eV.from(eW.split(i,[]),r)}sliceString(e,t=this.length,n="\n"){[e,t]=eZ(this,e,t);let s="";for(let i=0,r=0;i<=t&&r<this.text.length;r++){let o=this.text[r],a=i+o.length;i>e&&r&&(s+=n),e<a&&t>i&&(s+=o.slice(Math.max(0,e-i),t-i)),i=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],s=-1;for(let i of e)n.push(i),s+=i.length+1,32==n.length&&(t.push(new eW(n,s)),n=[],s=-1);return s>-1&&t.push(new eW(n,s)),t}}class eV extends eB{constructor(e,t){for(let n of(super(),this.children=e,this.length=t,this.lines=0,e))this.lines+=n.lines}lineInner(e,t,n,s){for(let i=0;;i++){let r=this.children[i],o=s+r.length,a=n+r.lines-1;if((t?a:o)>=e)return r.lineInner(e,t,n,s);s=o+1,n=a+1}}decompose(e,t,n,s){for(let i=0,r=0;r<=t&&i<this.children.length;i++){let o=this.children[i],a=r+o.length;if(e<=a&&t>=r){let i=s&(r<=e|2*(a>=t));r>=e&&a<=t&&!i?n.push(o):o.decompose(e-r,t-r,n,i)}r=a+1}}replace(e,t,n){if([e,t]=eZ(this,e,t),n.lines<this.lines)for(let s=0,i=0;s<this.children.length;s++){let r=this.children[s],o=i+r.length;if(e>=i&&t<=o){let a=r.replace(e-i,t-i,n),l=this.lines-r.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let i=this.children.slice();return i[s]=a,new eV(i,this.length-(t-e)+n.length)}return super.replace(i,o,a)}i=o+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=eZ(this,e,t);let s="";for(let i=0,r=0;i<this.children.length&&r<=t;i++){let o=this.children[i],a=r+o.length;r>e&&i&&(s+=n),e<a&&t>r&&(s+=o.sliceString(e-r,t-r,n)),r=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof eV))return 0;let n=0,[s,i,r,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,i+=t){if(s==r||i==o)return n;let a=this.children[s],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new eW(n,t)}let s=Math.max(32,n>>5),i=s<<1,r=s>>1,o=[],a=0,l=-1,c=[];function h(){0!=a&&(o.push(1==c.length?c[0]:eV.from(c,l)),l=-1,a=c.length=0)}for(let t of e)!function e(t){let n;if(t.lines>i&&t instanceof eV)for(let n of t.children)e(n);else t.lines>r&&(a>r||!a)?(h(),o.push(t)):t instanceof eW&&a&&(n=c[c.length-1])instanceof eW&&t.lines+n.lines<=32?(a+=t.lines,l+=t.length+1,c[c.length-1]=new eW(n.text.concat(t.text),n.length+1+t.length)):(a+t.lines>s&&h(),a+=t.lines,l+=t.length+1,c.push(t))}(t);return h(),1==o.length?o[0]:new eV(o,t)}}function eF(e,t,n=0,s=1e9){for(let i=0,r=0,o=!0;r<e.length&&i<=s;r++){let a=e[r],l=i+a.length;l>=n&&(l>s&&(a=a.slice(0,s-i)),i<n&&(a=a.slice(n-i)),o?(t[t.length-1]+=a,o=!1):t.push(a)),i=l+1}return t}eB.empty=new eW([""],0);class eH{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof eW?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],i=this.offsets[n],r=i>>1,o=s instanceof eW?s.text.length:s.children.length;if(r==(t>0?o:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(s instanceof eW){let i=s.text[r+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=s.children[r+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof eW?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class eX{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new eH(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=n?s:t<0?s.slice(s.length-n):s.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class eU{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}"u">typeof Symbol&&(eB.prototype[Symbol.iterator]=function(){return this.iter()},eH.prototype[Symbol.iterator]=eX.prototype[Symbol.iterator]=eU.prototype[Symbol.iterator]=function(){return this});class eG{constructor(e,t,n,s){this.from=e,this.to=t,this.number=n,this.text=s}get length(){return this.to-this.from}}function eZ(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function eY(e,t,n=!0,s=!0){return function(e,t,n=!0,s=!0){return(n?e$:function(e,t,n){for(;t>0;){let s=e$(e,t-2,n);if(s<t)return s;t--}return 0})(e,t,s)}(e,t,n,s)}function eK(e,t){let n=e.charCodeAt(t);if(!(n>=55296&&n<56320)||t+1==e.length)return n;let s=e.charCodeAt(t+1);return s>=56320&&s<57344?(n-55296<<10)+(s-56320)+65536:n}function eJ(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(((e-=65536)>>10)+55296,(1023&e)+56320)}function e0(e){return e<65536?1:2}let e1=/\r\n?|\n/;var e2=((mL=e2||(e2={}))[mL.Simple=0]="Simple",mL[mL.TrackDel=1]="TrackDel",mL[mL.TrackBefore=2]="TrackBefore",mL[mL.TrackAfter=3]="TrackAfter",mL);class e5{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,s=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?(e(n,s,i),s+=i):s+=r,n+=i}}iterChangedRanges(e,t=!1){e6(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];s<0?e.push(n,s):e.push(s,n)}return new e5(e)}composeDesc(e){return this.empty?e:e.empty?this:e7(this,e)}mapDesc(e,t=!1){return e.empty?this:e9(this,e,t)}mapPos(e,t=-1,n=e2.Simple){let s=0,i=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],a=this.sections[r++],l=s+o;if(a<0){if(l>e)return i+(e-s);i+=o}else{if(n!=e2.Simple&&l>=e&&(n==e2.TrackDel&&s<e&&l>e||n==e2.TrackBefore&&s<e||n==e2.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!o)return e==s||t<0?i:i+a;i+=a}s=l}if(e>s)throw RangeError(`Position ${e} is out of range for changeset of length ${s}`);return i}touchesRange(e,t=e){for(let n=0,s=0;n<this.sections.length&&s<=t;){let i=this.sections[n++],r=this.sections[n++],o=s+i;if(r>=0&&s<=t&&o>=e)return!(s<e)||!(o>t)||"cover";s=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+n+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw RangeError("Invalid JSON representation of ChangeDesc");return new e5(e)}static create(e){return new e5(e)}}class e3 extends e5{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError("Applying change set to a document with the wrong length");return e6(this,(t,n,s,i,r)=>e=e.replace(s,s+(n-t),r),!1),e}mapDesc(e,t=!1){return e9(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let s=0,i=0;s<t.length;s+=2){let r=t[s],o=t[s+1];if(o>=0){t[s]=o,t[s+1]=r;let a=s>>1;for(;n.length<a;)n.push(eB.empty);n.push(r?e.slice(i,i+r):eB.empty)}i+=r}return new e3(t,n)}compose(e){return this.empty?e:e.empty?this:e7(this,e,!0)}map(e,t=!1){return e.empty?this:e9(this,e,t,!0)}iterChanges(e,t=!1){e6(this,e,t)}get desc(){return e5.create(this.sections)}filter(e){let t=[],n=[],s=[],i=new te(this);e:for(let r=0,o=0;;){let a=r==e.length?1e9:e[r++];for(;o<a||o==a&&0==i.len;){if(i.done)break e;let e=Math.min(i.len,a-o);e4(s,e,-1);let r=-1==i.ins?-1:0==i.off?i.ins:0;e4(t,e,r),r>0&&e8(n,t,i.text),i.forward(e),o+=e}let l=e[r++];for(;o<l;){if(i.done)break e;let e=Math.min(i.len,l-o);e4(t,e,-1),e4(s,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),o+=e}}return{changes:new e3(t,n),filtered:e5.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],s=this.sections[t+1];s<0?e.push(n):0==s?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let s=[],i=[],r=0,o=null;function a(e=!1){if(!e&&!s.length)return;r<t&&e4(s,t-r,-1);let n=new e3(s,i);o=o?o.compose(n.map(o)):n,s=[],i=[],r=0}return!function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof e3){if(l.length!=t)throw RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),o=o?o.compose(l.map(o)):l}else{let{from:e,to:o=e,insert:c}=l;if(e>o||e<0||o>t)throw RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let h=c?"string"==typeof c?eB.of(c.split(n||e1)):c:eB.empty,d=h.length;if(e==o&&0==d)return;e<r&&a(),e>r&&e4(s,e-r,-1),e4(s,o-e,d),e8(i,s,h),r=o}}(e),a(!o),o}static empty(e){return new e3(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let s=0;s<e.length;s++){let i=e[s];if("number"==typeof i)t.push(i,-1);else if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==i.length)t.push(i[0],0);else{for(;n.length<s;)n.push(eB.empty);n[s]=eB.of(i.slice(1)),t.push(i[0],n[s].length)}}return new e3(t,n)}static createSet(e,t){return new e3(e,t)}}function e4(e,t,n,s=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:s?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function e8(e,t,n){if(0==n.length)return;let s=t.length-2>>1;if(s<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<s;)e.push(eB.empty);e.push(n)}}function e6(e,t,n){let s=e.inserted;for(let i=0,r=0,o=0;o<e.sections.length;){let a=e.sections[o++],l=e.sections[o++];if(l<0)i+=a,r+=a;else{let c=i,h=r,d=eB.empty;for(;c+=a,h+=l,l&&s&&(d=d.append(s[o-2>>1])),!n&&o!=e.sections.length&&!(e.sections[o+1]<0);)a=e.sections[o++],l=e.sections[o++];t(i,c,r,h,d),i=c,r=h}}}function e9(e,t,n,s=!1){let i=[],r=s?[]:null,o=new te(e),a=new te(t);for(let e=-1;;)if(o.done&&a.len||a.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==a.ins){let e=Math.min(o.len,a.len);e4(i,e,-1),o.forward(e),a.forward(e)}else if(a.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(a.len<o.len||a.len==o.len&&!n))){let t=a.len;for(e4(i,a.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(e4(i,0,o.ins),r&&e8(r,i,o.text),e=o.i),o.forward(n),t-=n}a.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else if(0==a.ins&&a.len<n)n-=a.len,a.next();else break;e4(i,t,e<o.i?o.ins:0),r&&e<o.i&&e8(r,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&a.done)return r?e3.createSet(i,r):e5.create(i);else throw Error("Mismatched change set lengths")}function e7(e,t,n=!1){let s=[],i=n?[]:null,r=new te(e),o=new te(t);for(let e=!1;;)if(r.done&&o.done)return i?e3.createSet(s,i):e5.create(s);else if(0==r.ins)e4(s,r.len,0,e),r.next();else if(0!=o.len||o.done)if(r.done||o.done)throw Error("Mismatched change set lengths");else{let t=Math.min(r.len2,o.len),n=s.length;if(-1==r.ins){let n=-1==o.ins?-1:o.off?0:o.ins;e4(s,t,n,e),i&&n&&e8(i,s,o.text)}else -1==o.ins?(e4(s,r.off?0:r.len,t,e),i&&e8(i,s,r.textBit(t))):(e4(s,r.off?0:r.len,o.off?0:o.ins,e),i&&!o.off&&e8(i,s,o.text));e=(r.ins>t||o.ins>=0&&o.len>t)&&(e||s.length>n),r.forward2(t),o.forward(t)}else e4(s,0,o.ins,e),i&&e8(i,s,o.text),o.next()}class te{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?eB.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?eB.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class tt{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 0xffffff==e?void 0:e}map(e,t=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new tt(n,s,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return tn.range(e,t,void 0,void 0,n);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return tn.range(this.anchor,s,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw RangeError("Invalid JSON representation for SelectionRange");return tn.range(e.anchor,e.head)}static create(e,t,n){return new tt(e,t,n)}}class tn{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:tn.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new tn([this.main],0)}addRange(e,t=!0){return tn.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,tn.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new tn(e.ranges.map(e=>tt.fromJSON(e)),e.main)}static single(e,t=e){return new tn([tn.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw RangeError("A selection needs at least one range");for(let n=0,s=0;s<e.length;s++){let i=e[s];if(i.empty?i.from<=n:i.from<n)return tn.normalized(e.slice(),t);n=i.to}return new tn(e,t)}static cursor(e,t=0,n,s){return tt.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=s?s:0xffffff)<<6)}static range(e,t,n,s,i){let r=(null!=n?n:0xffffff)<<6|(null==s?7:Math.min(6,s));return i||e==t||(i=t<e?1:-1),t<e?tt.create(t,e,48|r):tt.create(e,t,(i?i<0?8:16:0)|r)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let s=e[n],i=e[n-1];if(s.empty?s.from<=i.to:s.from<i.to){let r=i.from,o=Math.max(s.to,i.to);n<=t&&t--,e.splice(--n,2,s.anchor>s.head?tn.range(o,r):tn.range(r,o))}}return new tn(e,t)}}function ts(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError("Selection points outside of document")}let ti=0;class tr{constructor(e,t,n,s,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=ti++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new tr(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(!e.combine?to:(e,t)=>e===t),!!e.static,e.enables)}of(e){return new ta([],this,0,e)}compute(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ta(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ta(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function to(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class ta{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=ti++}dynamicSlot(e){var t;let n=this.value,s=this.facet.compareInput,i=this.id,r=e[i]>>1,o=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:((null!=(t=e[n.id])?t:1)&1)==0&&c.push(e[n.id]);return{create:e=>(e.values[r]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||tc(e,c)){let t=n(e);if(o?!tl(t,e.values[r],s):!s(t,e.values[r]))return e.values[r]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=tv(t,l);if(this.dependencies.every(n=>n instanceof tr?t.facet(n)===e.facet(n):!(n instanceof td)||t.field(n,!1)==e.field(n,!1))||(o?tl(a=n(e),i,s):s(a=n(e),i)))return e.values[r]=i,0}else a=n(e);return e.values[r]=a,1}}}}function tl(e,t,n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s]))return!1;return!0}function tc(e,t){let n=!1;for(let s of t)1&tb(e,s)&&(n=!0);return n}let th=tr.define({static:!0});class td{constructor(e,t,n,s,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=s,this.spec=i,this.provides=void 0}static define(e){let t=new td(ti++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(th).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let s=e.values[t],i=this.updateF(s,n);return this.compareF(s,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let s=e.facet(th),i=n.facet(th),r;return(r=s.find(e=>e.field==this))&&r!=i.find(e=>e.field==this)?(e.values[t]=r.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,th.of({field:this,create:e})]}get extension(){return this}}function tu(e){return t=>new tf(t,e)}let tp={highest:tu(0),high:tu(1),default:tu(2),low:tu(3),lowest:tu(4)};class tf{constructor(e,t){this.inner=e,this.prec=t}}class tm{of(e){return new tg(this,e)}reconfigure(e){return tm.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class tg{constructor(e,t){this.compartment=e,this.inner=t}}class tx{constructor(e,t,n,s,i,r){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=s,this.staticValues=i,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){var s,i,r;let o,a,l=[],c=Object.create(null),h=new Map;for(let n of(s=e,i=t,r=h,o=[[],[],[],[],[]],a=new Map,!function e(t,n){let s=a.get(t);if(null!=s){if(s<=n)return;let e=o[s].indexOf(t);e>-1&&o[s].splice(e,1),t instanceof tg&&r.delete(t.compartment)}if(a.set(t,n),Array.isArray(t))for(let s of t)e(s,n);else if(t instanceof tg){if(r.has(t.compartment))throw RangeError("Duplicate use of compartment in extensions");let s=i.get(t.compartment)||t.inner;r.set(t.compartment,s),e(s,n)}else if(t instanceof tf)e(t.inner,t.prec);else if(t instanceof td)o[n].push(t),t.provides&&e(t.provides,n);else if(t instanceof ta)o[n].push(t),t.facet.extensions&&e(t.facet.extensions,2);else{let s=t.extension;if(!s)throw Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(s,n)}}(s,2),o.reduce((e,t)=>e.concat(t))))n instanceof td?l.push(n):(c[n.facet.id]||(c[n.facet.id]=[])).push(n);let d=Object.create(null),u=[],p=[];for(let e of l)d[e.id]=p.length<<1,p.push(t=>e.slot(t));let f=null==n?void 0:n.config.facets;for(let e in c){let t=c[e],s=t[0].facet,i=f&&f[e]||[];if(t.every(e=>0==e.type))if(d[s.id]=u.length<<1|1,to(i,t))u.push(n.facet(s));else{let e=s.combine(t.map(e=>e.value));u.push(n&&s.compare(e,n.facet(s))?n.facet(s):e)}else{for(let e of t)0==e.type?(d[e.id]=u.length<<1|1,u.push(e.value)):(d[e.id]=p.length<<1,p.push(t=>e.dynamicSlot(t)));d[s.id]=p.length<<1,p.push(e=>(function(e,t,n){let s=n.map(t=>e[t.id]),i=n.map(e=>e.type),r=s.filter(e=>!(1&e)),o=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<s.length;t++){let r=tv(e,s[t]);if(2==i[t])for(let e of r)n.push(e);else n.push(r)}return t.combine(n)}return{create(e){for(let t of s)tb(e,t);return e.values[o]=a(e),1},update(e,n){if(!tc(e,r))return 0;let s=a(e);return t.compare(s,e.values[o])?0:(e.values[o]=s,1)},reconfigure(e,i){let r=tc(e,s),l=i.config.facets[t.id],c=i.facet(t);if(l&&!r&&to(n,l))return e.values[o]=c,0;let h=a(e);return t.compare(h,c)?(e.values[o]=c,0):(e.values[o]=h,1)}}})(e,s,t))}}return new tx(e,h,p.map(e=>e(d)),d,u,c)}}function tb(e,t){if(1&t)return 2;let n=t>>1,s=e.status[n];if(4==s)throw Error("Cyclic dependency between fields and/or facets");if(2&s)return s;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function tv(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}let ty=tr.define(),tw=tr.define({combine:e=>e.some(e=>e),static:!0}),tO=tr.define({combine:e=>e.length?e[0]:void 0,static:!0}),tk=tr.define(),tj=tr.define(),tN=tr.define(),tS=tr.define({combine:e=>!!e.length&&e[0]});class tz{constructor(e,t){this.type=e,this.value=t}static define(){return new tC}}class tC{of(e){return new tz(this,e)}}class t_{constructor(e){this.map=e}of(e){return new tT(this,e)}}class tT{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new tT(this.type,t)}is(e){return this.type==e}static define(e={}){return new t_(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let s of e){let e=s.map(t);e&&n.push(e)}return n}}tT.reconfigure=tT.define(),tT.appendConfig=tT.define();class tA{constructor(e,t,n,s,i,r){this.startState=e,this.changes=t,this.selection=n,this.effects=s,this.annotations=i,this.scrollIntoView=r,this._doc=null,this._state=null,n&&ts(n,t.newLength),i.some(e=>e.type==tA.time)||(this.annotations=i.concat(tA.time.of(Date.now())))}static create(e,t,n,s,i,r){return new tA(e,t,n,s,i,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(tA.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function tM(e,t,n){var s;let i,r,o;return n?(i=t.changes,r=e3.empty(t.changes.length),o=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),r=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(i)),{changes:o,selection:t.selection?t.selection.map(r):null==(s=e.selection)?void 0:s.map(i),effects:tT.mapEffects(e.effects,i).concat(tT.mapEffects(t.effects,r)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function tP(e,t,n){let s=t.selection,i=tR(t.annotations);return t.userEvent&&(i=i.concat(tA.userEvent.of(t.userEvent))),{changes:t.changes instanceof e3?t.changes:e3.of(t.changes||[],n,e.facet(tO)),selection:s&&(s instanceof tn?s:tn.single(s.anchor,s.head)),effects:tR(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}tA.time=tz.define(),tA.userEvent=tz.define(),tA.addToHistory=tz.define(),tA.remote=tz.define();let tE=[];function tR(e){return null==e?tE:Array.isArray(e)?e:[e]}var tD=((mq=tD||(tD={}))[mq.Word=0]="Word",mq[mq.Space=1]="Space",mq[mq.Other=2]="Other",mq);let t$=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{t=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class tQ{constructor(e,t,n,s,i,r){this.config=e,this.doc=t,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=i,r&&(r._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)tb(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null==n){if(t)throw RangeError("Field is not present in this state");return}return tb(this,n),tv(this,n)}update(...e){return function e(t,n,s){let i=tP(t,n.length?n[0]:{},t.doc.length);n.length&&!1===n[0].filter&&(s=!1);for(let e=1;e<n.length;e++){!1===n[e].filter&&(s=!1);let r=!!n[e].sequential;i=tM(i,tP(t,n[e],r?i.changes.newLength:t.doc.length),r)}let r=tA.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(tN),s=e;for(let i=n.length-1;i>=0;i--){let r=n[i](e);r&&Object.keys(r).length&&(s=tM(s,tP(t,r,e.changes.newLength),!0))}return s==e?e:tA.create(t,e.changes,e.selection,s.effects,s.annotations,s.scrollIntoView)}(s?function(t){let n=t.startState,s=!0;for(let e of n.facet(tk)){let n=e(t);if(!1===n){s=!1;break}Array.isArray(n)&&(s=!0===s?n:function(e,t){let n=[];for(let s=0,i=0;;){let r,o;if(s<e.length&&(i==t.length||t[i]>=e[s]))r=e[s++],o=e[s++];else{if(!(i<t.length))return n;r=t[i++],o=t[i++]}!n.length||n[n.length-1]<r?n.push(r,o):n[n.length-1]<o&&(n[n.length-1]=o)}}(s,n))}if(!0!==s){let e,i;if(!1===s)i=t.changes.invertedDesc,e=e3.empty(n.doc.length);else{let n=t.changes.filter(s);e=n.changes,i=n.filtered.mapDesc(n.changes).invertedDesc}t=tA.create(n,e,t.selection&&t.selection.map(i),tT.mapEffects(t.effects,i),t.annotations,t.scrollIntoView)}let i=n.facet(tj);for(let s=i.length-1;s>=0;s--){let r=i[s](t);t=r instanceof tA?r:Array.isArray(r)&&1==r.length&&r[0]instanceof tA?r[0]:e(n,tR(r),!1)}return t}(r):r)}(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:s,compartments:i}=n;for(let t of e.effects)t.is(tm.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(tT.reconfigure)?(n=null,s=t.value):t.is(tT.appendConfig)&&(n=null,s=tR(s).concat(t.value));t=n?e.startState.values.slice():new tQ(n=tx.resolve(s,i,this),this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values;let r=e.startState.facet(tw)?e.newSelection:e.newSelection.asSingle();new tQ(n,e.newDoc,r,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:tn.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),s=this.changes(n.changes),i=[n.range],r=tR(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),a=this.changes(o.changes),l=a.map(s);for(let e=0;e<n;e++)i[e]=i[e].map(l);let c=s.mapDesc(a,!0);i.push(o.range.map(c)),s=s.compose(l),r=tT.mapEffects(r,l).concat(tT.mapEffects(tR(o.effects),c))}return{changes:s,selection:tn.create(i,t.mainIndex),effects:r}}changes(e=[]){return e instanceof e3?e:e3.of(e,this.doc.length,this.facet(tQ.lineSeparator))}toText(e){return eB.of(e.split(this.facet(tQ.lineSeparator)||e1))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(tb(this,t),tv(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof td&&null!=this.config.address[s.id]&&(t[n]=s.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],r=e[t];s.push(i.init(e=>i.spec.fromJSON(r,e)))}}return tQ.create({doc:e.doc,selection:tn.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=tx.resolve(e.extensions||[],new Map),n=e.doc instanceof eB?e.doc:eB.of((e.doc||"").split(t.staticFacet(tQ.lineSeparator)||e1)),s=e.selection?e.selection instanceof tn?e.selection:tn.single(e.selection.anchor,e.selection.head):tn.single(0);return ts(s,n.length),t.staticFacet(tw)||(s=s.asSingle()),new tQ(t,n,s,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(tQ.tabSize)}get lineBreak(){return this.facet(tQ.lineSeparator)||"\n"}get readOnly(){return this.facet(tS)}phrase(e,...t){for(let t of this.facet(tQ.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let s=+(n||1);return!s||s>t.length?e:t[s-1]})),e}languageDataAt(e,t,n=-1){let s=[];for(let i of this.facet(ty))for(let r of i(this,t,n))Object.prototype.hasOwnProperty.call(r,e)&&s.push(r[e]);return s}charCategorizer(e){var n;let s=this.languageDataAt("wordChars",e);return n=s.length?s[0]:"",e=>{if(!/\S/.test(e))return tD.Space;if(function(e){if(t)return t.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||t$.test(n)))return!0}return!1}(e))return tD.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return tD.Word;return tD.Other}}wordAt(e){let{text:t,from:n,length:s}=this.doc.lineAt(e),i=this.charCategorizer(e),r=e-n,o=e-n;for(;r>0;){let e=eY(t,r,!1);if(i(t.slice(e,r))!=tD.Word)break;r=e}for(;o<s;){let e=eY(t,o);if(i(t.slice(o,e))!=tD.Word)break;o=e}return r==o?null:tn.range(r+n,o+n)}}function tI(e,t,n={}){let s={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],r=s[e];if(void 0===r)s[e]=i;else if(r===i||void 0===i);else if(Object.hasOwnProperty.call(n,e))s[e]=n[e](r,i);else throw Error("Config merge conflict for field "+e)}for(let e in t)void 0===s[e]&&(s[e]=t[e]);return s}tQ.allowMultipleSelections=tw,tQ.tabSize=tr.define({combine:e=>e.length?e[0]:4}),tQ.lineSeparator=tO,tQ.readOnly=tS,tQ.phrases=tr.define({compare(e,t){let n=Object.keys(e),s=Object.keys(t);return n.length==s.length&&n.every(n=>e[n]==t[n])}}),tQ.languageData=ty,tQ.changeFilter=tk,tQ.transactionFilter=tj,tQ.transactionExtender=tN,tm.reconfigure=tT.define();class tL{eq(e){return this==e}range(e,t=e){return tB.create(e,t,this)}}function tq(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}tL.prototype.startSide=tL.prototype.endSide=0,tL.prototype.point=!1,tL.prototype.mapMode=e2.TrackDel;class tB{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new tB(e,t,n)}}function tW(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class tV{constructor(e,t,n,s){this.from=e,this.to=t,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,s=0){let i=n?this.to:this.from;for(let r=s,o=i.length;;){if(r==o)return r;let s=r+o>>1,a=i[s]-e||(n?this.value[s].endSide:this.value[s].startSide)-t;if(s==r)return a>=0?r:o;a>=0?o=s:r=s+1}}between(e,t,n,s){for(let i=this.findIndex(t,-1e9,!0),r=this.findIndex(n,1e9,!1,i);i<r;i++)if(!1===s(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],s=[],i=[],r=-1,o=-1;for(let a=0;a<this.value.length;a++){let l=this.value[a],c=this.from[a]+e,h=this.to[a]+e,d,u;if(c==h){let e=t.mapPos(c,l.startSide,l.mapMode);if(null==e||(d=u=e,l.startSide!=l.endSide&&(u=t.mapPos(c,l.endSide))<d))continue}else if((d=t.mapPos(c,l.startSide))>(u=t.mapPos(h,l.endSide))||d==u&&l.startSide>0&&l.endSide<=0)continue;0>(u-d||l.endSide-l.startSide)||(r<0&&(r=d),l.point&&(o=Math.max(o,u-d)),n.push(l),s.push(d-r),i.push(u-r))}return{mapped:n.length?new tV(s,i,n,o):null,pos:r}}}class tF{constructor(e,t,n,s){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=s}static create(e,t,n,s){return new tF(e,t,n,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:s=0,filterTo:i=this.length}=e,r=e.filter;if(0==t.length&&!r)return this;if(n&&(t=t.slice().sort(tW)),this.isEmpty)return t.length?tF.of(t):this;let o=new tU(this,null,-1).goto(0),a=0,l=[],c=new tH;for(;o.value||a<t.length;)if(a<t.length&&(o.from-t[a].from||o.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(o.chunkIndex)<t[a].from)&&(!r||s>this.chunkEnd(o.chunkIndex)||i<this.chunkPos[o.chunkIndex])&&c.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||s>o.to||i<o.from||r(o.from,o.to,o.value))&&!c.addInner(o.from,o.to,o.value)&&l.push(tB.create(o.from,o.to,o.value)),o.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?tF.empty:this.nextLayer.update({add:l,filter:r,filterFrom:s,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],s=-1;for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],o=this.chunk[i],a=e.touchesRange(r,r+o.length);if(!1===a)s=Math.max(s,o.maxPoint),t.push(o),n.push(e.mapPos(r));else if(!0===a){let{mapped:i,pos:a}=o.map(r,e);i&&(s=Math.max(s,i.maxPoint),t.push(i),n.push(a))}}let i=this.nextLayer.map(e);return 0==t.length?i:new tF(n,t,i||tF.empty,s)}between(e,t,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let i=this.chunkPos[s],r=this.chunk[s];if(t>=i&&e<=i+r.length&&!1===r.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return tG.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return tG.from(e).goto(t)}static compare(e,t,n,s,i=-1){let r=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),a=tX(r,o,n),l=new tY(r,a,i),c=new tY(o,a,i);n.iterGaps((e,t,n)=>tK(l,e,c,t,n,s)),n.empty&&0==n.length&&tK(l,0,c,0,0,s)}static eq(e,t,n=0,s){null==s&&(s=0x3b9ac9ff);let i=e.filter(e=>!e.isEmpty&&0>t.indexOf(e)),r=t.filter(t=>!t.isEmpty&&0>e.indexOf(t));if(i.length!=r.length)return!1;if(!i.length)return!0;let o=tX(i,r),a=new tY(i,o,0).goto(n),l=new tY(r,o,0).goto(n);for(;;){if(a.to!=l.to||!tJ(a.active,l.active)||a.point&&(!l.point||!tq(a.point,l.point)))return!1;if(a.to>s)return!0;a.next(),l.next()}}static spans(e,t,n,s,i=-1){let r=new tY(e,null,i).goto(t),o=t,a=r.openStart;for(;;){let e=Math.min(r.to,n);if(r.point){let n=r.activeForPoint(r.to),i=r.pointFrom<t?n.length+1:r.point.startSide<0?n.length:Math.min(n.length,a);s.point(o,e,r.point,n,i,r.pointRank),a=Math.min(r.openEnd(e),n.length)}else e>o&&(s.span(o,e,r.active,a),a=r.openEnd(e));if(r.to>n)return a+(r.point&&r.to>n?1:0);o=r.to,r.next()}}static of(e,t=!1){let n=new tH;for(let s of e instanceof tB?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let s=e[n];if(tW(t,s)>0)return e.slice().sort(tW);t=s}return e}(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return tF.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=tF.empty;s=s.nextLayer)t=new tF(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}tF.empty=new tF([],[],null,-1),tF.empty.nextLayer=tF.empty;class tH{finishChunk(e){this.chunks.push(new tV(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new tH)).add(e,t,n)}addInner(e,t,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&0>(e-this.lastFrom||n.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(s<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if(0>(e-this.lastTo||t.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(tF.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=tF.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function tX(e,t,n){let s=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&s.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let r=s.get(e.chunk[t]);null==r||(n?n.mapPos(r):r)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(r,r+e.chunk[t].length))||i.add(e.chunk[t])}return i}class tU{constructor(e,t,n,s=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,t){0>(this.to-e||this.endSide-t)&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class tG{constructor(e){this.heap=e}static from(e,t=null,n=-1){let s=[];for(let i=0;i<e.length;i++)for(let r=e[i];!r.isEmpty;r=r.nextLayer)r.maxPoint>=n&&s.push(new tU(r,t,n,i));return 1==s.length?s[0]:new tG(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)tZ(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)tZ(this.heap,e);0>(this.to-e||this.value.endSide-t)&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),tZ(this.heap,0)}}}function tZ(e,t){for(let n=e[t];;){let s=(t<<1)+1;if(s>=e.length)break;let i=e[s];if(s+1<e.length&&i.compare(e[s+1])>=0&&(i=e[s+1],s++),0>n.compare(i))break;e[s]=n,e[t]=i,t=s}}class tY{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=tG.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t);)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){t0(this.active,e),t0(this.activeTo,e),t0(this.activeRank,e),this.minActive=t2(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:s,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||s-this.activeTo[t])>0;)t++;t1(this.active,t,n),t1(this.activeTo,t,s),t1(this.activeRank,t,i),e&&t1(e,t,this.cursor.from),this.minActive=t2(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&0>(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&t0(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(e.point)if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(n),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function tK(e,t,n,s,i,r){e.goto(t),n.goto(s);let o=s+i,a=s,l=s-t,c=!!r.boundChange;for(let t=!1;;){let s=e.to+l-n.to,i=s||e.endSide-n.endSide,h=i<0?e.to+l:n.to,d=Math.min(h,o);if(e.point||n.point?(e.point&&n.point&&tq(e.point,n.point)&&tJ(e.activeForPoint(e.to),n.activeForPoint(n.to))||r.comparePoint(a,d,e.point,n.point),t=!1):(t&&r.boundChange(a),d>a&&!tJ(e.active,n.active)&&r.compareRange(a,d,e.active,n.active),c&&d<o&&(s||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>o)break;a=h,i<=0&&e.next(),i>=0&&n.next()}}function tJ(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!tq(e[n],t[n]))return!1;return!0}function t0(e,t){for(let n=t,s=e.length-1;n<s;n++)e[n]=e[n+1];e.pop()}function t1(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function t2(e,t){let n=-1,s=1e9;for(let i=0;i<t.length;i++)0>(t[i]-s||e[i].endSide-e[n].endSide)&&(n=i,s=t[i]);return n}function t5(e,t,n=e.length){let s=0;for(let i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(s+=t-s%t,i++):(s++,i=eY(e,i));return s}function t3(e,t,n,s){for(let s=0,i=0;;){if(i>=t)return s;if(s==e.length)break;i+=9==e.charCodeAt(s)?n-i%n:1,s=eY(e,s)}return!0===s?-1:e.length}let t4="u"<typeof Symbol?"__ͼ":Symbol.for("ͼ"),t8="u"<typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),t6="u">typeof globalThis?globalThis:"u">typeof window?window:{};class t9{constructor(e,t){this.rules=[];let{finish:n}=t||{};function s(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}for(let t in e)!function e(t,i,r,o){let a=[],l=/^@(\w+)\b/.exec(t[0]),c=l&&"keyframes"==l[1];if(l&&null==i)return r.push(t[0]+";");for(let n in i){let o=i[n];if(/&/.test(n))e(n.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((e,t)=>e.concat(t)),o,r);else if(o&&"object"==typeof o){if(!l)throw RangeError("The value of a property ("+n+") should be a primitive value.");e(s(n),o,a,c)}else null!=o&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(a.length||c)&&r.push((n&&!l&&!o?t.map(n):t).join(", ")+" {"+a.join(" ")+"}")}(s(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=t6[t4]||1;return t6[t4]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let s=e[t8],i=n&&n.nonce;s?i&&s.setNonce(i):s=new ne(e,i),s.mount(Array.isArray(t)?t:[t],e)}}let t7=new Map;class ne{constructor(e,t){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let t=t7.get(n);if(t)return e[t8]=t;this.sheet=new s.CSSStyleSheet,t7.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[t8]=this}mount(e,t){let n=this.sheet,s=0,i=0;for(let t=0;t<e.length;t++){let r=e[t],o=this.modules.indexOf(r);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),-1==o){if(this.modules.splice(i++,0,r),n)for(let e=0;e<r.rules.length;e++)n.insertRule(r.rules[e],s++)}else{for(;i<o;)s+=this.modules[i++].rules.length;s+=r.rules.length,i++}}if(n)0>t.adoptedStyleSheets.indexOf(this.sheet)&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var nt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},nn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ns="u">typeof navigator&&/Mac/.test(navigator.platform),ni="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),nr=0;nr<10;nr++)nt[48+nr]=nt[96+nr]=String(nr);for(var nr=1;nr<=24;nr++)nt[nr+111]="F"+nr;for(var nr=65;nr<=90;nr++)nt[nr]=String.fromCharCode(nr+32),nn[nr]=String.fromCharCode(nr);for(var no in nt)nn.hasOwnProperty(no)||(nn[no]=nt[no]);function na(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var s in n)if(Object.prototype.hasOwnProperty.call(n,s)){var i=n[s];"string"==typeof i?e.setAttribute(s,i):null!=i&&(e[s]=i)}t++}for(;t<arguments.length;t++)!function e(t,n){if("string"==typeof n)t.appendChild(document.createTextNode(n));else if(null==n);else if(null!=n.nodeType)t.appendChild(n);else if(Array.isArray(n))for(var s=0;s<n.length;s++)e(t,n[s]);else throw RangeError("Unsupported child node: "+n)}(e,arguments[t]);return e}let nl="u">typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},nc="u">typeof document?document:{documentElement:{style:{}}},nh=/Edge\/(\d+)/.exec(nl.userAgent),nd=/MSIE \d/.test(nl.userAgent),nu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nl.userAgent),np=!!(nd||nu||nh),nf=!np&&/gecko\/(\d+)/i.test(nl.userAgent),nm=!np&&/Chrome\/(\d+)/.exec(nl.userAgent),ng="webkitFontSmoothing"in nc.documentElement.style,nx=!np&&/Apple Computer/.test(nl.vendor),nb=nx&&(/Mobile\/\w+/.test(nl.userAgent)||nl.maxTouchPoints>2);var nv={mac:nb||/Mac/.test(nl.platform),windows:/Win/.test(nl.platform),linux:/Linux|X11/.test(nl.platform),ie:np,ie_version:nd?nc.documentMode||6:nu?+nu[1]:nh?+nh[1]:0,gecko:nf,gecko_version:nf?+(/Firefox\/(\d+)/.exec(nl.userAgent)||[0,0])[1]:0,chrome:!!nm,chrome_version:nm?+nm[1]:0,ios:nb,android:/Android\b/.test(nl.userAgent),webkit:ng,webkit_version:ng?+(/\bAppleWebKit\/(\d+)/.exec(nl.userAgent)||[0,0])[1]:0,safari:nx,safari_version:nx?+(/\bVersion\/(\d+(\.\d+)?)/.exec(nl.userAgent)||[0,0])[1]:0,tabSize:null!=nc.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function ny(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}let nw=Object.create(null);function nO(e,t,n){if(e==t)return!0;e||(e=nw),t||(t=nw);let s=Object.keys(e),i=Object.keys(t);if(s.length-(n&&s.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let r of s)if(r!=n&&(-1==i.indexOf(r)||e[r]!==t[r]))return!1;return!0}function nk(e,t,n){let s=!1;if(t)for(let i in t)n&&i in n||(s=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(s=!0,"style"==i?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return s}class nj{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var nN=((mB=nN||(nN={}))[mB.Text=0]="Text",mB[mB.WidgetBefore=1]="WidgetBefore",mB[mB.WidgetAfter=2]="WidgetAfter",mB[mB.WidgetRange=3]="WidgetRange",mB);class nS extends tL{constructor(e,t,n,s){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=s}get heightRelevant(){return!1}static mark(e){return new nz(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new n_(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,s;if(e.isBlockGap)n=-5e8,s=4e8;else{let{start:i,end:r}=nT(e,t);n=(i?t?-3e8:-1:5e8)-1,s=(r?t?2e8:1:-6e8)+1}return new n_(e,n,s,t,e.widget||null,!0)}static line(e){return new nC(e)}static set(e,t=!1){return tF.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}nS.none=tF.empty;class nz extends nS{constructor(e){let{start:t,end:n}=nT(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?ny(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||nw}eq(e){return this==e||e instanceof nz&&this.tagName==e.tagName&&nO(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw RangeError("Mark decorations may not be empty");return super.range(e,t)}}nz.prototype.point=!1;class nC extends nS{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof nC&&this.spec.class==e.spec.class&&nO(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}nC.prototype.mapMode=e2.TrackBefore,nC.prototype.point=!0;class n_ extends nS{constructor(e,t,n,s,i,r){super(t,n,i,e),this.block=s,this.isReplace=r,this.mapMode=s?t<=0?e2.TrackBefore:e2.TrackAfter:e2.TrackDel}get type(){return this.startSide!=this.endSide?nN.WidgetRange:this.startSide<=0?nN.WidgetBefore:nN.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){var t,n;return e instanceof n_&&(t=this.widget,t==(n=e.widget)||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function nT(e,t=!1){let{inclusiveStart:n,inclusiveEnd:s}=e;return null==n&&(n=e.inclusive),null==s&&(s=e.inclusive),{start:null!=n?n:t,end:null!=s?s:t}}function nA(e,t,n,s=0){let i=n.length-1;i>=0&&n[i]+s>=e?n[i]=Math.max(n[i],t):n.push(e,t)}n_.prototype.point=!0;class nM extends tL{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof nM&&this.tagName==e.tagName&&nO(this.attributes,e.attributes)}static create(e){return new nM(e.tagName,e.attributes||nw)}static set(e,t=!1){return tF.of(e,t)}}function nP(e){return(11==e.nodeType?e.getSelection?e:e.ownerDocument:e).getSelection()}function nE(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function nR(e,t){if(!t.anchorNode)return!1;try{return nE(e,t.anchorNode)}catch(e){return!1}}function nD(e){return 3==e.nodeType?nU(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function n$(e,t,n,s){return!!n&&(nL(e,t,n,s,-1)||nL(e,t,n,s,1))}function nQ(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function nI(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function nL(e,t,n,s,i){for(;;){if(e==n&&t==s)return!0;if(t==(i<0?0:nq(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=nQ(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType||1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?nq(e):0}}}function nq(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function nB(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function nW(e,t){let n=t.width/e.offsetWidth,s=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||1>Math.abs(t.width-e.offsetWidth))&&(n=1),(s>.995&&s<1.005||!isFinite(s)||1>Math.abs(t.height-e.offsetHeight))&&(s=1),{scaleX:n,scaleY:s}}function nV(e,t=!0){let n=e.ownerDocument,s=null,i=null;for(let r=e.parentNode;r;)if(r==n.body||(!t||s)&&i)break;else if(1==r.nodeType)!i&&r.scrollHeight>r.clientHeight&&(i=r),t&&!s&&r.scrollWidth>r.clientWidth&&(s=r),r=r.assignedSlot||r.parentNode;else if(11==r.nodeType)r=r.host;else break;return{x:s,y:i}}nM.prototype.startSide=nM.prototype.endSide=-1;class nF{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?nq(t):0),n,Math.min(e.focusOffset,n?nq(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}}let nH=null;function nX(e){if(e.setActive)return e.setActive();if(nH)return e.focus(nH);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==nH?{get preventScroll(){return nH={preventScroll:!0},!0}}:void 0),!nH){nH=!1;for(let e=0;e<t.length;){let n=t[e++],s=t[e++],i=t[e++];n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=i&&(n.scrollLeft=i)}}}function nU(e,t,s=t){let i=n||(n=document.createRange());return i.setEnd(e,s),i.setStart(e,t),i}function nG(e,t,n,s){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};s&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=s);let r=new KeyboardEvent("keydown",i);r.synthetic=!0,e.dispatchEvent(r);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,e.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function nZ(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function nY(e,t){for(let n=e,s=t;;)if(3==n.nodeType&&s>0)return{node:n,offset:s};else if(1==n.nodeType&&s>0){if("false"==n.contentEditable)return null;s=nq(n=n.childNodes[s-1])}else{if(!n.parentNode||nI(n))return null;s=nQ(n),n=n.parentNode}}function nK(e,t){for(let n=e,s=t;;)if(3==n.nodeType&&s<n.nodeValue.length)return{node:n,offset:s};else if(1==n.nodeType&&s<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[s],s=0}else{if(!n.parentNode||nI(n))return null;s=nQ(n)+1,n=n.parentNode}}nv.safari&&nv.safari_version>=26&&(nH=!1);class nJ{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new nJ(e.parentNode,nQ(e),t)}static after(e,t){return new nJ(e.parentNode,nQ(e)+1,t)}}var n0=((mW=n0||(n0={}))[mW.LTR=0]="LTR",mW[mW.RTL=1]="RTL",mW);let n1=n0.LTR,n2=n0.RTL;function n5(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}let n3=n5("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),n4=n5("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),n8=Object.create(null),n6=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);n8[t]=n,n8[n]=-t}function n9(e){return e<=247?n3[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?n4[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}let n7=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class se{get dir(){return this.level%2?n2:n1}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,s){let i=-1;for(let r=0;r<e.length;r++){let o=e[r];if(o.from<=t&&o.to>=t){if(o.level==n)return r;(i<0||(0!=s?s<0?o.from<t:o.to>t:e[i].level>o.level))&&(i=r)}}if(i<0)throw RangeError("Index out of range");return i}}let st=[];function sn(e){return[new se(0,e,0)]}let ss="",si=tr.define(),sr=tr.define(),so=tr.define(),sa=tr.define(),sl=tr.define(),sc=tr.define(),sh=tr.define(),sd=tr.define(),su=tr.define(),sp=tr.define({combine:e=>e.some(e=>e)}),sf=tr.define({combine:e=>e.some(e=>e)}),sm=tr.define();class sg{constructor(e,t,n,s,i,r=!1){this.range=e,this.y=t,this.x=n,this.yMargin=s,this.xMargin=i,this.isSnapshot=r}map(e){return e.empty?this:new sg(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new sg(tn.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let sx=tT.define({map:(e,t)=>e.map(t)}),sb=tT.define();function sv(e,t,n){let s=e.facet(sa);s.length?s[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}let sy=tr.define({combine:e=>!e.length||e[0]}),sw=0,sO=tr.define({combine:e=>e.filter((t,n)=>{for(let s=0;s<n;s++)if(e[s].plugin==t.plugin)return!1;return!0})});class sk{constructor(e,t,n,s,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=s,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(sO.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(sO.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:n,eventObservers:s,provide:i,decorations:r}=t||{};return new sk(sw++,e,n,s,e=>{let t=[];return r&&t.push(sz.of(t=>{let n=t.plugin(e);return n?r(n):nS.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return sk.define((t,n)=>new e(t,n),t)}}class sj{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(sv(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){sv(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null==(t=this.value)?void 0:t.destroy)try{this.value.destroy()}catch(t){sv(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let sN=tr.define(),sS=tr.define(),sz=tr.define(),sC=tr.define(),s_=tr.define(),sT=tr.define(),sA=tr.define();function sM(e,t){let n=e.state.facet(sA);if(!n.length)return n;let s=n.map(t=>t instanceof Function?t(e):t),i=[];return tF.spans(s,t.from,t.to,{point(){},span(e,n,s,r){let o=e-t.from,a=n-t.from,l=i;for(let e=s.length-1;e>=0;e--,r--){let n=s[e].spec.bidiIsolate,i;if(null==n&&(n=function(e,t,n){for(let s=t;s<n;s++){let t=n9(e.charCodeAt(s));if(1==t)break;if(2==t||4==t)return n2}return n1}(t.text,o,a)),r>0&&l.length&&(i=l[l.length-1]).to==o&&i.direction==n)i.to=a,l=i.inner;else{let e={from:o,to:a,direction:n,inner:[]};l.push(e),l=e.inner}}}}),i}let sP=tr.define();function sE(e){let t=0,n=0,s=0,i=0;for(let r of e.state.facet(sP)){let o=r(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(n=Math.max(n,o.right)),null!=o.top&&(s=Math.max(s,o.top)),null!=o.bottom&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:s,bottom:i}}let sR=tr.define();class sD{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new sD(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>n.toA)){if(s.toA<n.fromA)break;n=n.join(s),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let s=0,i=0,r=0;;){let o=Math.min(s<e.length?e[s].fromB:1e9,i<t.length?t[i]:1e9);if(1e9==o)break;let a=o+r,l=o,c=a;for(;;)if(i<t.length&&t[i]<=l){let n=t[i+1];i+=2,l=Math.max(l,n);for(let t=s;t<e.length&&e[t].fromB<=l;t++)r=e[t].toA-e[t].toB;c=Math.max(c,n+r)}else if(s<e.length&&e[s].fromB<=l){let t=e[s++];l=Math.max(l,t.toB),c=Math.max(c,t.toA),r=t.toA-t.toB}else break;n.push(new sD(a,c,o,l))}return n}}class s${constructor(e,t,n){for(let s of(this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=e3.empty(this.startState.doc.length),n))this.changes=this.changes.compose(s.changes);let s=[];this.changes.iterChangedRanges((e,t,n,i)=>s.push(new sD(e,t,n,i))),this.changedRanges=s}static create(e,t,n){return new s$(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}let sQ=[];class sI{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return sQ}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let s=e.attributes[n].name;null==t[s]&&e.removeAttribute(s)}for(let n in t){let s=t[n];"style"==n?e.style.cssText=s:e.getAttribute(n)!=s&&e.setAttribute(n,s)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=nQ(this.dom),s=this.length?e>0:t>0;return new nJ(this.parent.dom,n+ +!!s,0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof sB)return e;return null}static get(e){return e.cmTile}}class sL extends sI{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t=this.dom,n=null,s,i=(null==e?void 0:e.node)==t?e:null,r=0;for(let o of this.children){if(o.sync(e),r+=o.length+o.breakAfter,s=n?n.nextSibling:t.firstChild,i&&s!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;s&&s!=o.dom;)s=sq(s);else t.insertBefore(o.dom,s);n=o.dom}for(s=n?n.nextSibling:t.firstChild,i&&s&&(i.written=!0);s;)s=sq(s);this.length=r}}function sq(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class sB extends sL{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=sI.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,s=0,i=0;;)if(s==n.children.length){if(!t.length)return;(n=n.parent).breakAfter&&i++,s=t.pop()}else{let r=n.children[s++];if(r instanceof sW)t.push(s),n=r,s=0;else{let t=i+r.length,n=e(r,i);if(void 0!==n)return n;i=t+r.breakAfter}}}resolveBlock(e,t){let n,s=-1,i,r=-1;if(this.blockTiles((o,a)=>{let l=a+o.length;if(e>=a&&e<=l){if(o.isWidget()&&t>=-1&&t<=1){if(32&o.flags)return!0;16&o.flags&&(n=void 0)}(a<e||e==l&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,s=e-a),(l>e||e==a&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,r=e-a)}}),!n&&!i)throw Error("No tile at position "+e);return n&&t<0||!i?{tile:n,offset:s}:{tile:i,offset:r}}}class sW extends sL{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new sW(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class sV extends sL{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let s=new sV(t||document.createElement("div"),e);return t&&n||(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,t,n){let s=null,i=-1,r=null,o=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let d=a.children[c],u=h+d.length;u>=l&&(d.isComposite()?e(d,l-h):(!r||r.isHidden&&(t>0||n&&function(e,t){let n=e.coordsIn(0,1),s=t.coordsIn(0,1);return n&&s&&s.top<n.bottom}(r,d)))&&(u>l||32&d.flags)?(r=d,o=l-h):(h<l||16&d.flags&&!d.isHidden)&&(s=d,i=l-h)),h=u}}(this,e);let a=(t<0?s:r)||s||r;return a?{tile:a,offset:a==s?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=nD(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:s}=n;if(this.dom.contains(e.dom))return e.isText()?new nJ(e.dom,Math.min(e.dom.nodeValue.length,s)):e.domPosFor(s,16&e.flags?1:32&e.flags?-1:t);let i=n.tile.parent,r=!1;for(let e of i.children){if(r)return new nJ(e.dom,0);e==n.tile&&(r=!0)}}return new nJ(this.dom,0)}}class sF extends sL{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new sF(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class sH extends sI{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let s=e,i=e,r=0;0==e&&t<0||e==n&&t>=0?!(nv.chrome||nv.gecko)&&(e?(s--,r=1):i<n&&(i++,r=-1)):t<0?s--:i<n&&i++;let o=nU(this.dom,s,i).getClientRects();if(!o.length)return null;let a=o[(r?r<0:t>=0)?0:o.length-1];return nv.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(o,e=>e.width)||a),r?nB(a,r<0):a||null}static of(e,t){let n=new sH(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class sX extends sI{constructor(e,t,n,s){super(e,t,s),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let s=this.widget.coordsAt(this.dom,e,t);if(s)return s;if(n)return nB(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let s=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let i=s?t.length-1:0;n=t[i],e>0?0!=i:i!=t.length-1&&!(n.top<n.bottom);i+=s?-1:1);return nB(n,!s)}}get overrideDOMText(){if(!this.length)return eB.empty;let{root:e}=this;if(!e)return eB.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,s,i){return!i&&(i=e.toDOM(t),e.editable||(i.contentEditable="false")),new sX(i,n,e,s)}}class sU extends sI{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return eB.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class sG{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:s,index:i,beforeBreak:r,parents:o}=this;for(;e||t>0;)if(s.isComposite())if(r){if(!e)break;n&&n.break(),e--,r=!1}else if(i==s.children.length){if(!e&&!o.length)break;n&&n.leave(s),r=!!s.breakAfter,({tile:s,index:i}=o.pop()),i++}else{let a=s.children[i],l=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!n||!1!==n.skip(a,0,a.length)||!a.isComposite)?(r=!!l,i++,e-=a.length):(o.push({tile:s,index:i}),s=a,i=0,n&&a.isComposite()&&n.enter(a))}else if(i==s.length)r=!!s.breakAfter,({tile:s,index:i}=o.pop()),i++;else if(e){let t=Math.min(e,s.length-i);n&&n.skip(s,i,i+t),e-=t,i+=t}else break;return this.tile=s,this.index=i,this.beforeBreak=r,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class sZ{constructor(e,t,n,s){this.from=e,this.to=t,this.wrapper=n,this.rank=s}}class sY{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,s){var i;this.flushBuffer();let r=this.ensureMarks(t,n),o=r.lastChild;o&&o.isText()&&!(8&o.flags)&&o.length+e.length<512?(this.cache.reused.set(o,2),(r.children[r.children.length-1]=new sH(o.dom,o.text+e)).parent=r):r.append(s||sH.of(e,null==(i=this.cache.find(sH))?void 0:i.dom)),this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?s3(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let s=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=s.lastChild;if(i instanceof sF&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(s3(n.dom)),s=i;else{if(this.cache.reused.get(n)){let e=sI.get(n.dom);e&&e.setDOM(s3(n.dom))}let e=sF.of(n.mark,n.dom);s.append(e),s=e}this.cache.reused.set(n,2)}let i=sI.get(e.text);i&&this.cache.reused.set(i,2);let r=new sH(e.text,e.text.nodeValue);r.flags|=8,s.append(r)}addInlineWidget(e,t,n){let s=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);s||this.flushBuffer();let i=this.ensureMarks(t,n);s||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=s5);let s=sV.start(e,t||(null==(n=this.cache.find(sV))?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let s=this.curLine;for(let i=e.length-1;i>=0;i--){let r=e[i],o;if(t>0&&(o=s.lastChild)&&o instanceof sF&&o.mark.eq(r))s=o,t--;else{let e=sF.of(r,null==(n=this.cache.find(sF,e=>e.mark.eq(r)))?void 0:n.dom);s.append(e),s=e,t=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!s2(this.curLine,!1)||"BR"!=e.dom.nodeName&&e.isWidget()&&!(nv.ios&&s2(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(s8,0,32)||new sX(s8.toDOM(),0,s8,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new sZ(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&0>(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to);)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let s=t.lastChild;if(n.from<this.pos&&s instanceof sW&&s.wrapper.eq(n.wrapper))t=s;else{let s=sW.of(n.wrapper,null==(e=this.cache.find(sW,e=>e.wrapper.eq(n.wrapper)))?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(sU,void 0,1);return n&&(n.flags=t),n||new sU(t)}flushBuffer(){this.afterWidget&&!(32&this.afterWidget.flags)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class sK{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:s}=this.cursor.next(this.skipCount);if(this.skipCount=0,s)throw Error("Ran out of text content when drawing inline views");this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}let sJ=[sX,sV,sH,sF,sU,sW,sB];for(let e=0;e<sJ.length;e++)sJ[e].bucket=e;class s0{constructor(e){this.view=e,this.buckets=sJ.map(()=>[]),this.index=sJ.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let s=e.bucket,i=this.buckets[s],r=this.index[s];for(let e=i.length-1;e>=0;e--){let o=(e+r)%i.length,a=i[o];if((!t||t(a))&&!this.reused.has(a))return i.splice(o,1),o<r&&this.index[s]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let s=this.buckets[0];if(s.length)for(let i=0,r=0;;i++){if(i==s.length){if(r)return null;r=1,i=0}let o=s[i];if(!this.reused.has(o)&&(0==r?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget))){if(s.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(497&o.flags)==n)return this.reused.set(o,1),o;return this.reused.set(o,2),new sX(o.dom,t,e,-498&o.flags|n)}}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class s1{constructor(e,t,n,s,i){this.view=e,this.decorations=s,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new s0(e),this.text=new sK(e.state.doc),this.builder=new sY(this.cache,new sB(e,e.contentDOM),tF.iter(n)),this.cache.reused.set(t,2),this.old=new sG(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let s=0,i=0,r=0;;){let o=r<e.length?e[r++]:null,a=o?o.fromA:this.old.root.length;if(a>s){let e=a-s;this.preserve(e,!r,!o),s=a,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,s=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let s=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let s=n==e.parents.length?e.tile:e.parents[n].tile;s instanceof sF&&t.push(s.mark)}return t}(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let r=n>0||t<e.length?sX.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&r.flags?(r.flags&=-2,this.builder.addBlockWidget(r)):(this.builder.ensureLine(null),this.builder.addInlineWidget(r,s,i),i=s.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length||this.cache.reused.has(e)?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),s,i)):this.builder.addText(e.text,s,i,this.cache.reuse(e)),i=s.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof sU)this.cache.add(e);else{if(!(e instanceof sF))return!1;this.builder.ensureLine(null),this.builder.addMark(e,s,i),this.cache.reused.set(e,1),i=s.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof sF&&s.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?s.length&&(s.length=i=0):e instanceof sF&&(s.shift(),i=Math.min(i,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,s=this.builder,i=0,r=tF.spans(this.decorations,e,t,{point:(e,t,r,o,a,l)=>{var c,h,d;if(r instanceof n_){if(this.disallowBlockEffectsFor[l]){if(r.block)throw RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=o.length,a>o.length)s.continueWidget(t-e);else{let i,l=r.widget||(r.block?s4.block:s4.inline),h=(i=(c=r).isReplace?64*(c.startSide<0)|128*(c.endSide>0):c.startSide>0?32:16,c.block&&(i|=256),i),d=this.cache.findWidget(l,t-e,h)||sX.of(l,this.view,t-e,h);r.block?(r.startSide>0&&s.addLineStartIfNotCovered(n),s.addBlockWidget(d)):(s.ensureLine(n),s.addInlineWidget(d,o,a))}n=null}else{let e,t;h=n,e=(d=r).spec.attributes,t=d.spec.class,(e||t)&&(h||(h={class:"cm-line"}),e&&ny(e,h),t&&(h.class+=" "+t)),n=h}t>e&&this.text.skip(t-e)},span:(e,t,i,r)=>{for(let o=e;o<t;){let a=this.text.next(Math.min(512,t-o));null==a?(s.addLineStartIfNotCovered(n),s.addBreak(),o++):(s.ensureLine(n),s.addText(a,i,o==e?r:i.length),o+=a.length),n=null}}});s.addLineStartIfNotCovered(n),this.openWidget=r>i,this.openMarks=r}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let s=e.parentNode;;s=s.parentNode){let e=sI.get(s);if(s==this.view.contentDOM)break;e instanceof sF?t.push(e):(null==e?void 0:e.isLine())?n=e:e instanceof sW||("DIV"!=s.nodeName||n||s==this.view.contentDOM?n||t.push(sF.of(new nz({tagName:s.nodeName.toLowerCase(),attributes:function(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let s=e.attributes[n];t[s.name]=s.value}return t}(s)}),s)):n=new sV(s,s5))}return{line:n,marks:t}}}function s2(e,t){let n=e=>{for(let s of e.children)if((t?s.isText():s.length)||n(s))return!0;return!1};return n(e)}let s5={class:"cm-line"};function s3(e){let t=sI.get(e);return t&&t.setDOM(e.cloneNode()),e}class s4 extends nj{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}s4.inline=new s4("span"),s4.block=new s4("div");let s8=new class extends nj{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class s6{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=nS.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new sB(e,e.contentDOM),this.updateInner([new sD(0,0,0,e.state.doc.length)],null)}update(e){var t,n,s,i,r,o,a,l,c;let h,d,u,p=e.changedRanges;this.minWidth>0&&p.length&&(p.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let f=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null==(t=this.domChanged)?void 0:t.newSel)?f=this.domChanged.newSel.head:(n=e.changes,s=this.hasComposition,h=!1,s&&n.iterChangedRanges((e,t)=>{e<s.to&&t>s.from&&(h=!0)}),h||e.selectionSet||(f=e.state.selection.main.head)));let m=f>-1?function(e,t,n){let s=s7(e,n);if(!s)return null;let{node:i,from:r,to:o}=s,a=i.nodeValue;if(/[\n\r]/.test(a)||e.state.doc.sliceString(s.from,s.to)!=a)return null;let l=t.invertedDesc;return{range:new sD(l.mapPos(r),l.mapPos(o),r,o),text:i}}(this.view,e.changes,f):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:n}=this.hasComposition;p=new sD(t,n,e.changes.mapPos(t,-1),e.changes.mapPos(n,1)).addToSet(p.slice())}this.hasComposition=m?{from:m.range.fromB,to:m.range.toB}:null,(nv.ie||nv.chrome)&&!m&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let g=this.decorations,x=this.blockWrappers;this.updateDeco();let b=(i=g,r=this.decorations,o=e.changes,d=new ie,tF.compare(i,r,o,d),d.changes);b.length&&(p=sD.extendWithRanges(p,b));let v=(a=x,l=this.blockWrappers,c=e.changes,u=new it,tF.compare(a,l,c,u),u.changes);return v.length&&(p=sD.extendWithRanges(p,v)),m&&!p.some(e=>e.fromA<=m.range.fromA&&e.toA>=m.range.toA)&&(p=m.range.addToSet(p.slice())),(!(2&this.tile.flags)||0!=p.length)&&(this.updateInner(p,m),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,s=new s1(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&sI.get(t.text)&&s.cache.reused.set(sI.get(t.text),2),this.tile=s.run(e,t),s9(n,s.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=nv.chrome||nv.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||n.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof is&&s.push(e.dom);n.updateGaps(s)}updateEditContextFormatting(e){for(let t of(this.editContextFormatting=this.editContextFormatting.map(e.changes),e.transactions))for(let e of t.effects)e.is(sb)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){var n;(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:s}=this.tile,i=this.view.root.activeElement,r=i==s,o=!r&&!(this.view.state.facet(sy)||s.tabIndex>-1)&&nR(s,this.view.observer.selectionRange)&&!(i&&s.contains(i));if(!(r||t||o))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,h;if(l.empty?h=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(h=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),nv.gecko&&l.empty&&!this.hasComposition&&1==(n=c).node.nodeType&&n.node.firstChild&&(0==n.offset||"false"==n.node.childNodes[n.offset-1].contentEditable)&&(n.offset==n.node.childNodes.length||"false"==n.node.childNodes[n.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=h=new nJ(e,0),a=!0}let d=this.view.observer.selectionRange;!a&&d.focusNode&&(n$(c.node,c.offset,d.anchorNode,d.anchorOffset)&&n$(h.node,h.offset,d.focusNode,d.focusOffset)||this.suppressWidgetCursorChange(d,l))||(this.view.observer.ignore(()=>{nv.android&&nv.chrome&&s.contains(d.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(d.focusNode,s)&&(s.blur(),s.focus({preventScroll:!0}));let e=nP(this.view.root);if(e)if(l.empty){if(nv.gecko){var t,n;let e=(t=c.node,n=c.offset,1!=t.nodeType?0:(n&&"false"==t.childNodes[n-1].contentEditable?1:0)|2*(n<t.childNodes.length&&"false"==t.childNodes[n].contentEditable));if(e&&3!=e){let t=(1==e?nY:nK)(c.node,c.offset);t&&(c=new nJ(t.node,t.offset))}}e.collapse(c.node,c.offset),null!=l.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=l.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(h.node,h.offset)}catch(e){}}else{let t=document.createRange();l.anchor>l.head&&([c,h]=[h,c]),t.setEnd(h.node,h.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}o&&this.view.root.activeElement==s&&(s.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new nJ(d.anchorNode,d.anchorOffset),this.impreciseHead=h.precise?null:new nJ(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&n$(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=nP(e.root),{anchorNode:s,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let r=this.lineAt(t.head,t.assoc);if(!r)return;let o=r.posAtStart;if(t.head==o||t.head==o+r.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(s,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let s=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let s=0==nq(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==s&&t.firstChild!=t.lastChild&&(s=e==t.firstChild?-1:1),e=t}i=s<0?e:e.nextSibling}if(i==n.dom.firstChild)return s;for(;i&&!sI.get(i);)i=i.nextSibling;if(!i)return s+n.length;for(let e=0,t=s;;e++){let s=n.children[e];if(s.dom==i)return t;t+=s.length+s.breakAfter}}else if(n.isText())return e==n.dom?s+t:s+(t?n.length:0);else return s}domAtPos(e,t){let{tile:n,offset:s}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(s,t)}inlineDOMNearPos(e,t){let n,s=-1,i=!1,r,o=-1,a=!1;return(this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(i=!0)}else{let c=l+t.length;if(l<=e&&(n=t,s=e-l,i=c<e),c>=e&&!r&&(r=t,o=e-l,a=l>e),l>e&&r)return!0}}),n||r)?(i&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(s,t):r.domIn(o,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:s}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof is?null:n.coordsInWidget(s,t,!0):n.coordsIn(s,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);return t.isLine()?function e(t,n){if(t.isComposite())for(let s of t.children){if(s.length>=n){let t=e(s,n);if(t)return t}if((n-=s.length)<0)break}else if(t.isText()&&n<t.length){let e=eY(t.text,n);if(e==n)return null;let s=nU(t.dom,n,e).getClientRects();for(let e=0;e<s.length;e++){let t=s[e];if(e==s.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n):null}measureVisibleLineHeights(e){let t=[],{from:n,to:s}=e,i=this.view.contentDOM.clientWidth,r=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==n0.LTR,l=0,c=(e,h,d)=>{for(let u=0;u<e.children.length&&!(h>s);u++){let s=e.children[u],p=h+s.length,f=s.dom.getBoundingClientRect(),{height:m}=f;if(d&&!u&&(l+=f.top-d.top),s instanceof sW)p>n&&c(s,h,f);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,r)){let e=s.dom.lastChild,t=e?nD(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-f.left:f.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=h,this.minWidthTo=p)}}d&&u==e.children.length-1&&(l+=d.bottom-f.bottom),h=p+s.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?n0.RTL:n0.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let s of e.children){if(!s.isText()||/[^ -~]/.test(s.text))return;let e=nD(s.dom);if(1!=e.length)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement("div"),n,s,i;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=nD(t.firstChild)[0];n=t.getBoundingClientRect().height,s=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:s,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,s=0;;s++){let i=s==t.viewports.length?null:t.viewports[s],r=i?i.from-1:this.view.state.doc.length;if(r>n){let s=(t.lineBlockAt(r).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(nS.replace({widget:new is(s),block:!0,inclusive:!0,isBlockGap:!0}).range(n,r))}if(!i)break;n=i.to+1}return nS.set(e)}updateDeco(){let e=1,t=this.view.state.facet(sz).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,s=this.view.state.facet(s_).map((e,t)=>{let s="function"==typeof e;return s&&(n=!0),s?e(this.view):e});for(s.length&&(this.dynamicDecorationMap[e++]=n,t.push(tF.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(sC).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){var t;if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(sm))try{if(t(this.view,e.range,e))return!0}catch(e){sv(this.view.state,e,"scroll handler")}let{range:n}=e,s=this.coordsAt(n.head,null!=(t=n.assoc)?t:n.empty?0:n.head>n.anchor?-1:1),i;if(!s)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(s={left:Math.min(s.left,i.left),top:Math.min(s.top,i.top),right:Math.max(s.right,i.right),bottom:Math.max(s.bottom,i.bottom)});let r=sE(this.view),o={left:s.left-r.left,top:s.top-r.top,right:s.right+r.right,bottom:s.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(!function(e,t,n,s,i,r,o,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,d=!1;h&&!d;)if(1==h.nodeType){let e,u=h==l.body,p=1,f=1;if(u)e=function(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(d=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:p,scaleY:f}=nW(h,t)),e={left:t.left,right:t.left+h.clientWidth*p,top:t.top,bottom:t.top+h.clientHeight*f}}let m=0,g=0;if("nearest"==i)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let s=t.bottom-t.top,r=e.bottom-e.top;g=("center"==i&&s<=r?t.top+s/2-r/2:"start"==i||"center"==i&&n<0?t.top-o:t.bottom-r+o)-e.top}if("nearest"==s?t.left<e.left+r?(m=t.left-(e.left+r),n>0&&t.right>e.right+m&&(m=t.right-e.right+r)):t.right>e.right-r&&(m=t.right-e.right+r,n<0&&t.left<e.left+m&&(m=t.left-(e.left+r))):m=("center"==s?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==s==a?t.left-r:t.right-(e.right-e.left)+r)-e.left,m||g)if(u)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=h.scrollTop;h.scrollTop+=g/f,n=(h.scrollTop-e)*f}if(m){let t=h.scrollLeft;h.scrollLeft+=m/p,e=(h.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&1>Math.abs(e-m)&&(s="nearest"),n&&1>Math.abs(n-g)&&(i="nearest")}if(u)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else if(11==h.nodeType)h=h.host;else break}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==n0.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(s.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||s.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(n.head,1);e&&e.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){s9(this.tile)}}function s9(e,t){let n=null==t?void 0:t.get(e);if(1!=n)for(let s of(null==n&&e.destroy(),e.children))s9(s,t)}function s7(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let s=nY(n.focusNode,n.focusOffset),i=nK(n.focusNode,n.focusOffset),r=s||i;if(i&&s&&i.node!=s.node){let t=sI.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)r=i;else if(e.docView.lastCompositionAfterCursor){let e=sI.get(s.node);!e||e.isText()&&e.text!=s.node.nodeValue||(r=i)}}if(e.docView.lastCompositionAfterCursor=r!=s,!r)return null;let o=t-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}let ie=class{constructor(){this.changes=[]}compareRange(e,t){nA(e,t,this.changes)}comparePoint(e,t){nA(e,t,this.changes)}boundChange(e){nA(e,e,this.changes)}};class it{constructor(){this.changes=[]}compareRange(e,t){nA(e,t,this.changes)}comparePoint(){}boundChange(e){nA(e,e,this.changes)}}class is extends nj{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function ii(e,t,n){let s=e.lineBlockAt(t);if(Array.isArray(s.type)){let e;for(let i of s.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==nN.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||s}return s}function ir(e,t,n,s){let i=e.state.doc.lineAt(t.head),r=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let a=t,l=null;;){let t=function(e,t,n,s,i){var r;let o=s.head-e.from,a=se.find(t,o,null!=(r=s.bidiLevel)?r:-1,s.assoc),l=t[a],c=l.side(i,n);if(o==c){let e=a+=i?1:-1;if(e<0||e>=t.length)return null;o=(l=t[a=e]).side(!i,n),c=l.side(i,n)}let h=eY(e.text,o,l.forward(i,n));(h<l.from||h>l.to)&&(h=c),ss=e.text.slice(Math.min(o,h),Math.max(o,h));let d=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return d&&h==c&&d.level+ +!i<l.level?tn.cursor(d.side(!i,n)+e.from,d.forward(i,n)?1:-1,d.level):tn.cursor(h+e.from,l.forward(i,n)?-1:1,l.level)}(i,r,o,a,n),c=ss;if(!t){if(i.number==(n?e.state.doc.lines:1))return a;c="\n",i=e.state.doc.line(i.number+(n?1:-1)),r=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!s)return t;l=s(c)}a=t}}function io(e,t,n){for(;;){let s=0;for(let i of e)i.between(t-1,t+1,(e,i,r)=>{if(t>e&&t<i){let r=s||n||(t-e<i-t?-1:1);t=r<0?e:i,s=r}});if(!s)return t}}function ia(e,t){let n=null;for(let s=0;s<t.ranges.length;s++){let i=t.ranges[s],r=null;if(i.empty){let t=io(e,i.from,0);t!=i.from&&(r=tn.cursor(t,-1))}else{let t=io(e,i.from,-1),n=io(e,i.to,1);(t!=i.from||n!=i.to)&&(r=tn.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}r&&(n||(n=t.ranges.slice()),n[s]=r)}return n?tn.create(n,t.mainIndex):t}function il(e,t,n){let s=io(e.state.facet(sT).map(t=>t(e)),n.from,t.head>n.from?-1:1);return s==n.from?n:tn.cursor(s,s<n.from?1:-1)}class ic{constructor(e,t){this.pos=e,this.assoc=t}}function ih(e,t,n,s){let i=e.contentDOM.getBoundingClientRect(),r=i.top+e.viewState.paddingTop,{x:o,y:a}=t,l=a-r,c;for(;;){if(l<0)return new ic(0,1);if(l>e.viewState.docHeight)return new ic(e.state.doc.length,-1);if(c=e.elementAtHeight(l),null==s)break;if(c.type==nN.Text){if(s<0?c.to<e.viewport.from:c.from>e.viewport.to)break;let t=e.docView.coordsAt(s<0?c.from:c.to,s>0?-1:1);if(t&&(s<0?t.top<=l+r:t.bottom>=l+r))break}let t=e.viewState.heightOracle.textHeight/2;l=s>0?c.bottom+t:c.top-t}if(e.viewport.from>=c.to||e.viewport.to<=c.from){if(n)return null;if(c.type==nN.Text){let t=function(e,t,n,s,i){let r=Math.round((s-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;r+=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+t3(o,r,e.state.tabSize)}(e,i,c,o,a);return new ic(t,t==c.from?1:-1)}}if(c.type!=nN.Text)return l<(c.top+c.bottom)/2?new ic(c.from,1):new ic(c.to,-1);let h=e.docView.lineAt(c.from,2);return h&&h.length==c.length||(h=e.docView.lineAt(c.from,-2)),new id(e,o,a,e.textDirectionAt(c.from)).scanTile(h,c.from)}class id{constructor(e,t,n,s){this.view=e,this.x=t,this.y=n,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:s}=this.bidiSpansAt(e);return s[se.find(s,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:s}=this.bidiSpansAt(e);return s[se.find(s,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:s}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+s.from<t)}scan(e,t){let n,s,i=0,r=e.length-1,o=new Set,a=this.bidiIn(e[0],e[r]),l=-1,c=1e9,h;for(;i<r;){let d=r-i,u=i+r>>1;t:if(o.has(u)){let e=i+Math.floor(Math.random()*d);for(let t=0;t<d;t++){if(!o.has(e)){u=e;break t}++e==r&&(e=i)}break}o.add(u);let p=t(u);if(p)for(let t=0;t<p.length;t++){let o=p[t],d=0;if(0!=o.width||!(p.length>1)){if(o.bottom<this.y)(!n||n.bottom<o.bottom)&&(n=o),d=1;else if(o.top>this.y)(!s||s.top>o.top)&&(s=o),d=-1;else{let e=o.left>this.x?this.x-o.left:o.right<this.x?this.x-o.right:0,t=Math.abs(e);t<c&&(l=u,c=t,h=o),e&&(d=e<0==(this.baseDir==n0.LTR)?-1:1)}-1==d&&(!a||this.baseDirAt(e[u],1))?r=u:1==d&&(!a||this.baseDirAt(e[u+1],-1))&&(i=u+1)}}}if(!h){let i=n&&(!s||this.y-n.bottom<s.top-this.y)?n:s;return this.y=(i.top+i.bottom)/2,this.scan(e,t)}if(c){if(n&&n.bottom>h.top)return this.y=n.bottom-1,this.scan(e,t);if(s&&s.top<h.bottom)return this.y=s.top+1,this.scan(e,t)}let d=(a?this.dirAt(e[l],1):this.baseDir)==n0.LTR;return{i:l,after:this.x>(h.left+h.right)/2==d}}scanText(e,t){let n=[];for(let s=0;s<e.length;s=eY(e.text,s))n.push(t+s);n.push(t+e.length);let s=this.scan(n,s=>{let i=n[s]-t,r=n[s+1]-t;return nU(e.dom,i,r).getClientRects()});return s.after?new ic(n[s.i+1],-1):new ic(n[s.i],1)}scanTile(e,t){if(!e.length)return new ic(t,1);if(1==e.children.length){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let s=0,i=t;s<e.children.length;s++)n.push(i+=e.children[s].length);let s=this.scan(n,t=>{let n=e.children[t];return 48&n.flags?null:(1==n.dom.nodeType?n.dom:nU(n.dom,0,n.length)).getClientRects()}),i=e.children[s.i],r=n[s.i];return i.isText()?this.scanText(i,r):i.isComposite()?this.scanTile(i,r):s.after?new ic(n[s.i+1],-1):new ic(r,1)}}class iu{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(tQ.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=""}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let s=e;;){this.findPointBefore(n,s);let e=this.text.length;this.readNode(s);let i=sI.get(s),r=s.nextSibling;if(r==t){(null==i?void 0:i.breakAfter)&&!r&&n!=this.view.contentDOM&&this.lineBreak();break}let o=sI.get(r);(i&&o?i.breakAfter:(i?i.breakAfter:nI(s))||nI(r)&&("BR"!=s.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!function(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=sI.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}(r,t)&&this.lineBreak(),s=r}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,r=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),r=this.lineSeparator.length):(o=s.exec(t))&&(i=o.index,r=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),r>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=r-1);n=i+r}}readNode(e){let t=sI.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(!function(e,t,n){for(;;){if(!t||n<nq(t))return!1;if(t==e)return!0;n=nQ(t)+1,t=t.parentNode}}(e,n.node,n.offset)?0:t))}}class ip{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class im{constructor(e,t,n,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:r}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=function e(t,n,s,i){if(t.isComposite()){let r=-1,o=-1,a=-1,l=-1;for(let c=0,h=i,d=i;c<t.children.length;c++){let i=t.children[c],u=h+i.length;if(h<n&&u>s)return e(i,n,s,h);if(u>=n&&-1==r&&(r=c,o=h),h>s&&i.dom.parentNode==t.dom){a=c,l=d;break}d=u,h=u+i.breakAfter}return{from:o,to:l<0?i+t.length:l,startDOM:(r?t.children[r-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:a<t.children.length&&a>=0?t.children[a].dom:null}}return t.isText()?{from:i,to:i+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}(e.docView.tile,t,n,0))){let t=i||r?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:r}=e.observer.selectionRange;return n&&(t.push(new ip(n,s)),(i!=n||r!=s)&&t.push(new ip(i,r))),t}(e),n=new iu(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,s=2==e.length?e[1].pos:n;return n>-1&&s>-1?tn.single(n+t,s+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!nE(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),s=r&&r.node==t.anchorNode&&r.offset==t.anchorOffset||!nE(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),a=e.viewport;if((nv.ios||nv.chrome)&&o.main.empty&&n!=s&&(a.from>0||a.to<e.state.doc.length)){let t=Math.min(n,s),i=Math.max(n,s),r=a.from-t,o=a.to-i;(0==r||1==r||0==t)&&(0==o||-1==o||i==e.state.doc.length)&&(n=0,s=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(tn.range(s,n));else if(e.lineWrapping&&s==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),s=0;t&&(s=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=tn.create([tn.cursor(n,s)])}else this.newSel=tn.single(s,n)}}}function ig(e,t){let n,{newSel:s}=t,{state:i}=e,r=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:s}=t.bounds,a=r.from,l=null;(8===o||nv.android&&t.text.length<s-e)&&(a=r.to,l="end");let c=i.doc.sliceString(e,s,""),h,d;!r.empty&&r.from>=e&&r.to<=s&&(t.typeOver||c!=t.text)&&c.slice(0,r.from-e)==t.text.slice(0,r.from-e)&&c.slice(r.to-e)==t.text.slice(h=t.text.length-(c.length-(r.to-e)))?n={from:r.from,to:r.to,insert:eB.of(t.text.slice(r.from-e,h).split(""))}:(d=ib(c,t.text,a-e,l))&&(nv.chrome&&13==o&&d.toB==d.from+2&&""==t.text.slice(d.from,d.toB)&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:eB.of(t.text.slice(d.from,d.toB).split(""))})}else s&&(!e.hasFocus&&i.facet(sy)||iv(s,r))&&(s=null);if(!n&&!s)return!1;if((nv.mac||nv.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(s&&2==n.insert.length&&(s=tn.single(s.main.anchor-1,s.main.head-1)),n={from:n.from,to:n.to,insert:eB.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(r.from).to<r.to&&e.docView.lineHasWidget(r.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:r.from,to:r.to,insert:i.toText(e.inputState.insertingText)}:nv.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(s&&(s=tn.single(s.main.anchor-1,s.main.head-1)),n={from:r.from,to:r.to,insert:eB.of([" "])}),n)return ix(e,n,s,o);if(!s||iv(s,r))return!1;{let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),"select.pointer"==(n=e.inputState.lastSelectionOrigin)&&(s=ia(i.facet(sT).map(t=>t(e)),s))),e.dispatch({selection:s,scrollIntoView:t,userEvent:n}),!0}}function ix(e,t,n,s=-1){let i;if(nv.ios&&e.inputState.flushIOSKey(t))return!0;let r=e.state.selection.main;if(nv.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&" "==e.state.sliceDoc(t.from,r.from))&&1==t.insert.length&&2==t.insert.lines&&nG(e.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&0==t.insert.length||8==s&&t.insert.length<t.to-t.from&&t.to>r.head)&&nG(e.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&0==t.insert.length&&nG(e.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>i||(i=function(e,t,n){let s,i=e.state,r=i.selection.main,o=-1;if(t.from==t.to&&t.from<r.from||t.from>r.to){let n=t.from<r.from?-1:1,s=n<0?r.from:r.to,a=io(i.facet(sT).map(t=>t(e)),s,n);t.from==a&&(o=a)}if(o>-1)s={changes:t,selection:tn.cursor(t.from+t.insert.length,-1)};else if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=r.from<t.from?i.sliceDoc(r.from,t.from):"",o=r.to>t.to?i.sliceDoc(t.to,r.to):"";s=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),a=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=r.to+10&&t.to>=r.to-10){let l=e.state.sliceDoc(t.from,t.to),c,h=n&&s7(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);c={from:h.from,to:h.to-e}}else c=e.state.doc.lineAt(r.head);let d=r.to-t.to;s=i.changeByRange(n=>{if(n.from==r.from&&n.to==r.to)return{changes:o,range:a||n.map(o)};let s=n.to-d,h=s-l.length;if(e.state.sliceDoc(h,s)!=l||s>=c.from&&h<=c.to)return{range:n};let u=i.changes({from:h,to:s,insert:t.insert}),p=n.to-r.to;return{changes:u,range:a?tn.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):n.map(u)}})}else s={changes:o,selection:a&&i.selection.replaceRange(a)}}let a="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1)),i.update(s,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(sc).some(n=>n(e,t.from,t.to,o,a))||e.dispatch(a()),!0}function ib(e,t,n,s){let i=Math.min(e.length,t.length),r=0;for(;r<i&&e.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==i&&e.length==t.length)return null;let o=e.length,a=t.length;for(;o>0&&a>0&&e.charCodeAt(o-1)==t.charCodeAt(a-1);)o--,a--;if("end"==s){let e=Math.max(0,r-Math.min(o,a));n-=o+e-r}if(o<r&&e.length<t.length){let e=n<=r&&n>=o?r-n:0;r-=e,a=r+(a-o),o=r}else if(a<r){let e=n<=r&&n>=a?r-n:0;r-=e,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function iv(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class iy{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,nv.safari&&e.contentDOM.addEventListener("input",()=>null),nv.gecko&&function(e){iW.has(e)||(iW.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,s;n!=e.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(s=sI.get(n))&&s.isWidget()&&!s.isHidden&&s.widget.ignoreEvent(t))return!1;return!0}(this.view,e)||this.ignoreDuringComposition(e)||"keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=function(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,s=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(s)for(let e in s){let i=s[e];i&&n(e).handlers.push(iw(t.value,i))}if(i)for(let e in i){let s=i[e];s&&n(e).observers.push(iw(t.value,s))}}for(let e in iz)n(e).handlers.push(iz[e]);for(let e in iC)n(e).observers.push(iC[e]);return t}(e),n=this.handlers,s=this.view.contentDOM;for(let e in t)if("scroll"!=e){let i=!t[e].handlers.length,r=n[e];r&&!r.handlers.length!=i&&(s.removeEventListener(e,this.handleEvent),r=null),r||s.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)"scroll"==e||t[e]||s.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){let t;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=e.keyCode&&0>ij.indexOf(e.keyCode)&&(this.tabFocusMode=-1),nv.android&&nv.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))?(this.view.observer.delayAndroidKey(e.key,e.keyCode),!0):nv.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=iO.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||ik.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=e.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(e){let t=this.pendingIOSKey;return!(!t||"Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,nG(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&!e.synthetic&&(this.composing>0||!!(nv.safari&&!nv.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function iw(e,t){return(n,s)=>{try{return t.call(e,s,n)}catch(e){sv(n.state,e)}}}let iO=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ik="dthko",ij=[16,17,18,20,91,92,224,225];function iN(e){return .7*Math.max(0,e)+8}class iS{constructor(e,t,n,s){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=nV(e.contentDOM),this.atoms=e.state.facet(sT).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(tQ.allowMultipleSelections)&&function(e,t){let n=e.state.facet(si);return n.length?n[0](t):nv.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let s=nP(e.root);if(!s||0==s.rangeCount)return!0;let i=s.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)&&1==i$(t)&&null}start(e){!1===this.dragging&&this.select(e)}move(e){var t;if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>(t=this.startEvent,Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))))return;this.select(this.lastEvent=e);let n=0,s=0,i=0,r=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=sE(this.view);e.clientX-l.left<=i+6?n=-iN(i-e.clientX):e.clientX+l.right>=o-6&&(n=iN(e.clientX-o)),e.clientY-l.top<=r+6?s=-iN(r-e.clientY):e.clientY+l.bottom>=a-6&&(s=iN(e.clientY-a)),this.setScrollSpeed(n,s)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=ia(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,!1===this.dragging))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}let iz=Object.create(null),iC=Object.create(null),i_=nv.ie&&nv.ie_version<15||nv.ios&&nv.webkit_version<604;function iT(e,t,n){for(let s of e.facet(t))n=s(n,e);return n}function iA(e,t){t=iT(e.state,sd,t);let{state:n}=e,s,i=1,r=n.toText(t),o=r.lines==n.selection.ranges.length;if(null!=iI&&n.selection.ranges.every(e=>e.empty)&&iI==r.toString()){let e=-1;s=n.changeByRange(s=>{let a=n.doc.lineAt(s.from);if(a.from==e)return{range:s};e=a.from;let l=n.toText((o?r.line(i++).text:t)+n.lineBreak);return{changes:{from:a.from,insert:l},range:tn.cursor(s.from+l.length)}})}else s=o?n.changeByRange(e=>{let t=r.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:tn.cursor(e.from+t.length)}}):n.replaceSelection(r);e.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}function iM(e,t,n,s){if(1==s)return tn.cursor(t,n);{if(2==s)return function(e,t,n=1){let s=e.charCategorizer(t),i=e.doc.lineAt(t),r=t-i.from;if(0==i.length)return tn.cursor(t);0==r?n=1:r==i.length&&(n=-1);let o=r,a=r;n<0?o=eY(i.text,r,!1):a=eY(i.text,r);let l=s(i.text.slice(o,a));for(;o>0;){let e=eY(i.text,o,!1);if(s(i.text.slice(e,o))!=l)break;o=e}for(;a<i.length;){let e=eY(i.text,a);if(s(i.text.slice(a,e))!=l)break;a=e}return tn.range(o+i.from,a+i.from)}(e.state,t,n);let i=e.docView.lineAt(t,n),r=e.state.doc.lineAt(i?i.posAtEnd:t),o=i?i.posAtStart:r.from,a=i?i.posAtEnd:r.to;return a<e.state.doc.length&&a==r.to&&a++,tn.range(o,a)}}iC.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},iC.wheel=iC.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},iz.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),iC.touchstart=(e,t)=>{let n=e.inputState,s=t.targetTouches[0];n.lastTouchTime=Date.now(),s&&(n.lastTouchX=s.clientX,n.lastTouchY=s.clientY),n.setSelectionOrigin("select.pointer")},iC.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},iz.mousedown=(e,t)=>{var n,s;let i,r,o;if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let a=null;for(let n of e.state.facet(so))if(a=n(e,t))break;if(a||0!=t.button||(n=e,s=t,i=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),r=i$(s),o=n.state.selection,a={update(e){e.docChanged&&(i.pos=e.changes.mapPos(i.pos),o=o.map(e.changes))},get(e,t,s){let a=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),l,c=iM(n,a.pos,a.assoc,r);if(i.pos!=a.pos&&!t){let e=iM(n,i.pos,i.assoc,r),t=Math.min(e.from,c.from),s=Math.max(e.to,c.to);c=t<c.from?tn.range(t,s,c.assoc):tn.range(s,t,c.assoc)}return t?o.replaceRange(o.main.extend(c.from,c.to,c.assoc)):s&&1==r&&o.ranges.length>1&&(l=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:s,to:i}=e.ranges[n];if(s<=t&&i>=t)return tn.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n))}return null}(o,a.pos))?l:s?o.addRange(c):tn.create([c])}}),a){let n=!e.hasFocus;e.inputState.startMouseSelection(new iS(e,t,a,n)),n&&e.observer.ignore(()=>{nX(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let s=e.inputState.mouseSelection;if(s)return s.start(t),!1===s.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};let iP=nv.ie&&nv.ie_version<=11,iE=null,iR=0,iD=0;function i$(e){if(!iP)return e.detail;let t=iE,n=iD;return iE=e,iD=Date.now(),iR=!t||n>Date.now()-400&&2>Math.abs(t.clientX-e.clientX)&&2>Math.abs(t.clientY-e.clientY)?(iR+1)%3:1}function iQ(e,t,n,s){let i;if(!(n=iT(e.state,sd,n)))return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,a=s&&o&&((i=e.state.facet(sr)).length?i[0](t):nv.mac?!t.altKey:!t.ctrlKey)?{from:o.from,to:o.to}:null,l={from:r,insert:n},c=e.state.changes(a?[a,l]:l);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(r,-1),head:c.mapPos(r,1)},userEvent:a?"move.drop":"input.drop"}),e.inputState.draggedContent=null}iz.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let s=e.docView.tile.nearest(t.target);if(s&&s.isWidget()){let e=s.posAtStart,t=e+s.length;(e>=n.to||t<=n.from)&&(n=tn.range(e,t))}}let{inputState:s}=e;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",iT(e.state,su,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},iz.dragend=e=>(e.inputState.draggedContent=null,!1),iz.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let s=Array(n.length),i=0,r=()=>{++i==n.length&&iQ(e,t,s.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=r,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(s[e]=t.result),r()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return iQ(e,t,n,!0),!0}return!1},iz.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=i_?null:t.clipboardData;return n?(iA(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(!function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),iA(e,n.value)},50)}(e),!1)};let iI=null;iz.copy=iz.cut=(e,t)=>{if(!nR(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:s,linewise:i}=function(e){let t=[],n=[],s=!1;for(let s of e.selection.ranges)s.empty||(t.push(e.sliceDoc(s.from,s.to)),n.push(s));if(!t.length){let i=-1;for(let{from:s}of e.selection.ranges){let r=e.doc.lineAt(s);r.number>i&&(t.push(r.text),n.push({from:r.from,to:Math.min(e.doc.length,r.to+1)})),i=r.number}s=!0}return{text:iT(e,su,t.join(e.lineBreak)),ranges:n,linewise:s}}(e.state);if(!n&&!i)return!1;iI=i?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let r=i_?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",n),!0):(!function(e,t){let n=e.dom.parentNode;if(!n)return;let s=n.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=t,s.focus(),s.selectionEnd=t.length,s.selectionStart=0,setTimeout(()=>{s.remove(),e.focus()},50)}(e,n),!1)};let iL=tz.define();function iq(e,t){let n=[];for(let s of e.facet(sh)){let i=s(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:iL.of(!0)}):null}function iB(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=iq(e.state,t);n?e.dispatch(n):e.update([])}},10)}iC.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),iB(e)},iC.blur=e=>{e.observer.clearSelectionRange(),iB(e)},iC.compositionstart=iC.compositionupdate=e=>{!e.observer.editContext&&(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},iC.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,nv.chrome&&nv.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},iC.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},iz.beforeinput=(e,t)=>{var n,s;let i;if(("insertText"==t.inputType||"insertCompositionText"==t.inputType)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let s=null==(n=t.dataTransfer)?void 0:n.getData("text/plain"),i=t.getTargetRanges();if(s&&i.length){let t=i[0],n=e.posAtDOM(t.startContainer,t.startOffset),r=e.posAtDOM(t.endContainer,t.endOffset);return ix(e,{from:n,to:r,insert:e.state.toText(s)},null),!0}}if(nv.chrome&&nv.android&&(i=iO.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){let t=(null==(s=window.visualViewport)?void 0:s.height)||0;setTimeout(()=>{var n;((null==(n=window.visualViewport)?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return nv.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),nv.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>iC.compositionend(e,t),20),!1};let iW=new Set,iV=["pre-wrap","normal","pre-line","break-spaces"],iF=!1;class iH{constructor(e){this.lineWrapping=e,this.doc=eB.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return iV.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];s<0?n++:this.heightSamples[Math.floor(10*s)]||(t=!0,this.heightSamples[Math.floor(10*s)]=!0)}return t}refresh(e,t,n,s,i,r){let o=iV.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=s,this.lineLength=i,a){this.heightSamples={};for(let e=0;e<r.length;e++){let t=r[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class iX{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class iU{constructor(e,t,n,s,i){this.from=e,this.length=t,this.top=n,this.height=s,this._content=i}get type(){return"number"==typeof this._content?nN.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof n_?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new iU(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var iG=((mV=iG||(iG={}))[mV.ByPos=0]="ByPos",mV[mV.ByHeight=1]="ByHeight",mV[mV.ByPosNoHeight=2]="ByPosNoHeight",mV);class iZ{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=2*!!e|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>.001&&(iF=!0),this.height=e)}replace(e,t,n){return iZ.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,s){let i=this,r=n.doc;for(let o=s.length-1;o>=0;o--){let{fromA:a,toA:l,fromB:c,toB:h}=s[o],d=i.lineAt(a,iG.ByPosNoHeight,n.setDoc(t),0,0),u=d.to>=l?d:i.lineAt(l,iG.ByPosNoHeight,n,0,0);for(h+=u.to-l,l=u.to;o>0&&d.from<=s[o-1].toA;)a=s[o-1].fromA,c=s[o-1].fromB,o--,a<d.from&&(d=i.lineAt(a,iG.ByPosNoHeight,n,0,0));c+=d.from-a,a=d.from;let p=i3.build(n.setDoc(r),e,c,h);i=iY(i,i.replace(a,l,p))}return i.updateHeight(n,0)}static empty(){return new i0(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,s=0,i=0;for(;;)if(t==n)if(s>2*i){let i=e[t-1];i.break?e.splice(--t,1,i.left,null,i.right):e.splice(--t,1,i.left,i.right),n+=1+i.break,s-=i.size}else if(i>2*s){let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,i-=t.size}else break;else if(s<i){let n=e[t++];n&&(s+=n.size)}else{let t=e[--n];t&&(i+=t.size)}let r=0;return null==e[t-1]?(r=1,t--):null==e[t]&&(r=1,n++),new i2(iZ.of(e.slice(0,t)),r,iZ.of(e.slice(n)))}}function iY(e,t){return e==t?e:(e.constructor!=t.constructor&&(iF=!0),t)}iZ.prototype.size=1;let iK=nS.replace({});class iJ extends iZ{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new iU(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,s){return this.spaceAbove&&e<n+this.spaceAbove?new iU(s,0,n,this.spaceAbove,iK):this.mainBlock(n,s)}lineAt(e,t,n,s,i){let r=this.mainBlock(s,i);return this.spaceAbove?this.blockAt(0,n,s,i).join(r):r}forEachLine(e,t,n,s,i,r){e<=i+this.length&&t>=i&&r(this.lineAt(0,iG.ByPos,n,s,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class i0 extends iJ{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new iU(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let s=n[0];return 1==n.length&&(s instanceof i0||s instanceof i1&&4&s.flags)&&10>Math.abs(this.length-s.length)?(s instanceof i1?s=new i0(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):iZ.of(n)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more?this.setMeasuredHeight(s):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class i1 extends iZ{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,i=s-n+1,r,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);r=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else r=this.height/i;return{firstLine:n,lastLine:s,perLine:r,perChar:o}}blockAt(e,t,n,s){let{firstLine:i,lastLine:r,perLine:o,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let i=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),r=t.doc.lineAt(i),l=o+r.length*a,c=Math.max(n,e-l/2);return new iU(r.from,r.length,c,l,0)}{let s=Math.max(0,Math.min(r-i,Math.floor((e-n)/o))),{from:a,length:l}=t.doc.line(i+s);return new iU(a,l,n+o*s,o,0)}}lineAt(e,t,n,s,i){if(t==iG.ByHeight)return this.blockAt(e,n,s,i);if(t==iG.ByPosNoHeight){let{from:t,to:s}=n.doc.lineAt(e);return new iU(t,s-t,0,0,0)}let{firstLine:r,perLine:o,perChar:a}=this.heightMetrics(n,i),l=n.doc.lineAt(e),c=o+l.length*a,h=l.number-r,d=s+o*h+a*(l.from-i-h);return new iU(l.from,l.length,Math.max(s,Math.min(d,s+this.height-c)),c,0)}forEachLine(e,t,n,s,i,r){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(n,i);for(let c=e,h=s;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-o;h+=a*n+l*(e-i-n)}let s=a+l*t.length;r(new iU(t.from,t.length,h,s,0)),h+=s,c=t.to+1}}replace(e,t,n){let s=this.length-t;if(s>0){let e=n[n.length-1];e instanceof i1?n[n.length-1]=new i1(e.length+s):n.push(null,new i1(s-1))}if(e>0){let t=n[0];t instanceof i1?n[0]=new i1(e+t.length):n.unshift(new i1(e-1),null)}return iZ.of(n)}decomposeLeft(e,t){t.push(new i1(e-1),null)}decomposeRight(e,t){t.push(null,new i1(this.length-e-1))}updateHeight(e,t=0,n=!1,s){let i=t+this.length;if(s&&s.from<=t+this.length&&s.more){let n=[],r=Math.max(t,s.from),o=-1;for(s.from>t&&n.push(new i1(s.from-t-1).updateHeight(e,t));r<=i&&s.more;){let t=e.doc.lineAt(r).length;n.length&&n.push(null);let i=s.heights[s.index++],a=0;i<0&&(a=-i,i=s.heights[s.index++]),-1==o?o=i:Math.abs(i-o)>=.001&&(o=-2);let l=new i0(t,i,a);l.outdated=!1,n.push(l),r+=t+1}r<=i&&n.push(null,new i1(i-r).updateHeight(e,r));let a=iZ.of(n);return(o<0||Math.abs(a.height-this.height)>=.001||Math.abs(o-this.heightMetrics(e,t).perLine)>=.001)&&(iF=!0),iY(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class i2 extends iZ{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return 1&this.flags}blockAt(e,t,n,s){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,s):this.right.blockAt(e,t,i,s+this.left.length+this.break)}lineAt(e,t,n,s,i){let r=s+this.left.height,o=i+this.left.length+this.break,a=t==iG.ByHeight?e<r:e<o,l=a?this.left.lineAt(e,t,n,s,i):this.right.lineAt(e,t,n,r,o);if(this.break||(a?l.to<o:l.from>o))return l;let c=t==iG.ByPosNoHeight?iG.ByPosNoHeight:iG.ByPos;return a?l.join(this.right.lineAt(o,c,n,r,o)):this.left.lineAt(o,c,n,s,i).join(l)}forEachLine(e,t,n,s,i,r){let o=s+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,s,i,r),t>=a&&this.right.forEachLine(e,t,n,o,a,r);else{let l=this.lineAt(a,iG.ByPos,n,s,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,s,i,r),l.to>=e&&l.from<=t&&r(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,o,a,r)}}replace(e,t,n){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,n));let i=[];e>0&&this.decomposeLeft(e,i);let r=i.length;for(let e of n)i.push(e);if(e>0&&i5(i,r-1),t<this.length){let e=i.length;this.decomposeRight(t,i),i5(i,e)}return iZ.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&e>=++n&&t.push(null),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,s=n+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?iZ.of(this.break?[e,null,t]:[e,t]):(this.left=iY(this.left,e),this.right=iY(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,s){let{left:i,right:r}=this,o=t+i.length+this.break,a=null;return(s&&s.from<=t+i.length&&s.more?a=i=i.updateHeight(e,t,n,s):i.updateHeight(e,t,n),s&&s.from<=o+r.length&&s.more?a=r=r.updateHeight(e,o,n,s):r.updateHeight(e,o,n),a)?this.balanced(i,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function i5(e,t){let n,s;null==e[t]&&(n=e[t-1])instanceof i1&&(s=e[t+1])instanceof i1&&e.splice(t-1,3,new i1(n.length+1+s.length))}class i3{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof i0?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new i0(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let s=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let r=t-e;n.block?this.addBlock(new iJ(r,s,n)):(r||i||s>=5)&&this.addLineDeco(s,i,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new i0(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new i1(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof i0)return e;let t=new i0(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let s=this.ensureLine();s.length+=n,s.collapsed+=n,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof i0||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new i0(0,-1,0));let n=e;for(let e of this.nodes)e instanceof i0&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,s){let i=new i3(n,e);return tF.spans(t,n,s,i,0),i.finish(n)}}class i4{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&nA(e,t,this.changes,5)}}class i8{constructor(e,t,n,s){this.from=e,this.to=t,this.size=n,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let s=e[n],i=t[n];if(s.from!=i.from||s.to!=i.to||s.size!=i.size)return!1}return!0}draw(e,t){return nS.replace({widget:new i6(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class i6 extends nj{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class i9{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=rn,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=n0.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(sS).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new iH(n),this.stateDeco=rs(t),this.heightMap=iZ.empty().applyChanges(this.stateDeco,eB.empty,this.heightOracle.setDoc(t.doc),[new sD(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=nS.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let s=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>s>=e&&s<=t)){let{from:t,to:n}=this.lineBlockAt(s);e.push(new i7(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?rn:new ri(this.heightOracle,this.heightMap,this.viewports),2*!e.eq(this.scaler)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(rr(e,this.scaler))})}update(e,t=null){var n,s;let i;this.state=e.state;let r=this.stateDeco;this.stateDeco=rs(this.state);let o=e.changedRanges,a=sD.extendWithRanges(o,(n=this.stateDeco,s=e?e.changes:e3.empty(this.state.doc.length),i=new i4,tF.compare(r,n,s,i,0),i.changes)),l=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);iF=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=l||iF)&&(e.flags|=2),c?(this.scrollAnchorPos=e.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=l);let h=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<h.from||t.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,t));let d=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,e.flags|=this.updateForViewport(),(d||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(sf)&&(this.mustEnforceCursorAssoc=!0)}measure(){var e;let t,n,{view:s}=this,i=s.contentDOM,r=window.getComputedStyle(i),o=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection="rtl"==r.direction?n0.RTL:n0.LTR;let l=this.heightOracle.mustRefreshForWrapping(a)||"refresh"===this.mustMeasureContent,c=i.getBoundingClientRect(),h=l||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let d=0,u=0;if(c.width&&c.height){let{scaleX:e,scaleY:t}=nW(i,c);(e>.005&&Math.abs(this.scaleX-e)>.005||t>.005&&Math.abs(this.scaleY-t)>.005)&&(this.scaleX=e,this.scaleY=t,d|=16,l=h=!0)}let p=(parseInt(r.paddingTop)||0)*this.scaleY,f=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=f)&&(this.paddingTop=p,this.paddingBottom=f,d|=18),this.editorWidth!=s.scrollDOM.clientWidth&&(o.lineWrapping&&(h=!0),this.editorWidth=s.scrollDOM.clientWidth,d|=16);let m=nV(this.view.contentDOM,!1).y;m!=this.scrollParent&&(this.scrollParent=m,this.scrollAnchorHeight=-1,this.scrollOffset=0);let g=this.getScrollOffset();this.scrollOffset!=g&&(this.scrollAnchorHeight=-1,this.scrollOffset=g),this.scrolledToBottom=nZ(this.scrollParent||s.win);let x=(this.printing?function(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}:function(e,t){let n=e.getBoundingClientRect(),s=e.ownerDocument,i=s.defaultView||window,r=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=s.body;)if(1==t.nodeType){let n=t,s=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=s.overflow){let s=n.getBoundingClientRect();r=Math.max(r,s.left),o=Math.min(o,s.right),a=Math.max(a,s.top),l=Math.min(t==e.parentNode?i.innerHeight:l,s.bottom)}t="absolute"==s.position||"fixed"==s.position?n.offsetParent:n.parentNode}else if(11==t.nodeType)t=t.host;else break;return{left:r-n.left,right:Math.max(r,o)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}})(i,this.paddingTop),b=x.top-this.pixelViewport.top,v=x.bottom-this.pixelViewport.bottom;this.pixelViewport=x;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(h=!0)),!this.inView&&!this.scrollTarget&&(t=(e=s.dom).getBoundingClientRect(),n=e.ownerDocument.defaultView||window,!(t.left<n.innerWidth)||!(t.right>0)||!(t.top<n.innerHeight)||!(t.bottom>0)))return 0;let w=c.width;if((this.contentDOMWidth!=w||this.editorHeight!=s.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=s.scrollDOM.clientHeight,d|=16),h){let e=s.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(l=!0),l||o.lineWrapping&&Math.abs(w-this.contentDOMWidth)>o.charWidth){let{lineHeight:t,charWidth:n,textHeight:i}=s.docView.measureTextSize();(l=t>0&&o.refresh(a,t,n,i,Math.max(5,w/n),e))&&(s.docView.minWidth=0,d|=16)}for(let t of(b>0&&v>0?u=Math.max(b,v):b<0&&v<0&&(u=Math.min(b,v)),iF=!1,this.viewports)){let n=t.from==this.viewport.from?e:s.docView.measureVisibleLineHeights(t);this.heightMap=(l?iZ.empty().applyChanges(this.stateDeco,eB.empty,this.heightOracle,[new sD(0,0,0,s.state.doc.length)]):this.heightMap).updateHeight(o,0,l,new iX(t.from,n))}iF&&(d|=2)}let O=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(2&d&&(d|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),d|=this.updateForViewport()),(2&d||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(l?[]:this.lineGaps,s)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,s.docView.enforceCursorAssoc()),d}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,i=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,a=new i7(s.lineAt(r-1e3*n,iG.ByHeight,i,0,0).from,s.lineAt(o+(1-n)*1e3,iG.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=s.lineAt(e,iG.ByPos,i,0,0),o;o="center"==t.y?(r.top+r.bottom)/2-n/2:"start"==t.y||"nearest"==t.y&&e<a.from?r.top:r.bottom-n,a=new i7(s.lineAt(o-500,iG.ByHeight,i,0,0).from,s.lineAt(o+n+500,iG.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new i7(this.heightMap.lineAt(n,iG.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,iG.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,iG.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,iG.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==e||s<=r-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&s>r-2e3&&i<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let s of e)t.touchesRange(s.from,s.to)||n.push(new i8(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,s=n?1e4:2e3,i=s>>1,r=s<<1;if(this.defaultTextDirection!=n0.LTR&&!n)return[];let o=[],a=(s,r,l,c)=>{if(r-s<i)return;let h=this.state.selection.main,d=[h.from];for(let e of(h.empty||d.push(h.to),d))if(e>s&&e<r){a(s,e-10,l,c),a(e+10,r,l,c);return}let u=function(e,t){for(let n of e)if(t(n))return n}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-s)<i&&Math.abs(e.to-r)<i&&!d.some(t=>e.from<t&&e.to>t));if(!u){if(r<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=r&&e.to>=r)){let e=t.moveToLineBoundary(tn.cursor(r),!1,!0).head;e>s&&(r=e)}let e=this.gapSize(l,s,r,c),i=n||e<2e6?e:2e6;u=new i8(s,r,e,i)}o.push(u)},l=t=>{var i,o,l;let c,h,d,u,p;if(t.length<r||t.type!=nN.Text)return;let f=(i=t.from,o=t.to,l=this.stateDeco,d=[],u=i,p=0,tF.spans(l,i,o,{span(){},point(e,t){e>u&&(d.push({from:u,to:e}),p+=e-u),u=t}},20),u<o&&(d.push({from:u,to:o}),p+=o-u),{total:p,ranges:d});if(f.total<r)return;let m=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,i=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=m){let s=rt(f,m),r=((this.visibleBottom-this.visibleTop)/2+i)/t.height;e=s-r,n=s+r}else e=(this.visibleTop-t.top-i)/t.height,n=(this.visibleBottom-t.top+i)/t.height;c=re(f,e),h=re(f,n)}else{let n,i,r=f.total*this.heightOracle.charWidth,o=s*this.heightOracle.charWidth,a=0;if(r>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let l=this.pixelViewport.left+a,d=this.pixelViewport.right+a;if(null!=m){let e=rt(f,m),t=((d-l)/2+o)/r;n=e-t,i=e+t}else n=(l-o)/r,i=(d+o)/r;c=re(f,n),h=re(f,i)}c>t.from&&a(t.from,c,t,f),h<t.to&&a(h,t.to,t,f)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return o}gapSize(e,t,n,s){let i=rt(s,n)-rt(s,t);return this.heightOracle.lineWrapping?e.height*i:s.total*this.heightOracle.charWidth*i}updateLineGaps(e){i8.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=nS.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];tF.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let s=0;if(n.length!=this.visibleRanges.length)s=12;else for(let t=0;t<n.length&&!(8&s);t++){let i=this.visibleRanges[t],r=n[t];(i.from!=r.from||i.to!=r.to)&&(s|=4,e&&e.mapPos(i.from,-1)==r.from&&e.mapPos(i.to,1)==r.to||(s|=8))}return this.visibleRanges=n,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||rr(this.heightMap.lineAt(e,iG.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||rr(this.heightMap.lineAt(this.scaler.fromDOM(e),iG.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return rr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class i7{constructor(e,t){this.from=e,this.to=t}}function re({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let s=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],r=i-n;if(s<=r)return n+s;s-=r}}function rt(e,t){let n=0;for(let{from:s,to:i}of e.ranges){if(t<=i){n+=t-s;break}n+=i-s}return n/e.total}let rn={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function rs(e){let t=e.facet(sz).filter(e=>"function"!=typeof e),n=e.facet(s_).filter(e=>"function"!=typeof e);return n.length&&t.push(tF.join(n)),t}class ri{constructor(e,t,n){let s=0,i=0,r=0;for(let o of(this.viewports=n.map(({from:n,to:i})=>{let r=t.lineAt(n,iG.ByPos,e,0,0).top,o=t.lineAt(i,iG.ByPos,e,0,0).bottom;return s+=o-r,{from:n,to:i,top:r,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s),this.viewports))o.domTop=r+(o.top-i)*this.scale,r=o.domBottom=o.domTop+(o.bottom-o.top),i=o.bottom}toDOM(e){for(let t=0,n=0,s=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return s+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,s=i.domBottom}}fromDOM(e){for(let t=0,n=0,s=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-s)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,s=i.domBottom}}eq(e){return e instanceof ri&&this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to)}}function rr(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),s=t.toDOM(e.bottom);return new iU(e.from,e.length,n,s-n,Array.isArray(e._content)?e._content.map(e=>rr(e,t)):e._content)}let ro=tr.define({combine:e=>e.join(" ")}),ra=tr.define({combine:e=>e.indexOf(!0)>-1}),rl=t9.newName(),rc=t9.newName(),rh=t9.newName(),rd={"&light":"."+rc,"&dark":"."+rh};function ru(e,t,n){return new t9(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}let rp=ru("."+rl,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},rd),rf={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},rm=nv.ie&&nv.ie_version<=11;class rg{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new nF,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(nv.ie&&nv.ie_version<=11||nv.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&nv.android&&!1!==e.constructor.EDIT_CONTEXT&&!(nv.chrome&&nv.chrome_version<126)&&(this.editContext=new rv(e),e.state.facet(sy)&&(e.contentDOM.editContext=this.editContext.editContext)),rm&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null==(e=this.view.docView)?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){for(let t of(this.gapIntersection.disconnect(),e))this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,s=this.selectionRange;if(n.state.facet(sy)?n.root.activeElement!=this.dom:!nR(this.dom,s))return;let i=s.anchorNode&&n.docView.tile.nearest(s.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(nv.ie&&nv.ie_version<=11||nv.android&&nv.chrome)&&!n.state.selection.main.empty&&s.focusNode&&n$(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=nP(e.root);if(!t)return!1;let n=nv.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return rb(e,n)}let n=null;function s(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",s,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",s,!0),n?rb(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=nR(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,s=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=s)return!1;for(s=Math.min(s,nq(n));;)if(s){if(1!=n.nodeType)return!1;let e=n.childNodes[s-1];"false"==e.contentEditable?s--:s=nq(n=e)}else{if(n==e)return!0;s=nQ(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(11==n.nodeType)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,rf),rm&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),rm&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&nG(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null==(n=this.delayedAndroidKey)?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,s=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(s=!0),-1==t?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:s}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),s=this.selectionChanged&&nR(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new im(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,s=ig(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!iv(this.view.state.selection,t.newSel.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=rx(t,e.previousSibling||e.target.previousSibling,-1),s=rx(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sy)!=e.state.facet(sy)&&(e.view.contentDOM.editContext=e.state.facet(sy)?this.editContext.editContext:null))}destroy(){var e,t,n;for(let s of(this.stop(),null==(e=this.intersection)||e.disconnect(),null==(t=this.gapIntersection)||t.disconnect(),null==(n=this.resizeScroll)||n.disconnect(),this.scrollTargets))s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function rx(e,t,n){for(;t;){let s=sI.get(t);if(s&&s.parent==e)return s;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function rb(e,t){let n=t.startContainer,s=t.startOffset,i=t.endContainer,r=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return n$(o.node,o.offset,i,r)&&([n,s,i,r]=[i,r,n,s]),{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:r}}class rv{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});for(let n in this.handlers.textupdate=n=>{let s=e.state.selection.main,{anchor:i,head:r}=s,o=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let l=a-o>n.text.length;o==this.from&&i<this.from?o=i:a==this.to&&i>this.to&&(a=i);let c=ib(e.state.sliceDoc(o,a),n.text,(l?s.from:s.to)-o,l?"end":null);if(!c){let t=tn.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));iv(t,s)||e.dispatch({selection:t,userEvent:"select"});return}let h={from:c.from+o,to:c.toA+o,insert:eB.of(n.text.slice(c.from,c.toB).split("\n"))};if((nv.mac||nv.android)&&h.from==r-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:o,to:a,insert:eB.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);ix(e,h,tn.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let s=[],i=null;for(let t=this.toEditorPos(n.rangeStart),r=this.toEditorPos(n.rangeEnd);t<r;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,s.push(i)}t.updateCharacterBounds(n.rangeStart,s)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,s=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(s)){let i=this.toEditorPos(e.rangeStart),r=this.toEditorPos(e.rangeEnd);if(i<r){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(s)?1:2}px`;n.push(nS.mark({attributes:{style:e}}).range(i,r))}}}e.dispatch({effects:sb.of(nS.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}},this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=nP(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((i,r,o,a,l)=>{if(n)return;let c=l.length-(r-i);if(s&&r>=s.to)if(s.from==i&&s.to==r&&s.insert.eq(l)){s=this.pendingContextChange=null,t+=c,this.to+=c;return}else s=null,this.revertPending(e.state);if(i+=t,(r+=t)<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||r>this.to||this.to-this.from+l.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(r),l.toString()),this.to+=c}t+=c}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class ry{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;for(let t of(this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new i9(this,e.state||tQ.create(e)),e.scrollTo&&e.scrollTo.is(sx)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(sO).map(e=>new sj(e)),this.plugins))t.update(this);this.observer=new rg(this),this.inputState=new iy(this),this.inputState.ensureHandlers(this.plugins),this.docView=new s6(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null==(t=document.fonts)?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof tA?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,s,i=this.state;for(let t of e){if(t.startState!=i)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=t.state}if(this.destroyed){this.viewState.state=i;return}let r=this.hasFocus,o=0,a=null;e.some(e=>e.annotation(iL))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,(a=iq(i,r))||(o=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),((c=this.observer.readChange())&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(tQ.phrases)!=this.state.facet(tQ.phrases))return this.setState(i);s=s$.create(this,i,e),s.flags|=o;let h=this.viewState.scrollTarget;try{for(let t of(this.updateState=2,e)){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection,{x:n,y:s}=this.state.facet(ry.cursorScrollMargin);h=new sg(e.empty?e:tn.cursor(e.head,e.head>e.anchor?-1:1),"nearest","nearest",s,n)}for(let e of t.effects)e.is(sx)&&(h=e.value.clip(this.state))}this.viewState.update(s,h),this.bidiCache=rk.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(sR)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(ro)!=s.state.facet(ro)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let e of this.state.facet(sl))try{e(s)}catch(e){sv(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!ig(this,c)&&l.force&&nG(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);for(let t of(this.viewState=new i9(this,e),this.plugins=e.facet(sO).map(e=>new sj(e)),this.pluginMap.clear(),this.plugins))t.update(this);this.docView.destroy(),this.docView=new s6(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(sO),n=e.state.facet(sO);if(t!=n){let s=[];for(let i of n){let n=t.indexOf(i);if(n<0)s.push(new sj(i));else{let t=this.plugins[n];t.mustUpdate=e,s.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){sv(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:r}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(r<0)if(nZ(n||this.win))i=-1,r=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(s);i=e.from,r=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&o||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return sv(this.state,e),rO}}),c=s$.create(this,this.state,[]),h=!1;c.flags|=o,t?t.flags|=o:t=c,this.updateState=2,!c.empty&&(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),(h=this.docView.update(c))&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=rO)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){sv(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-r)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),r=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(sl))e(t)}get themeClasses(){return rl+" "+(this.state.facet(ra)?rh:rc)+" "+this.state.facet(ro)}updateAttrs(){let e=rj(this,sN,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sy)?"true":"false",class:"cm-content",style:`${nv.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),rj(this,sS,t);let n=this.observer.ignore(()=>{let n=nk(this.contentDOM,this.contentAttrs,t),s=nk(this.dom,this.editorAttrs,e);return n||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)e.is(ry.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(sR);let e=this.state.facet(ry.cspNonce);t9.mount(this.root,this.styleModules.concat(rp).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if((this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e)&&!(this.measureRequests.indexOf(e)>-1)){if(null!=e.key){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return il(this,e,ir(this,e,t,n))}moveByGroup(e,t){return il(this,e,ir(this,e,t,t=>{var n;let s,i;return n=e.head,i=(s=this.state.charCategorizer(n))(t),e=>{let t=s(e);return i==tD.Space&&(i=t),i==t}}))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return tn.cursor(i.side(t,s)+e.from,i.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,s){let i=ii(e,t.head,t.assoc||-1),r=s&&i.type==nN.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(r){let t=e.dom.getBoundingClientRect(),s=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(s==n0.LTR)?t.right-1:t.left+1,y:(r.top+r.bottom)/2});if(null!=o)return tn.cursor(o,n?-1:1)}return tn.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return il(this,e,function(e,t,n,s){let i=t.head,r=n?1:-1;if(i==(n?e.state.doc.length:0))return tn.cursor(i,t.assoc);let o=t.goalColumn,a,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),h=e.documentTop;if(c)null==o&&(o=c.left-l.left),a=r<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(i);null==o&&(o=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-t.from))),a=(r<0?t.top:t.bottom)+h}let d=l.left+o,u=e.viewState.heightOracle.textHeight>>1,p=null!=s?s:u;for(let t=0;;t+=u){let s=a+(p+t)*r,i=ih(e,{x:d,y:s},!1,r);if(n?s>l.bottom:s<l.top)return tn.cursor(i.pos,i.assoc);let c=e.coordsAtPos(i.pos,i.assoc),h=c?(c.top+c.bottom)/2:0;if(!c||(n?h>a:h<a))return tn.cursor(i.pos,i.assoc,void 0,o)}}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=ih(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),ih(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let s=this.state.doc.lineAt(e),i=this.bidiSpans(s);return nB(n,i[se.find(i,e-s.from,-1,t)].dir==n0.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(sp)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>rw)return sn(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||function e(t,n){if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++){let i=t[s],r=n[s];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!e(i.inner,r.inner))return!1}return!0}(s.isolates,n=sM(this,e))))return s.order;n||(n=sM(this,e));let s=function(e,t,n){if(!e)return[new se(0,0,+(t==n2))];if(t==n1&&!n.length&&!n7.test(e))return sn(e.length);if(n.length)for(;e.length>st.length;)st[st.length]=256;let s=[],i=+(t!=n1);return function e(t,n,s,i,r,o,a){let l=n%2?2:1;!function(e,t,n,s,i){for(let r=0;r<=s.length;r++){let o=r?s[r-1].to:t,a=r<s.length?s[r].from:n,l=r?256:i;for(let t=o,n=l,s=l;t<a;t++){let i=n9(e.charCodeAt(t));512==i?i=n:8==i&&4==s&&(i=16),st[t]=4==i?2:i,7&i&&(s=i),n=i}for(let e=o,t=l,s=l;e<a;e++){let i=st[e];if(128==i)e<a-1&&t==st[e+1]&&24&t?i=st[e]=t:st[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==st[i];)i++;let r=e&&8==t||i<n&&8==st[i]?1==s?1:8:256;for(let t=e;t<i;t++)st[t]=r;e=i-1}else 8==i&&1==s&&(st[e]=1);t=i,7&i&&(s=i)}}}(t,r,o,i,l),function(e,t,n,s,i){let r=1==i?2:1;for(let o=0,a=0,l=0;o<=s.length;o++){let c=o?s[o-1].to:t,h=o<s.length?s[o].from:n;for(let t=c,n,s,o;t<h;t++)if(s=n8[n=e.charCodeAt(t)])if(s<0){for(let e=a-3;e>=0;e-=3)if(n6[e+1]==-s){let n=n6[e+2],s=2&n?i:4&n?1&n?r:i:0;s&&(st[t]=st[n6[e]]=s),a=e;break}}else if(189==n6.length)break;else n6[a++]=t,n6[a++]=n,n6[a++]=l;else if(2==(o=st[t])||1==o){let e=o==i;l=+!e;for(let t=a-3;t>=0;t-=3){let n=n6[t+2];if(2&n)break;if(e)n6[t+2]|=2;else{if(4&n)break;n6[t+2]|=4}}}}}(t,r,o,i,l),function(e,t,n,s){for(let i=0,r=s;i<=n.length;i++){let o=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=o;l<a;){let o=st[l];if(256==o){let o=l+1;for(;;)if(o==a){if(i==n.length)break;o=n[i++].to,a=i<n.length?n[i].from:t}else if(256==st[o])o++;else break;let c=1==r,h=c==((o<t?st[o]:s)==1)?c?1:2:s;for(let t=o,s=i,r=s?n[s-1].to:e;t>l;)t==r&&(t=n[--s].from,r=s?n[s-1].to:e),st[--t]=h;l=o}else r=o,l++}}}(r,o,i,l),function t(n,s,i,r,o,a,l){let c=r%2?2:1;if(r%2==o%2)for(let h=s,d=0;h<i;){let s=!0,u=!1;if(d==a.length||h<a[d].from){let e=st[h];e!=c&&(s=!1,u=16==e)}let p=s||1!=c?null:[],f=s?r:r+1,m=h;n:for(;;)if(d<a.length&&m==a[d].from){if(u)break;let t=a[d];if(!s)for(let e=t.to,n=d+1;;){if(e==i)break n;if(n<a.length&&a[n].from==e)e=a[n++].to;else if(st[e]==c)break n;else break}d++,p?p.push(t):(t.from>h&&l.push(new se(h,t.from,f)),e(n,t.direction==n1!=!(f%2)?r+1:r,o,t.inner,t.from,t.to,l),h=t.to),m=t.to}else if(m==i||(s?st[m]!=c:st[m]==c))break;else m++;p?t(n,h,m,r+1,o,p,l):h<m&&l.push(new se(h,m,f)),h=m}else for(let h=i,d=a.length;h>s;){let i=!0,u=!1;if(!d||h>a[d-1].to){let e=st[h-1];e!=c&&(i=!1,u=16==e)}let p=i||1!=c?null:[],f=i?r:r+1,m=h;n:for(;;)if(d&&m==a[d-1].to){if(u)break;let t=a[--d];if(!i)for(let e=t.from,n=d;;){if(e==s)break n;if(n&&a[n-1].to==e)e=a[--n].from;else if(st[e-1]==c)break n;else break}p?p.push(t):(t.to<h&&l.push(new se(t.to,h,f)),e(n,t.direction==n1!=!(f%2)?r+1:r,o,t.inner,t.from,t.to,l),h=t.from),m=t.from}else if(m==s||(i?st[m-1]!=c:st[m-1]==c))break;else m--;p?t(n,m,h,r+1,o,p,l):m<h&&l.push(new se(m,h,f)),h=m}}(t,r,o,n,s,i,a)}(e,i,i,n,0,e.length,s),s}(e.text,t,n);return this.bidiCache.push(new rk(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||nv.safari&&(null==(e=this.inputState)?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{nX(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var n,s,i,r;return sx.of(new sg("number"==typeof e?tn.cursor(e):e,null!=(n=t.y)?n:"nearest",null!=(s=t.x)?s:"nearest",null!=(i=t.yMargin)?i:5,null!=(r=t.xMargin)?r:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return sx.of(new sg(tn.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return sk.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return sk.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=t9.newName(),s=[ro.of(n),sR.of(ru(`.${n}`,e))];return t&&t.dark&&s.push(ra.of(!0)),s}static baseTheme(e){return tp.lowest(sR.of(ru("."+rl,e,rd)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&sI.get(n)||sI.get(e);return(null==(t=null==s?void 0:s.root)?void 0:t.view)||null}}ry.styleModule=sR,ry.inputHandler=sc,ry.clipboardInputFilter=sd,ry.clipboardOutputFilter=su,ry.scrollHandler=sm,ry.focusChangeEffect=sh,ry.perLineTextDirection=sp,ry.exceptionSink=sa,ry.updateListener=sl,ry.editable=sy,ry.mouseSelectionStyle=so,ry.dragMovesSelection=sr,ry.clickAddsSelectionRange=si,ry.decorations=sz,ry.blockWrappers=sC,ry.outerDecorations=s_,ry.atomicRanges=sT,ry.bidiIsolatedRanges=sA,ry.cursorScrollMargin=tr.define({combine:e=>{let t=5,n=5;for(let s of e)"number"==typeof s?t=n=s:{x:t,y:n}=s;return{x:t,y:n}}}),ry.scrollMargins=sP,ry.darkTheme=ra,ry.cspNonce=tr.define({combine:e=>e.length?e[0]:""}),ry.contentAttributes=sS,ry.editorAttributes=sN,ry.lineWrapping=ry.contentAttributes.of({class:"cm-lineWrapping"}),ry.announce=tT.define();let rw=4096,rO={};class rk{constructor(e,t,n,s,i,r){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=i,this.order=r}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:n0.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let r=e[i];r.dir!=s||t.touchesRange(r.from,r.to)||n.push(new rk(t.mapPos(r.from,1),t.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return n}}function rj(e,t,n){for(let s=e.state.facet(t),i=s.length-1;i>=0;i--){let t=s[i],r="function"==typeof t?t(e):t;r&&ny(r,n)}return n}let rN=nv.mac?"mac":nv.windows?"win":nv.linux?"linux":"key";function rS(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}let rz=tp.default(ry.domEventHandlers({keydown:(e,t)=>rP(rT(t.state),e,t,"editor")})),rC=tr.define({enables:rz}),r_=new WeakMap;function rT(e){let t=e.facet(rC),n=r_.get(t);return n||r_.set(t,n=function(e,t=rN){let n=Object.create(null),s=Object.create(null),i=(e,t)=>{let n=s[e];if(null==n)s[e]=t;else if(n!=t)throw Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},r=(e,s,r,o,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),d=s.split(/ (?!$)/).map(e=>(function(e,t){let n,s,i,r,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(let e=0;e<o.length-1;++e){let a=o[e];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))"mac"==t?r=!0:s=!0;else throw Error("Unrecognized modifier name: "+a)}return n&&(a="Alt-"+a),s&&(a="Ctrl-"+a),r&&(a="Meta-"+a),i&&(a="Shift-"+a),a})(e,t));for(let t=1;t<d.length;t++){let n=d.slice(0,t).join(" ");i(n,!0),h[n]||(h[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let s=rA={view:t,prefix:n,scope:e};return setTimeout(()=>{rA==s&&(rA=null)},4e3),!0}]})}let u=d.join(" ");i(u,!1);let p=h[u]||(h[u]={preventDefault:!1,stopPropagation:!1,run:(null==(c=null==(l=h._any)?void 0:l.run)?void 0:c.slice())||[]});r&&p.run.push(r),o&&(p.preventDefault=!0),a&&(p.stopPropagation=!0)};for(let s of e){let e=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:i}=s;for(let t in e)e[t].run.push(e=>i(e,rM))}let i=s[t]||s.key;if(i)for(let t of e)r(t,i,s.run,s.preventDefault,s.stopPropagation),s.shift&&r(t,"Shift-"+i,s.shift,s.preventDefault,s.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let rA=null,rM=null;function rP(e,t,n,s){var i;rM=t;let r=("Esc"==(i=!(ns&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ni&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?nn:nt)[t.keyCode]||t.key||"Unidentified")&&(i="Escape"),"Del"==i&&(i="Delete"),"Left"==i&&(i="ArrowLeft"),"Up"==i&&(i="ArrowUp"),"Right"==i&&(i="ArrowRight"),"Down"==i&&(i="ArrowDown"),i),o=e0(eK(r,0))==r.length&&" "!=r,a="",l=!1,c=!1,h=!1;rA&&rA.view==n&&rA.scope==s&&(a=rA.prefix+" ",0>ij.indexOf(t.keyCode)&&(c=!0,rA=null));let d=new Set,u=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(h=!0),!0;e.preventDefault&&(e.stopPropagation&&(h=!0),c=!0)}return!1},p=e[s],f,m;return p&&(u(p[a+rS(r,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(nv.windows&&t.ctrlKey&&t.altKey)&&!(nv.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(f=nt[t.keyCode])&&f!=r?u(p[a+rS(f,t,!0)])?l=!0:t.shiftKey&&(m=nn[t.keyCode])!=r&&m!=f&&u(p[a+rS(m,t,!1)])&&(l=!0):o&&t.shiftKey&&u(p[a+rS(r,t,!0)])&&(l=!0),!l&&u(p._any)&&(l=!0)),c&&(l=!0),l&&h&&t.stopPropagation(),rM=null,l}class rE{constructor(e,t,n,s,i){this.className=e,this.left=t,this.top=n,this.width=s,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(!n.empty)return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let s=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),r=e.textDirection==n0.LTR,o=e.contentDOM,a=o.getBoundingClientRect(),l=rR(e),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),d=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),u=a.right-(h?parseInt(h.paddingRight):0),p=ii(e,s,1),f=ii(e,i,-1),m=p.type==nN.Text?p:null,g=f.type==nN.Text?f:null;if(m&&(e.lineWrapping||p.widgetLineBreaks)&&(m=rD(e,s,1,m)),g&&(e.lineWrapping||f.widgetLineBreaks)&&(g=rD(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return b(v(n.from,n.to,m));{let t=m?v(n.from,null,m):y(p,!1),s=g?v(null,n.to,g):y(f,!0),i=[];return(m||p).to<(g||f).from-(m&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<s.top?i.push(x(d,t.bottom,u,s.top)):t.bottom<s.top&&e.elementAtHeight((t.bottom+s.top)/2).type==nN.Text&&(t.bottom=s.top=(t.bottom+s.top)/2),b(t).concat(i).concat(b(s))}function x(e,n,s,i){return new rE(t,e-l.left,n-l.top,Math.max(0,s-e),i-n)}function b({top:e,bottom:t,horizontal:n}){let s=[];for(let i=0;i<n.length;i+=2)s.push(x(n[i],e,n[i+1],t));return s}function v(t,n,s){let i=1e9,o=-1e9,a=[];function l(t,n,l,c,h){let p=e.coordsAtPos(t,t==s.to?-2:2),f=e.coordsAtPos(l,l==s.from?2:-2);p&&f&&(i=Math.min(p.top,f.top,i),o=Math.max(p.bottom,f.bottom,o),h==n0.LTR?a.push(r&&n?d:p.left,r&&c?u:f.right):a.push(!r&&c?d:f.left,!r&&n?u:p.right))}let c=null!=t?t:s.from,h=null!=n?n:s.to;for(let s of e.visibleRanges)if(s.to>c&&s.from<h)for(let i=Math.max(s.from,c),r=Math.min(s.to,h);;){let s=e.state.doc.lineAt(i);for(let o of e.bidiSpans(s)){let e=o.from+s.from,a=o.to+s.from;if(e>=r)break;a>i&&l(Math.max(e,i),null==t&&e<=c,Math.min(a,r),null==n&&a>=h,o.dir)}if((i=s.to+1)>=r)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:i,bottom:o,horizontal:a}}function y(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n);{let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let i=rR(e);return[new rE(t,s.left-i.left,s.top-i.top,null,s.bottom-s.top)]}}}function rR(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==n0.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function rD(e,t,n,s){let i=e.coordsAtPos(t,2*n);if(!i)return s;let r=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,a=e.posAtCoords({x:r.left+1,y:o}),l=e.posAtCoords({x:r.right-1,y:o});return null==a||null==l?s:{from:Math.max(s.from,Math.min(a,l)),to:Math.min(s.to,Math.max(a,l))}}class r${constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(rQ)!=e.state.facet(rQ)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(rQ);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{var n;return n=this.drawn[t],!(e.constructor==n.constructor&&e.eq(n))})){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(s.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,nv.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}let rQ=tr.define();function rI(e){return[sk.define(t=>new r$(t,e)),rQ.of(e)]}let rL=tr.define({combine:e=>tI(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function rq(e){return e.startState.facet(rL)!=e.state.facet(rL)}let rB=rI({above:!0,markers(e){let{state:t}=e,n=t.facet(rL),s=[];for(let i of t.selection.ranges){let r=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(r&&nv.ios&&n.iosSelectionHandles)){let t=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=i.empty?i:tn.cursor(i.head,i.assoc);for(let i of rE.forRange(e,t,n))s.push(i)}}return s},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=rq(e);return n&&rW(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){rW(t.state,e)},class:"cm-cursorLayer"});function rW(e,t){t.style.animationDuration=e.facet(rL).cursorBlinkRate+"ms"}let rV=rI({above:!1,markers(e){let t=[],{main:n,ranges:s}=e.state.selection;for(let n of s)if(!n.empty)for(let s of rE.forRange(e,"cm-selectionBackground",n))t.push(s);if(nv.ios&&!n.empty&&e.state.facet(rL).iosSelectionHandles){for(let s of rE.forRange(e,"cm-selectionHandle cm-selectionHandle-start",tn.cursor(n.from,1)))t.push(s);for(let s of rE.forRange(e,"cm-selectionHandle cm-selectionHandle-end",tn.cursor(n.to,1)))t.push(s)}return t},update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||rq(e),class:"cm-selectionLayer"}),rF=tp.highest(ry.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),rH=tT.define({map:(e,t)=>null==e?null:t.mapPos(e)}),rX=td.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(rH)?t.value:e,e))}),rU=sk.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(rX);null==n?null!=this.cursor&&(null==(t=this.cursor)||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(rX)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(rX),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let s=e.scrollDOM.getBoundingClientRect();return{left:n.left-s.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-s.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(rX)!=e&&this.view.dispatch({effects:rH.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function rG(e,t,n,s,i){t.lastIndex=0;for(let r=e.iterRange(n,s),o=n,a;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;a=t.exec(r.value);)i(o+a.index,a)}class rZ{constructor(e){const{regexp:t,decoration:n,decorate:s,boundary:i,maxLength:r=1e3}=e;if(!t.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(e,t,n,i)=>s(i,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,s,i)=>{let r=n(e,t,s);r&&i(s,s+e[0].length,r)};else if(n)this.addMatch=(e,t,s,i)=>i(s,s+e[0].length,n);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=r}createDeco(e){let t=new tH,n=t.add.bind(t);for(let{from:t,to:s}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let s=[];for(let{from:i,to:r}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),r=Math.min(e.state.doc.lineAt(r).to,r+t),s.length&&s[s.length-1].to>=i?s[s.length-1].to=r:s.push({from:i,to:r});return s}(e,this.maxLength))rG(e.state.doc,this.regexp,t,s,(t,s)=>this.addMatch(s,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return(e.docChanged&&e.changes.iterChanges((t,i,r,o)=>{o>=e.view.viewport.from&&r<=e.view.viewport.to&&(n=Math.min(r,n),s=Math.max(o,s))}),e.viewportMoved||s-n>1e3)?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let i of e.visibleRanges){let r=Math.max(i.from,n),o=Math.min(i.to,s);if(o>=r){let n=e.state.doc.lineAt(r),s=n.to<o?e.state.doc.lineAt(o):n,a=Math.max(i.from,n.from),l=Math.min(i.to,s.to);if(this.boundary){for(;r>n.from;r--)if(this.boundary.test(n.text[r-1-n.from])){a=r;break}for(;o<s.to;o++)if(this.boundary.test(s.text[o-s.from])){l=o;break}}let c=[],h,d=(e,t,n)=>c.push(n.range(e,t));if(n==s)for(this.regexp.lastIndex=a-n.from;(h=this.regexp.exec(n.text))&&h.index<l-n.from;)this.addMatch(h,e,h.index+n.from,d);else rG(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,d));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:c})}}return t}}let rY=null!=/x/.unicode?"gu":"g",rK=RegExp("[\0-\b\n-\x1f-\u2028\u2029\uFEFF-]",rY),rJ={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},r0=null,r1=tr.define({combine(e){let t=tI(e,{render:null,specialChars:rK,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==r0&&"u">typeof document&&document.body){let t=document.body.style;r0=(null!=(e=t.tabSize)?e:t.MozTabSize)!=null}return r0||!1}())&&(t.specialChars=RegExp(" |"+t.specialChars.source,rY)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,rY)),t}}),r2=null;class r5 extends nj{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){var t;let n=(t=this.code)>=32?"•":10==t?"":String.fromCharCode(9216+t),s=e.state.phrase("Control character")+" "+(rJ[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,s,n);if(i)return i;let r=document.createElement("span");return r.textContent=n,r.title=s,r.setAttribute("aria-label",s),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class r3 extends nj{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}let r4=nS.line({class:"cm-activeLine"}),r8=sk.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let s of e.state.selection.ranges){let i=e.lineBlockAt(s.head);i.from>t&&(n.push(r4.range(i.from)),t=i.from)}return nS.set(n)}},{decorations:e=>e.decorations});function r6(e,t){var n;let s,i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(i),o=i-r.from,a=o>2e3?-1:o==r.length?(n=t.clientX,(s=e.coordsAtPos(e.viewport.from))?Math.round(Math.abs((s.left-n)/e.defaultCharacterWidth)):-1):t5(r.text,e.state.tabSize,i-r.from);return{line:r.number,col:a,off:o}}let r9={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},r7={style:"cursor: crosshair"},oe="-10000px";class ot{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let s=e.state.facet(this.facet),i=s.filter(e=>e);if(s===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let r=[],o=t?[]:null;for(let n=0;n<i.length;n++){let s=i[n],a=-1;if(s){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==s.create&&(a=e)}if(a<0)r[n]=this.createTooltipView(s,n?r[n-1]:null),o&&(o[n]=!!s.above);else{let s=r[n]=this.tooltipViews[a];o&&(o[n]=t[a]),s.update&&s.update(e)}}}for(let e of this.tooltipViews)0>r.indexOf(e)&&(this.removeTooltipView(e),null==(n=e.destroy)||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=s,this.tooltips=i,this.tooltipViews=r,!0}}function on(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}let os=tr.define({combine:e=>{var t,n,s;return{position:nv.ios?"absolute":(null==(t=e.find(e=>e.position))?void 0:t.position)||"fixed",parent:(null==(n=e.find(e=>e.parent))?void 0:n.parent)||null,tooltipSpace:(null==(s=e.find(e=>e.tooltipSpace))?void 0:s.tooltipSpace)||on}}}),oi=new WeakMap,or=sk.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(os);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new ot(e,oc,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let e of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(e.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,s=e.state.facet(os);if(s.position!=this.position&&!this.madeAbsolute){for(let e of(this.position=s.position,this.manager.tooltipViews))e.dom.style.position=this.position;n=!0}if(s.parent!=this.parent){for(let e of(this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),s=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=oe,n.dom.style.left="0px",this.container.insertBefore(n.dom,s),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;for(let t of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))t.dom.remove(),null==(e=t.destroy)||e.call(t);this.parent&&this.container.remove(),null==(t=this.resizeObserver)||t.disconnect(),null==(n=this.intersectionObserver)||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(nv.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let s=this.view.scrollDOM.getBoundingClientRect(),i=sE(this.view);return{visible:{left:s.left+i.left,top:s.top+i.top,right:s.right-i.right,bottom:s.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(os).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute)for(let e of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))e.dom.style.position="absolute";let{visible:n,space:s,scaleX:i,scaleY:r}=e,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,d=e.pos[a],u=e.size[a];if(!d||!1!==l.clip&&(d.bottom<=Math.max(n.top,s.top)||d.top>=Math.min(n.bottom,s.bottom)||d.right<Math.max(n.left,s.left)-.1||d.left>Math.min(n.right,s.right)+.1)){h.style.top=oe;continue}let p=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,f=7*!!p,m=u.right-u.left,g=null!=(t=oi.get(c))?t:u.bottom-u.top,x=c.offset||ol,b=this.view.textDirection==n0.LTR,v=u.width>s.right-s.left?b?s.left:s.right-u.width:b?Math.max(s.left,Math.min(d.left-14*!!p+x.x,s.right-m)):Math.min(Math.max(s.left,d.left-m+14*!!p-x.x),s.right-m),y=this.above[a];!l.strictSide&&(y?d.top-g-f-x.y<s.top:d.bottom+g+f+x.y>s.bottom)&&y==s.bottom-d.bottom>d.top-s.top&&(y=this.above[a]=!y);let w=(y?d.top-s.top:s.bottom-d.bottom)-f;if(w<g&&!1!==c.resize){if(w<this.view.defaultLineHeight){h.style.top=oe;continue}oi.set(c,g),h.style.height=(g=w)/r+"px"}else h.style.height&&(h.style.height="");let O=y?d.top-g-f-x.y:d.bottom+f+x.y,k=v+m;if(!0!==c.overlap)for(let e of o)e.left<k&&e.right>v&&e.top<O+g&&e.bottom>O&&(O=y?e.top-g-2-f:e.bottom+f+2);if("absolute"==this.position?(h.style.top=(O-e.parent.top)/r+"px",oo(h,(v-e.parent.left)/i)):(h.style.top=O/r+"px",oo(h,v/i)),p){let e=d.left+(b?x.x:-x.x)-(v+14-7);p.style.left=e/i+"px"}!0!==c.overlap&&o.push({left:v,top:O,right:k,bottom:O+g}),h.classList.toggle("cm-tooltip-above",y),h.classList.toggle("cm-tooltip-below",!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView)&&(this.inView=this.view.inView,!this.inView))for(let e of this.manager.tooltipViews)e.dom.style.top=oe}},{eventObservers:{scroll(){this.maybeMeasure()}}});function oo(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}let oa=ry.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),ol={x:0,y:0},oc=tr.define({enables:[or,oa]}),oh=tr.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class od{static create(e){return new od(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new ot(e,oh,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null==(e=t.destroy)||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let s=n[e];if(void 0!==s){if(void 0===t)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}let ou=oc.compute([oh],e=>{let t=e.facet(oh);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!=(t=e.end)?t:e.pos})),create:od.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class op{constructor(e,t,n,s,i){this.view=e,this.source=t,this.field=n,this.setHover=s,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let s,i=1;if(n.isWidget())s=n.posAtStart;else{if(null==(s=e.posAtCoords(t)))return;let n=e.coordsAtPos(s);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let r=e.bidiSpans(e.state.doc.lineAt(s)).find(e=>e.from<=s&&e.to>=s),o=r&&r.dir==n0.RTL?-1:1;i=t.x<n.left?-o:o}let r=this.source(e,s,i);if(null==r?void 0:r.then){let t=this.pending={pos:s};r.then(n=>{this.pending==t&&(this.pending=null,n&&!(Array.isArray(n)&&!n.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>sv(e.state,t,"hover tooltip"))}else r&&!(Array.isArray(r)&&!r.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(r)?r:[r])})}get tooltip(){let e=this.view.plugin(or),t=e?e.manager.tooltips.findIndex(e=>e.create==od.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:i}=this;if(s.length&&i&&!function(e,t){let{left:n,right:s,top:i,bottom:r}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let e=o.getBoundingClientRect();i=Math.min(e.top,i),r=Math.max(e.bottom,r)}return t.clientX>=n-4&&t.clientX<=s+4&&t.clientY>=i-4&&t.clientY<=r+4}(i.dom,e)||this.pending){let{pos:i}=s[0]||this.pending,r=null!=(n=null==(t=s[0])?void 0:t.end)?n:i;(i==r?this.view.posAtCoords(this.lastMove)!=i:!function(e,t,n,s,i){let r=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(r.left>s||r.right<s||r.top>i||Math.min(r.bottom,o)<i)return!1;let a=e.posAtCoords({x:s,y:i},!1);return a>=t&&a<=n}(this.view,i,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function of(e,t){let n=e.plugin(or);if(!n)return null;let s=n.manager.tooltips.indexOf(t);return s<0?null:n.manager.tooltipViews[s]}let om=tT.define(),og=tr.define({combine(e){let t,n;for(let s of e)t=t||s.topContainer,n=n||s.bottomContainer;return{topContainer:t,bottomContainer:n}}});function ox(e,t){let n=e.plugin(ob),s=n?n.specs.indexOf(t):-1;return s>-1?n.panels[s]:null}let ob=sk.fromClass(class{constructor(e){this.input=e.state.facet(ow),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(og);for(let n of(this.top=new ov(e,!0,t.topContainer),this.bottom=new ov(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top)),this.panels))n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(og);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new ov(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new ov(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(ow);if(n!=this.input){let t=n.filter(e=>e),s=[],i=[],r=[],o=[];for(let n of t){let t=this.specs.indexOf(n),a;t<0?(a=n(e.view),o.push(a)):(a=this.panels[t]).update&&a.update(e),s.push(a),(a.top?i:r).push(a)}for(let e of(this.specs=t,this.panels=s,this.top.sync(i),this.bottom.sync(r),o))e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>ry.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class ov{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&0>e.indexOf(t)&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=oy(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=oy(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function oy(e){let t=e.nextSibling;return e.remove(),t}let ow=tr.define({enables:ob}),oO=td.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(ok)?e=[n.value].concat(e):n.is(oj)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>ow.computeN([e],t=>t.field(e))}),ok=tT.define(),oj=tT.define();class oN extends tL{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}oN.prototype.elementClass="",oN.prototype.toDOM=void 0,oN.prototype.mapMode=e2.TrackBefore,oN.prototype.startSide=oN.prototype.endSide=-1,oN.prototype.point=!0;let oS=tr.define(),oz=tr.define(),oC={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>tF.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},o_=tr.define(),oT=tr.define({combine:e=>e.some(e=>e)});function oA(e){let t=[oM];return e&&!1===e.fixed&&t.push(oT.of(!0)),t}let oM=sk.fromClass(class{constructor(e){for(let t of(this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(o_).map(t=>new oD(e,t)),this.fixed=!e.state.facet(oT),this.gutters))"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,s=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(s<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(oT)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=tF.iter(this.view.state.facet(oS),this.view.viewport.from),s=[],i=this.gutters.map(e=>new oR(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(e.type)){let t=!0;for(let r of e.type)if(r.type==nN.Text&&t){for(let e of(oE(n,s,r.from),i))e.line(this.view,r,s);t=!1}else if(r.widget)for(let e of i)e.widget(this.view,r)}else if(e.type==nN.Text)for(let t of(oE(n,s,e.from),i))t.line(this.view,e,s);else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(o_),n=e.state.facet(o_),s=e.docChanged||e.heightChanged||e.viewportChanged||!tF.eq(e.startState.facet(oS),e.state.facet(oS),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(s=!0);else{s=!0;let i=[];for(let s of n){let n=t.indexOf(s);n<0?i.push(new oD(this.view,s)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),0>i.indexOf(e)&&e.destroy();for(let e of i)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return s}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>ry.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let s=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==n0.LTR?{left:s,right:i}:{right:s,left:i}})});function oP(e){return Array.isArray(e)?e:[e]}function oE(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class oR{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=tF.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:s}=this,i=(t.top-this.height)/e.scaleY,r=t.height/e.scaleY;if(this.i==s.elements.length){let t=new o$(e,r,i,n);s.elements.push(t),s.dom.appendChild(t.dom)}else s.elements[this.i].update(e,r,i,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];oE(this.cursor,s,t.from),n.length&&(s=s.concat(n));let i=this.gutter.config.lineMarker(e,t,s);i&&s.unshift(i);let r=this.gutter;(0!=s.length||r.config.renderEmptyElements)&&this.addElement(e,t,s)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let n of e.state.facet(oz)){let i=n(e,t.widget,t);i&&(s||(s=[])).push(i)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class oD{constructor(e,t){for(let n in this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),t.domEventHandlers)this.dom.addEventListener(n,s=>{let i=s.target,r;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();r=(e.top+e.bottom)/2}else r=s.clientY;let o=e.lineBlockAtHeight(r-e.documentTop);t.domEventHandlers[n](e,o,s)&&s.preventDefault()});this.markers=oP(t.markers(e)),t.initialSpacer&&(this.spacer=new o$(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=oP(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!tF.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class o${constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),!function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,s)&&this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let i=0,r=0;;){let o=r,a=i<t.length?t[i++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=r;e<this.markers.length;e++)if(this.markers[e].compare(a)){o=e,l=!0;break}}else o=this.markers.length;for(;r<o;){let e=this.markers[r++];if(e.toDOM){e.destroy(s);let t=s.nextSibling;s.remove(),s=t}}if(!a)break;a.toDOM&&(l?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),l&&r++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}let oQ=tr.define(),oI=tr.define(),oL=tr.define({combine:e=>tI(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let s=n[e],i=t[e];n[e]=s?(e,t,n)=>s(e,t,n)||i(e,t,n):i}return n}})});class oq extends oN{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function oB(e,t){return e.state.facet(oL).formatNumber(t,e.state)}let oW=o_.compute([oL],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(oQ),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new oq(oB(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let s of e.state.facet(oI)){let i=s(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(oL)!=e.state.facet(oL),initialSpacer:e=>new oq(oB(e,oV(e.state.doc.lines))),updateSpacer(e,t){let n=oB(t.view,oV(t.view.state.doc.lines));return n==e.number?e:new oq(n)},domEventHandlers:e.facet(oL).domEventHandlers,side:"before"}));function oV(e){let t=9;for(;t<e;)t=10*t+9;return t}let oF=new class extends oN{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},oH=oS.compute(["selection"],e=>{let t=[],n=-1;for(let s of e.selection.ranges){let i=e.doc.lineAt(s.head).from;i>n&&(n=i,t.push(oF.range(i)))}return tF.of(t)}),oX=0;class oU{constructor(e,t){this.from=e,this.to=t}}class oG{constructor(e={}){this.id=oX++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=oK.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}oG.closedBy=new oG({deserialize:e=>e.split(" ")}),oG.openedBy=new oG({deserialize:e=>e.split(" ")}),oG.group=new oG({deserialize:e=>e.split(" ")}),oG.isolate=new oG({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),oG.contextHash=new oG({perNode:!0}),oG.lookAhead=new oG({perNode:!0}),oG.mounted=new oG({perNode:!0});class oZ{constructor(e,t,n,s=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=s}static get(e){return e&&e.props&&e.props[oG.mounted.id]}}let oY=Object.create(null);class oK{constructor(e,t,n,s=0){this.name=e,this.props=t,this.id=n,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):oY,n=!!e.top|2*!!e.skipped|4*!!e.error|8*(null==e.name),s=new oK(e.name||"",t,e.id,n);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(s)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(oG.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let s of n.split(" "))t[s]=e[n];return e=>{for(let n=e.prop(oG.group),s=-1;s<(n?n.length:0);s++){let i=t[s<0?e.name:n[s]];if(i)return i}}}}oK.none=new oK("",Object.create(null),0,8);class oJ{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let s=null;for(let t of e){let e=t(n);if(e){s||(s=Object.assign({},n.props));let t=e[1],i=e[0];i.combine&&i.id in s&&(t=i.combine(s[i.id],t)),s[i.id]=t}}t.push(s?new oK(n.name,s,n.id,n.flags):n)}return new oJ(t)}}let o0=new WeakMap,o1=new WeakMap;(mF=mX||(mX={}))[mF.ExcludeBuffers=1]="ExcludeBuffers",mF[mF.IncludeAnonymous=2]="IncludeAnonymous",mF[mF.IgnoreMounts=4]="IgnoreMounts",mF[mF.IgnoreOverlays=8]="IgnoreOverlays",mF[mF.EnterBracketed=16]="EnterBracketed";class o2{constructor(e,t,n,s,i){if(this.type=e,this.children=t,this.positions=n,this.length=s,this.props=null,i&&i.length)for(let[e,t]of(this.props=Object.create(null),i))this.props["number"==typeof e?e:e.id]=t}toString(){let e=oZ.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ar(this.topNode,e)}cursorAt(e,t=0,n=0){let s=new ar(o0.get(this)||this.topNode);return s.moveTo(e,t),o0.set(this,s._tree),s}get topNode(){return new o9(this,0,0,null)}resolve(e,t=0){let n=o8(o0.get(this)||this.topNode,e,t,!1);return o0.set(this,n),n}resolveInner(e,t=0){let n=o8(o1.get(this)||this.topNode,e,t,!0);return o1.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let s=e.resolveInner(t,n),i=null;for(let e=s instanceof o9?s:s.context.parent;e;e=e.parent)if(e.index<0){let r=e.parent;(i||(i=[s])).push(r.resolve(t,n)),e=r}else{let r=oZ.get(e.tree);if(r&&r.overlay&&r.overlay[0].from<=t&&r.overlay[r.overlay.length-1].to>=t){let o=new o9(r.tree,r.overlay[0].from+e.from,-1,e);(i||(i=[s])).push(o8(o,t,n,!1))}}return i?as(i):s}(this,e,t)}iterate(e){let{enter:t,leave:n,from:s=0,to:i=this.length}=e,r=e.mode||0,o=(r&mX.IncludeAnonymous)>0;for(let e=this.cursor(r|mX.IncludeAnonymous);;){let r=!1;if(e.from<=i&&e.to>=s&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;r=!0}for(;r&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;r=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:ac(oK.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new o2(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new o2(oK.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:s,maxBufferLength:i=1024,reused:r=[],minRepeatType:o=s.types.length}=e,a=Array.isArray(n)?new o5(n,n.length):n,l=s.types,c=0,h=0;function d(e,t,n,i,r,o,a,l,c){let h=[],d=[];for(;e.length>i;)h.push(e.pop()),d.push(t.pop()+n-r);e.push(u(s.types[a],h,d,o-r,l-o,c)),t.push(r-n)}function u(e,t,n,s,i,r,o){if(r){let e=[oG.contextHash,r];o=o?[e].concat(o):[e]}if(i>25){let e=[oG.lookAhead,i];o=o?[e].concat(o):[e]}return new o2(e,t,n,s,o)}let p=[],f=[];for(;a.pos>0;)!function e(t,n,p,f,m,g){let{id:x,start:b,end:v,size:y}=a,w=h,O=c;if(y<0){if(a.next(),-1==y){let e=r[x];p.push(e),f.push(b-t);return}if(-3==y){c=x;return}if(-4==y){h=x;return}else throw RangeError(`Unrecognized record size: ${y}`)}let k=l[x],j,N,S=b-t;if(v-b<=i&&(N=function(e,t){let n=a.fork(),s=0,r=0,l=0,c=n.end-i,h={size:0,start:0,skip:0};s:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){h.size=s,h.start=r,h.skip=l,l+=4,s+=4,n.next();continue}let a=n.pos-e;if(e<0||a<i||n.start<c)break;let d=4*(n.id>=o),u=n.start;for(n.next();n.pos>a;){if(n.size<0)if(-3==n.size||-4==n.size)d+=4;else break s;else n.id>=o&&(d+=4);n.next()}r=u,s+=e,l+=d}return(t<0||s==e)&&(h.size=s,h.start=r,h.skip=l),h.size>4?h:void 0}(a.pos-n,m))){let e=new Uint16Array(N.size-N.skip),n=a.pos-N.size,i=e.length;for(;a.pos>n;)i=function e(t,n,s){let{id:i,start:r,end:l,size:d}=a;if(a.next(),d>=0&&i<o){let o=s;if(d>4){let i=a.pos-(d-4);for(;a.pos>i;)s=e(t,n,s)}n[--s]=o,n[--s]=l-t,n[--s]=r-t,n[--s]=i}else -3==d?c=i:-4==d&&(h=i);return s}(N.start,e,i);j=new o3(e,v-N.start,s),S=N.start-t}else{let t=a.pos-y;a.next();let n=[],r=[],l=x>=o?x:-1,c=0,h=v;for(;a.pos>t;)l>=0&&a.id==l&&a.size>=0?(a.end<=h-i&&(d(n,r,b,c,a.end,h,l,w,O),c=n.length,h=a.end),a.next()):g>2500?function(e,t,n,r){let o=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:s}=a;if(s>4)a.next();else if(c>-1&&t<c)break;else c<0&&(c=n-i),o.push(e,t,n),l++,a.next()}if(l){let t=new Uint16Array(4*l),i=o[o.length-2];for(let e=o.length-3,n=0;e>=0;e-=3)t[n++]=o[e],t[n++]=o[e+1]-i,t[n++]=o[e+2]-i,t[n++]=n;n.push(new o3(t,o[2]-i,s)),r.push(i-e)}}(b,t,n,r):e(b,t,n,r,l,g+1);if(l>=0&&c>0&&c<n.length&&d(n,r,b,c,b,h,l,w,O),n.reverse(),r.reverse(),l>-1&&c>0){let e=function(e,t){return(n,s,i)=>{let r=0,o=n.length-1,a,l;if(o>=0&&(a=n[o])instanceof o2){if(!o&&a.type==e&&a.length==i)return a;(l=a.prop(oG.lookAhead))&&(r=s[o]+a.length+l)}return u(e,n,s,i,r,t)}}(k,O);j=ac(k,n,r,0,n.length,0,v-b,e,e)}else j=u(k,n,r,v-b,w-v,O)}p.push(j),f.push(S)}(e.start||0,e.bufferStart||0,p,f,-1,0);let m=null!=(t=e.length)?t:p.length?f[0]+p[0].length:0;return new o2(l[e.topID],p.reverse(),f.reverse(),m)}(e)}}o2.empty=new o2(oK.none,[],[],0);class o5{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new o5(this.buffer,this.index)}}class o3{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return oK.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],s=this.set.types[t],i=s.name;if(/\W/.test(i)&&!s.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let r=[];for(;e<n;)r.push(this.childString(e)),e=this.buffer[e+3];return i+"("+r.join(",")+")"}findChild(e,t,n,s,i){let{buffer:r}=this,o=-1;for(let a=e;a!=t&&(!o4(i,s,r[a+1],r[a+2])||(o=a,!(n>0)));a=r[a+3]);return o}slice(e,t,n){let s=this.buffer,i=new Uint16Array(t-e),r=0;for(let o=e,a=0;o<t;){i[a++]=s[o++],i[a++]=s[o++]-n;let t=i[a++]=s[o++]-n;i[a++]=s[o++]-e,r=Math.max(r,t)}return new o3(i,r,this.set)}}function o4(e,t,n,s){switch(e){case -2:return n<t;case -1:return s>=t&&n<t;case 0:return n<t&&s>t;case 1:return n<=t&&s>t;case 2:return s>t;case 4:return!0}}function o8(e,t,n,s){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!s&&e instanceof o9&&e.index<0?null:e.parent;if(!t)return e;e=t}let r=s?0:mX.IgnoreOverlays;if(s)for(let s=e,o=s.parent;o;o=(s=o).parent)s instanceof o9&&s.index<0&&(null==(i=o.enter(t,n,r))?void 0:i.from)!=s.from&&(e=o);for(;;){let s=e.enter(t,n,r);if(!s)return e;e=s}}class o6{cursor(e=0){return new ar(this,e)}getChild(e,t=null,n=null){let s=o7(this,e,t,n);return s.length?s[0]:null}getChildren(e,t=null,n=null){return o7(this,e,t,n)}resolve(e,t=0){return o8(this,e,t,!1)}resolveInner(e,t=0){return o8(this,e,t,!0)}matchContext(e){return ae(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class o9 extends o6{constructor(e,t,n,s){super(),this._tree=e,this.from=t,this.index=n,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,s,i=0){for(let r=this;;){for(let{children:o,positions:a}=r._tree,l=t>0?o.length:-1;e!=l;e+=t){let l=o[e],c=a[e]+r.from,h;if(i&mX.EnterBracketed&&l instanceof o2&&(h=oZ.get(l))&&!h.overlay&&h.bracketed&&n>=c&&n<=c+l.length||o4(s,n,c,c+l.length)){if(l instanceof o3){if(i&mX.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,t,n-c,s);if(o>-1)return new an(new at(r,l,e,c),null,o)}else if(i&mX.IncludeAnonymous||!l.type.isAnonymous||ao(l)){let o;if(!(i&mX.IgnoreMounts)&&(o=oZ.get(l))&&!o.overlay)return new o9(o.tree,c,e,r);let a=new o9(l,c,e,r);return i&mX.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,n,s,i)}}}if(i&mX.IncludeAnonymous||!r.type.isAnonymous||(e=r.index>=0?r.index+t:t<0?-1:r._parent._tree.children.length,!(r=r._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let s;if(!(n&mX.IgnoreOverlays)&&(s=oZ.get(this._tree))&&s.overlay){let i=e-this.from,r=n&mX.EnterBracketed&&s.bracketed;for(let{from:e,to:n}of s.overlay)if((t>0||r?e<=i:e<i)&&(t<0||r?n>=i:n>i))return new o9(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function o7(e,t,n,s){let i=e.cursor(),r=[];if(!i.firstChild())return r;if(null!=n){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return r}for(;;){if(null!=s&&i.type.is(s))return r;if(i.type.is(t)&&r.push(i.node),!i.nextSibling())return null==s?r:[]}}function ae(e,t,n=t.length-1){for(let s=e;n>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}class at{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class an extends o6{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:s}=this.context,i=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new an(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&mX.ExcludeBuffers)return null;let{buffer:s}=this.context,i=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new an(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new an(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new an(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,s=this.index+4,i=n.buffer[this.index+3];if(i>s){let r=n.buffer[this.index+1];e.push(n.slice(s,i,r)),t.push(0)}return new o2(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function as(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;s<e.length;s++){let i=e[s];(i.from>n.from||i.to<n.to)&&(n=i,t=s)}let s=n instanceof o9&&n.index<0?null:n.parent,i=e.slice();return s?i[t]=s:i.splice(t,1),new ai(i,n)}class ai{constructor(e,t){this.heads=e,this.node=t}get next(){return as(this.heads)}}class ar{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~mX.EnterBracketed,e instanceof o9)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return!!e&&(e instanceof o9?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:s}=this.buffer,i=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&mX.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&mX.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&mX.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(s.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=s)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,i=e<0?-1:n._tree.children.length;s!=i;s+=e){let e=n._tree.children[s];if(this.mode&mX.IncludeAnonymous||e instanceof o3||!e.type.isAnonymous||ao(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)s:for(let s=this.index,i=this.stack.length;i>=0;){for(let r=e;r;r=r._parent)if(r.index==s){if(s==this.index)return r;t=r,n=i+1;break s}s=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new an(this.buffer,t,this.stack[e]);return this.bufferNode=new an(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let s=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,s=!0}}}matchContext(e){if(!this.buffer)return ae(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let s=e.length-1,i=this.stack.length-1;s>=0;i--){if(i<0)return ae(this._tree,e,s);let r=n[t.buffer[this.stack[i]]];if(!r.isAnonymous){if(e[s]&&e[s]!=r.name)return!1;s--}}return!0}}function ao(e){return e.children.some(e=>e instanceof o3||!e.type.isAnonymous||ao(e))}let aa=new WeakMap;function al(e,t){if(!e.isAnonymous||t instanceof o3||t.type!=e)return 1;let n=aa.get(t);if(null==n){for(let s of(n=1,t.children)){if(s.type!=e||!(s instanceof o2)){n=1;break}n+=al(e,s)}aa.set(t,n)}return n}function ac(e,t,n,s,i,r,o,a,l){let c=0;for(let n=s;n<i;n++)c+=al(e,t[n]);let h=Math.ceil(1.5*c/8),d=[],u=[];return!function t(n,s,i,o,a){for(let c=i;c<o;){let i=c,p=s[c],f=al(e,n[c]);for(c++;c<o;c++){let t=al(e,n[c]);if(f+t>=h)break;f+=t}if(c==i+1){if(f>h){let e=n[i];t(e.children,e.positions,0,e.children.length,s[i]+a);continue}d.push(n[i])}else{let t=s[c-1]+n[c-1].length-p;d.push(ac(e,n,s,i,c,p,t,null,l))}u.push(p+a-r)}}(t,n,s,i,0),(a||l)(d,u,o)}class ah{constructor(e,t,n,s,i=!1,r=!1){this.from=e,this.to=t,this.tree=n,this.offset=s,this.open=!!i|2*!!r}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let s=[new ah(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&s.push(n);return s}static applyChanges(e,t,n=128){if(!t.length)return e;let s=[],i=1,r=e.length?e[0]:null;for(let o=0,a=0,l=0;;o++){let c=o<t.length?t[o]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;r&&r.from<h;){let t=r;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new ah(e,n,t.tree,t.offset+l,o>0,!!c)}if(t&&s.push(t),r.to>h)break;r=i<e.length?e[i++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return s}}class ad{startParse(e,t,n){return"string"==typeof e&&(e=new au(e)),n=n?n.length?n.map(e=>new oU(e.from,e.to)):[new oU(0,0)]:[new oU(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let s=this.startParse(e,t,n);for(;;){let e=s.advance();if(e)return e}}}class au{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new oG({perNode:!0});let ap=0;class af{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=ap++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){if(e instanceof af&&(t=e),null==t?void 0:t.base)throw Error("Can not derive from a modified tag");let n=new af("string"==typeof e?e:"?",[],null,[]);if(n.set.push(n),t)for(let e of t.set)n.set.push(e);return n}static defineModifier(e){let t=new ag(e);return e=>e.modified.indexOf(t)>-1?e:ag.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let am=0;class ag{constructor(e){this.name=e,this.instances=[],this.id=am++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{var s,i;return n.base==e&&(s=t,i=n.modified,s.length==i.length&&s.every((e,t)=>e==i[t]))});if(n)return n;let s=[],i=new af(e.name,s,e,t);for(let e of t)e.instances.push(i);let r=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let s=0,i=t.length;s<i;s++)t.push(t[s].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of r)s.push(ag.get(t,e));return i}}function ax(e){let t=Object.create(null);for(let n in e){let s=e[n];for(let e of(Array.isArray(s)||(s=[s]),n.split(" ")))if(e){let n=[],i=2,r=e;for(let t=0;;){if("..."==r&&t>0&&t+3==e.length){i=1;break}let s=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!s)throw RangeError("Invalid path: "+e);if(n.push("*"==s[0]?"":'"'==s[0][0]?JSON.parse(s[0]):s[0]),(t+=s[0].length)==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){i=0;break}if("/"!=o)throw RangeError("Invalid path: "+e);r=e.slice(t)}let o=n.length-1,a=n[o];if(!a)throw RangeError("Invalid path: "+e);let l=new av(s,i,o>0?n.slice(0,o):null);t[a]=l.sort(t[a])}}return ab.add(t)}let ab=new oG({combine(e,t){let n,s,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let r=new av(i.tags,i.mode,i.context);n?n.next=r:s=r,n=r}return s}});class av{constructor(e,t,n,s){this.tags=e,this.mode=t,this.context=n,this.next=s}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function ay(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:s,all:i=null}=t||{};return{style:e=>{let t=i;for(let s of e)for(let e of s.set){let s=n[e.id];if(s){t=t?t+" "+s:s;break}}return t},scope:s}}av.empty=new av([],2,null);class aw{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,s,i){let{type:r,from:o,to:a}=e;if(o>=n||a<=t)return;r.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(r)));let l=s,c=function(e){let t=e.type.prop(ab);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||av.empty,h=function(e,t){let n=null;for(let s of e){let e=s.style(t);e&&(n=n?n+" "+e:e)}return n}(i,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(s+=(s?" ":"")+h)),this.startSpan(Math.max(t,o),l),c.opaque)return;let d=e.tree&&e.tree.prop(oG.mounted);if(d&&d.overlay){let r=e.node.enter(d.overlay[0].from+o,1),c=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),h=e.firstChild();for(let u=0,p=o;;u++){let f=u<d.overlay.length?d.overlay[u]:null,m=f?f.from+o:a,g=Math.max(t,p),x=Math.min(n,m);if(g<x&&h)for(;e.from<x&&(this.highlightRange(e,g,x,s,i),this.startSpan(Math.min(x,e.to),l),!(e.to>=m)&&e.nextSibling()););if(!f||m>n)break;(p=f.to+o)>t&&(this.highlightRange(r.cursor(),Math.max(t,f.from+o),Math.min(n,p),"",c),this.startSpan(Math.min(n,p),l))}h&&e.parent()}else if(e.firstChild()){d&&(s="");do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,s,i),this.startSpan(Math.min(n,e.to),l)}while(e.nextSibling())e.parent()}}}let aO=af.define,ak=aO(),aj=aO(),aN=aO(aj),aS=aO(aj),az=aO(),aC=aO(az),a_=aO(az),aT=aO(),aA=aO(aT),aM=aO(),aP=aO(),aE=aO(),aR=aO(aE),aD=aO(),a$={comment:ak,lineComment:aO(ak),blockComment:aO(ak),docComment:aO(ak),name:aj,variableName:aO(aj),typeName:aN,tagName:aO(aN),propertyName:aS,attributeName:aO(aS),className:aO(aj),labelName:aO(aj),namespace:aO(aj),macroName:aO(aj),literal:az,string:aC,docString:aO(aC),character:aO(aC),attributeValue:aO(aC),number:a_,integer:aO(a_),float:aO(a_),bool:aO(az),regexp:aO(az),escape:aO(az),color:aO(az),url:aO(az),keyword:aM,self:aO(aM),null:aO(aM),atom:aO(aM),unit:aO(aM),modifier:aO(aM),operatorKeyword:aO(aM),controlKeyword:aO(aM),definitionKeyword:aO(aM),moduleKeyword:aO(aM),operator:aP,derefOperator:aO(aP),arithmeticOperator:aO(aP),logicOperator:aO(aP),bitwiseOperator:aO(aP),compareOperator:aO(aP),updateOperator:aO(aP),definitionOperator:aO(aP),typeOperator:aO(aP),controlOperator:aO(aP),punctuation:aE,separator:aO(aE),bracket:aR,angleBracket:aO(aR),squareBracket:aO(aR),paren:aO(aR),brace:aO(aR),content:aT,heading:aA,heading1:aO(aA),heading2:aO(aA),heading3:aO(aA),heading4:aO(aA),heading5:aO(aA),heading6:aO(aA),contentSeparator:aO(aT),list:aO(aT),quote:aO(aT),emphasis:aO(aT),strong:aO(aT),link:aO(aT),monospace:aO(aT),strikethrough:aO(aT),inserted:aO(),deleted:aO(),changed:aO(),invalid:aO(),meta:aD,documentMeta:aO(aD),annotation:aO(aD),processingInstruction:aO(aD),definition:af.defineModifier("definition"),constant:af.defineModifier("constant"),function:af.defineModifier("function"),standard:af.defineModifier("standard"),local:af.defineModifier("local"),special:af.defineModifier("special")};for(let e in a$){let t=a$[e];t instanceof af&&(t.name=e)}ay([{tag:a$.link,class:"tok-link"},{tag:a$.heading,class:"tok-heading"},{tag:a$.emphasis,class:"tok-emphasis"},{tag:a$.strong,class:"tok-strong"},{tag:a$.keyword,class:"tok-keyword"},{tag:a$.atom,class:"tok-atom"},{tag:a$.bool,class:"tok-bool"},{tag:a$.url,class:"tok-url"},{tag:a$.labelName,class:"tok-labelName"},{tag:a$.inserted,class:"tok-inserted"},{tag:a$.deleted,class:"tok-deleted"},{tag:a$.literal,class:"tok-literal"},{tag:a$.string,class:"tok-string"},{tag:a$.number,class:"tok-number"},{tag:[a$.regexp,a$.escape,a$.special(a$.string)],class:"tok-string2"},{tag:a$.variableName,class:"tok-variableName"},{tag:a$.local(a$.variableName),class:"tok-variableName tok-local"},{tag:a$.definition(a$.variableName),class:"tok-variableName tok-definition"},{tag:a$.special(a$.variableName),class:"tok-variableName2"},{tag:a$.definition(a$.propertyName),class:"tok-propertyName tok-definition"},{tag:a$.typeName,class:"tok-typeName"},{tag:a$.namespace,class:"tok-namespace"},{tag:a$.className,class:"tok-className"},{tag:a$.macroName,class:"tok-macroName"},{tag:a$.propertyName,class:"tok-propertyName"},{tag:a$.operator,class:"tok-operator"},{tag:a$.comment,class:"tok-comment"},{tag:a$.meta,class:"tok-meta"},{tag:a$.invalid,class:"tok-invalid"},{tag:a$.punctuation,class:"tok-punctuation"}]);let aQ=new oG,aI=new oG;class aL{constructor(e,t,n=[],s=""){this.data=e,this.name=s,tQ.prototype.hasOwnProperty("tree")||Object.defineProperty(tQ.prototype,"tree",{get(){return aW(this)}}),this.parser=t,this.extension=[aK.of(this),tQ.languageData.of((e,t,n)=>{let s=aq(e,t,n),i=s.type.prop(aQ);if(!i)return[];let r=e.facet(i),o=s.type.prop(aI);if(o){let i=s.resolve(t-s.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(r)}}return r})].concat(n)}isActiveAt(e,t,n=-1){return aq(e,t,n).type.prop(aQ)==this.data}findRegions(e){let t=e.facet(aK);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(e,t)=>{if(e.prop(aQ)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(oG.mounted);if(i){if(i.tree.prop(aQ)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(s(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof o2&&s(i,e.positions[n]+t)}};return s(aW(e),0),n}get allowsNesting(){return!0}}function aq(e,t,n){let s=e.facet(aK),i=aW(e).topNode;if(!s||s.allowsNesting)for(let e=i;e;e=e.enter(t,n,mX.ExcludeBuffers|mX.EnterBracketed))e.type.isTop&&(i=e);return i}aL.setState=tT.define();class aB extends aL{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){var t;let n=(t=e.languageData,tr.define({combine:t?e=>e.concat(t):void 0}));return new aB(n,e.parser.configure({props:[aQ.add(e=>e.isTop?n:void 0)]}),e.name)}configure(e,t){return new aB(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function aW(e){let t=e.field(aL.state,!1);return t?t.tree:o2.empty}class aV{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let aF=null;class aH{constructor(e,t,n=[],s,i,r,o,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=i,this.viewport=r,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new aH(e,t,[],o2.empty,0,n,[],null)}startParse(){return this.parser.startParse(new aV(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=o2.empty&&this.isDone(null!=t?t:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s){if(this.fragments=this.withoutTempSkipped(ah.addTree(s,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=s,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ah.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=aF;aF=this;try{return e()}finally{aF=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=aX(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:i,viewport:r,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,s,i)=>t.push({fromA:e,toA:n,fromB:s,toB:i})),n=ah.applyChanges(n,t),s=o2.empty,i=0,r={from:e.mapPos(r.from,-1),to:e.mapPos(r.to,1)},this.skipped.length)for(let t of(o=[],this.skipped)){let n=e.mapPos(t.from,1),s=e.mapPos(t.to,-1);n<s&&o.push({from:n,to:s})}}return new aH(this.parser,t,n,s,i,r,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:s}=this.skipped[t];n<e.to&&s>e.from&&(this.fragments=aX(this.fragments,n,s),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends ad{createParse(t,n,s){let i=s[0].from,r=s[s.length-1].to;return{parsedPos:i,advance(){let t=aF;if(t){for(let e of s)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=r,new o2(oK.none,[],[],r-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return aF}}function aX(e,t,n){return ah.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class aU{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new aU(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=aH.create(e.facet(aK).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new aU(n)}}aL.state=td.define({create:aU.init,update(e,t){for(let e of t.effects)if(e.is(aL.setState))return e.value;return t.startState.facet(aK)!=t.state.facet(aK)?aU.init(t.state):e.apply(t)}});let aG=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"u">typeof requestIdleCallback&&(aG=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});let aZ="u">typeof navigator&&(null==(mU=navigator.scheduling)?void 0:mU.isInputPending)?()=>navigator.scheduling.isInputPending():null,aY=sk.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(aL.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(aL.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=aG(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:s}}=this.view,i=n.field(aL.state);if(i.tree==i.context.tree&&i.context.isDone(s+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,e&&!aZ?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<s&&n.doc.length>s+1e3,a=i.context.work(()=>aZ&&aZ()||Date.now()>r,s+1e5*!o);this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:aL.setState.of(new aU(i.context))})),this.chunkBudget>0&&!(a&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>sv(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),aK=tr.define({combine:e=>e.length?e[0]:null,enables:e=>[aL.state,aY,ry.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class aJ{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}let a0=tr.define(),a1=tr.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function a2(e){let t=e.facet(a1);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function a5(e,t){let n="",s=e.tabSize,i=e.facet(a1)[0];if(" "==i){for(;t>=s;)n+=" ",t-=s;i=" "}for(let e=0;e<t;e++)n+=i;return n}function a3(e,t){for(let n of(e instanceof tQ&&(e=new a4(e)),e.state.facet(a0))){let s=n(e,t);if(void 0!==s)return s}let n=aW(e.state);return n.length>=t?function(e,t,n){let s=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=s.node){let e=[];for(let t=i;t&&!(t.from<s.node.from||t.to>s.node.to||t.from==s.node.from&&t.type==s.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)s={node:e[t],next:s}}return a6(s,e,n)}(e,n,t):null}class a4{constructor(e,t={}){this.state=e,this.options=t,this.unit=a2(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:i}=this.options;if(null!=s&&s>=n.from&&s<=n.to)if(i&&s==e)return{text:"",from:e};else if(t<0?s<e:s<=e)return{text:n.text.slice(s-n.from),from:s};else return{text:n.text.slice(0,s-n.from),from:n.from};return n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:s}=this.lineAt(e,t);return n.slice(e-s,Math.min(n.length,e+100-s))}column(e,t=1){let{text:n,from:s}=this.lineAt(e,t),i=this.countColumn(n,e-s),r=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return r>-1&&(i+=r-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return t5(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(s);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let a8=new oG;function a6(e,t,n){for(let s=e;s;s=s.next){let e=function(e){let t=e.type.prop(a8);if(t)return t;let n=e.firstChild,s;if(n&&(s=n.type.prop(oG.closedBy))){let t=e.lastChild,n=t&&s.indexOf(t.name)>-1;return e=>lt(e,!0,1,void 0,n&&!(e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak)?t.from:void 0)}return null==e.parent?a9:null}(s.node);if(e)return e(a7.create(t,n,s))}return 0}function a9(){return 0}class a7 extends a4{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new a7(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(function(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return a6(this.context.next,this.base,this.pos)}}function le({closing:e,align:t=!0,units:n=1}){return s=>lt(s,t,n,e)}function lt(e,t,n,s,i){let r=e.textAfter,o=r.match(/^\s*/)[0].length,a=s&&r.slice(o,o+s.length)==s||i==e.pos+o,l=t?function(e){let t=e.node,n=t.childAfter(t.from),s=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,r=e.state.doc.lineAt(n.from),o=null==i||i<=r.from?r.to:Math.min(r.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==s)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(r.text.slice(n.to-r.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}let ln=tr.define(),ls=new oG;function li(e,t,n){for(let s of e.facet(ln)){let i=s(e,t,n);if(i)return i}return function(e,t,n){let s=aW(e);if(s.length<n)return null;let i=s.resolveStack(n,1),r=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(r&&i.from<t)break;let a=i.type.prop(ls);if(a&&(i.to<s.length-50||s.length==e.doc.length||!function(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}(i))){let s=a(i,e);s&&s.from<=n&&s.from>=t&&s.to>n&&(r=s)}}return r}(e,t,n)}function lr(e,t){let n=t.mapPos(e.from,1),s=t.mapPos(e.to,-1);return n>=s?void 0:{from:n,to:s}}let lo=tT.define({map:lr}),la=tT.define({map:lr});function ll(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}let lc=td.define({create:()=>nS.none,update(e,t){for(let n of(t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=lh(e,t,n)),e=e.map(t.changes),t.effects))if(n.is(lo)&&!function(e,t,n){let s=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(s=!0)}),s}(e,n.value.from,n.value.to)){let{preparePlaceholder:s}=t.state.facet(lg),i=s?nS.replace({widget:new ly(s(t.state,n.value))}):lv;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(la)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=lh(e,t.selection.main.head)),e},provide:e=>ry.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let s=e[n++],i=e[n++];if("number"!=typeof s||"number"!=typeof i)throw RangeError("Invalid JSON for fold state");t.push(lv.range(s,i))}return nS.set(t,!0)}});function lh(e,t,n=t){let s=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(s=!0)}),s?e.update({filterFrom:t,filterTo:n,filter:(e,s)=>e>=n||s<=t}):e}function ld(e,t,n){var s;let i=null;return null==(s=e.field(lc,!1))||s.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function lu(e,t){return e.field(lc,!1)?t:t.concat(tT.appendConfig.of(lx()))}function lp(e,t,n=!0){let s=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return ry.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${s} ${e.state.phrase("to")} ${i}.`)}let lf=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of ll(e)){let n=li(e.state,t.from,t.to);if(n)return e.dispatch({effects:lu(e.state,[lo.of(n),lp(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(lc,!1))return!1;let t=[];for(let n of ll(e)){let s=ld(e.state,n.from,n.to);s&&t.push(la.of(s),lp(e,s,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let s=0;s<t.doc.length;){let i=e.lineBlockAt(s),r=li(t,i.from,i.to);r&&n.push(lo.of(r)),s=(r?e.lineBlockAt(r.to):i).to+1}return n.length&&e.dispatch({effects:lu(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(lc,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(la.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],lm={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},lg=tr.define({combine:e=>tI(e,lm)});function lx(e){let t=[lc,lk];return e&&t.push(lg.of(e)),t}function lb(e,t){let{state:n}=e,s=n.facet(lg),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),s=ld(e.state,n.from,n.to);s&&e.dispatch({effects:la.of(s)}),t.preventDefault()};if(s.placeholderDOM)return s.placeholderDOM(e,i,t);let r=document.createElement("span");return r.textContent=s.placeholderText,r.setAttribute("aria-label",n.phrase("folded code")),r.title=n.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=i,r}let lv=nS.replace({widget:new class extends nj{toDOM(e){return lb(e,null)}}});class ly extends nj{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return lb(e,this.value)}}let lw={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class lO extends oN{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}let lk=ry.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class lj{constructor(e,t){let n;function s(e){let t=t9.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?s(t.all):void 0,r=t.scope;this.scope=r instanceof aL?e=>e.prop(aQ)==r.data:r?e=>e==r:void 0,this.style=ay(e.map(e=>({tag:e.tag,class:e.class||s(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new t9(n):null,this.themeType=t.themeType}static define(e,t){return new lj(e,t||{})}}let lN=tr.define(),lS=tr.define({combine:e=>e.length?[e[0]]:null});function lz(e){let t=e.facet(lN);return t.length?t:e.facet(lS)}function lC(e,t){let n=[l_],s;return e instanceof lj&&(e.module&&n.push(ry.styleModule.of(e.module)),s=e.themeType),(null==t?void 0:t.fallback)?n.push(lS.of(e)):s?n.push(lN.computeN([ry.darkTheme],t=>t.facet(ry.darkTheme)==("dark"==s)?[e]:[])):n.push(lN.of(e)),n}let l_=tp.high(sk.fromClass(class{constructor(e){this.markCache=Object.create(null),this.tree=aW(e.state),this.decorations=this.buildDeco(e,lz(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=aW(e.state),n=lz(e.state),s=n!=lz(e.startState),{viewport:i}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!s&&t.type==this.tree.type&&r>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return nS.none;let n=new tH;for(let{from:s,to:i}of e.visibleRanges)!function(e,t,n,s=0,i=e.length){let r=new aw(s,Array.isArray(t)?t:[t],n);r.highlightRange(e.cursor(),s,i,"",r.highlighters),r.flush(i)}(this.tree,t,(e,t,s)=>{n.add(e,t,this.markCache[s]||(this.markCache[s]=nS.mark({class:s})))},s,i);return n.finish()}},{decorations:e=>e.decorations})),lT=lj.define([{tag:a$.meta,color:"#404740"},{tag:a$.link,textDecoration:"underline"},{tag:a$.heading,textDecoration:"underline",fontWeight:"bold"},{tag:a$.emphasis,fontStyle:"italic"},{tag:a$.strong,fontWeight:"bold"},{tag:a$.strikethrough,textDecoration:"line-through"},{tag:a$.keyword,color:"#708"},{tag:[a$.atom,a$.bool,a$.url,a$.contentSeparator,a$.labelName],color:"#219"},{tag:[a$.literal,a$.inserted],color:"#164"},{tag:[a$.string,a$.deleted],color:"#a11"},{tag:[a$.regexp,a$.escape,a$.special(a$.string)],color:"#e40"},{tag:a$.definition(a$.variableName),color:"#00f"},{tag:a$.local(a$.variableName),color:"#30a"},{tag:[a$.typeName,a$.namespace],color:"#085"},{tag:a$.className,color:"#167"},{tag:[a$.special(a$.variableName),a$.macroName],color:"#256"},{tag:a$.definition(a$.propertyName),color:"#00c"},{tag:a$.comment,color:"#940"},{tag:a$.invalid,color:"#f00"}]),lA=ry.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),lM="()[]{}",lP=tr.define({combine:e=>tI(e,{afterCursor:!0,brackets:lM,maxScanDistance:1e4,renderMatch:lD})}),lE=nS.mark({class:"cm-matchingBracket"}),lR=nS.mark({class:"cm-nonmatchingBracket"});function lD(e){let t=[],n=e.matched?lE:lR;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function l$(e){let t=[],n=e.facet(lP);for(let s of e.selection.ranges){if(!s.empty)continue;let i=lB(e,s.head,-1,n)||s.head>0&&lB(e,s.head-1,1,n)||n.afterCursor&&(lB(e,s.head,1,n)||s.head<e.doc.length&&lB(e,s.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return nS.set(t,!0)}let lQ=[sk.fromClass(class{constructor(e){this.paused=!1,this.decorations=l$(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=l$(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),lA],lI=new oG;function lL(e,t,n){let s=e.prop(t<0?oG.openedBy:oG.closedBy);if(s)return s;if(1==e.name.length){let s=n.indexOf(e.name);if(s>-1&&s%2==+(t<0))return[n[s+t]]}return null}function lq(e){let t=e.type.prop(lI);return t?t(e.node):e}function lB(e,t,n,s={}){let i=s.maxScanDistance||1e4,r=s.brackets||lM,o=aW(e),a=o.resolveInner(t,n);for(let e=a;e;e=e.parent){let s=lL(e.type,n,r);if(s&&e.from<e.to){let i=lq(e);if(i&&(n>0?t>=i.from&&t<i.to:t>i.from&&t<=i.to))return function(e,t,n,s,i){let r=t.parent,o={from:n.from,to:n.to},a=0,l=null==r?void 0:r.cursor();if(l&&(e<0?l.childBefore(t.from):l.childAfter(t.to)))do if(e<0?l.to<=t.from:l.from>=t.to){if(0==a&&s.indexOf(l.type.name)>-1&&l.from<l.to){let e=lq(l);return{start:o,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(lL(l.type,e,i))a++;else if(lL(l.type,-e,i)){if(0==a){let e=lq(l);return{start:o,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}a--}}while(e<0?l.prevSibling():l.nextSibling())return{start:o,matched:!1}}(n,e,i,s,r)}}return function(e,t,n,s,i,r,o){if(n<0?!t:t==e.doc.length)return null;let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!h.next().done&&e<=r;){let r=h.value;n<0&&(e+=r.length);let a=t+e*n;for(let e=n>0?0:r.length-1,t=n>0?r.length:-1;e!=t;e+=n){let t=o.indexOf(r[e]);if(!(t<0)&&s.resolveInner(a+e,1).type==i)if(t%2==0==n>0)d++;else{if(1==d)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};d--}}n>0&&(e+=r.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,o,a.type,i,r)}let lW=Object.create(null),lV=[oK.none],lF=[],lH=Object.create(null),lX=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])lX[e]=function(e,t){let n=[];for(let s of t.split(" ")){let t=[];for(let n of s.split(".")){let s=e[n]||a$[n];s?"function"==typeof s?t.length?t=t.map(s):lU(n,`Modifier ${n} used at start of tag`):t.length?lU(n,`Tag ${n} used as modifier`):t=Array.isArray(s)?s:[s]:lU(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let s=t.replace(/ /g,"_"),i=s+" "+n.map(e=>e.id),r=lH[i];if(r)return r.id;let o=lH[i]=oK.define({id:lV.length,name:s,props:[ax({[s]:n})]});return lV.push(o),o.id}(lW,t);function lU(e,t){lF.indexOf(e)>-1||(lF.push(e),console.warn(t))}function lG(e,t){return({state:n,dispatch:s})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(s(n.update(i)),!0)}}n0.RTL,n0.LTR;let lZ=lG(function(e,t,n=t.selection.ranges){let s=[],i=-1;i:for(let{from:e,to:r}of n){let n=s.length,o=1e9,a;for(let n=e;n<=r;){let l=t.doc.lineAt(n);if(void 0==a&&!(a=lJ(t,l.from).line))continue i;if(l.from>i&&(e==r||r>l.from)){i=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,n=l.text.slice(e,e+a.length)==a?e:-1;e<l.text.length&&e<o&&(o=e),s.push({line:l,comment:n,token:a,indent:e,empty:t,single:!1})}n=l.to+1}if(o<1e9)for(let e=n;e<s.length;e++)s[e].indent<s[e].line.text.length&&(s[e].indent=o);s.length==n+1&&(s[n].single=!0)}if(2!=e&&s.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:r,single:o}of s)(o||!r)&&e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&s.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of s)if(n>=0){let s=t.from+n,r=s+i.length;" "==t.text[r-t.from]&&r++,e.push({from:s,to:r})}return{changes:e}}return null},0),lY=lG(l0,0),lK=lG((e,t)=>l0(e,t,function(e){let t=[];for(let n of e.selection.ranges){let s=e.doc.lineAt(n.from),i=n.to<=s.to?s:e.doc.lineAt(n.to);i.from>s.from&&i.from==n.to&&(i=n.to==s.to+1?s:e.doc.lineAt(n.to-1));let r=t.length-1;r>=0&&t[r].to>s.from?t[r].to=i.to:t.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:i.to})}return t}(t)),0);function lJ(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function l0(e,t,n=t.selection.ranges){let s=n.map(e=>lJ(t,e.from).block);if(!s.every(e=>e))return null;let i=n.map((e,n)=>(function(e,{open:t,close:n},s,i){let r,o,a=e.sliceDoc(s-50,s),l=e.sliceDoc(i,i+50),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,d=a.length-c;if(a.slice(d-t.length,d)==t&&l.slice(h,h+n.length)==n)return{open:{pos:s-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-s<=100?r=o=e.sliceDoc(s,i):(r=e.sliceDoc(s,s+50),o=e.sliceDoc(i-50,i));let u=/^\s*/.exec(r)[0].length,p=/\s*$/.exec(o)[0].length,f=o.length-p-n.length;return r.slice(u,u+t.length)==t&&o.slice(f,f+n.length)==n?{open:{pos:s+u+t.length,margin:+!!/\s/.test(r.charAt(u+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(o.charAt(f-1))}}:null})(t,s[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:s[t].open+" "},{from:e.to,insert:" "+s[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=s[t],{open:r,close:o}=n;e.push({from:r.pos-i.open.length,to:r.pos+r.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}let l1=tz.define(),l2=tz.define(),l5=tr.define(),l3=tr.define({combine:e=>tI(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}),l4=td.define({create:()=>cl.empty,update(e,t){let n=t.state.facet(l3),s=t.annotation(l1);if(s){let i=ct.fromTransaction(t,s.selection),r=s.side,o=0==r?e.undone:e.done;return o=i?cn(o,o.length,n.minDepth,i):cr(o,t.startState.selection),new cl(0==r?s.rest:o,0==r?o:s.rest)}let i=t.annotation(l2);if(("full"==i||"before"==i)&&(e=e.isolate()),!1===t.annotation(tA.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let r=ct.fromTransaction(t),o=t.annotation(tA.time),a=t.annotation(tA.userEvent);return r?e=e.addChanges(r,o,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,a,n.newGroupDelay)),("full"==i||"after"==i)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new cl(e.done.map(ct.fromJSON),e.undone.map(ct.fromJSON))});function l8(e,t){return function({state:n,dispatch:s}){if(!t&&n.readOnly)return!1;let i=n.field(l4,!1);if(!i)return!1;let r=i.pop(e,n,t);return!!r&&(s(r),!0)}}let l6=l8(0,!1),l9=l8(1,!1),l7=l8(0,!0),ce=l8(1,!0);class ct{constructor(e,t,n,s,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=i}setSelAfter(e){return new ct(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null==(e=this.changes)?void 0:e.toJSON(),mapped:null==(t=this.mapped)?void 0:t.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new ct(e.changes&&e3.fromJSON(e.changes),[],e.mapped&&e5.fromJSON(e.mapped),e.startSelection&&tn.fromJSON(e.startSelection),e.selectionsAfter.map(tn.fromJSON))}static fromTransaction(e,t){let n=ci;for(let t of e.startState.facet(l5)){let s=t(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new ct(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,ci)}static selection(e){return new ct(void 0,ci,void 0,void 0,e)}}function cn(e,t,n,s){let i=e.slice(t+1>n+20?t-n-1:0,t);return i.push(s),i}function cs(e,t){return e.length?t.length?e.concat(t):e:t}let ci=[];function cr(e,t){if(!e.length)return[ct.selection([t])];{let n=e[e.length-1],s=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return s.length&&s[s.length-1].eq(t)?e:(s.push(t),cn(e,e.length-1,1e9,n.setSelAfter(s)))}}function co(e,t){if(!e.length)return e;let n=e.length,s=ci;for(;n;){let i=function(e,t,n){let s=cs(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):ci,n);if(!e.changes)return ct.selection(s);let i=e.changes.map(t),r=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(r):r;return new ct(i,tT.mapEffects(e.effects,t),o,e.startSelection.map(r),s)}(e[n-1],t,s);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,s=i.selectionsAfter}return s.length?[ct.selection(s)]:ci}let ca=/^(input\.type|delete)($|\.)/;class cl{constructor(e,t,n=0,s){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new cl(this.done,this.undone):this}addChanges(e,t,n,s,i){var r,o;let a,l,c=this.done,h=c[c.length-1];return new cl(c=h&&h.changes&&!h.changes.empty&&e.changes&&(!n||ca.test(n))&&(!h.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(i,(r=h.changes,o=e.changes,a=[],l=!1,r.iterChangedRanges((e,t)=>a.push(e,t)),o.iterChangedRanges((e,t,n,s)=>{for(let e=0;e<a.length;){let t=a[e++],i=a[e++];s>=t&&n<=i&&(l=!0)}}),l))||"input.type.compose"==n)?cn(c,c.length-1,s.minDepth,new ct(e.changes.compose(h.changes),cs(tT.mapEffects(e.effects,h.changes),h.effects),h.mapped,h.startSelection,ci)):cn(c,c.length,s.minDepth,e),ci,t,n)}addSelection(e,t,n,s){var i;let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ci;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(i=r[r.length-1],i.ranges.length==e.ranges.length&&0===i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length)?this:new cl(cr(this.done,e),this.undone,t,n)}addMapping(e){return new cl(co(this.done,e),co(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let s=0==e?this.done:this.undone;if(0==s.length)return null;let i=s[s.length-1],r=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length){let n,o;return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:l1.of({side:e,rest:(n=s[s.length-1],(o=s.slice())[s.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:r}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!i.changes)return null;let n=1==s.length?ci:s.slice(0,s.length-1);return i.mapped&&(n=co(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:l1.of({side:e,rest:n,selection:r}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}cl.empty=new cl(ci,ci);function cc(e,t){return tn.create(e.ranges.map(t),e.mainIndex)}function ch(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function cd({state:e,dispatch:t},n){let s=cc(e.selection,n);return!s.eq(e.selection,!0)&&(t(ch(e,s)),!0)}function cu(e,t){return tn.cursor(t?e.to:e.from)}function cp(e,t){return cd(e,n=>n.empty?e.moveByChar(n,t):cu(n,t))}function cf(e){return e.textDirectionAt(e.state.selection.main.head)==n0.LTR}let cm=e=>cp(e,!cf(e)),cg=e=>cp(e,cf(e));function cx(e,t){return cd(e,n=>n.empty?e.moveByGroup(n,t):cu(n,t))}function cb(e,t,n){let s,i,r=aW(e).resolveInner(t.head),o=n?oG.closedBy:oG.openedBy;for(let s=t.head;;){let t=n?r.childAfter(s):r.childBefore(s);if(!t)break;!function(e,t,n){if(t.type.prop(n))return!0;let s=t.to-t.from;return s&&(s>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,o)?s=n?t.to:t.from:r=t}return i=r.type.prop(o)&&(s=n?lB(e,r.from,1):lB(e,r.to,-1))&&s.matched?n?s.end.to:s.end.from:n?r.to:r.from,tn.cursor(i,n?-1:1)}function cv(e,t){return cd(e,n=>{if(!n.empty)return cu(n,t);let s=e.moveVertically(n,t);return s.head!=n.head?s:e.moveToLineBoundary(n,t)})}"u">typeof Intl&&Intl.Segmenter;let cy=e=>cv(e,!1),cw=e=>cv(e,!0);function cO(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,s=0,i;if(t){for(let t of e.state.facet(ry.scrollMargins)){let i=t(e);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(s=Math.max(null==i?void 0:i.bottom,s))}i=e.scrollDOM.clientHeight-n-s}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:s,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function ck(e,t){let n,s=cO(e),{state:i}=e,r=cc(i.selection,n=>n.empty?e.moveVertically(n,t,s.height):cu(n,t));if(r.eq(i.selection))return!1;if(s.selfScroll){let t=e.coordsAtPos(i.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),a=o.top+s.marginTop,l=o.bottom-s.marginBottom;t&&t.top>a&&t.bottom<l&&(n=ry.scrollIntoView(r.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(ch(i,r),{effects:n}),!0}let cj=e=>ck(e,!1),cN=e=>ck(e,!0);function cS(e,t,n){let s=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?s.to:s.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==s.from&&s.length){let n=/^\s*/.exec(e.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;n&&t.head!=s.from+n&&(i=tn.cursor(s.from+n))}return i}function cz(e,t){let n=cc(e.state.selection,e=>{let n=t(e);return tn.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return!n.eq(e.state.selection)&&(e.dispatch(ch(e.state,n)),!0)}function cC(e,t){return cz(e,n=>e.moveByChar(n,t))}let c_=e=>cC(e,!cf(e)),cT=e=>cC(e,cf(e));function cA(e,t){return cz(e,n=>e.moveByGroup(n,t))}function cM(e,t){return cz(e,n=>e.moveVertically(n,t))}let cP=e=>cM(e,!1),cE=e=>cM(e,!0);function cR(e,t){return cz(e,n=>e.moveVertically(n,t,cO(e).height))}let cD=e=>cR(e,!1),c$=e=>cR(e,!0),cQ=({state:e,dispatch:t})=>(t(ch(e,{anchor:0})),!0),cI=({state:e,dispatch:t})=>(t(ch(e,{anchor:e.doc.length})),!0),cL=({state:e,dispatch:t})=>(t(ch(e,{anchor:e.selection.main.anchor,head:0})),!0),cq=({state:e,dispatch:t})=>(t(ch(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function cB(e,t){let{state:n}=e,s=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let r=n.doc.lineAt(s.head);if(t?r.to<e.state.doc.length:r.from>0)for(let n=s;;){let s=e.moveVertically(n,t);if(s.head<r.from||s.head>r.to){i.some(e=>e.head==s.head)||i.push(s);break}if(s.head==n.head)break;n=s}}return i.length!=s.ranges.length&&(e.dispatch(ch(n,tn.create(i,i.length-1))),!0)}function cW(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:s}=e,i=s.changeByRange(s=>{let{from:i,to:r}=s;if(i==r){let o=t(s);o<i?(n="delete.backward",o=cV(e,o,!1)):o>i&&(n="delete.forward",o=cV(e,o,!0)),i=Math.min(i,o),r=Math.max(r,o)}else i=cV(e,i,!1),r=cV(e,r,!0);return i==r?{range:s}:{changes:{from:i,to:r},range:tn.cursor(i,i<s.head?-1:1)}});return!i.changes.empty&&(e.dispatch(s.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?ry.announce.of(s.phrase("Selection deleted")):void 0})),!0)}function cV(e,t,n){if(e instanceof ry)for(let s of e.state.facet(ry.atomicRanges).map(t=>t(e)))s.between(t,t,(e,s)=>{e<t&&s>t&&(t=n?s:e)});return t}let cF=(e,t,n)=>cW(e,s=>{let i=s.from,{state:r}=e,o=r.doc.lineAt(i),a,l;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,i-o.from))){if(" "==a[a.length-1])return i-1;let e=t5(a,r.tabSize)%a2(r)||a2(r);for(let t=0;t<e&&" "==a[a.length-1-t];t++)i--;l=i}else(l=eY(o.text,i-o.from,t,t)+o.from)==i&&o.number!=(t?r.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,i-o.from))&&(l=eY(o.text,l-o.from,!1,!1)+o.from);return l}),cH=e=>cF(e,!1,!0),cX=e=>cF(e,!0,!1),cU=(e,t)=>cW(e,n=>{let s=n.head,{state:i}=e,r=i.doc.lineAt(s),o=i.charCategorizer(s);for(let e=null;;){if(s==(t?r.to:r.from)){s==n.head&&r.number!=(t?i.doc.lines:1)&&(s+=t?1:-1);break}let a=eY(r.text,s-r.from,t)+r.from,l=r.text.slice(Math.min(s,a)-r.from,Math.max(s,a)-r.from),c=o(l);if(null!=e&&c!=e)break;(" "!=l||s!=n.head)&&(e=c),s=a}return s}),cG=e=>cU(e,!1);function cZ(e){let t=[],n=-1;for(let s of e.selection.ranges){let i=e.doc.lineAt(s.from),r=e.doc.lineAt(s.to);if(s.empty||s.to!=r.from||(r=e.doc.lineAt(s.to-1)),n>=i.number){let e=t[t.length-1];e.to=r.to,e.ranges.push(s)}else t.push({from:i.from,to:r.to,ranges:[s]});n=r.number+1}return t}function cY(e,t,n){if(e.readOnly)return!1;let s=[],i=[];for(let t of cZ(e)){if(n?t.to==e.doc.length:0==t.from)continue;let r=e.doc.lineAt(n?t.to+1:t.from-1),o=r.length+1;if(n)for(let n of(s.push({from:t.to,to:r.to},{from:t.from,insert:r.text+e.lineBreak}),t.ranges))i.push(tn.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)));else for(let n of(s.push({from:r.from,to:t.from},{from:t.to,insert:e.lineBreak+r.text}),t.ranges))i.push(tn.range(n.anchor-o,n.head-o))}return!!s.length&&(t(e.update({changes:s,scrollIntoView:!0,selection:tn.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function cK(e,t,n){if(e.readOnly)return!1;let s=[];for(let t of cZ(e))n?s.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):s.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(s);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}let cJ=c1(!1),c0=c1(!0);function c1(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=t.changeByRange(n=>{let{from:s,to:i}=n,r=t.doc.lineAt(s),o=!e&&s==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=aW(e).resolveInner(t),s=n.childBefore(t),i=n.childAfter(t),r;return s&&i&&s.to<=t&&i.from>=t&&(r=s.type.prop(oG.closedBy))&&r.indexOf(i.name)>-1&&e.doc.lineAt(s.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(s.to,i.from))?{from:s.to,to:i.from}:null}(t,s);e&&(s=i=(i<=r.to?r:t.doc.lineAt(i)).to);let a=new a4(t,{simulateBreak:s,simulateDoubleBreak:!!o}),l=a3(a,s);for(null==l&&(l=t5(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));i<r.to&&/\s/.test(r.text[i-r.from]);)i++;o?{from:s,to:i}=o:s>r.from&&s<r.from+100&&!/\S/.test(r.text.slice(0,s))&&(s=r.from);let c=["",a5(t,l)];return o&&c.push(a5(t,a.lineIndent(r.from,-1))),{changes:{from:s,to:i,insert:eB.of(c)},range:tn.cursor(s+1+c[1].length)}});return n(t.update(s,{scrollIntoView:!0,userEvent:"input"})),!0}}function c2(e,t){let n=-1;return e.changeByRange(s=>{let i=[];for(let r=s.from;r<=s.to;){let o=e.doc.lineAt(r);o.number>n&&(s.empty||s.to>o.from)&&(t(o,i,s),n=o.number),r=o.to+1}let r=e.changes(i);return{changes:i,range:tn.range(r.mapPos(s.anchor,1),r.mapPos(s.head,1))}})}let c5=[{key:"Ctrl-b",run:cm,shift:c_,preventDefault:!0},{key:"Ctrl-f",run:cg,shift:cT},{key:"Ctrl-p",run:cy,shift:cP},{key:"Ctrl-n",run:cw,shift:cE},{key:"Ctrl-a",run:e=>cd(e,t=>tn.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>cz(e,t=>tn.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>cd(e,t=>tn.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>cz(e,t=>tn.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:cX},{key:"Ctrl-h",run:cH},{key:"Ctrl-k",run:e=>cW(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:cG},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:eB.of(["",""])},range:tn.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,s=e.doc.lineAt(n),i=n==s.from?n-1:eY(s.text,n-s.from,!1)+s.from,r=n==s.to?n+1:eY(s.text,n-s.from,!0)+s.from;return{changes:{from:i,to:r,insert:e.doc.slice(n,r).append(e.doc.slice(i,n))},range:tn.cursor(r)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:cN}],c3=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>cd(e,t=>cb(e.state,t,!cf(e))),shift:e=>cz(e,t=>cb(e.state,t,!cf(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>cd(e,t=>cb(e.state,t,cf(e))),shift:e=>cz(e,t=>cb(e.state,t,cf(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>cY(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>cK(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>cY(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>cK(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>cB(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>cB(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,s=null;return n.ranges.length>1?s=tn.create([n.main]):n.main.empty||(s=tn.create([tn.cursor(n.main.head)])),!!s&&(t(ch(e,s)),!0)}},{key:"Mod-Enter",run:c0},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=cZ(e).map(({from:t,to:n})=>tn.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:tn.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=cc(e.selection,t=>{let n=aW(e),s=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=s.node.from&&e.node.to<=s.node.to&&(s=e)}for(let e=s;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return tn.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(ch(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(c2(e,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let i=t5(s,e.tabSize),r=0,o=a5(e,Math.max(0,i-a2(e)));for(;r<s.length&&r<o.length&&s.charCodeAt(r)==o.charCodeAt(r);)r++;n.push({from:t.from+r,to:t.from+s.length,insert:o.slice(r)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(c2(e,(t,n)=>{n.push({from:t.from,insert:e.facet(a1)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),s=new a4(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=c2(e,(t,i,r)=>{let o=a3(s,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let a=/^\s*/.exec(t.text)[0],l=a5(e,o);(a!=l||r.from<t.from+a.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+a.length,insert:l}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(cZ(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),s=cc(t.selection,t=>{let n;if(e.lineWrapping){let s=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=s.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>{let n,s;return n=!1,s=cc(e.selection,t=>{let s=lB(e,t.head,-1)||lB(e,t.head,1)||t.head>0&&lB(e,t.head-1,1)||t.head<e.doc.length&&lB(e,t.head+1,-1);if(!s||!s.end)return t;n=!0;let i=s.start.from==t.head?s.end.to:s.end.from;return tn.cursor(i)}),!!n&&(t(ch(e,s)),!0)}},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),s=lJ(e.state,n.from);return s.line?lZ(e):!!s.block&&lK(e)}},{key:"Alt-A",run:lY},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:cm,shift:c_,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>cx(e,!cf(e)),shift:e=>cA(e,!cf(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>cd(e,t=>cS(e,t,!cf(e))),shift:e=>cz(e,t=>cS(e,t,!cf(e))),preventDefault:!0},{key:"ArrowRight",run:cg,shift:cT,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>cx(e,cf(e)),shift:e=>cA(e,cf(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>cd(e,t=>cS(e,t,cf(e))),shift:e=>cz(e,t=>cS(e,t,cf(e))),preventDefault:!0},{key:"ArrowUp",run:cy,shift:cP,preventDefault:!0},{mac:"Cmd-ArrowUp",run:cQ,shift:cL},{mac:"Ctrl-ArrowUp",run:cj,shift:cD},{key:"ArrowDown",run:cw,shift:cE,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cI,shift:cq},{mac:"Ctrl-ArrowDown",run:cN,shift:c$},{key:"PageUp",run:cj,shift:cD},{key:"PageDown",run:cN,shift:c$},{key:"Home",run:e=>cd(e,t=>cS(e,t,!1)),shift:e=>cz(e,t=>cS(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:cQ,shift:cL},{key:"End",run:e=>cd(e,t=>cS(e,t,!0)),shift:e=>cz(e,t=>cS(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:cI,shift:cq},{key:"Enter",run:cJ,shift:cJ},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:cH,shift:cH,preventDefault:!0},{key:"Delete",run:cX,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:cG,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>cU(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>cW(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>cW(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(c5.map(e=>({mac:e.key,run:e.run,shift:e.shift})))),c4="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class c8{constructor(e,t,n=0,s=e.length,i,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=i?e=>i(c4(e)):c4,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return eK(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=eJ(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=e0(e);let s=this.normalize(t);if(s.length)for(let e=0,i=n;;e++){let r=s.charCodeAt(e),o=this.match(r,i,this.bufferPos+this.bufferStart);if(e==s.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==r&&i++}}}match(e,t,n){let s=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],r=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?s={from:this.matches[t+1],to:n}:(this.matches[t]++,r=!0)),r||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?s={from:t,to:n}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}"u">typeof Symbol&&(c8.prototype[Symbol.iterator]=function(){return this});let c6={from:-1,to:-1,match:/.*/.exec("")},c9="gm"+(null==/x/.unicode?"":"u");class c7{constructor(e,t,n,s=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=c6,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hn(e,t,n,s,i);this.re=new RegExp(t,c9+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let r=e.lineAt(s);this.curLineStart=r.from,this.matchPos=hs(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=hs(this.text,s+ +(n==s)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}let he=new WeakMap;class ht{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=he.get(e);if(!s||s.from>=n||s.to<=t){let s=new ht(t,e.sliceString(t,n));return he.set(e,s),s}if(s.from==t&&s.to==n)return s;let{text:i,from:r}=s;return r>t&&(i=e.sliceString(t,r)+i,r=t),s.to<n&&(i+=e.sliceString(s.to,n)),he.set(e,new ht(r,i)),new ht(t,i.slice(t-r,n-r))}}class hn{constructor(e,t,n,s,i){this.text=e,this.to=i,this.done=!1,this.value=c6,this.matchPos=hs(e,s),this.re=new RegExp(t,c9+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=ht.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=hs(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ht.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function hs(e,t){if(t>=e.length)return t;let n=e.lineAt(t),s;for(;t<n.to&&(s=n.text.charCodeAt(t-n.from))>=56320&&s<57344;)t++;return t}"u">typeof Symbol&&(c7.prototype[Symbol.iterator]=hn.prototype[Symbol.iterator]=function(){return this});let hi={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},hr=tr.define({combine:e=>tI(e,hi,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),ho=nS.mark({class:"cm-selectionMatch"}),ha=nS.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function hl(e,t,n,s){return(0==n||e(t.sliceDoc(n-1,n))!=tD.Word)&&(s==t.doc.length||e(t.sliceDoc(s,s+1))!=tD.Word)}let hc=sk.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(hr),{state:n}=e,s=n.selection;if(s.ranges.length>1)return nS.none;let i=s.main,r,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return nS.none;let e=n.wordAt(i.head);if(!e)return nS.none;o=n.charCategorizer(i.head),r=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return nS.none;if(t.wholeWords){var a,l,c;if(r=n.sliceDoc(i.from,i.to),!(hl(o=n.charCategorizer(i.head),n,i.from,i.to)&&(a=o,l=i.from,c=i.to,a(n.sliceDoc(l,l+1))==tD.Word&&a(n.sliceDoc(c-1,c))==tD.Word)))return nS.none}else if(!(r=n.sliceDoc(i.from,i.to)))return nS.none}let h=[];for(let s of e.visibleRanges){let e=new c8(n.doc,r,s.from,s.to);for(;!e.next().done;){let{from:s,to:r}=e.value;if((!o||hl(o,n,s,r))&&(i.empty&&s<=i.from&&r>=i.to?h.push(ha.range(s,r)):(s>=i.to||r<=i.from)&&h.push(ho.range(s,r)),h.length>t.maxMatches))return nS.none}}return nS.set(h)}},{decorations:e=>e.decorations}),hh=ry.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),hd=tr.define({combine:e=>tI(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new hL(e),scrollToMatch:e=>ry.scrollIntoView(e)})});class hu{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,c9),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new hv(this):new hm(this)}getCursor(e,t=0,n){let s=e.doc?e:tQ.create({doc:e});return null==n&&(n=s.doc.length),this.regexp?hg(this,s,t,n):hf(this,s,t,n)}}class hp{constructor(e){this.spec=e}}function hf(e,t,n,s){var i,r,o,a;let l;return e.wholeWord&&(o=t.doc,a=t.charCategorizer(t.selection.main.head),l=(e,t,n,s)=>((s>e||s+n.length<t)&&(s=Math.max(0,e-2),n=o.sliceString(s,Math.min(o.length,t+2))),(a(hx(n,e-s))!=tD.Word||a(hb(n,e-s))!=tD.Word)&&(a(hb(n,t-s))!=tD.Word||a(hx(n,t-s))!=tD.Word))),e.test&&(i=e.test,r=l,l=(e,n,s,o)=>(!r||!!r(e,n,s,o))&&i(e>=o&&n<=o+s.length?s.slice(e-o,n-o):t.doc.sliceString(e,n),t,e,n)),new c8(t.doc,e.unquoted,n,s,e.caseSensitive?void 0:e=>e.toLowerCase(),l)}class hm extends hp{constructor(e){super(e)}nextMatch(e,t,n){let s=hf(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);s=hf(this.spec,e,0,n).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==n?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let n=Math.max(t,s-1e4-this.spec.unquoted.length),i=hf(this.spec,e,n,s),r=null;for(;!i.nextOverlapping().done;)r=i.value;if(r)return r;if(n==t)return null;s-=1e4}}prevMatch(e,t,n){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=hf(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let i=hf(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)s(i.value.from,i.value.to)}}function hg(e,t,n,s){var i,r,o;let a;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),a=(e,t,n)=>!n[0].length||(o(hx(n.input,n.index))!=tD.Word||o(hb(n.input,n.index))!=tD.Word)&&(o(hb(n.input,n.index+n[0].length))!=tD.Word||o(hx(n.input,n.index+n[0].length))!=tD.Word)),e.test&&(i=e.test,r=a,a=(e,n,s)=>(!r||r(e,n,s))&&i(s[0],t,e,n)),new c7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:a},n,s)}function hx(e,t){return e.slice(eY(e,t,!1),t)}function hb(e,t){return e.slice(t,eY(e,t))}class hv extends hp{nextMatch(e,t,n){let s=hg(this.spec,e,n,e.doc.length).next();return s.done&&(s=hg(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let i=Math.max(t,n-1e4*s),r=hg(this.spec,e,i,n),o=null;for(;!r.next().done;)o=r.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let s=+n.slice(0,t);if(s>0&&s<e.match.length)return e.match[s]+n.slice(t)}return t})}matchAll(e,t){let n=hg(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let i=hg(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)s(i.value.from,i.value.to)}}let hy=tT.define(),hw=tT.define(),hO=td.define({create:e=>new hk(hE(e).create(),null),update(e,t){for(let n of t.effects)n.is(hy)?e=new hk(n.value.create(),e.panel):n.is(hw)&&(e=new hk(e.query,n.value?hP:null));return e},provide:e=>ow.from(e,e=>e.panel)});class hk{constructor(e,t){this.query=e,this.panel=t}}let hj=nS.mark({class:"cm-searchMatch"}),hN=nS.mark({class:"cm-searchMatch cm-searchMatch-selected"}),hS=sk.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(hO))}update(e){let t=e.state.field(hO);(t!=e.startState.field(hO)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return nS.none;let{view:n}=this,s=new tH;for(let t=0,i=n.visibleRanges,r=i.length;t<r;t++){let{from:o,to:a}=i[t];for(;t<r-1&&a>i[t+1].from-500;)a=i[++t].to;e.highlight(n.state,o,a,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);s.add(e,t,i?hN:hj)})}return s.finish()}},{decorations:e=>e.decorations});function hz(e){return t=>{let n=t.state.field(hO,!1);return n&&n.query.spec.valid?e(t,n):h$(t)}}let hC=hz((e,{query:t})=>{let{to:n}=e.state.selection.main,s=t.nextMatch(e.state,n,n);if(!s)return!1;let i=tn.single(s.from,s.to),r=e.state.facet(hd);return e.dispatch({selection:i,effects:[hW(e,s),r.scrollToMatch(i.main,e)],userEvent:"select.search"}),hD(e),!0}),h_=hz((e,{query:t})=>{let{state:n}=e,{from:s}=n.selection.main,i=t.prevMatch(n,s,s);if(!i)return!1;let r=tn.single(i.from,i.to),o=e.state.facet(hd);return e.dispatch({selection:r,effects:[hW(e,i),o.scrollToMatch(r.main,e)],userEvent:"select.search"}),hD(e),!0}),hT=hz((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!!n&&!!n.length&&(e.dispatch({selection:tn.create(n.map(e=>tn.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),hA=hz((e,{query:t})=>{let{state:n}=e,{from:s,to:i}=n.selection.main;if(n.readOnly)return!1;let r=t.nextMatch(n,s,s);if(!r)return!1;let o=r,a=[],l,c,h=[];o.from==s&&o.to==i&&(c=n.toText(t.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),o=t.nextMatch(n,o.from,o.to),h.push(ry.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(s).number)+".")));let d=e.state.changes(a);return o&&(l=tn.single(o.from,o.to).map(d),h.push(hW(e,o)),h.push(n.facet(hd).scrollToMatch(l.main,e))),e.dispatch({changes:d,selection:l,effects:h,userEvent:"input.replace"}),!0}),hM=hz((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:s}=e;return{from:n,to:s,insert:t.getReplacement(e)}});if(!n.length)return!1;let s=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:ry.announce.of(s),userEvent:"input.replace.all"}),!0});function hP(e){return e.state.facet(hd).createPanel(e)}function hE(e,t){var n,s,i,r,o;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(hd);return new hu({search:(null!=(n=null==t?void 0:t.literal)?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!=(s=null==t?void 0:t.caseSensitive)?s:c.caseSensitive,literal:null!=(i=null==t?void 0:t.literal)?i:c.literal,regexp:null!=(r=null==t?void 0:t.regexp)?r:c.regexp,wholeWord:null!=(o=null==t?void 0:t.wholeWord)?o:c.wholeWord})}function hR(e){let t=ox(e,hP);return t&&t.dom.querySelector("[main-field]")}function hD(e){let t=hR(e);t&&t==e.root.activeElement&&t.select()}let h$=e=>{let t=e.state.field(hO,!1);if(t&&t.panel){let n=hR(e);if(n&&n!=e.root.activeElement){let s=hE(e.state,t.query.spec);s.valid&&e.dispatch({effects:hy.of(s)}),n.focus(),n.select()}}else e.dispatch({effects:[hw.of(!0),t?hy.of(hE(e.state,t.query.spec)):tT.appendConfig.of(hF)]});return!0},hQ=e=>{let t=e.state.field(hO,!1);if(!t||!t.panel)return!1;let n=ox(e,hP);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:hw.of(!1)}),!0},hI=[{key:"Mod-f",run:h$,scope:"editor search-panel"},{key:"F3",run:hC,shift:h_,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:hC,shift:h_,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hQ,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:s,to:i}=n.main,r=[],o=0;for(let t=new c8(e.doc,e.sliceDoc(s,i));!t.next().done;){if(r.length>1e3)return!1;t.value.from==s&&(o=r.length),r.push(tn.range(t.value.from,t.value.to))}return t(e.update({selection:tn.create(r,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{var t;let n,s,i,r,{state:o}=e,a=String(o.doc.lineAt(e.state.selection.main.head).number),{close:l,result:c}=(t={label:o.phrase("Go to line"),input:{type:"text",name:"line",value:a},focus:!0,submitLabel:o.phrase("go")},s=new Promise(e=>n=e),i=e=>(function(e,t,n){let s=t.content?t.content(e,()=>o(null)):null;if(!s){if(s=na("form"),t.input){let e=na("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),s.appendChild(na("label",(t.label||"")+": ",e))}else s.appendChild(document.createTextNode(t.label||""));s.appendChild(document.createTextNode(" ")),s.appendChild(na("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i="FORM"==s.nodeName?[s]:s.querySelectorAll("form");for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),o(null)):13==e.keyCode&&(e.preventDefault(),o(t))}),t.addEventListener("submit",e=>{e.preventDefault(),o(t)})}let r=na("div",s,na("button",{onclick:()=>o(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));function o(t){r.contains(r.ownerDocument.activeElement)&&e.focus(),n(t)}return t.class&&(r.className=t.class),r.classList.add("cm-dialog"),{dom:r,top:t.top,mount:()=>{if(t.focus){let e;(e="string"==typeof t.focus?s.querySelector(t.focus):s.querySelector("input")||s.querySelector("button"))&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}})(e,t,n),e.state.field(oO,!1)?e.dispatch({effects:ok.of(i)}):e.dispatch({effects:tT.appendConfig.of(oO.init(()=>[i]))}),{close:r=oj.of(i),result:s.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(oO).indexOf(i)>-1&&e.dispatch({effects:r})}),t))});return c.then(t=>{let n=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!n)return void e.dispatch({effects:l});let s=o.doc.lineAt(o.selection.main.head),[,i,r,a,c]=n,h=a?+a.slice(1):0,d=r?+r:s.number;if(r&&c){let e=d/100;i&&(e=e*("-"==i?-1:1)+s.number/o.doc.lines),d=Math.round(o.doc.lines*e)}else r&&i&&(d=d*("-"==i?-1:1)+s.number);let u=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),p=tn.cursor(u.from+Math.max(0,Math.min(h,u.length)));e.dispatch({effects:[l,ry.scrollIntoView(p.from,{y:"center"})],selection:p})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,s=tn.create(n.ranges.map(t=>e.wordAt(t.head)||tn.cursor(t.head)),n.mainIndex);return!s.eq(n)&&(t(e.update({selection:s})),!0)})({state:e,dispatch:t});let s=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=s))return!1;let i=function(e,t){let{main:n,ranges:s}=e.selection,i=e.wordAt(n.head),r=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new c8(e.doc,t,s[s.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new c8(e.doc,t,0,Math.max(0,s[s.length-1].from-1)),n=!0}else{if(n&&s.some(e=>e.from==i.value.from))continue;if(r){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}(e,s);return!!i&&(t(e.update({selection:e.selection.addRange(tn.range(i.from,i.to),!1),effects:ry.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class hL{constructor(e){this.view=e;let t=this.query=e.state.field(hO).query.spec;function n(e,t,n){return na("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=na("input",{value:t.search,placeholder:hq(e,"Find"),"aria-label":hq(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=na("input",{value:t.replace,placeholder:hq(e,"Replace"),"aria-label":hq(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=na("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=na("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=na("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=na("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>hC(e),[hq(e,"next")]),n("prev",()=>h_(e),[hq(e,"previous")]),n("select",()=>hT(e),[hq(e,"all")]),na("label",null,[this.caseField,hq(e,"match case")]),na("label",null,[this.reField,hq(e,"regexp")]),na("label",null,[this.wordField,hq(e,"by word")]),...e.state.readOnly?[]:[na("br"),this.replaceField,n("replace",()=>hA(e),[hq(e,"replace")]),n("replaceAll",()=>hM(e),[hq(e,"replace all")])],na("button",{name:"close",onclick:()=>hQ(e),"aria-label":hq(e,"close"),type:"button"},["×"])])}commit(){let e=new hu({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:hy.of(e)}))}keydown(e){var t;(t=this.view,rP(rT(t.state),e,t,"search-panel"))?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?h_:hC)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),hA(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(hy)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(hd).top}}function hq(e,t){return e.state.phrase(t)}let hB=/[\s\.,:;?!]/;function hW(e,{from:t,to:n}){let s=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,r=Math.max(s.from,t-30),o=Math.min(i,n+30),a=e.state.sliceDoc(r,o);if(r!=s.from){for(let e=0;e<30;e++)if(!hB.test(a[e+1])&&hB.test(a[e])){a=a.slice(e);break}}if(o!=i){for(let e=a.length-1;e>a.length-30;e--)if(!hB.test(a[e-1])&&hB.test(a[e])){a=a.slice(0,e);break}}return ry.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${s.number}.`)}let hV=ry.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),hF=[hO,tp.low(hS),hV];class hH{constructor(e,t,n,s){this.state=e,this.pos=t,this.explicit=n,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=aW(this.state).resolveInner(this.pos,-1);for(;t&&0>e.indexOf(t.name);)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),i=s.search(hZ(e,!1));return i<0?null:{from:n+i,to:this.pos,text:s.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function hX(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}class hU{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function hG(e){return e.selection.main.from}function hZ(e,t){var n;let{source:s}=e,i=t&&"^"!=s[0],r="$"!=s[s.length-1];return i||r?RegExp(`${i?"^":""}(?:${s})${r?"$":""}`,null!=(n=e.flags)?n:e.ignoreCase?"i":""):e}let hY=tz.define(),hK=new WeakMap;function hJ(e){if(!Array.isArray(e))return e;let t=hK.get(e);return t||hK.set(e,t=function(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,s]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:s}of e){t[s[0]]=!0;for(let e=1;e<s.length;e++)n[s[e]]=!0}let s=hX(t)+hX(n)+"*$";return[RegExp("^"+s),new RegExp(s)]}(t);return e=>{let i=e.matchBefore(s);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}(e)),t}let h0=tT.define(),h1=tT.define();class h2{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=eK(e,t),s=e0(n);this.chars.push(n);let i=e.slice(t,t+s),r=i.toUpperCase();this.folded.push(eK(r==i?i.toLowerCase():r,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:s,precise:i,byWord:r}=this;if(1==t.length){let s=eK(e,0),i=e0(s),r=i==e.length?0:-100;if(s==t[0]);else{if(s!=n[0])return null;r+=-200}return this.ret(r,[0,i])}let o=e.indexOf(this.pattern);if(0==o)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(o<0){for(let i=0,r=Math.min(e.length,200);i<r&&l<a;){let r=eK(e,i);(r==t[l]||r==n[l])&&(s[l++]=i),i+=e0(r)}if(l<a)return null}let c=0,h=0,d=!1,u=0,p=-1,f=-1,m=/[a-z]/.test(e),g=!0;for(let s=0,l=Math.min(e.length,200),x=0;s<l&&h<a;){let l=eK(e,s);o<0&&(c<a&&l==t[c]&&(i[c++]=s),u<a&&(l==t[u]||l==n[u]?(0==u&&(p=s),f=s+1,u++):u=0));let b,v=l<255?l>=48&&l<=57||l>=97&&l<=122?2:+(l>=65&&l<=90):(b=eJ(l))!=b.toLowerCase()?1:2*(b!=b.toUpperCase());(!s||1==v&&m||0==x&&0!=v)&&(t[h]==l||n[h]==l&&(d=!0)?r[h++]=s:r.length&&(g=!1)),x=v,s+=e0(l)}return h==a&&0==r[0]&&g?this.result(-100+(d?-200:0),r,e):u==a&&0==p?this.ret(-200-e.length+(f==e.length?0:-100),[0,f]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):u==a?this.ret(-900-e.length,[p,f]):h==a?this.result(-100+(d?-200:0)+-700+(g?0:-1100),r,e):2==t.length?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],i=0;for(let e of t){let t=e+(this.astral?e0(eK(n,e)):1);i&&s[i-1]==e?s[i-1]=t:(s[i++]=e,s[i++]=t)}return this.ret(e-n.length,s)}}class h5{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}let h3=tr.define({combine:e=>tI(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:h8,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>h4(e(n),t(n)),optionClass:(e,t)=>n=>h4(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function h4(e,t){return e?t?e+" "+t:e:t}function h8(e,t,n,s,i,r){let o=e.textDirection==n0.RTL,a=o,l=!1,c="top",h,d,u=t.left-i.left,p=i.right-t.right,f=s.right-s.left,m=s.bottom-s.top;if(a&&u<Math.min(f,p)?a=!1:!a&&p<Math.min(f,u)&&(a=!0),f<=(a?u:p))h=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,d=Math.min(400,a?u:p);else{l=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=m||e>t.top?h=n.bottom-t.top:(c="bottom",h=t.bottom-n.top)}let g=(t.bottom-t.top)/r.offsetHeight,x=(t.right-t.left)/r.offsetWidth;return{style:`${c}: ${h/g}px; max-width: ${d/x}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}let h6=tT.define();function h9(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let s=Math.floor((e-t)/n);return{from:e-(s+1)*n,to:e-s*n}}class h7{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:i,selected:r}=s.open,o=e.state.facet(h3);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,s){let i=document.createElement("span");i.className="cm-completionLabel";let r=e.displayLabel||e.label,o=0;for(let e=0;e<s.length;){let t=s[e++],n=s[e++];t>o&&i.appendChild(document.createTextNode(r.slice(o,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(r.slice(t,n))),a.className="cm-completionMatchedText",o=n}return o<r.length&&i.appendChild(document.createTextNode(r.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=h9(i.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:s}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if("LI"==t.nodeName&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<s.length){this.applyCompletion(e,s[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains("cm-completionListIncompleteTop")&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=t&&(e.dispatch({effects:h6.of(t)}),n.preventDefault())}}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(h3).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:h1.of(null)})}),this.showOptions(i,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:i,selected:r,disabled:o}=n.open;s.open&&s.open.options==i||(this.range=h9(i.length,r,e.state.facet(h3).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),o!=(null==(t=s.open)?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=h9(t.options.length,t.selected,this.view.state.facet(h3).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:i}=s;if(!i)return;let r="string"==typeof i?document.createTextNode(i):i(s);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,s)}).catch(e=>sv(this.view.state,e,"completion info")):(this.addInfoPane(r,s),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:s}=e;n.appendChild(t),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){var t,n;let s,i,r,o=null;for(let t=this.list.firstChild,n=this.range.from;t;t=t.nextSibling,n++)"LI"==t.nodeName&&t.id?n==e?t.hasAttribute("aria-selected")||(t.setAttribute("aria-selected","true"),o=t):t.hasAttribute("aria-selected")&&(t.removeAttribute("aria-selected"),t.removeAttribute("aria-describedby")):n--;return o&&(t=this.list,n=o,s=t.getBoundingClientRect(),i=n.getBoundingClientRect(),r=s.height/t.offsetHeight,i.top<s.top?t.scrollTop-=(s.top-i.top)/r:i.bottom>s.bottom&&(t.scrollTop+=(i.bottom-s.bottom)/r)),o}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return s.top>Math.min(i.bottom,t.bottom)-10||s.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(h3).positionInfo(this.view,t,s,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){let s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",e=>{e.target==s&&e.preventDefault()});let i=null;for(let r=n.from;r<n.to;r++){let{completion:o,match:a}=e[r],{section:l}=o;if(l){let e="string"==typeof l?l:l.name;e!=i&&(r>n.from||0==n.from)&&(i=e,"string"!=typeof l&&l.header?s.appendChild(l.header(l)):s.appendChild(document.createElement("completion-section")).textContent=e)}let c=s.appendChild(document.createElement("li"));c.id=t+"-"+r,c.setAttribute("role","option");let h=this.optionClass(o);for(let e of(h&&(c.className=h),this.optionContent)){let t=e(o,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function de(e){return 100*(e.boost||0)+10*!!e.apply+5*!!e.info+ +!!e.type}class dt{constructor(e,t,n,s,i,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=i,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new dt(this.options,dr(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,i,r){if(s&&!r&&e.some(e=>e.isPending))return s.setDisabled();let o=function(e,t){let n=[],s=null,i=null,r=e=>{n.push(e);let{section:t}=e.completion;if(t){s||(s=[]);let e="string"==typeof t?t:t.name;s.some(t=>t.name==e)||s.push("string"==typeof t?{name:e}:t)}},o=t.facet(h3);for(let s of e)if(s.hasResult()){let e=s.result.getMatch;if(!1===s.result.filter)for(let t of s.result.options)r(new hU(t,s.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(s.from,s.to),a,l=o.filterStrict?new h5(n):new h2(n);for(let t of s.result.options)if(a=l.match(t.label)){let n=t.displayLabel?e?e(t,a.matched):[]:a.matched,o=a.score+(t.boost||0);if(r(new hU(t,s.source,n,o)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;i||(i=Object.create(null)),i[e]=Math.max(o,i[e]||-1e9)}}}}if(s){let e=Object.create(null),t=0;for(let n of s.sort((e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?i[t.name]-i[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1)))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;l&&l.label==t.label&&l.detail==t.detail&&(null==l.type||null==t.type||l.type==t.type)&&l.apply==t.apply&&l.boost==t.boost?de(e.completion)>de(l)&&(a[a.length-1]=e):a.push(e),l=e.completion}return a}(e,t);if(!o.length)return s&&e.some(e=>e.isPending)?s.setDisabled():null;let a=t.facet(h3).selectOnOpen?0:-1;if(s&&s.selected!=a&&-1!=s.selected){let e=s.options[s.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){a=t;break}}return new dt(o,dr(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:df,above:i.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new dt(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new dt(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class dn{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new dn(da,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(h3),s=(n.override||t.languageDataAt("autocomplete",hG(t)).map(hJ)).map(t=>(this.active.find(e=>e.source==t)||new dc(t,+!!this.active.some(e=>0!=e.state))).update(e,n));s.length==this.active.length&&s.every((e,t)=>e==this.active[t])&&(s=this.active);let i=this.open,r=e.effects.some(e=>e.is(dd));for(let o of(i&&e.docChanged&&(i=i.map(e.changes)),e.selection||s.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,s=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;s<t.length&&!t[s].hasResult();)s++;let i=n==e.length,r=s==t.length;if(i||r)return i==r;if(e[n++].result!=t[s++].result)return!1}}(s,this.active)||r?i=dt.build(s,t,this.id,i,n,r):i&&i.disabled&&!s.some(e=>e.isPending)&&(i=null),!i&&s.every(e=>!e.isPending)&&s.some(e=>e.hasResult())&&(s=s.map(e=>e.hasResult()?new dc(e.source,0):e)),e.effects))o.is(h6)&&(i=i&&i.setSelected(o.value,this.id));return s==this.active&&i==this.open?this:new dn(s,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ds:di}}let ds={"aria-autocomplete":"list"},di={};function dr(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}let da=[];function dl(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(hY);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:16*!!e.docChanged}class dc{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=dl(e,t),s=this;for(let t of((8&n||16&n&&this.touches(e))&&(s=new dc(s.source,0)),4&n&&0==s.state&&(s=new dc(this.source,1)),s=s.updateFor(e,n),e.effects))if(t.is(h0))s=new dc(s.source,1,t.value);else if(t.is(h1))s=new dc(s.source,0);else if(t.is(dd))for(let e of t.value)e.source==s.source&&(s=e);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(hG(e.state))}}class dh extends dc{constructor(e,t,n,s,i,r){super(e,3,t),this.limit=n,this.result=s,this.from=i,this.to=r}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let i=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),o=hG(e.state);if(o>r||!s||2&t&&(hG(e.startState)==this.from||o<this.limit))return new dc(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return!function(e,t,n,s){if(!e)return!1;let i=t.sliceDoc(n,s);return"function"==typeof e?e(i,n,s,t):hZ(e,!0).test(i)}(s.validFor,e.state,i,r)?s.update&&(s=s.update(s,i,r,new hH(e.state,o,!1)))?new dh(this.source,this.explicit,a,s,s.from,null!=(n=s.to)?n:hG(e.state)):new dc(this.source,1,this.explicit):new dh(this.source,this.explicit,a,s,i,r)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new dh(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new dc(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}let dd=tT.define({map:(e,t)=>e.map(e=>e.map(t))}),du=td.define({create:()=>dn.start(),update:(e,t)=>e.update(t),provide:e=>[oc.from(e,e=>e.tooltip),ry.contentAttributes.from(e,e=>e.attrs)]});function dp(e,t){let n=t.completion.apply||t.completion.label,s=e.state.field(du).active.find(e=>e.source==t.source);return s instanceof dh&&("string"==typeof n?e.dispatch({...function(e,t,n,s){let{main:i}=e.selection,r=n-i.from,o=s-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=s&&e.sliceDoc(a.from+r,a.from+o)!=e.sliceDoc(n,s))return{range:a};let l=e.toText(t);return{changes:{from:a.from+r,to:s==i.from?a.to:a.from+o,insert:l},range:tn.cursor(a.from+r+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}(e.state,n,s.from,s.to),annotations:hY.of(t.completion)}):n(e,t.completion,s.from,s.to),!0)}let df=e=>new h7(e,du,dp);function dm(e,t="option"){return n=>{let s=n.state.field(du,!1);if(!s||!s.open||s.open.disabled||Date.now()-s.open.timestamp<n.state.facet(h3).interactionDelay)return!1;let i=1,r;"page"==t&&(r=of(n,s.open.tooltip))&&(i=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=s.open.options,a=s.open.selected>-1?s.open.selected+i*(e?1:-1):e?0:o-1;return a<0?a="page"==t?0:o-1:a>=o&&(a="page"==t?o-1:0),n.dispatch({effects:h6.of(a)}),!0}}let dg=e=>!!e.state.field(du,!1)&&(e.dispatch({effects:h0.of(!0)}),!0);class dx{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}let db=sk.fromClass(class{constructor(e){for(let t of(this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0,e.state.field(du).active))t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(du),n=e.state.facet(h3);if(!e.selectionSet&&!e.docChanged&&e.startState.field(du)==t)return;let s=e.transactions.some(e=>{let t=dl(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(s||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){sv(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(h0)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(du);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(h3).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=hG(t),s=new hH(t,n,e.explicit,this.view),i=new dx(e,s);this.running.push(i),Promise.resolve(e.source(s)).then(e=>{i.context.aborted||(i.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:h1.of(null)}),sv(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(h3).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(h3),s=this.view.state.field(du);for(let i=0;i<this.running.length;i++){let r=this.running[i];if(void 0===r.done)continue;if(this.running.splice(i--,1),r.done){let s=hG(r.updates.length?r.updates[0].startState:this.view.state),i=Math.min(s,r.done.from+ +!r.active.explicit),o=new dh(r.active.source,r.active.explicit,i,r.done,r.done.from,null!=(e=r.done.to)?e:s);for(let e of r.updates)o=o.update(e,n);if(o.hasResult()){t.push(o);continue}}let o=s.active.find(e=>e.source==r.active.source);if(o&&o.isPending)if(null==r.done){let e=new dc(r.active.source,0);for(let t of r.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(o)}(t.length||s.open&&s.open.disabled)&&this.view.dispatch({effects:dd.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(du,!1);if(t&&t.tooltip&&this.view.state.facet(h3).closeOnBlur){let n=t.open&&of(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:h1.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:h0.of(!1)}),20),this.composing=0}}}),dv="object"==typeof navigator&&/Win/.test(navigator.platform),dy=tp.highest(ry.domEventHandlers({keydown(e,t){let n=t.state.field(du,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(dv&&e.altKey)||e.metaKey)return!1;let s=n.open.options[n.open.selected],i=n.active.find(e=>e.source==s.source),r=s.completion.commitCharacters||i.result.commitCharacters;return r&&r.indexOf(e.key)>-1&&dp(t,s),!1}})),dw=ry.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),dO=nS.widget({widget:new class extends nj{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),dk=nS.mark({class:"cm-snippetField"});class dj{constructor(e,t){this.ranges=e,this.active=t,this.deco=nS.set(e.map(e=>(e.from==e.to?dO:dk).range(e.from,e.to)),!0)}map(e){let t=[];for(let n of this.ranges){let s=n.map(e);if(!s)return null;t.push(s)}return new dj(t,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}}let dN=tT.define({map:(e,t)=>e&&e.map(t)}),dS=tT.define(),dz=td.define({create:()=>null,update(e,t){for(let n of t.effects){if(n.is(dN))return n.value;if(n.is(dS)&&e)return new dj(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>ry.decorations.from(e,e=>e?e.deco:nS.none)});function dC(e){return({state:t,dispatch:n})=>{var s;let i=t.field(dz,!1);if(!i||e<0&&0==i.active)return!1;let r=i.active+e,o=e>0&&!i.ranges.some(t=>t.field==r+e);return n(t.update({selection:(s=i.ranges,tn.create(s.filter(e=>e.field==r).map(e=>tn.range(e.from,e.to)))),effects:dN.of(o?null:new dj(i.ranges,r)),scrollIntoView:!0})),!0}}let d_=[{key:"Tab",run:dC(1),shift:dC(-1)},{key:"Escape",run:({state:e,dispatch:t})=>!!e.field(dz,!1)&&(t(e.update({effects:dN.of(null)})),!0)}],dT={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},dA=tT.define({map(e,t){let n=t.mapPos(e,-1,e2.TrackAfter);return null==n?void 0:n}}),dM=new class extends tL{};dM.startSide=1,dM.endSide=-1;let dP=td.define({create:()=>tF.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(dA)&&(e=e.update({add:[dM.range(n.value,n.value+1)]}));return e}}),dE="()[]{}<>«»»«[]{}";function dR(e){for(let t=0;t<dE.length;t+=2)if(dE.charCodeAt(t)==e)return dE.charAt(t+1);return eJ(e<128?e:e+1)}function dD(e,t){return e.languageDataAt("closeBrackets",t)[0]||dT}let d$="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),dQ=ry.inputHandler.of((e,t,n,s)=>{if((d$?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(s.length>2||2==s.length&&1==e0(eK(s,0))||t!=i.from||n!=i.to)return!1;let r=function(e,t){let n=dD(e,e.selection.main.head),s=n.brackets||dT.brackets;for(let i of s){let r=dR(eK(i,0));if(t==i)return r==i?function(e,t,n,s){let i=s.stringPrefixes||dT.stringPrefixes,r=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:dA.of(s.to+t.length),range:tn.range(s.anchor+t.length,s.head+t.length)};let o=s.head,a=dq(e.doc,o),l;if(a==t){if(dB(e,o))return{changes:{insert:t+t,from:o},effects:dA.of(o+t.length),range:tn.cursor(o+t.length)};else if(dL(e,o)){let s=n&&e.sliceDoc(o,o+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+s.length,insert:s},range:tn.cursor(o+s.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(l=dW(e,o-2*t.length,i))>-1&&dB(e,l))return{changes:{insert:t+t+t+t,from:o},effects:dA.of(o+t.length),range:tn.cursor(o+t.length)};else if(e.charCategorizer(o)(a)!=tD.Word&&dW(e,o,i)>-1&&!function(e,t,n,s){let i=aW(e).resolveInner(t,-1),r=s.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+r)),a=o.indexOf(n);if(!a||a>-1&&s.indexOf(o.slice(0,a))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=i.to==t&&i.parent;if(!l)break;i=l}return!1}(e,o,t,i))return{changes:{insert:t+t,from:o},effects:dA.of(o+t.length),range:tn.cursor(o+t.length)};return{range:r=s}});return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}(e,i,s.indexOf(i+i+i)>-1,n):function(e,t,n,s){let i=null,r=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:n,from:r.to}],effects:dA.of(r.to+t.length),range:tn.range(r.anchor+t.length,r.head+t.length)};let o=dq(e.doc,r.head);return!o||/\s/.test(o)||s.indexOf(o)>-1?{changes:{insert:t+n,from:r.head},effects:dA.of(r.head+t.length),range:tn.cursor(r.head+t.length)}:{range:i=r}});return i?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}(e,i,r,n.before||dT.before);if(t==r&&dL(e,e.selection.main.from))return function(e,t){let n=null,s=e.changeByRange(s=>s.empty&&dq(e.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:tn.cursor(s.head+t.length)}:n={range:s});return n?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}(e,r)}return null}(e.state,s);return!!r&&(e.dispatch(r),!0)}),dI=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=dD(e,e.selection.main.head).brackets||dT.brackets,s=null,i=e.changeByRange(t=>{if(t.empty){var i,r;let s,o=(i=e.doc,r=t.head,e0(eK(s=i.sliceString(r-2,r),0))==s.length?s:s.slice(1));for(let s of n)if(s==o&&dq(e.doc,t.head)==dR(eK(s,0)))return{changes:{from:t.head-s.length,to:t.head+s.length},range:tn.cursor(t.head-s.length)}}return{range:s=t}});return s||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!s}}];function dL(e,t){let n=!1;return e.field(dP).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function dq(e,t){let n=e.sliceString(t,t+2);return n.slice(0,e0(eK(n,0)))}function dB(e,t){let n=aW(e).resolveInner(t+1);return n.parent&&n.from==t}function dW(e,t,n){let s=e.charCategorizer(t);if(s(e.sliceDoc(t-1,t))!=tD.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&s(e.sliceDoc(n-1,n))!=tD.Word)return n}return -1}let dV=[{key:"Ctrl-Space",run:dg},{mac:"Alt-`",run:dg},{mac:"Alt-i",run:dg},{key:"Escape",run:e=>{let t=e.state.field(du,!1);return!!t&&!!t.active.some(e=>0!=e.state)&&(e.dispatch({effects:h1.of(null)}),!0)}},{key:"ArrowDown",run:dm(!0)},{key:"ArrowUp",run:dm(!1)},{key:"PageDown",run:dm(!0,"page")},{key:"PageUp",run:dm(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(du,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(h3).interactionDelay)&&dp(e,t.open.options[t.open.selected])}}],dF=tp.highest(rC.computeN([h3],e=>e.facet(h3).defaultKeymap?[dV]:[]));class dH{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class dX{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(d3).markerFilter;s&&(e=s(e,n));let i=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),r=new tH,o=[],a=0,l=n.doc.iter(),c=0,h=n.doc.length;for(let e=0;;){let t,n,s=e==i.length?null:i[e];if(!s&&!o.length)break;if(o.length)t=a,n=o.reduce((e,t)=>Math.min(e,t.to),s&&s.from>t?s.from:1e8);else{if((t=s.from)>h)break;n=s.to,o.push(s),e++}for(;e<i.length;){let s=i[e];if(s.from==t&&(s.to>s.from||s.to==t))o.push(s),e++,n=Math.min(s.to,n);else{n=Math.min(s.from,n);break}}n=Math.min(n,h);let d=!1;if(o.some(e=>e.from==t&&(e.to==n||n==h))&&!(d=t==n)&&n-t<10){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){d=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let u=us(o);if(d)r.add(t,t,nS.widget({widget:new d9(u),diagnostics:o.slice()}));else{let e=o.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");r.add(t,n,nS.mark({class:"cm-lintRange cm-lintRange-"+u+e,diagnostics:o.slice(),inclusiveEnd:o.some(e=>e.to>n)}))}if((a=n)==h)break;for(let e=0;e<o.length;e++)o[e].to<=a&&o.splice(e--,1)}let d=r.finish();return new dX(d,t,dU(d))}}function dU(e,t=null,n=0){let s=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&0>i.diagnostics.indexOf(t)))if(s){if(0>i.diagnostics.indexOf(s.diagnostic))return!1;s=new dH(s.from,n,s.diagnostic)}else s=new dH(e,n,t||i.diagnostics[0])}),s}function dG(e,t){let n=t.pos,s=t.end||n,i=e.state.facet(d3).hideOn(e,n,s);if(null!=i)return i;let r=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(dZ))||e.changes.touchesRange(r.from,Math.max(r.to,s)))}let dZ=tT.define(),dY=tT.define(),dK=tT.define(),dJ=td.define({create:()=>new dX(nS.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),s=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);s=dU(n,e.selected.diagnostic,i)||dU(n,null,i)}!n.size&&i&&t.state.facet(d3).autoPanel&&(i=null),e=new dX(n,i,s)}for(let n of t.effects)if(n.is(dZ)){let s=t.state.facet(d3).autoPanel?n.value.length?ue.open:null:e.panel;e=dX.init(n.value,s,t.state)}else n.is(dY)?e=new dX(e.diagnostics,n.value?ue.open:null,e.selected):n.is(dK)&&(e=new dX(e.diagnostics,e.panel,n.value));return e},provide:e=>[ow.from(e,e=>e.panel),ry.decorations.from(e,e=>e.diagnostics)]}),d0=nS.mark({class:"cm-lintRange cm-lintRange-active"});function d1(e,t){return na("ul",{class:"cm-tooltip-lint"},t.map(t=>d6(e,t,!1)))}let d2=e=>{let t=e.state.field(dJ,!1);return!!t&&!!t.panel&&(e.dispatch({effects:dY.of(!1)}),!0)},d5=[{key:"Mod-Shift-m",run:e=>{var t,n;let s=e.state.field(dJ,!1);s&&s.panel||e.dispatch({effects:(t=e.state,n=[dY.of(!0)],t.field(dJ,!1)?n:n.concat(tT.appendConfig.of(uo)))});let i=ox(e,ue.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(dJ,!1);if(!t)return!1;let n=e.state.selection.main,s=dU(t.diagnostics,null,n.to+1);return(!!s||!!(s=dU(t.diagnostics,null,0))&&(s.from!=n.from||s.to!=n.to))&&(e.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0}),!0)}}],d3=tr.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...tI(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:d4,tooltipFilter:d4,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,s,i)=>e(n,s,i)||t(n,s,i):e:t,autoPanel:(e,t)=>e||t})})});function d4(e,t){return e?t?(n,s)=>t(e(n,s),s):e:t}function d8(e){let t=[];if(e)r:for(let{name:n}of e){for(let e=0;e<n.length;e++){let s=n[e];if(/[a-zA-Z]/.test(s)&&!t.some(e=>e.toLowerCase()==s.toLowerCase())){t.push(s);continue r}}t.push("")}return t}function d6(e,t,n){var s;let i=n?d8(t.actions):[];return na("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},na("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null==(s=t.actions)?void 0:s.map((n,s)=>{let r=!1,o=s=>{if(s.preventDefault(),r)return;r=!0;let i=dU(e.state.field(dJ).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,l=i[s]?a.indexOf(i[s]):-1,c=l<0?a:[a.slice(0,l),na("u",a.slice(l,l+1)),a.slice(l+1)];return na("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:o,onmousedown:o,"aria-label":` Action: ${a}${l<0?"":` (access key "${i[s]})"`}.`},c)}),t.source&&na("div",{class:"cm-diagnosticSource"},t.source))}class d9 extends nj{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return na("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class d7{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=d6(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ue{constructor(e){this.view=e,this.items=[];let t=t=>{if(!t.ctrlKey&&!t.altKey&&!t.metaKey){if(27==t.keyCode)d2(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65)||!(t.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],s=d8(n.actions);for(let i=0;i<s.length;i++)if(s[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=dU(this.view.state.field(dJ).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=na("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=na("div",{class:"cm-panel-lint"},this.list,na("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>d2(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(dJ).selected;if(!e)return -1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return -1}update(){let{diagnostics:e,selected:t}=this.view.state.field(dJ),n=0,s=!1,i=null,r=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:a})=>{for(let e of a.diagnostics){if(r.has(e))continue;r.add(e);let o=-1,a;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(a=new d7(this.view,e),this.items.splice(n,0,a),s=!0):(a=this.items[o],o>n&&(this.items.splice(n,o-n),s=!0)),t&&a.diagnostic==t.diagnostic?a.dom.hasAttribute("aria-selected")||(a.dom.setAttribute("aria-selected","true"),i=a):a.dom.hasAttribute("aria-selected")&&a.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();0==this.items.length&&(this.items.push(new d7(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=dU(this.view.state.field(dJ).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:dK.of(t)})}static open(e){return new ue(e)}}function ut(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}let un=ry.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ut("#d11")},".cm-lintRange-warning":{backgroundImage:ut("orange")},".cm-lintRange-info":{backgroundImage:ut("#999")},".cm-lintRange-hint":{backgroundImage:ut("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function us(e){let t="hint",n=1;for(let i of e){var s;let e="error"==(s=i.severity)?4:"warning"==s?3:"info"==s?2:1;e>n&&(n=e,t=i.severity)}return t}let ui=tT.define(),ur=td.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=dG(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((e,t)=>t.is(ui)?t.value:e,e)),provide:e=>oc.from(e)}),uo=[dJ,ry.decorations.compute([dJ],e=>{let{selected:t,panel:n}=e.field(dJ);return t&&n&&t.from!=t.to?nS.set([d0.range(t.from,t.to)]):nS.none}),function(e,t={}){let n=tT.define(),s=td.define({create:()=>[],update(e,s){if(e.length&&(t.hideOnChange&&(s.docChanged||s.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(s,e))),s.docChanged)){let t=[];for(let n of e){let e=s.changes.mapPos(n.pos,-1,e2.TrackDel);if(null!=e){let i=Object.assign(Object.create(null),n);i.pos=e,null!=i.end&&(i.end=s.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of s.effects)t.is(n)&&(e=t.value),t.is(om)&&(e=[]);return e},provide:e=>oh.from(e)});return{active:s,extension:[s,sk.define(i=>new op(i,e,s,n,t.hoverTime||300)),ou]}}(function(e,t,n){let{diagnostics:s}=e.state.field(dJ),i,r=-1,o=-1;s.between(t-(n<0),t+ +(n>0),(e,s,{spec:a})=>{if(t>=e&&t<=s&&(e==s||(t>e||n>0)&&(t<s||n<0)))return i=a.diagnostics,r=e,o=s,!1});let a=e.state.facet(d3).tooltipFilter;return(i&&a&&(i=a(i,e.state)),i)?{pos:r,end:o,above:e.state.doc.lineAt(r).to<o,create:()=>({dom:d1(e,i)})}:null},{hideOn:dG}),un],ua=tr.define({combine:e=>tI(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})}),ul=[function(e={}){return[oL.of(e),oA(),oW]}(),oH,function(e={}){return[r1.of(e),r2||(r2=sk.fromClass(class{constructor(e){this.view=e,this.decorations=nS.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(r1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new rZ({regexp:e.specialChars,decoration:(t,n,s)=>{let{doc:i}=n.state,r=eK(t[0],0);if(9==r){let e=i.lineAt(s),t=n.state.tabSize,r=t5(e.text,t,s-e.from);return nS.replace({widget:new r3((t-r%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=nS.replace({widget:new r5(e,r)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(r1);e.startState.facet(r1)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}(),function(e={}){return[l4,l3.of(e),ry.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?l6:"historyRedo"==e.inputType?l9:null;return!!n&&(e.preventDefault(),n(t))}})]}(),function(e={}){var t;let n={...lw,...e},s=new lO(n,!0),i=new lO(n,!1),r=sk.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(aK)!=e.state.facet(aK)||e.startState.field(lc,!1)!=e.state.field(lc,!1)||aW(e.startState)!=aW(e.state)||n.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new tH;for(let n of e.viewportLineBlocks){let r=ld(e.state,n.from,n.to)?i:li(e.state,n.from,n.to)?s:null;r&&t.add(n.from,n.from,r)}return t.finish()}}),{domEventHandlers:o}=n;return[r,(t={class:"cm-foldGutter",markers(e){var t;return(null==(t=e.plugin(r))?void 0:t.markers)||tF.empty},initialSpacer:()=>new lO(n,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let s=ld(e.state,t.from,t.to);if(s)return e.dispatch({effects:la.of(s)}),!0;let i=li(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:lo.of(i)}),!0)}}},[oA(),o_.of({...oC,...t})]),lx()]}(),function(e={}){return[rL.of(e),rB,rV,rF,sf.of(!0)]}(),[rX,rU],tQ.allowMultipleSelections.of(!0),tQ.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:s}=e.newSelection.main,i=n.lineAt(s);if(s>i.from+200)return e;let r=n.sliceString(i.from,s);if(!t.some(e=>e.test(r)))return e;let{state:o}=e,a=-1,l=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=a3(o,t.from);if(null==n)continue;let s=/^\s*/.exec(t.text)[0],i=a5(o,n);s!=i&&l.push({from:t.from,to:t.from+s.length,insert:i})}return l.length?[e,{changes:l,sequential:!0}]:e}),lC(lT,{fallback:!0}),function(e={}){return[lP.of(e),lQ]}(),[dQ,dP],function(e={}){return[dy,du,h3.of(e),db,dF,dw]}(),(s=e=>e.altKey&&0==e.button,ry.mouseSelectionStyle.of((e,t)=>{let n,i;return s(t)?(n=r6(e,t),i=e.state.selection,{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),s=e.state.doc.lineAt(t);n={line:s.number,col:n.col,off:Math.min(n.off,s.length)},i=i.map(e.changes)}},get(t,s,r){let o=r6(e,t),a=function(e,t,n){let s=Math.min(t.line,n.line),i=Math.max(t.line,n.line),r=[];if(t.off>2e3||n.off>2e3||t.col<0||n.col<0){let o=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=s;t<=i;t++){let n=e.doc.line(t);n.length<=a&&r.push(tn.range(n.from+o,n.to+a))}}else{let o=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=s;t<=i;t++){let n=e.doc.line(t),s=t3(n.text,o,e.tabSize,!0);if(s<0)r.push(tn.cursor(n.to));else{let t=t3(n.text,a,e.tabSize);r.push(tn.range(n.from+s,n.from+t))}}}return r}(e.state,n,o);return a.length?r?tn.create(a.concat(i.ranges)):tn.create(a):i}}):null})),function(e={}){let[t,n]=r9[e.key||"Alt"],s=sk.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[s,ry.contentAttributes.of(e=>{var t;return(null==(t=e.plugin(s))?void 0:t.isDown)?r7:null})]}(),r8,[hh,hc],rC.of([...dI,...c3,...hI,{key:"Mod-z",run:l6,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:l9,preventDefault:!0},{linux:"Ctrl-Shift-z",run:l9,preventDefault:!0},{key:"Mod-u",run:l7,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ce,preventDefault:!0},...lf,...dV,...d5])];var uc=e.i(47167);class uh{constructor(e,t,n,s,i,r,o,a,l,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=s,this.pos=i,this.score=r,this.buffer=o,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let s=e.parser.context;return new uh(e,[],t,n,n,0,[],0,s?new ud(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,s=65535&e,{parser:i}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),o=i.dynamicPrecedence(s);if(o&&(this.score+=o),0==n){this.pushState(i.getGoto(this.state,s,!0),this.reducePos),s<i.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(n-1)*3-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null==(t=this.p.parser.nodeSet.types[s])?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,d=this.bufferBase+this.buffer.length-h;if(s<i.minRepeatTerm||131072&e){let e=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,l,e,d+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=i.getGoto(e,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,l)}storeNode(e,t,n,s=4,i=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,s=this.buffer.length;if(0==s&&e.parent&&(s=e.bufferBase-e.parent.bufferBase,e=e.parent),s>0&&0==e.buffer[s-4]&&e.buffer[s-1]>-1){if(t==n)return;if(e.buffer[s-2]>=t){e.buffer[s-2]=n;return}}}if(i&&this.pos!=n){let i=this.buffer.length;if(i>0&&(0!=this.buffer[i-4]||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,s>4&&(s-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=s}else this.buffer.push(e,t,n,s)}shift(e,t,n,s){if(131072&e)this.pushState(65535&e,this.pos);else if((262144&e)==0){let{parser:i}=this.p;this.pos=s;let r=i.stateFlag(e,1);!r&&(s>n||t<=i.maxNode)&&(this.reducePos=s),this.pushState(e,r?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=i.maxNode&&this.buffer.push(t,n,s,4)}else this.pos=s,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,s,4)}apply(e,t,n,s){65536&e?this.reduce(e):this.shift(e,t,n,s)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(n,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new uh(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new uu(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if((65536&n)==0)return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let s=0,i;s<t.length;s+=2)(i=t[s+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[s],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let s=t[e+1];n.some((e,t)=>1&t&&e==s)||n.push(t[e],s)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let s=t[e+1];if(s==this.state)continue;let i=this.split();i.pushState(s,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((65536&t)==0)return!1;if(!e.validAction(this.state,t)){let n=t>>19,s=65535&t,i=this.stack.length-3*n;if(i<0||0>e.getGoto(this.stack[i],s,!1)){let e=this.findForcedReduction();if(null==e)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(s,i)=>{if(!t.includes(s))return t.push(s),e.allActions(s,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-i;if(n>1){let s=65535&t,i=this.stack.length-3*n;if(i>=0&&e.getGoto(this.stack[i],s,!1)>=0)return n<<19|65536|s}}else{let e=n(t,i+1);if(null!=e)return e}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new ud(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class ud{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class uu{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e>>19;0==t?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(t-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],65535&e,!0);this.state=n}}class up{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new up(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new up(this.stack,this.pos,this.index)}}function uf(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let s=0,i=0;s<e.length;){let r=0;for(;;){let t=e.charCodeAt(s++),n=!1;if(126==t){r=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),r+=i,n)break;r*=46}n?n[i++]=r:n=new t(r)}return n}class um{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}let ug=new um;class ux{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=ug,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,s=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!s)return null;let e=this.ranges[--s];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(s==this.ranges.length-1)return null;let e=this.ranges[++s];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,s;if(t>=0&&t<this.chunk.length)n=this.pos+e,s=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(null==t)return -1;if((n=t)>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),s=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),s}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=ug,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(n+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return n}}class ub{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;uy(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}ub.prototype.contextual=ub.prototype.fallback=ub.prototype.extend=!1,(class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data="string"==typeof e?uf(e):e}token(e,t){let n=e.pos,s=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(uy(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(null==this.elseToken)return;if(!n&&s++,null==i)break;e.reset(i,e.token)}s&&(e.reset(n,e.token),e.acceptToken(this.elseToken,s))}}).prototype.contextual=ub.prototype.fallback=ub.prototype.extend=!1;class uv{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function uy(e,t,n,s,i,r){let o=0,a=1<<s,{dialect:l}=n.p.parser;s:for(;(a&e[o])!=0;){let n=e[o+1];for(let s=o+3;s<n;s+=2)if((e[s+1]&a)>0){let n=e[s];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||function(e,t,n,s){let i=uw(n,s,t);return i<0||uw(n,s,e)<i}(n,t.token.value,i,r))){t.acceptToken(n);break}}let s=t.next,c=0,h=e[o+2];if(t.next<0&&h>c&&65535==e[n+3*h-3]){o=e[n+3*h-1];continue}for(;c<h;){let i=c+h>>1,r=n+i+(i<<1),a=e[r],l=e[r+1]||65536;if(s<a)h=i;else if(s>=l)c=i+1;else{o=e[r+2],t.advance();continue s}}break}}function uw(e,t,n){for(let s=t,i;65535!=(i=e[s]);s++)if(i==n)return s-t;return -1}let uO=void 0!==uc.default&&uc.default.env&&/\bparse\b/.test(uc.default.env.LOG),uk=null;function uj(e,t,n){let s=e.cursor(mX.IncludeAnonymous);for(s.moveTo(t);;)if(!(n<0?s.childBefore(t):s.childAfter(t)))for(;;){if((n<0?s.to<t:s.from>t)&&!s.type.isError)return n<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(e.length,Math.max(s.from+1,t+25));if(n<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return n<0?0:e.length}}class uN{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?uj(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?uj(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],s=this.index[t];if(s==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[s],r=this.start[t]+n.positions[s];if(r>e)return this.nextStart=r,null;if(i instanceof o2){if(r==e){if(r<this.safeFrom)return null;let e=r+i.length;if(e<=this.safeTo){let t=i.prop(oG.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,r+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(r),this.index.push(0))}else this.index[t]++,this.nextStart=r+i.length}}}class uS{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new um)}getActions(e){let t=0,n=null,{parser:s}=e.p,{tokenizers:i}=s,r=s.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,a=0;for(let s=0;s<i.length;s++){if((1<<s&r)==0)continue;let l=i[s],c=this.tokens[s];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=r||c.context!=o)&&(this.updateCachedToken(c,l,e),c.mask=r,c.context=o),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let s=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>s))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||((n=new um).value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new um,{pos:n,p:s}=e;return t.start=n,t.end=Math.min(n+1,s.stream.end),t.value=n==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,n){let s=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(s,e),n),e.value>-1){let{parser:t}=n.p;for(let s=0;s<t.specialized.length;s++)if(t.specialized[s]==e.value){let i=t.specializers[s](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){(1&i)==0?e.value=i>>1:e.extended=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,n,s){for(let t=0;t<s;t+=3)if(this.actions[t]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=n,s}addActions(e,t,n,s){let{state:i}=e,{parser:r}=e.p,{data:o}=r;for(let e=0;e<2;e++)for(let a=r.stateSlot(i,e?2:1);;a+=3){if(65535==o[a])if(1==o[a+1])a=uM(o,a+2);else{0==s&&2==o[a+1]&&(s=this.putAction(uM(o,a+2),t,n,s));break}o[a]==t&&(s=this.putAction(uM(o,a+1),t,n,s))}return s}}class uz{constructor(e,t,n,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new ux(t,s),this.tokens=new uS(e,this.stream),this.topTerm=e.top[1];let{from:i}=s[0];this.stacks=[uh.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>4*e.bufferLength?new uN(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,s=this.minStackPos,i=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<n.length;r++){let o=n[r];for(;;){if(this.tokens.mainToken=null,o.pos>s)i.push(o);else{if(this.advanceStack(o,i,n))continue;e||(e=[],t=[]),e.push(o);let s=this.tokens.getMainToken(o);t.push(s.value,s.end)}break}}if(!i.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return uO&&console.log("Finish with "+this.stackID(t)),this.stackToTree(t);if(this.parser.strict)throw uO&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),SyntaxError("No parse at "+s);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,i);if(n)return uO&&console.log("Force-finish "+this.stackID(n)),this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(i.length>e)for(i.sort((e,t)=>t.score-e.score);i.length>e;)i.pop();i.some(e=>e.reducePos>s)&&this.recovering--}else if(i.length>1){o:for(let e=0;e<i.length-1;e++){let t=i[e];for(let n=e+1;n<i.length;n++){let s=i[n];if(t.sameState(s)||t.buffer.length>500&&s.buffer.length>500)if((t.score-s.score||t.buffer.length-s.buffer.length)>0)i.splice(n--,1);else{i.splice(e--,1);continue o}}}i.length>12&&(i.sort((e,t)=>t.score-e.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let e=1;e<i.length;e++)i[e].pos<this.minStackPos&&(this.minStackPos=i[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let s=e.pos,{parser:i}=this,r=uO?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(s);o;){let s=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(s>-1&&o.length&&(!t||(o.prop(oG.contextHash)||0)==n))return e.useNode(o,s),uO&&console.log(r+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof o2)||0==o.children.length||o.positions[0]>0)break;let a=o.children[0];if(a instanceof o2&&0==o.positions[0])o=a;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),uO&&console.log(r+this.stackID(e)+` (via always-reduce ${i.getName(65535&o)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let o=0;o<a.length;){let l=a[o++],c=a[o++],h=a[o++],d=o==a.length||!n,u=d?e:e.split(),p=this.tokens.mainToken;if(u.apply(l,c,p?p.start:u.pos,h),uO&&console.log(r+this.stackID(u)+` (via ${(65536&l)==0?"shift":`reduce of ${i.getName(65535&l)}`} for ${i.getName(c)} @ ${s}${u==e?"":", split"})`),d)return!0;u.pos>s?t.push(u):n.push(u)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return uC(e,t),!0}}runRecovery(e,t,n){let s=null,i=!1;for(let r=0;r<e.length;r++){let o=e[r],a=t[r<<1],l=t[(r<<1)+1],c=uO?this.stackID(o)+" -> ":"";if(o.deadEnd&&(i||(i=!0,o.restart(),uO&&console.log(c+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))))continue;let h=o.split(),d=c;for(let e=0;e<10&&h.forceReduce()&&(uO&&console.log(d+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));e++)uO&&(d=this.stackID(h)+" -> ");for(let e of o.recoverByInsert(a))uO&&console.log(c+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>o.pos?(l==o.pos&&(l++,a=0),o.recoverByDelete(a,l),uO&&console.log(c+this.stackID(o)+` (via recover-delete ${this.parser.getName(a)})`),uC(o,n)):(!s||s.score<h.score)&&(s=h)}return s}stackToTree(e){return e.close(),o2.build({buffer:up.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(uk||(uk=new WeakMap)).get(e);return t||uk.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function uC(e,t){for(let n=0;n<t.length;n++){let s=t[n];if(s.pos==e.pos&&s.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}class u_{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}let uT=e=>e;class uA extends ad{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),s=[];for(let e=0;e<t.length;e++)s.push([]);function i(e,t,n){s[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=oG[e]);for(let n=1;n<t.length;){let s=t[n++];if(s>=0)i(s,e,t[n++]);else{let r=t[n+-s];for(let o=-s;o>0;o--)i(t[n++],e,r);n++}}}this.nodeSet=new oJ(t.map((t,i)=>oK.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:s[i],top:n.indexOf(i)>-1,error:0==i,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let r=uf(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(uP),this.states=uf(e.states,Uint32Array),this.data=uf(e.stateData),this.goto=uf(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new ub(r,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let s=new uz(this,e,t,n);for(let i of this.wrappers)s=i(s,e,t,n);return s}getGoto(e,t,n=!1){let s=this.goto;if(t>=s[0])return -1;for(let i=s[t+1];;){let t=s[i++],r=1&t,o=s[i++];if(r&&n)return o;for(let n=i+(t>>1);i<n;i++)if(s[i]==e)return o;if(r)return -1}}hasAction(e,t){let n=this.data;for(let s=0;s<2;s++)for(let i=this.stateSlot(e,s?2:1),r;;i+=3){if(65535==(r=n[i]))if(1==n[i+1])r=n[i=uM(n,i+2)];else if(2==n[i+1])return uM(n,i+2);else break;if(r==t||0==r)return uM(n,i+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),s=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==s;n+=3){if(65535==this.data[n])if(1==this.data[n+1])n=uM(this.data,n+2);else break;s=t(uM(this.data,n+1))}return s}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n])if(1==this.data[n+1])n=uM(this.data,n+2);else break;if((1&this.data[n+2])==0){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(uA.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,s)=>{let i=e.specializers.find(e=>e.from==n.external);if(!i)return n;let r=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[s]=uP(r),r})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let e=t.indexOf(s);e>=0&&(n[e]=!0)}let s=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;65535!=(i=this.data[n++]);)(s||(s=new Uint8Array(this.maxTerm+1)))[i]=1;return new u_(e,n,s)}static deserialize(e){return new uA(e)}}function uM(e,t){return e[t]|e[t+1]<<16}function uP(e){if(e.external){let t=+!!e.extend;return(n,s)=>e.external(n,s)<<1|t}return e.get}let uE=new Set([25,49,50,263,65,130,56,57,238,62,63,72,73,77,60,61,151,152,155,112]);function uR(e){return 10==e||13==e}function uD(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}let u$=new uv((e,t)=>{let n;if(e.next<0)e.acceptToken(199);else if(t.context.flags&uI)uR(e.next)&&e.acceptToken(198,1);else if(((n=e.peek(-1))<0||uR(n))&&t.canShift(197)){let t=0;for(;32==e.next||9==e.next;)e.advance(),t++;(10==e.next||13==e.next||35==e.next)&&e.acceptToken(197,-t)}else uR(e.next)&&e.acceptToken(196,1)},{contextual:!0}),uQ=new uv((e,t)=>{let n=t.context;if(n.flags)return;let s=e.peek(-1);if(10==s||13==s){let t=0,s=0;for(;;){if(32==e.next)t++;else if(9==e.next)t+=8-t%8;else break;e.advance(),s++}t!=n.indent&&10!=e.next&&13!=e.next&&35!=e.next&&(t<n.indent?e.acceptToken(195,-s):e.acceptToken(194))}}),uI=1;function uL(e,t,n){this.parent=e,this.indent=t,this.flags=n,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+n+(n<<6)}let uq=new uL(null,0,0),uB=new Map([[241,0],[242,4],[243,8],[244,12],[245,16],[246,20],[247,24],[248,28],[249,32],[250,36],[251,40],[252,44],[253,48],[254,52],[255,56],[256,60]].map(([e,t])=>[e,2|t])),uW=new class{constructor(e){this.start=e.start,this.shift=e.shift||uT,this.reduce=e.reduce||uT,this.reuse=e.reuse||uT,this.hash=e.hash||(()=>0),this.strict=!1!==e.strict}}({start:uq,reduce:(e,t,n,s)=>e.flags&uI&&uE.has(t)||(71==t||72==t)&&2&e.flags?e.parent:e,shift:(e,t,n,s)=>194==t?new uL(e,function(e){let t=0;for(let n=0;n<e.length;n++)t+=9==e.charCodeAt(n)?8-t%8:1;return t}(s.read(s.pos,n.pos)),0):195==t?e.parent:24==t||55==t||59==t||3==t?new uL(e,0,uI):uB.has(t)?new uL(e,0,uB.get(t)|e.flags&uI):e,hash:e=>e.hash}),uV=new uv(e=>{for(let t=0;t<5;t++){if(e.next!="print".charCodeAt(t))return;e.advance()}if(!/\w/.test(String.fromCharCode(e.next)))for(let t=0;;t++){let n=e.peek(t);if(32!=n&&9!=n){40!=n&&46!=n&&10!=n&&13!=n&&35!=n&&e.acceptToken(1);return}}}),uF=new uv((e,t)=>{let{flags:n}=t.context,s=4&n?34:39,i=(8&n)>0,r=!(16&n),o=(32&n)>0,a=e.pos;for(;;)if(e.next<0)break;else if(o&&123==e.next)if(123==e.peek(1))e.advance(2);else{if(e.pos==a)return void e.acceptToken(3,1);break}else if(r&&92==e.next){if(e.pos==a){e.advance();let t=e.next;t>=0&&(e.advance(),function(e,t){if(111==t)for(let t=0;t<2&&e.next>=48&&e.next<=55;t++)e.advance();else if(120==t)for(let t=0;t<2&&uD(e.next);t++)e.advance();else if(117==t)for(let t=0;t<4&&uD(e.next);t++)e.advance();else if(85==t)for(let t=0;t<8&&uD(e.next);t++)e.advance();else if(78==t&&123==e.next){for(e.advance();e.next>=0&&125!=e.next&&39!=e.next&&34!=e.next&&10!=e.next;)e.advance();125==e.next&&e.advance()}}(e,t)),e.acceptToken(2);return}break}else if(92==e.next&&!r&&e.peek(1)>-1)e.advance(2);else if(e.next!=s||i&&(e.peek(1)!=s||e.peek(2)!=s))if(10==e.next){if(i)e.advance();else if(e.pos==a)return void e.acceptToken(201);break}else e.advance();else{if(e.pos==a)return void e.acceptToken(201,i?3:1);break}e.pos>a&&e.acceptToken(200)}),uH=ax({'async "*" "**" FormatConversion FormatSpec':a$.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":a$.controlKeyword,"in not and or is del":a$.operatorKeyword,"from def class global nonlocal lambda":a$.definitionKeyword,import:a$.moduleKeyword,"with as print":a$.keyword,Boolean:a$.bool,None:a$.null,VariableName:a$.variableName,"CallExpression/VariableName":a$.function(a$.variableName),"FunctionDefinition/VariableName":a$.function(a$.definition(a$.variableName)),"ClassDefinition/VariableName":a$.definition(a$.className),PropertyName:a$.propertyName,"CallExpression/MemberExpression/PropertyName":a$.function(a$.propertyName),Comment:a$.lineComment,Number:a$.number,String:a$.string,FormatString:a$.special(a$.string),Escape:a$.escape,UpdateOp:a$.updateOperator,"ArithOp!":a$.arithmeticOperator,BitOp:a$.bitwiseOperator,CompareOp:a$.compareOperator,AssignOp:a$.definitionOperator,Ellipsis:a$.punctuation,At:a$.meta,"( )":a$.paren,"[ ]":a$.squareBracket,"{ }":a$.brace,".":a$.derefOperator,", ;":a$.separator}),uX={__proto__:null,await:44,or:54,and:56,in:60,not:62,is:64,if:70,else:72,lambda:76,yield:94,from:96,async:102,for:104,None:162,True:164,False:164,del:178,pass:182,break:186,continue:190,return:194,raise:202,import:206,as:208,global:212,nonlocal:214,assert:218,type:223,elif:236,while:240,try:246,except:248,finally:250,with:254,def:258,class:268,match:279,case:285},uU=uA.deserialize({version:14,states:"##jO`QeOOP$}OSOOO&WQtO'#HUOOQS'#Co'#CoOOQS'#Cp'#CpO'vQdO'#CnO*UQtO'#HTOOQS'#HU'#HUOOQS'#DU'#DUOOQS'#HT'#HTO*rQdO'#D_O+VQdO'#DfO+gQdO'#DjO+zOWO'#DuO,VOWO'#DvO.[QtO'#GuOOQS'#Gu'#GuO'vQdO'#GtO0ZQtO'#GtOOQS'#Eb'#EbO0rQdO'#EcOOQS'#Gs'#GsO0|QdO'#GrOOQV'#Gr'#GrO1XQdO'#FYOOQS'#G^'#G^O1^QdO'#FXOOQV'#IS'#ISOOQV'#Gq'#GqOOQV'#Fq'#FqQ`QeOOO'vQdO'#CqO1lQdO'#C}O1sQdO'#DRO2RQdO'#HYO2cQtO'#EVO'vQdO'#EWOOQS'#EY'#EYOOQS'#E['#E[OOQS'#E^'#E^O2wQdO'#E`O3_QdO'#EdO3rQdO'#EfO3zQtO'#EfO1XQdO'#EiO0rQdO'#ElO1XQdO'#EnO0rQdO'#EtO0rQdO'#EwO4VQdO'#EyO4^QdO'#FOO4iQdO'#EzO0rQdO'#FOO1XQdO'#FQO1XQdO'#FVO4nQdO'#F[P4uOdO'#GpPOOO)CBd)CBdOOQS'#Ce'#CeOOQS'#Cf'#CfOOQS'#Cg'#CgOOQS'#Ch'#ChOOQS'#Ci'#CiOOQS'#Cj'#CjOOQS'#Cl'#ClO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO5TQdO'#DoOOQS,5:Y,5:YO5hQdO'#HdOOQS,5:],5:]O5uQ!fO,5:]O5zQtO,59YO1lQdO,59bO1lQdO,59bO1lQdO,59bO8jQdO,59bO8oQdO,59bO8vQdO,59jO8}QdO'#HTO:TQdO'#HSOOQS'#HS'#HSOOQS'#D['#D[O:lQdO,59aO'vQdO,59aO:zQdO,59aOOQS,59y,59yO;PQdO,5:RO'vQdO,5:ROOQS,5:Q,5:QO;_QdO,5:QO;dQdO,5:XO'vQdO,5:XO'vQdO,5:VOOQS,5:U,5:UO;uQdO,5:UO;zQdO,5:WOOOW'#Fy'#FyO<POWO,5:aOOQS,5:a,5:aO<[QdO'#HwOOOW'#Dw'#DwOOOW'#Fz'#FzO<lOWO,5:bOOQS,5:b,5:bOOQS'#F}'#F}O<zQtO,5:iO?lQtO,5=`O@VQ#xO,5=`O@vQtO,5=`OOQS,5:},5:}OA_QeO'#GWOBqQdO,5;^OOQV,5=^,5=^OB|QtO'#IPOCkQdO,5;tOOQS-E:[-E:[OOQV,5;s,5;sO4dQdO'#FQOOQV-E9o-E9oOCsQtO,59]OEzQtO,59iOFeQdO'#HVOFpQdO'#HVO1XQdO'#HVOF{QdO'#DTOGTQdO,59mOGYQdO'#HZO'vQdO'#HZO0rQdO,5=tOOQS,5=t,5=tO0rQdO'#EROOQS'#ES'#ESOGwQdO'#GPOHXQdO,58|OHXQdO,58|O*xQdO,5:oOHgQtO'#H]OOQS,5:r,5:rOOQS,5:z,5:zOHzQdO,5;OOI]QdO'#IOO1XQdO'#H}OOQS,5;Q,5;QOOQS'#GT'#GTOIqQtO,5;QOJPQdO,5;QOJUQdO'#IQOOQS,5;T,5;TOJdQdO'#H|OOQS,5;W,5;WOJuQdO,5;YO4iQdO,5;`O4iQdO,5;cOJ}QtO'#ITO'vQdO'#ITOKXQdO,5;eO4VQdO,5;eO0rQdO,5;jO1XQdO,5;lOK^QeO'#EuOLjQgO,5;fO!!kQdO'#IUO4iQdO,5;jO!!vQdO,5;lO!#OQdO,5;qO!#ZQtO,5;vO'vQdO,5;vPOOO,5=[,5=[P!#bOSO,5=[P!#jOdO,5=[O!&bQtO1G.jO!&iQtO1G.jO!)YQtO1G.jO!)dQtO1G.jO!+}QtO1G.jO!,bQtO1G.jO!,uQdO'#HcO!-TQtO'#GuO0rQdO'#HcO!-_QdO'#HbOOQS,5:Z,5:ZO!-gQdO,5:ZO!-lQdO'#HeO!-wQdO'#HeO!.[QdO,5>OOOQS'#Ds'#DsOOQS1G/w1G/wOOQS1G.|1G.|O!/[QtO1G.|O!/cQtO1G.|O1lQdO1G.|O!0OQdO1G/UOOQS'#DZ'#DZO0rQdO,59tOOQS1G.{1G.{O!0VQdO1G/eO!0gQdO1G/eO!0oQdO1G/fO'vQdO'#H[O!0tQdO'#H[O!0yQtO1G.{O!1ZQdO,59iO!2aQdO,5=zO!2qQdO,5=zO!2yQdO1G/mO!3OQtO1G/mOOQS1G/l1G/lO!3`QdO,5=uO!4VQdO,5=uO0rQdO1G/qO!4tQdO1G/sO!4yQtO1G/sO!5ZQtO1G/qOOQS1G/p1G/pOOQS1G/r1G/rOOOW-E9w-E9wOOQS1G/{1G/{O!5kQdO'#HxO0rQdO'#HxO!5|QdO,5>cOOOW-E9x-E9xOOQS1G/|1G/|OOQS-E9{-E9{O!6[Q#xO1G2zO!6{QtO1G2zO'vQdO,5<jOOQS,5<j,5<jOOQS-E9|-E9|OOQS,5<r,5<rOOQS-E:U-E:UOOQV1G0x1G0xO1XQdO'#GRO!7dQtO,5>kOOQS1G1`1G1`O!8RQdO1G1`OOQS'#DV'#DVO0rQdO,5=qOOQS,5=q,5=qO!8WQdO'#FrO!8cQdO,59oO!8kQdO1G/XO!8uQtO,5=uOOQS1G3`1G3`OOQS,5:m,5:mO!9fQdO'#GtOOQS,5<k,5<kOOQS-E9}-E9}O!9wQdO1G.hOOQS1G0Z1G0ZO!:VQdO,5=wO!:gQdO,5=wO0rQdO1G0jO0rQdO1G0jO!:xQdO,5>jO!;ZQdO,5>jO1XQdO,5>jO!;lQdO,5>iOOQS-E:R-E:RO!;qQdO1G0lO!;|QdO1G0lO!<RQdO,5>lO!<aQdO,5>lO!<oQdO,5>hO!=VQdO,5>hO!=hQdO'#EpO0rQdO1G0tO!=sQdO1G0tO!=xQgO1G0zO!AvQgO1G0}O!EqQdO,5>oO!E{QdO,5>oO!FTQtO,5>oO0rQdO1G1PO!F_QdO1G1PO4iQdO1G1UO!!vQdO1G1WOOQV,5;a,5;aO!FdQfO,5;aO!FiQgO1G1QO!JjQdO'#GZO4iQdO1G1QO4iQdO1G1QO!JzQdO,5>pO!KXQdO,5>pO1XQdO,5>pOOQV1G1U1G1UO!KaQdO'#FSO!KrQ!fO1G1WO!KzQdO1G1WOOQV1G1]1G1]O4iQdO1G1]O!LPQdO1G1]O!LXQdO'#F^OOQV1G1b1G1bO!#ZQtO1G1bPOOO1G2v1G2vP!L^OSO1G2vOOQS,5=},5=}OOQS'#Dp'#DpO0rQdO,5=}O!LfQdO,5=|O!LyQdO,5=|OOQS1G/u1G/uO!MRQdO,5>PO!McQdO,5>PO!MkQdO,5>PO!NOQdO,5>PO!N`QdO,5>POOQS1G3j1G3jOOQS7+$h7+$hO!8kQdO7+$pO#!RQdO1G.|O#!YQdO1G.|OOQS1G/`1G/`OOQS,5<`,5<`O'vQdO,5<`OOQS7+%P7+%PO#!aQdO7+%POOQS-E9r-E9rOOQS7+%Q7+%QO#!qQdO,5=vO'vQdO,5=vOOQS7+$g7+$gO#!vQdO7+%PO##OQdO7+%QO##TQdO1G3fOOQS7+%X7+%XO##eQdO1G3fO##mQdO7+%XOOQS,5<_,5<_O'vQdO,5<_O##rQdO1G3aOOQS-E9q-E9qO#$iQdO7+%]OOQS7+%_7+%_O#$wQdO1G3aO#%fQdO7+%_O#%kQdO1G3gO#%{QdO1G3gO#&TQdO7+%]O#&YQdO,5>dO#&sQdO,5>dO#&sQdO,5>dOOQS'#Dx'#DxO#'UO&jO'#DzO#'aO`O'#HyOOOW1G3}1G3}O#'fQdO1G3}O#'nQdO1G3}O#'yQ#xO7+(fO#(jQtO1G2UP#)TQdO'#GOOOQS,5<m,5<mOOQS-E:P-E:POOQS7+&z7+&zOOQS1G3]1G3]OOQS,5<^,5<^OOQS-E9p-E9pOOQS7+$s7+$sO#)bQdO,5=`O#){QdO,5=`O#*^QtO,5<aO#*qQdO1G3cOOQS-E9s-E9sOOQS7+&U7+&UO#+RQdO7+&UO#+aQdO,5<nO#+uQdO1G4UOOQS-E:Q-E:QO#,WQdO1G4UOOQS1G4T1G4TOOQS7+&W7+&WO#,iQdO7+&WOOQS,5<p,5<pO#,tQdO1G4WOOQS-E:S-E:SOOQS,5<l,5<lO#-SQdO1G4SOOQS-E:O-E:OO1XQdO'#EqO#-jQdO'#EqO#-uQdO'#IRO#-}QdO,5;[OOQS7+&`7+&`O0rQdO7+&`O#.SQgO7+&fO!JmQdO'#GXO4iQdO7+&fO4iQdO7+&iO#2QQtO,5<tO'vQdO,5<tO#2[QdO1G4ZOOQS-E:W-E:WO#2fQdO1G4ZO4iQdO7+&kO0rQdO7+&kOOQV7+&p7+&pO!KrQ!fO7+&rO!KzQdO7+&rO`QeO1G0{OOQV-E:X-E:XO4iQdO7+&lO4iQdO7+&lOOQV,5<u,5<uO#2nQdO,5<uO!JmQdO,5<uOOQV7+&l7+&lO#2yQgO7+&lO#6tQdO,5<vO#7PQdO1G4[OOQS-E:Y-E:YO#7^QdO1G4[O#7fQdO'#IWO#7tQdO'#IWO1XQdO'#IWOOQS'#IW'#IWO#8PQdO'#IVOOQS,5;n,5;nO#8XQdO,5;nO0rQdO'#FUOOQV7+&r7+&rO4iQdO7+&rOOQV7+&w7+&wO4iQdO7+&wO#8^QfO,5;xOOQV7+&|7+&|POOO7+(b7+(bO#8cQdO1G3iOOQS,5<c,5<cO#8qQdO1G3hOOQS-E9u-E9uO#9UQdO,5<dO#9aQdO,5<dO#9tQdO1G3kOOQS-E9v-E9vO#:UQdO1G3kO#:^QdO1G3kO#:nQdO1G3kO#:UQdO1G3kOOQS<<H[<<H[O#:yQtO1G1zOOQS<<Hk<<HkP#;WQdO'#FtO8vQdO1G3bO#;eQdO1G3bO#;jQdO<<HkOOQS<<Hl<<HlO#;zQdO7+)QOOQS<<Hs<<HsO#<[QtO1G1yP#<{QdO'#FsO#=YQdO7+)RO#=jQdO7+)RO#=rQdO<<HwO#=wQdO7+({OOQS<<Hy<<HyO#>nQdO,5<bO'vQdO,5<bOOQS-E9t-E9tOOQS<<Hw<<HwOOQS,5<g,5<gO0rQdO,5<gO#>sQdO1G4OOOQS-E9y-E9yO#?^QdO1G4OO<[QdO'#H{OOOO'#D{'#D{OOOO'#F|'#F|O#?oO&jO,5:fOOOW,5>e,5>eOOOW7+)i7+)iO#?zQdO7+)iO#@SQdO1G2zO#@mQdO1G2zP'vQdO'#FuO0rQdO<<IpO1XQdO1G2YP1XQdO'#GSO#AOQdO7+)pO#AaQdO7+)pOOQS<<Ir<<IrP1XQdO'#GUP0rQdO'#GQOOQS,5;],5;]O#ArQdO,5>mO#BQQdO,5>mOOQS1G0v1G0vOOQS<<Iz<<IzOOQV-E:V-E:VO4iQdO<<JQOOQV,5<s,5<sO4iQdO,5<sOOQV<<JQ<<JQOOQV<<JT<<JTO#BYQtO1G2`P#BdQdO'#GYO#BkQdO7+)uO#BuQgO<<JVO4iQdO<<JVOOQV<<J^<<J^O4iQdO<<J^O!KrQ!fO<<J^O#FpQgO7+&gOOQV<<JW<<JWO#FzQgO<<JWOOQV1G2a1G2aO1XQdO1G2aO#JuQdO1G2aO4iQdO<<JWO1XQdO1G2bP0rQdO'#G[O#KQQdO7+)vO#K_QdO7+)vOOQS'#FT'#FTO0rQdO,5>rO#KgQdO,5>rO#KrQdO,5>rO#K}QdO,5>qO#L`QdO,5>qOOQS1G1Y1G1YOOQS,5;p,5;pOOQV<<Jc<<JcO#LhQdO1G1dOOQS7+)T7+)TP#LmQdO'#FwO#L}QdO1G2OO#MbQdO1G2OO#MrQdO1G2OP#M}QdO'#FxO#N[QdO7+)VO#NlQdO7+)VO#NlQdO7+)VO#NtQdO7+)VO$ UQdO7+(|O8vQdO7+(|OOQSAN>VAN>VO$ oQdO<<LmOOQSAN>cAN>cO0rQdO1G1|O$!PQtO1G1|P$!ZQdO'#FvOOQS1G2R1G2RP$!hQdO'#F{O$!uQdO7+)jO$#`QdO,5>gOOOO-E9z-E9zOOOW<<MT<<MTO$#nQdO7+(fOOQSAN?[AN?[OOQS7+'t7+'tO$$XQdO<<M[OOQS,5<q,5<qO$$jQdO1G4XOOQS-E:T-E:TOOQVAN?lAN?lOOQV1G2_1G2_O4iQdOAN?qO$$xQgOAN?qOOQVAN?xAN?xO4iQdOAN?xOOQV<<JR<<JRO4iQdOAN?rO4iQdO7+'{OOQV7+'{7+'{O1XQdO7+'{OOQVAN?rAN?rOOQS7+'|7+'|O$(sQdO<<MbOOQS1G4^1G4^O0rQdO1G4^OOQS,5<w,5<wO$)QQdO1G4]OOQS-E:Z-E:ZOOQU'#G_'#G_O$)cQfO7+'OO$)nQdO'#F_O$*uQdO7+'jO$+VQdO7+'jOOQS7+'j7+'jO$+bQdO<<LqO$+rQdO<<LqO$+rQdO<<LqO$+zQdO'#H^OOQS<<Lh<<LhO$,UQdO<<LhOOQS7+'h7+'hOOQS'#D|'#D|OOOO1G4R1G4RO$,oQdO1G4RO$,wQdO1G4RP!=hQdO'#GVOOQVG25]G25]O4iQdOG25]OOQVG25dG25dOOQVG25^G25^OOQV<<Kg<<KgO4iQdO<<KgOOQS7+)x7+)xP$-SQdO'#G]OOQU-E:]-E:]OOQV<<Jj<<JjO$-vQtO'#FaOOQS'#Fc'#FcO$.WQdO'#FbO$.xQdO'#FbOOQS'#Fb'#FbO$.}QdO'#IYO$)nQdO'#FiO$)nQdO'#FiO$/fQdO'#FjO$)nQdO'#FkO$/mQdO'#IZOOQS'#IZ'#IZO$0[QdO,5;yOOQS<<KU<<KUO$0dQdO<<KUO$0tQdOANB]O$1UQdOANB]O$1^QdO'#H_OOQS'#H_'#H_O1sQdO'#DcO$1wQdO,5=xOOQSANBSANBSOOOO7+)m7+)mO$2`QdO7+)mOOQVLD*wLD*wOOQVANARANARO5uQ!fO'#GaO$2hQtO,5<SO$)nQdO'#FmOOQS,5<W,5<WOOQS'#Fd'#FdO$3YQdO,5;|O$3_QdO,5;|OOQS'#Fg'#FgO$)nQdO'#G`O$4PQdO,5<QO$4kQdO,5>tO$4{QdO,5>tO1XQdO,5<PO$5^QdO,5<TO$5cQdO,5<TO$)nQdO'#I[O$5hQdO'#I[O$5mQdO,5<UOOQS,5<V,5<VO0rQdO'#FpOOQU1G1e1G1eO4iQdO1G1eOOQSAN@pAN@pO$5rQdOG27wO$6SQdO,59}OOQS1G3d1G3dOOOO<<MX<<MXOOQS,5<{,5<{OOQS-E:_-E:_O$6XQtO'#FaO$6`QdO'#I]O$6nQdO'#I]O$6vQdO,5<XOOQS1G1h1G1hO$6{QdO1G1hO$7QQdO,5<zOOQS-E:^-E:^O$7lQdO,5=OO$8TQdO1G4`OOQS-E:b-E:bOOQS1G1k1G1kOOQS1G1o1G1oO$8eQdO,5>vO$)nQdO,5>vOOQS1G1p1G1pOOQS,5<[,5<[OOQU7+'P7+'PO$+zQdO1G/iO$)nQdO,5<YO$8sQdO,5>wO$8zQdO,5>wOOQS1G1s1G1sOOQS7+'S7+'SP$)nQdO'#GdO$9SQdO1G4bO$9^QdO1G4bO$9fQdO1G4bOOQS7+%T7+%TO$9tQdO1G1tO$:SQtO'#FaO$:ZQdO,5<}OOQS,5<},5<}O$:iQdO1G4cOOQS-E:a-E:aO$)nQdO,5<|O$:pQdO,5<|O$:uQdO7+)|OOQS-E:`-E:`O$;PQdO7+)|O$)nQdO,5<ZP$)nQdO'#GcO$;XQdO1G2hO$)nQdO1G2hP$;gQdO'#GbO$;nQdO<<MhO$;xQdO1G1uO$<WQdO7+(SO8vQdO'#C}O8vQdO,59bO8vQdO,59bO8vQdO,59bO$<fQtO,5=`O8vQdO1G.|O0rQdO1G/XO0rQdO7+$pP$<yQdO'#GOO'vQdO'#GtO$=WQdO,59bO$=]QdO,59bO$=dQdO,59mO$=iQdO1G/UO1sQdO'#DRO8vQdO,59j",stateData:"$>S~O%cOS%^OSSOS%]PQ~OPdOVaOfoOhYOopOs!POvqO!PrO!Q{O!T!SO!U!RO!XZO!][O!h`O!r`O!s`O!t`O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#l!QO#o!TO#s!UO#u!VO#z!WO#}hO$P!XO%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~O%]!YO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%j![O%k!]O%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aO~Ok%xXl%xXm%xXn%xXo%xXp%xXs%xXz%xX{%xX!x%xX#g%xX%[%xX%_%xX%z%xXg%xX!T%xX!U%xX%{%xX!W%xX![%xX!Q%xX#[%xXt%xX!m%xX~P%SOfoOhYO!XZO!][O!h`O!r`O!s`O!t`O%oRO%pRO%tSO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O~Oz%wX{%wX#g%wX%[%wX%_%wX%z%wX~Ok!pOl!qOm!oOn!oOo!rOp!sOs!tO!x%wX~P)pOV!zOg!|Oo0cOv0qO!PrO~P'vOV#OOo0cOv0qO!W#PO~P'vOV#SOa#TOo0cOv0qO![#UO~P'vOQ#XO%`#XO%a#ZO~OQ#^OR#[O%`#^O%a#`O~OV%iX_%iXa%iXh%iXk%iXl%iXm%iXn%iXo%iXp%iXs%iXz%iX!X%iX!f%iX%j%iX%k%iX%l%iX%m%iX%n%iX%o%iX%p%iX%q%iX%r%iX%s%iXg%iX!T%iX!U%iX~O&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O&c^O&d^O&e^O&f^O&g^O&h^O&i^O&j^O{%iX!x%iX#g%iX%[%iX%_%iX%z%iX%{%iX!W%iX![%iX!Q%iX#[%iXt%iX!m%iX~P,eOz#dO{%hX!x%hX#g%hX%[%hX%_%hX%z%hX~Oo0cOv0qO~P'vO#g#gO%[#iO%_#iO~O%uWO~O!T#nO#u!VO#z!WO#}hO~OopO~P'vOV#sOa#tO%uWO{wP~OV#xOo0cOv0qO!Q#yO~P'vO{#{O!x$QO%z#|O#g!yX%[!yX%_!yX~OV#xOo0cOv0qO#g#SX%[#SX%_#SX~P'vOo0cOv0qO#g#WX%[#WX%_#WX~P'vOh$WO%uWO~O!f$YO!r$YO%uWO~OV$eO~P'vO!U$gO#s$hO#u$iO~O{$jO~OV$qO~P'vOS$sO%[$rO%_$rO%c$tO~OV$}Oa$}Og%POo0cOv0qO~P'vOo0cOv0qO{%SO~P'vO&Y%UO~Oa!bOh!iO!X!kO!f!mOVba_bakbalbambanbaobapbasbazba{ba!xba#gba%[ba%_ba%jba%kba%lba%mba%nba%oba%pba%qba%rba%sba%zbagba!Tba!Uba%{ba!Wba![ba!Qba#[batba!mba~On%ZO~Oo%ZO~P'vOo0cO~P'vOk0eOl0fOm0dOn0dOo0mOp0nOs0rOg%wX!T%wX!U%wX%{%wX!W%wX![%wX!Q%wX#[%wX!m%wX~P)pO%{%]Og%vXz%vX!T%vX!U%vX!W%vX{%vX~Og%_Oz%`O!T%dO!U%cO~Og%_O~Oz%gO!T%dO!U%cO!W&SX~O!W%kO~Oz%lO{%nO!T%dO!U%cO![%}X~O![%rO~O![%sO~OQ#XO%`#XO%a%uO~OV%wOo0cOv0qO!PrO~P'vOQ#^OR#[O%`#^O%a%zO~OV!qa_!qaa!qah!qak!qal!qam!qan!qao!qap!qas!qaz!qa{!qa!X!qa!f!qa!x!qa#g!qa%[!qa%_!qa%j!qa%k!qa%l!qa%m!qa%n!qa%o!qa%p!qa%q!qa%r!qa%s!qa%z!qag!qa!T!qa!U!qa%{!qa!W!qa![!qa!Q!qa#[!qat!qa!m!qa~P#yOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P%SOV&OOopOvqO{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~P'vOz%|O{%ha!x%ha#g%ha%[%ha%_%ha%z%ha~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO#g$zX%[$zX%_$zX~P'vO#g#gO%[&TO%_&TO~O!f&UOh&sX%[&sXz&sX#[&sX#g&sX%_&sX#Z&sXg&sX~Oh!iO%[&WO~Okealeameaneaoeapeaseazea{ea!xea#gea%[ea%_ea%zeagea!Tea!Uea%{ea!Wea![ea!Qea#[eatea!mea~P%SOsqazqa{qa#gqa%[qa%_qa%zqa~Ok!pOl!qOm!oOn!oOo!rOp!sO!xqa~PEcO%z&YOz%yX{%yX~O%uWOz%yX{%yX~Oz&]O{wX~O{&_O~Oz%lO#g%}X%[%}X%_%}Xg%}X{%}X![%}X!m%}X%z%}X~OV0lOo0cOv0qO!PrO~P'vO%z#|O#gUa%[Ua%_Ua~Oz&hO#g&PX%[&PX%_&PXn&PX~P%SOz&kO!Q&jO#g#Wa%[#Wa%_#Wa~Oz&lO#[&nO#g&rX%[&rX%_&rXg&rX~O!f$YO!r$YO#Z&qO%uWO~O#Z&qO~Oz&sO#g&tX%[&tX%_&tX~Oz&uO#g&pX%[&pX%_&pX{&pX~O!X&wO%z&xO~Oz&|On&wX~P%SOn'PO~OPdOVaOopOvqO!PrO!Q{O!{tO!}uO#PvO#RwO#TxO#XyO#ZzO#^|O#_|O#a}O#c!OO%['UO~P'vOt'YO#p'WO#q'XOP#naV#naf#nah#nao#nas#nav#na!P#na!Q#na!T#na!U#na!X#na!]#na!h#na!r#na!s#na!t#na!{#na!}#na#P#na#R#na#T#na#X#na#Z#na#^#na#_#na#a#na#c#na#l#na#o#na#s#na#u#na#z#na#}#na$P#na%X#na%o#na%p#na%t#na%u#na&Z#na&[#na&]#na&^#na&_#na&`#na&a#na&b#na&c#na&d#na&e#na&f#na&g#na&h#na&i#na&j#na%Z#na%_#na~Oz'ZO#[']O{&xX~Oh'_O!X&wO~Oh!iO{$jO!X&wO~O{'eO~P%SO%['hO%_'hO~OS'iO%['hO%_'hO~OV!aO_!aOa!bOh!iO!X!kO!f!mO%l!^O%m!_O%n!_O%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%k!]O~P!#uO%kWi~P!#uOV!aO_!aOa!bOh!iO!X!kO!f!mO%o!`O%p!`O%q!aO%r!aO%s!aOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~O%m!_O%n!_O~P!&pO%mWi%nWi~P!&pOa!bOh!iO!X!kO!f!mOkWilWimWinWioWipWisWizWi{Wi!xWi#gWi%[Wi%_Wi%jWi%kWi%lWi%mWi%nWi%oWi%pWi%zWigWi!TWi!UWi%{Wi!WWi![Wi!QWi#[WitWi!mWi~OV!aO_!aO%q!aO%r!aO%s!aO~P!)nOVWi_Wi%qWi%rWi%sWi~P!)nO!T%dO!U%cOg&VXz&VX~O%z'kO%{'kO~P,eOz'mOg&UX~Og'oO~Oz'pO{'rO!W&XX~Oo0cOv0qOz'pO{'sO!W&XX~P'vO!W'uO~Om!oOn!oOo!rOp!sOkjisjizji{ji!xji#gji%[ji%_ji%zji~Ol!qO~P!.aOlji~P!.aOk0eOl0fOm0dOn0dOo0mOp0nO~Ot'wO~P!/jOV'|Og'}Oo0cOv0qO~P'vOg'}Oz(OO~Og(QO~O!U(SO~Og(TOz(OO!T%dO!U%cO~P%SOk0eOl0fOm0dOn0dOo0mOp0nOgqa!Tqa!Uqa%{qa!Wqa![qa!Qqa#[qatqa!mqa~PEcOV'|Oo0cOv0qO!W&Sa~P'vOz(WO!W&Sa~O!W(XO~Oz(WO!T%dO!U%cO!W&Sa~P%SOV(]Oo0cOv0qO![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~P'vOz(^O![%}a#g%}a%[%}a%_%}ag%}a{%}a!m%}a%z%}a~O![(aO~Oz(^O!T%dO!U%cO![%}a~P%SOz(dO!T%dO!U%cO![&Ta~P%SOz(gO{&lX![&lX!m&lX%z&lX~O{(kO![(mO!m(nO%z(jO~OV&OOopOvqO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~P'vOz(pO{%hi!x%hi#g%hi%[%hi%_%hi%z%hi~O!f&UOh&sa%[&saz&sa#[&sa#g&sa%_&sa#Z&sag&sa~O%[(uO~OV#sOa#tO%uWO~Oz&]O{wa~OopOvqO~P'vOz(^O#g%}a%[%}a%_%}ag%}a{%}a![%}a!m%}a%z%}a~P%SOz(zO#g%hX%[%hX%_%hX%z%hX~O%z#|O#gUi%[Ui%_Ui~O#g&Pa%[&Pa%_&Pan&Pa~P'vOz(}O#g&Pa%[&Pa%_&Pan&Pa~O%uWO#g&ra%[&ra%_&rag&ra~Oz)SO#g&ra%[&ra%_&rag&ra~Og)VO~OV)WOh$WO%uWO~O#Z)XO~O%uWO#g&ta%[&ta%_&ta~Oz)ZO#g&ta%[&ta%_&ta~Oo0cOv0qO#g&pa%[&pa%_&pa{&pa~P'vOz)^O#g&pa%[&pa%_&pa{&pa~OV)`Oa)`O%uWO~O%z)eO~Ot)hO#j)gOP#hiV#hif#hih#hio#his#hiv#hi!P#hi!Q#hi!T#hi!U#hi!X#hi!]#hi!h#hi!r#hi!s#hi!t#hi!{#hi!}#hi#P#hi#R#hi#T#hi#X#hi#Z#hi#^#hi#_#hi#a#hi#c#hi#l#hi#o#hi#s#hi#u#hi#z#hi#}#hi$P#hi%X#hi%o#hi%p#hi%t#hi%u#hi&Z#hi&[#hi&]#hi&^#hi&_#hi&`#hi&a#hi&b#hi&c#hi&d#hi&e#hi&f#hi&g#hi&h#hi&i#hi&j#hi%Z#hi%_#hi~Ot)iOP#kiV#kif#kih#kio#kis#kiv#ki!P#ki!Q#ki!T#ki!U#ki!X#ki!]#ki!h#ki!r#ki!s#ki!t#ki!{#ki!}#ki#P#ki#R#ki#T#ki#X#ki#Z#ki#^#ki#_#ki#a#ki#c#ki#l#ki#o#ki#s#ki#u#ki#z#ki#}#ki$P#ki%X#ki%o#ki%p#ki%t#ki%u#ki&Z#ki&[#ki&]#ki&^#ki&_#ki&`#ki&a#ki&b#ki&c#ki&d#ki&e#ki&f#ki&g#ki&h#ki&i#ki&j#ki%Z#ki%_#ki~OV)kOn&wa~P'vOz)lOn&wa~Oz)lOn&wa~P%SOn)pO~O%Y)tO~Ot)wO#p'WO#q)vOP#niV#nif#nih#nio#nis#niv#ni!P#ni!Q#ni!T#ni!U#ni!X#ni!]#ni!h#ni!r#ni!s#ni!t#ni!{#ni!}#ni#P#ni#R#ni#T#ni#X#ni#Z#ni#^#ni#_#ni#a#ni#c#ni#l#ni#o#ni#s#ni#u#ni#z#ni#}#ni$P#ni%X#ni%o#ni%p#ni%t#ni%u#ni&Z#ni&[#ni&]#ni&^#ni&_#ni&`#ni&a#ni&b#ni&c#ni&d#ni&e#ni&f#ni&g#ni&h#ni&i#ni&j#ni%Z#ni%_#ni~OV)zOo0cOv0qO{$jO~P'vOo0cOv0qO{&xa~P'vOz*OO{&xa~OV*SOa*TOg*WO%q*UO%uWO~O{$jO&{*YO~Oh'_O~Oh!iO{$jO~O%[*_O~O%[*aO%_*aO~OV$}Oa$}Oo0cOv0qOg&Ua~P'vOz*dOg&Ua~Oo0cOv0qO{*gO!W&Xa~P'vOz*hO!W&Xa~Oo0cOv0qOz*hO{*kO!W&Xa~P'vOo0cOv0qOz*hO!W&Xa~P'vOz*hO{*kO!W&Xa~Om0dOn0dOo0mOp0nOgjikjisjizji!Tji!Uji%{ji!Wji{ji![ji#gji%[ji%_ji!Qji#[jitji!mji%zji~Ol0fO~P!NkOlji~P!NkOV'|Og*pOo0cOv0qO~P'vOn*rO~Og*pOz*tO~Og*uO~OV'|Oo0cOv0qO!W&Si~P'vOz*vO!W&Si~O!W*wO~OV(]Oo0cOv0qO![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~P'vOz*zO!T%dO!U%cO![&Ti~Oz*}O![%}i#g%}i%[%}i%_%}ig%}i{%}i!m%}i%z%}i~O![+OO~Oa+QOo0cOv0qO![&Ti~P'vOz*zO![&Ti~O![+SO~OV+UOo0cOv0qO{&la![&la!m&la%z&la~P'vOz+VO{&la![&la!m&la%z&la~O!]+YO&n+[O![!nX~O![+^O~O{(kO![+_O~O{(kO![+_O!m+`O~OV&OOopOvqO{%hq!x%hq#g%hq%[%hq%_%hq%z%hq~P'vOz$ri{$ri!x$ri#g$ri%[$ri%_$ri%z$ri~P%SOV&OOopOvqO~P'vOV&OOo0cOv0qO#g%ha%[%ha%_%ha%z%ha~P'vOz+aO#g%ha%[%ha%_%ha%z%ha~Oz$ia#g$ia%[$ia%_$ian$ia~P%SO#g&Pi%[&Pi%_&Pin&Pi~P'vOz+dO#g#Wq%[#Wq%_#Wq~O#[+eOz$va#g$va%[$va%_$vag$va~O%uWO#g&ri%[&ri%_&rig&ri~Oz+gO#g&ri%[&ri%_&rig&ri~OV+iOh$WO%uWO~O%uWO#g&ti%[&ti%_&ti~Oo0cOv0qO#g&pi%[&pi%_&pi{&pi~P'vO{#{Oz#eX!W#eX~Oz+mO!W&uX~O!W+oO~Ot+rO#j)gOP#hqV#hqf#hqh#hqo#hqs#hqv#hq!P#hq!Q#hq!T#hq!U#hq!X#hq!]#hq!h#hq!r#hq!s#hq!t#hq!{#hq!}#hq#P#hq#R#hq#T#hq#X#hq#Z#hq#^#hq#_#hq#a#hq#c#hq#l#hq#o#hq#s#hq#u#hq#z#hq#}#hq$P#hq%X#hq%o#hq%p#hq%t#hq%u#hq&Z#hq&[#hq&]#hq&^#hq&_#hq&`#hq&a#hq&b#hq&c#hq&d#hq&e#hq&f#hq&g#hq&h#hq&i#hq&j#hq%Z#hq%_#hq~On$|az$|a~P%SOV)kOn&wi~P'vOz+yOn&wi~Oz,TO{$jO#[,TO~O#q,VOP#nqV#nqf#nqh#nqo#nqs#nqv#nq!P#nq!Q#nq!T#nq!U#nq!X#nq!]#nq!h#nq!r#nq!s#nq!t#nq!{#nq!}#nq#P#nq#R#nq#T#nq#X#nq#Z#nq#^#nq#_#nq#a#nq#c#nq#l#nq#o#nq#s#nq#u#nq#z#nq#}#nq$P#nq%X#nq%o#nq%p#nq%t#nq%u#nq&Z#nq&[#nq&]#nq&^#nq&_#nq&`#nq&a#nq&b#nq&c#nq&d#nq&e#nq&f#nq&g#nq&h#nq&i#nq&j#nq%Z#nq%_#nq~O#[,WOz%Oa{%Oa~Oo0cOv0qO{&xi~P'vOz,YO{&xi~O{#{O%z,[Og&zXz&zX~O%uWOg&zXz&zX~Oz,`Og&yX~Og,bO~O%Y,eO~O!T%dO!U%cOg&Viz&Vi~OV$}Oa$}Oo0cOv0qOg&Ui~P'vO{,hOz$la!W$la~Oo0cOv0qO{,iOz$la!W$la~P'vOo0cOv0qO{*gO!W&Xi~P'vOz,lO!W&Xi~Oo0cOv0qOz,lO!W&Xi~P'vOz,lO{,oO!W&Xi~Og$hiz$hi!W$hi~P%SOV'|Oo0cOv0qO~P'vOn,qO~OV'|Og,rOo0cOv0qO~P'vOV'|Oo0cOv0qO!W&Sq~P'vOz$gi![$gi#g$gi%[$gi%_$gig$gi{$gi!m$gi%z$gi~P%SOV(]Oo0cOv0qO~P'vOa+QOo0cOv0qO![&Tq~P'vOz,sO![&Tq~O![,tO~OV(]Oo0cOv0qO![%}q#g%}q%[%}q%_%}qg%}q{%}q!m%}q%z%}q~P'vO{,uO~OV+UOo0cOv0qO{&li![&li!m&li%z&li~P'vOz,zO{&li![&li!m&li%z&li~O!]+YO&n+[O![!na~O{(kO![,}O~OV&OOo0cOv0qO#g%hi%[%hi%_%hi%z%hi~P'vOz-OO#g%hi%[%hi%_%hi%z%hi~O%uWO#g&rq%[&rq%_&rqg&rq~Oz-RO#g&rq%[&rq%_&rqg&rq~OV)`Oa)`O%uWO!W&ua~Oz-TO!W&ua~On$|iz$|i~P%SOV)kO~P'vOV)kOn&wq~P'vOt-XOP#myV#myf#myh#myo#mys#myv#my!P#my!Q#my!T#my!U#my!X#my!]#my!h#my!r#my!s#my!t#my!{#my!}#my#P#my#R#my#T#my#X#my#Z#my#^#my#_#my#a#my#c#my#l#my#o#my#s#my#u#my#z#my#}#my$P#my%X#my%o#my%p#my%t#my%u#my&Z#my&[#my&]#my&^#my&_#my&`#my&a#my&b#my&c#my&d#my&e#my&f#my&g#my&h#my&i#my&j#my%Z#my%_#my~O%Z-]O%_-]O~P`O#q-^OP#nyV#nyf#nyh#nyo#nys#nyv#ny!P#ny!Q#ny!T#ny!U#ny!X#ny!]#ny!h#ny!r#ny!s#ny!t#ny!{#ny!}#ny#P#ny#R#ny#T#ny#X#ny#Z#ny#^#ny#_#ny#a#ny#c#ny#l#ny#o#ny#s#ny#u#ny#z#ny#}#ny$P#ny%X#ny%o#ny%p#ny%t#ny%u#ny&Z#ny&[#ny&]#ny&^#ny&_#ny&`#ny&a#ny&b#ny&c#ny&d#ny&e#ny&f#ny&g#ny&h#ny&i#ny&j#ny%Z#ny%_#ny~Oz-aO{$jO#[-aO~Oo0cOv0qO{&xq~P'vOz-dO{&xq~O%z,[Og&zaz&za~O{#{Og&zaz&za~OV*SOa*TO%q*UO%uWOg&ya~Oz-hOg&ya~O$S-lO~OV$}Oa$}Oo0cOv0qO~P'vOo0cOv0qO{-mOz$li!W$li~P'vOo0cOv0qOz$li!W$li~P'vO{-mOz$li!W$li~Oo0cOv0qO{*gO~P'vOo0cOv0qO{*gO!W&Xq~P'vOz-pO!W&Xq~Oo0cOv0qOz-pO!W&Xq~P'vOs-sO!T%dO!U%cOg&Oq!W&Oq![&Oqz&Oq~P!/jOa+QOo0cOv0qO![&Ty~P'vOz$ji![$ji~P%SOa+QOo0cOv0qO~P'vOV+UOo0cOv0qO~P'vOV+UOo0cOv0qO{&lq![&lq!m&lq%z&lq~P'vO{(kO![-xO!m-yO%z-wO~OV&OOo0cOv0qO#g%hq%[%hq%_%hq%z%hq~P'vO%uWO#g&ry%[&ry%_&ryg&ry~OV)`Oa)`O%uWO!W&ui~Ot-}OP#m!RV#m!Rf#m!Rh#m!Ro#m!Rs#m!Rv#m!R!P#m!R!Q#m!R!T#m!R!U#m!R!X#m!R!]#m!R!h#m!R!r#m!R!s#m!R!t#m!R!{#m!R!}#m!R#P#m!R#R#m!R#T#m!R#X#m!R#Z#m!R#^#m!R#_#m!R#a#m!R#c#m!R#l#m!R#o#m!R#s#m!R#u#m!R#z#m!R#}#m!R$P#m!R%X#m!R%o#m!R%p#m!R%t#m!R%u#m!R&Z#m!R&[#m!R&]#m!R&^#m!R&_#m!R&`#m!R&a#m!R&b#m!R&c#m!R&d#m!R&e#m!R&f#m!R&g#m!R&h#m!R&i#m!R&j#m!R%Z#m!R%_#m!R~Oo0cOv0qO{&xy~P'vOV*SOa*TO%q*UO%uWOg&yi~O$S-lO%Z.VO%_.VO~OV.aOh._O!X.^O!].`O!h.YO!s.[O!t.[O%p.XO%uWO&Z]O&[]O&]]O&^]O&_]O&`]O&a]O&b]O~Oo0cOv0qOz$lq!W$lq~P'vO{.fOz$lq!W$lq~Oo0cOv0qO{*gO!W&Xy~P'vOz.gO!W&Xy~Oo0cOv.kO~P'vOs-sO!T%dO!U%cOg&Oy!W&Oy![&Oyz&Oy~P!/jO{(kO![.nO~O{(kO![.nO!m.oO~OV*SOa*TO%q*UO%uWO~Oh.tO!f.rOz$TX#[$TX%j$TXg$TX~Os$TX{$TX!W$TX![$TX~P$-bO%o.vO%p.vOs$UXz$UX{$UX#[$UX%j$UX!W$UXg$UX![$UX~O!h.xO~Oz.|O#[/OO%j.yOs&|X{&|X!W&|Xg&|X~Oa/RO~P$)zOh.tOs&}Xz&}X{&}X#[&}X%j&}X!W&}Xg&}X![&}X~Os/VO{$jO~Oo0cOv0qOz$ly!W$ly~P'vOo0cOv0qO{*gO!W&X!R~P'vOz/ZO!W&X!R~Og&RXs&RX!T&RX!U&RX!W&RX![&RXz&RX~P!/jOs-sO!T%dO!U%cOg&Qa!W&Qa![&Qaz&Qa~O{(kO![/^O~O!f.rOh$[as$[az$[a{$[a#[$[a%j$[a!W$[ag$[a![$[a~O!h/eO~O%o.vO%p.vOs$Uaz$Ua{$Ua#[$Ua%j$Ua!W$Uag$Ua![$Ua~O%j.yOs$Yaz$Ya{$Ya#[$Ya!W$Yag$Ya![$Ya~Os&|a{&|a!W&|ag&|a~P$)nOz/jOs&|a{&|a!W&|ag&|a~O!W/mO~Og/mO~O{/oO~O![/pO~Oo0cOv0qO{*gO!W&X!Z~P'vO{/sO~O%z/tO~P$-bOz/uO#[/OO%j.yOg'PX~Oz/uOg'PX~Og/wO~O!h/xO~O#[/OOs%Saz%Sa{%Sa%j%Sa!W%Sag%Sa![%Sa~O#[/OO%j.yOs%Waz%Wa{%Wa!W%Wag%Wa~Os&|i{&|i!W&|ig&|i~P$)nOz/zO#[/OO%j.yO!['Oa~Og'Pa~P$)nOz0SOg'Pa~Oa0UO!['Oi~P$)zOz0WO!['Oi~Oz0WO#[/OO%j.yO!['Oi~O#[/OO%j.yOg$biz$bi~O%z0ZO~P$-bO#[/OO%j.yOg%Vaz%Va~Og'Pi~P$)nO{0^O~Oa0UO!['Oq~P$)zOz0`O!['Oq~O#[/OO%j.yOz%Ui![%Ui~Oa0UO~P$)zOa0UO!['Oy~P$)zO#[/OO%j.yOg$ciz$ci~O#[/OO%j.yOz%Uq![%Uq~Oz+aO#g%ha%[%ha%_%ha%z%ha~P%SOV&OOo0cOv0qO~P'vOn0hO~Oo0hO~P'vO{0iO~Ot0jO~P!/jO&]&Z&j&h&i&g&f&d&e&c&b&`&a&_&^&[%u~",goto:"!=j'QPPPPPP'RP'Z*s+[+t,_,y-fP.SP'Z.r.r'ZPPP'Z2[PPPPPP2[5PPP5PP7b7k=sPP=v>h>kPP'Z'ZPP>zPP'Z'ZPP'Z'Z'Z'Z'Z?O?w'ZP?zP@QDXGuGyPG|HWH['ZPPPH_Hk'RP'R'RP'RP'RP'RP'RP'R'R'RP'RPP'RPP'RP'RPHqH}IVPI^IdPI^PI^I^PPPI^PKrPK{LVL]KrPI^LfPI^PLmLsPLwM]MzNeLwLwNkNxLwLwLwLw! ^! d! g! l! o! y!!P!!]!!o!!u!#P!#V!#s!#y!$P!$Z!$a!$g!$y!%T!%Z!%a!%k!%q!%w!%}!&T!&Z!&e!&k!&u!&{!'U!'[!'k!'s!'}!(UPPPPPPPPPPP!([!(_!(e!(n!(x!)TPPPPPPPPPPPP!-u!/Z!3^!6oPP!6w!7W!7a!8Y!8P!8c!8i!8l!8o!8r!8z!9jPPPPPPPPPPPPPPPPP!9m!9q!9wP!:]!:a!:m!:v!;S!;j!;m!;p!;v!;|!<S!<VP!<_!<h!=d!=g]eOn#g$j)t,P'}`OTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!i!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'm'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0r{!cQ#c#p$R$d$p%e%j%p%q&`'O'g(q(|)j*o*x+w,v0g}!dQ#c#p$R$d$p$u%e%j%p%q&`'O'g(q(|)j*o*x+w,v0g!P!eQ#c#p$R$d$p$u$v%e%j%p%q&`'O'g(q(|)j*o*x+w,v0g!R!fQ#c#p$R$d$p$u$v$w%e%j%p%q&`'O'g(q(|)j*o*x+w,v0g!T!gQ#c#p$R$d$p$u$v$w$x%e%j%p%q&`'O'g(q(|)j*o*x+w,v0g!V!hQ#c#p$R$d$p$u$v$w$x$y%e%j%p%q&`'O'g(q(|)j*o*x+w,v0g!Z!hQ!n#c#p$R$d$p$u$v$w$x$y$z%e%j%p%q&`'O'g(q(|)j*o*x+w,v0g'}TOTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!i!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'm'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0r&eVOYZ[dnprxy}!P!Q!U!i!k!o!p!q!s!t#[#d#g#y#{#}$Q$h$j$}%S%Z%^%`%g%l%n%w%|&Z&_&j&k&u&x'P'W'Z'l'm'p'r's'w(O(W(^(d(g(p(r(z)^)e)g)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+U+V+Y+a+d+k,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0n0r%oXOYZ[dnrxy}!P!Q!U!i!k#[#d#g#y#{#}$Q$h$j$}%S%^%`%g%l%n%w%|&Z&_&j&k&u&x'P'W'Z'l'm'p'r's'w(O(W(^(d(g(p(r(z)^)e)g)p)t)z*O*Y*d*g*h*k*q*t*v*y*z*}+U+V+Y+a+d+k,P,X,Y,],g,h,i,k,l,o,s,u,w,y,z-O-d-f-m-p.f.g/V/Z0i0j0kQ#vqQ/[.kR0o0q't`OTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0rh#jhz{$W$Z&l&q)S)X+f+g-RW#rq&].k0qQ$]|Q$a!OQ$n!VQ$o!WW$|!i'm*d,gS&[#s#tQ'S$iQ(s&UQ)U&nU)Y&s)Z+jW)a&w+m-T-{Q*Q']W*R'_,`-h.TQ+l)`S,_*S*TQ-Q+eQ-_,TQ-c,WQ.R-al.W-l.^._.a.z.|/R/j/o/t/y0U0Z0^Q/S.`Q/a.tQ/l/OU0P/u0S0[X0V/z0W0_0`R&Z#r!_!wYZ!P!Q!k%S%`%g'p'r's(O(W)g*g*h*k*q*t*v,h,i,k,l,o-m-p.f.g/ZR%^!vQ!{YQ%x#[Q&d#}Q&g$QR,{+YT.j-s/s!Y!jQ!n#c#p$R$d$p$u$v$w$x$y$z%e%j%p%q&`'O'g(q(|)j*o*x+w,v0gQ&X#kQ'c$oR*^'dR'l$|Q%V!mR/_.r'|_OTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!i!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'm'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0rS#a_#b!P.[-l.^._.`.a.t.z.|/R/j/o/t/u/y/z0S0U0W0Z0[0^0_0`'|_OTYZ[adnoprtxy}!P!Q!R!U!X!c!d!e!f!g!h!i!k!o!p!q!s!t!z#O#S#T#[#d#g#x#y#{#}$Q$e$g$h$j$q$}%S%Z%^%`%c%g%l%n%w%|&O&Z&_&h&j&k&u&x&|'P'W'Z'l'm'p'r's'w'|(O(S(W(](^(d(g(p(r(z(})^)e)g)k)l)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+Q+U+V+Y+a+c+d+k+x+y,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0l0n0rT#a_#bT#^^#_R(o%xa(l%x(n(o+`,{-y-z.oT+[(k+]R-z,{Q$PsQ+l)aQ,^*RR-e,_X#}s$O$P&fQ&y$aQ'a$nQ'd$oR)s'SQ)b&wV-S+m-T-{ZgOn$j)t,PXkOn)t,PQ$k!TQ&z$bQ&{$cQ'^$mQ'b$oQ)q'RQ)x'WQ){'XQ)|'YQ*Z'`S*]'c'dQ+s)gQ+u)hQ+v)iQ+z)oS+|)r*[Q,Q)vQ,R)wS,S)y)zQ,d*^Q-V+rQ-W+tQ-Y+{S-Z+},OQ-`,UQ-b,VQ-|-XQ.O-[Q.P-^Q.Q-_Q.p-}Q.q.RQ/W.dR/r/XWkOn)t,PR#mjQ'`$nS)r'S'aR,O)sQ,]*RR-f,^Q*['`Q+})rR-[,OZiOjn)t,PQ'f$pR*`'gT-j,e-ku.c-l.^._.a.t.z.|/R/j/o/t/u/y0S0U0Z0[0^t.c-l.^._.a.t.z.|/R/j/o/t/u/y0S0U0Z0[0^Q/S.`X0V/z0W0_0`!P.Z-l.^._.`.a.t.z.|/R/j/o/t/u/y/z0S0U0W0Z0[0^0_0`Q.w.YR/f.xg.z.].{/b/i/n/|0O0Q0]0a0bu.b-l.^._.a.t.z.|/R/j/o/t/u/y0S0U0Z0[0^X.u.W.b/a0PR/c.tV0R/u0S0[R/X.dQnOS#on,PR,P)tQ&^#uR(x&^S%m#R#wS(_%m(bT(b%p&`Q%a!yQ%h!}W(P%a%h(U(YQ(U%eR(Y%jQ&i$RR)O&iQ(e%qQ*{(`T+R(e*{Q'n%OR*e'nS'q%R%SY*i'q*j,m-q.hU*j'r's'tU,m*k*l*mS-q,n,oR.h-rQ#Y]R%t#YQ#_^R%y#_Q(h%vS+W(h+XR+X(iQ+](kR,|+]Q#b_R%{#bQ#ebQ%}#cW&Q#e%}({+bQ({&cR+b0gQ$OsS&e$O&fR&f$PQ&v$_R)_&vQ&V#jR(t&VQ&m$VS)T&m+hR+h)UQ$Z{R&p$ZQ&t$]R)[&tQ+n)bR-U+nQ#hfR&S#hQ)f&zR+q)fQ&}$dS)m&})nR)n'OQ'V$kR)u'VQ'[$lS*P'[,ZR,Z*QQ,a*VR-i,aWjOn)t,PR#ljQ-k,eR.U-kd.{.]/b/i/n/|0O0Q0]0a0bR/h.{U.s.W/a0PR/`.sQ/{/nS0X/{0YR0Y/|S/v/b/cR0T/vQ.}.]R/k.}R!ZPXmOn)t,PWlOn)t,PR'T$jYfOn$j)t,PR&R#g[sOn#g$j)t,PR&d#}&dQOYZ[dnprxy}!P!Q!U!i!k!o!p!q!s!t#[#d#g#y#{#}$Q$h$j$}%S%Z%^%`%g%l%n%w%|&Z&_&j&k&u&x'P'W'Z'l'm'p'r's'w(O(W(^(d(g(p(r(z)^)e)g)p)t)z*O*Y*d*g*h*k*q*r*t*v*y*z*}+U+V+Y+a+d+k,P,X,Y,],g,h,i,k,l,o,q,s,u,w,y,z-O-d-f-m-p-s.f.g/V/Z/s0c0d0e0f0h0i0j0k0n0rQ!nTQ#caQ#poU$Rt%c(SS$d!R$gQ$p!XQ$u!cQ$v!dQ$w!eQ$x!fQ$y!gQ$z!hQ%e!zQ%j#OQ%p#SQ%q#TQ&`#xQ'O$eQ'g$qQ(q&OU(|&h(}+cW)j&|)l+x+yQ*o'|Q*x(]Q+w)kQ,v+QR0g0lQ!yYQ!}ZQ$b!PQ$c!QQ%R!kQ't%S^'{%`%g(O(W*q*t*v^*f'p*h,k,l-p.g/ZQ*l'rQ*m'sQ+t)gQ,j*gQ,n*kQ-n,hQ-o,iQ-r,oQ.e-mR/Y.f[bOn#g$j)t,P!^!vYZ!P!Q!k%S%`%g'p'r's(O(W)g*g*h*k*q*t*v,h,i,k,l,o-m-p.f.g/ZQ#R[Q#fdS#wrxQ$UyW$_}$Q'P)pS$l!U$hW${!i'm*d,gS%v#[+Y`&P#d%|(p(r(z+a-O0kQ&a#yQ&b#{Q&c#}Q'j$}Q'z%^W([%l(^*y*}Q(`%nQ(i%wQ(v&ZS(y&_0iQ)P&jQ)Q&kU)]&u)^+kQ)d&xQ)y'WY)}'Z*O,X,Y-dQ*b'lS*n'w0jW+P(d*z,s,wW+T(g+V,y,zQ+p)eQ,U)zQ,c*YQ,x+UQ-P+dQ-e,]Q-v,uQ.S-fR/q/VhUOn#d#g$j%|&_'w(p(r)t,P%U!uYZ[drxy}!P!Q!U!i!k#[#y#{#}$Q$h$}%S%^%`%g%l%n%w&Z&j&k&u&x'P'W'Z'l'm'p'r's(O(W(^(d(g(z)^)e)g)p)z*O*Y*d*g*h*k*q*t*v*y*z*}+U+V+Y+a+d+k,X,Y,],g,h,i,k,l,o,s,u,w,y,z-O-d-f-m-p.f.g/V/Z0i0j0kQ#qpW%W!o!s0d0nQ%X!pQ%Y!qQ%[!tQ%f0cS'v%Z0hQ'x0eQ'y0fQ,p*rQ-u,qS.i-s/sR0p0rU#uq.k0qR(w&][cOn#g$j)t,PZ!xY#[#}$Q+YQ#W[Q#zrR$TxQ%b!yQ%i!}Q%o#RQ'j${Q(V%eQ(Z%jQ(c%pQ(f%qQ*|(`Q,f*bQ-t,pQ.m-uR/].lQ$StQ(R%cR*s(SQ.l-sR/}/sR#QZR#V[R%Q!iQ%O!iV*c'm*d,g!Z!lQ!n#c#p$R$d$p$u$v$w$x$y$z%e%j%p%q&`'O'g(q(|)j*o*x+w,v0gR%T!kT#]^#_Q%x#[R,{+YQ(m%xS+_(n(oQ,}+`Q-x,{S.n-y-zR/^.oT+Z(k+]Q$`}Q&g$QQ)o'PR+{)pQ$XzQ)W&qR+i)XQ$XzQ&o$WQ)W&qR+i)XQ#khW$Vz$W&q)XQ$[{Q&r$ZZ)R&l)S+f+g-RR$^|R)c&wXlOn)t,PQ$f!RR'Q$gQ$m!UR'R$hR*X'_Q*V'_V-g,`-h.TQ.d-lQ/P.^R/Q._U.]-l.^._Q/U.aQ/b.tQ/g.zU/i.|/j/yQ/n/RQ/|/oQ0O/tU0Q/u0S0[Q0]0UQ0a0ZR0b0^R/T.`R/d.t",nodeNames:"⚠ print Escape { Comment Script AssignStatement * BinaryExpression BitOp BitOp BitOp BitOp ArithOp ArithOp @ ArithOp ** UnaryExpression ArithOp BitOp AwaitExpression await ) ( ParenthesizedExpression BinaryExpression or and CompareOp in not is UnaryExpression ConditionalExpression if else LambdaExpression lambda ParamList VariableName AssignOp , : NamedExpression AssignOp YieldExpression yield from TupleExpression ComprehensionExpression async for LambdaExpression ] [ ArrayExpression ArrayComprehensionExpression } { DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression CallExpression ArgList AssignOp MemberExpression . PropertyName Number String FormatString FormatReplacement FormatSelfDoc FormatConversion FormatSpec FormatReplacement FormatSelfDoc ContinuedString Ellipsis None Boolean TypeDef AssignOp UpdateStatement UpdateOp ExpressionStatement DeleteStatement del PassStatement pass BreakStatement break ContinueStatement continue ReturnStatement return YieldStatement PrintStatement RaiseStatement raise ImportStatement import as ScopeStatement global nonlocal AssertStatement assert TypeDefinition type TypeParamList TypeParam StatementGroup ; IfStatement Body elif WhileStatement while ForStatement TryStatement try except finally WithStatement with FunctionDefinition def ParamList AssignOp TypeDef ClassDefinition class DecoratedStatement Decorator At MatchStatement match MatchBody MatchClause case CapturePattern LiteralPattern ArithOp ArithOp AsPattern OrPattern LogicOp AttributePattern SequencePattern MappingPattern StarPattern ClassPattern PatternArgList KeywordPattern KeywordPattern Guard",maxTerm:277,context:uW,nodeProps:[["isolate",-5,4,71,72,73,77,""],["group",-15,6,85,87,88,90,92,94,96,98,99,100,102,105,108,110,"Statement Statement",-22,8,18,21,25,40,49,50,56,57,60,61,62,63,64,67,70,71,72,79,80,81,82,"Expression",-10,114,116,119,121,122,126,128,133,135,138,"Statement",-9,143,144,147,148,150,151,152,153,154,"Pattern"],["openedBy",23,"(",54,"[",58,"{"],["closedBy",24,")",55,"]",59,"}"]],propSources:[uH],skippedNodes:[0,4],repeatNodeCount:34,tokenData:"!2|~R!`OX%TXY%oY[%T[]%o]p%Tpq%oqr'ars)Yst*xtu%Tuv,dvw-hwx.Uxy/tyz0[z{0r{|2S|}2p}!O3W!O!P4_!P!Q:Z!Q!R;k!R![>_![!]Do!]!^Es!^!_FZ!_!`Gk!`!aHX!a!b%T!b!cIf!c!dJU!d!eK^!e!hJU!h!i!#f!i!tJU!t!u!,|!u!wJU!w!x!.t!x!}JU!}#O!0S#O#P&o#P#Q!0j#Q#R!1Q#R#SJU#S#T%T#T#UJU#U#VK^#V#YJU#Y#Z!#f#Z#fJU#f#g!,|#g#iJU#i#j!.t#j#oJU#o#p!1n#p#q!1s#q#r!2a#r#s!2f#s$g%T$g;'SJU;'S;=`KW<%lOJU`%YT&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T`%lP;=`<%l%To%v]&n`%c_OX%TXY%oY[%T[]%o]p%Tpq%oq#O%T#O#P&o#P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To&tX&n`OY%TYZ%oZ]%T]^%o^#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc'f[&n`O!_%T!_!`([!`#T%T#T#U(r#U#f%T#f#g(r#g#h(r#h#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(cTmR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc(yT!mR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk)aV&n`&[ZOr%Trs)vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk){V&n`Or%Trs*bs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk*iT&n`&^ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To+PZS_&n`OY*xYZ%TZ]*x]^%T^#o*x#o#p+r#p#q*x#q#r+r#r;'S*x;'S;=`,^<%lO*x_+wTS_OY+rZ]+r^;'S+r;'S;=`,W<%lO+r_,ZP;=`<%l+ro,aP;=`<%l*xj,kV%rQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-XT!xY&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj-oV%lQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.]V&n`&ZZOw%Twx.rx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk.wV&n`Ow%Twx/^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/eT&n`&]ZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk/{ThZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc0cTgR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk0yXVZ&n`Oz%Tz{1f{!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk1mVaR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk2ZV%oZ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc2wTzR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To3_W%pZ&n`O!_%T!_!`-Q!`!a3w!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Td4OT&{S&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk4fX!fQ&n`O!O%T!O!P5R!P!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5WV&n`O!O%T!O!P5m!P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk5tT!rZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti6[a!hX&n`O!Q%T!Q![6T![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S6T#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti7fZ&n`O{%T{|8X|}%T}!O8X!O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8^V&n`O!Q%T!Q![8s![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti8z]!hX&n`O!Q%T!Q![8s![!l%T!l!m9s!m#R%T#R#S8s#S#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti9zT!hX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk:bX%qR&n`O!P%T!P!Q:}!Q!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj;UV%sQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti;ro!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!d%T!d!e?q!e!g%T!g!h7a!h!l%T!l!m9s!m!q%T!q!rA]!r!z%T!z!{Bq!{#R%T#R#S>_#S#U%T#U#V?q#V#X%T#X#Y7a#Y#^%T#^#_9s#_#c%T#c#dA]#d#l%T#l#mBq#m#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti=xV&n`O!Q%T!Q![6T![#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti>fc!hX&n`O!O%T!O!P=s!P!Q%T!Q![>_![!g%T!g!h7a!h!l%T!l!m9s!m#R%T#R#S>_#S#X%T#X#Y7a#Y#^%T#^#_9s#_#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti?vY&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Ti@mY!hX&n`O!Q%T!Q!R@f!R!S@f!S#R%T#R#S@f#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiAbX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBUX!hX&n`O!Q%T!Q!YA}!Y#R%T#R#SA}#S#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiBv]&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TiCv]!hX&n`O!Q%T!Q![Co![!c%T!c!iCo!i#R%T#R#SCo#S#T%T#T#ZCo#Z#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToDvV{_&n`O!_%T!_!`E]!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TcEdT%{R&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkEzT#gZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkFbXmR&n`O!^%T!^!_F}!_!`([!`!a([!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjGUV%mQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkGrV%zZ&n`O!_%T!_!`([!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkH`WmR&n`O!_%T!_!`([!`!aHx!a#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TjIPV%nQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkIoV_Q#}P&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%ToJ_]&n`&YS%uZO!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoKZP;=`<%lJUoKge&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!tJU!t!uLx!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#gLx#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUoMRa&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUkN_V&n`&`ZOr%TrsNts#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%TkNyV&n`Or%Trs! `s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! gT&n`&bZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk! }V&n`&_ZOw%Twx!!dx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!!iV&n`Ow%Twx!#Ox#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!#VT&n`&aZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!#oe&n`&YS%uZOr%Trs!%Qsw%Twx!&px!Q%T!Q![JU![!c%T!c!tJU!t!u!(`!u!}JU!}#R%T#R#SJU#S#T%T#T#fJU#f#g!(`#g#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!%XV&n`&dZOr%Trs!%ns#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!%sV&n`Or%Trs!&Ys#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&aT&n`&fZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!&wV&n`&cZOw%Twx!'^x#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!'cV&n`Ow%Twx!'xx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!(PT&n`&eZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!(ia&n`&YS%uZOr%Trs!)nsw%Twx!+^x!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!)uV&n`&hZOr%Trs!*[s#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*aV&n`Or%Trs!*vs#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!*}T&n`&jZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!+eV&n`&gZOw%Twx!+zx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,PV&n`Ow%Twx!,fx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,mT&n`&iZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!-Vi&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!dJU!d!eLx!e!hJU!h!i!(`!i!}JU!}#R%T#R#SJU#S#T%T#T#UJU#U#VLx#V#YJU#Y#Z!(`#Z#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUo!.}a&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!0ZT!XZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc!0qT!WR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj!1XV%kQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!1sO!]~k!1zV%jR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!2fO![~i!2mT%tX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T",tokenizers:[uV,uQ,u$,uF,0,1,2,3,4],topRules:{Script:[0,5]},specialized:[{term:221,get:e=>uX[e]||-1}],tokenPrec:7668});class uG{constructor(e,t,n,s){this.state=e,this.pos=t,this.explicit=n,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=aW(this.state).resolveInner(this.pos,-1);for(;t&&0>e.indexOf(t.name);)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),i=s.search(u0(e,!1));return i<0?null:{from:n+i,to:this.pos,text:s.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function uZ(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function uY(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,s]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:s}of e){t[s[0]]=!0;for(let e=1;e<s.length;e++)n[s[e]]=!0}let s=uZ(t)+uZ(n)+"*$";return[RegExp("^"+s),new RegExp(s)]}(t);return e=>{let i=e.matchBefore(s);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class uK{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function uJ(e){return e.selection.main.from}function u0(e,t){var n;let{source:s}=e,i=t&&"^"!=s[0],r="$"!=s[s.length-1];return i||r?RegExp(`${i?"^":""}(?:${s})${r?"$":""}`,null!=(n=e.flags)?n:e.ignoreCase?"i":""):e}let u1=tz.define(),u2=new WeakMap;function u5(e){if(!Array.isArray(e))return e;let t=u2.get(e);return t||u2.set(e,t=uY(e)),t}let u3=tT.define(),u4=tT.define();class u8{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=eK(e,t),s=e0(n);this.chars.push(n);let i=e.slice(t,t+s),r=i.toUpperCase();this.folded.push(eK(r==i?i.toLowerCase():r,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:s,precise:i,byWord:r}=this;if(1==t.length){let s=eK(e,0),i=e0(s),r=i==e.length?0:-100;if(s==t[0]);else{if(s!=n[0])return null;r+=-200}return this.ret(r,[0,i])}let o=e.indexOf(this.pattern);if(0==o)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(o<0){for(let i=0,r=Math.min(e.length,200);i<r&&l<a;){let r=eK(e,i);(r==t[l]||r==n[l])&&(s[l++]=i),i+=e0(r)}if(l<a)return null}let c=0,h=0,d=!1,u=0,p=-1,f=-1,m=/[a-z]/.test(e),g=!0;for(let s=0,l=Math.min(e.length,200),x=0;s<l&&h<a;){let l=eK(e,s);o<0&&(c<a&&l==t[c]&&(i[c++]=s),u<a&&(l==t[u]||l==n[u]?(0==u&&(p=s),f=s+1,u++):u=0));let b,v=l<255?l>=48&&l<=57||l>=97&&l<=122?2:+(l>=65&&l<=90):(b=eJ(l))!=b.toLowerCase()?1:2*(b!=b.toUpperCase());(!s||1==v&&m||0==x&&0!=v)&&(t[h]==l||n[h]==l&&(d=!0)?r[h++]=s:r.length&&(g=!1)),x=v,s+=e0(l)}return h==a&&0==r[0]&&g?this.result(-100+(d?-200:0),r,e):u==a&&0==p?this.ret(-200-e.length+(f==e.length?0:-100),[0,f]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):u==a?this.ret(-900-e.length,[p,f]):h==a?this.result(-100+(d?-200:0)+-700+(g?0:-1100),r,e):2==t.length?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],i=0;for(let e of t){let t=e+(this.astral?e0(eK(n,e)):1);i&&s[i-1]==e?s[i-1]=t:(s[i++]=e,s[i++]=t)}return this.ret(e-n.length,s)}}class u6{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}let u9=tr.define({combine:e=>tI(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:pe,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>u7(e(n),t(n)),optionClass:(e,t)=>n=>u7(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function u7(e,t){return e?t?e+" "+t:e:t}function pe(e,t,n,s,i,r){let o=e.textDirection==n0.RTL,a=o,l=!1,c="top",h,d,u=t.left-i.left,p=i.right-t.right,f=s.right-s.left,m=s.bottom-s.top;if(a&&u<Math.min(f,p)?a=!1:!a&&p<Math.min(f,u)&&(a=!0),f<=(a?u:p))h=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,d=Math.min(400,a?u:p);else{l=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=m||e>t.top?h=n.bottom-t.top:(c="bottom",h=t.bottom-n.top)}let g=(t.bottom-t.top)/r.offsetHeight,x=(t.right-t.left)/r.offsetWidth;return{style:`${c}: ${h/g}px; max-width: ${d/x}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}let pt=tT.define();function pn(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let s=Math.floor((e-t)/n);return{from:e-(s+1)*n,to:e-s*n}}class ps{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:i,selected:r}=s.open,o=e.state.facet(u9);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,s){let i=document.createElement("span");i.className="cm-completionLabel";let r=e.displayLabel||e.label,o=0;for(let e=0;e<s.length;){let t=s[e++],n=s[e++];t>o&&i.appendChild(document.createTextNode(r.slice(o,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(r.slice(t,n))),a.className="cm-completionMatchedText",o=n}return o<r.length&&i.appendChild(document.createTextNode(r.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=pn(i.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:s}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if("LI"==t.nodeName&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<s.length){this.applyCompletion(e,s[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains("cm-completionListIncompleteTop")&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=t&&(e.dispatch({effects:pt.of(t)}),n.preventDefault())}}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(u9).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:u4.of(null)})}),this.showOptions(i,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:i,selected:r,disabled:o}=n.open;s.open&&s.open.options==i||(this.range=pn(i.length,r,e.state.facet(u9).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),o!=(null==(t=s.open)?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=pn(t.options.length,t.selected,this.view.state.facet(u9).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:i}=s;if(!i)return;let r="string"==typeof i?document.createTextNode(i):i(s);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,s)}).catch(e=>sv(this.view.state,e,"completion info")):(this.addInfoPane(r,s),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:s}=e;n.appendChild(t),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){var t,n;let s,i,r,o=null;for(let t=this.list.firstChild,n=this.range.from;t;t=t.nextSibling,n++)"LI"==t.nodeName&&t.id?n==e?t.hasAttribute("aria-selected")||(t.setAttribute("aria-selected","true"),o=t):t.hasAttribute("aria-selected")&&(t.removeAttribute("aria-selected"),t.removeAttribute("aria-describedby")):n--;return o&&(t=this.list,n=o,s=t.getBoundingClientRect(),i=n.getBoundingClientRect(),r=s.height/t.offsetHeight,i.top<s.top?t.scrollTop-=(s.top-i.top)/r:i.bottom>s.bottom&&(t.scrollTop+=(i.bottom-s.bottom)/r)),o}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return s.top>Math.min(i.bottom,t.bottom)-10||s.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(u9).positionInfo(this.view,t,s,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){let s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",e=>{e.target==s&&e.preventDefault()});let i=null;for(let r=n.from;r<n.to;r++){let{completion:o,match:a}=e[r],{section:l}=o;if(l){let e="string"==typeof l?l:l.name;e!=i&&(r>n.from||0==n.from)&&(i=e,"string"!=typeof l&&l.header?s.appendChild(l.header(l)):s.appendChild(document.createElement("completion-section")).textContent=e)}let c=s.appendChild(document.createElement("li"));c.id=t+"-"+r,c.setAttribute("role","option");let h=this.optionClass(o);for(let e of(h&&(c.className=h),this.optionContent)){let t=e(o,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function pi(e){return 100*(e.boost||0)+10*!!e.apply+5*!!e.info+ +!!e.type}class pr{constructor(e,t,n,s,i,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=i,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new pr(this.options,pc(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,i,r){if(s&&!r&&e.some(e=>e.isPending))return s.setDisabled();let o=function(e,t){let n=[],s=null,i=null,r=e=>{n.push(e);let{section:t}=e.completion;if(t){s||(s=[]);let e="string"==typeof t?t:t.name;s.some(t=>t.name==e)||s.push("string"==typeof t?{name:e}:t)}},o=t.facet(u9);for(let s of e)if(s.hasResult()){let e=s.result.getMatch;if(!1===s.result.filter)for(let t of s.result.options)r(new uK(t,s.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(s.from,s.to),a,l=o.filterStrict?new u6(n):new u8(n);for(let t of s.result.options)if(a=l.match(t.label)){let n=t.displayLabel?e?e(t,a.matched):[]:a.matched,o=a.score+(t.boost||0);if(r(new uK(t,s.source,n,o)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;i||(i=Object.create(null)),i[e]=Math.max(o,i[e]||-1e9)}}}}if(s){let e=Object.create(null),t=0;for(let n of s.sort((e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?i[t.name]-i[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1)))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;l&&l.label==t.label&&l.detail==t.detail&&(null==l.type||null==t.type||l.type==t.type)&&l.apply==t.apply&&l.boost==t.boost?pi(e.completion)>pi(l)&&(a[a.length-1]=e):a.push(e),l=e.completion}return a}(e,t);if(!o.length)return s&&e.some(e=>e.isPending)?s.setDisabled():null;let a=t.facet(u9).selectOnOpen?0:-1;if(s&&s.selected!=a&&-1!=s.selected){let e=s.options[s.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){a=t;break}}return new pr(o,pc(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:pg,above:i.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new pr(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new pr(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class po{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new po(ph,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(u9),s=(n.override||t.languageDataAt("autocomplete",uJ(t)).map(u5)).map(t=>(this.active.find(e=>e.source==t)||new pd(t,+!!this.active.some(e=>0!=e.state))).update(e,n));s.length==this.active.length&&s.every((e,t)=>e==this.active[t])&&(s=this.active);let i=this.open,r=e.effects.some(e=>e.is(pp));for(let o of(i&&e.docChanged&&(i=i.map(e.changes)),e.selection||s.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,s=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;s<t.length&&!t[s].hasResult();)s++;let i=n==e.length,r=s==t.length;if(i||r)return i==r;if(e[n++].result!=t[s++].result)return!1}}(s,this.active)||r?i=pr.build(s,t,this.id,i,n,r):i&&i.disabled&&!s.some(e=>e.isPending)&&(i=null),!i&&s.every(e=>!e.isPending)&&s.some(e=>e.hasResult())&&(s=s.map(e=>e.hasResult()?new pd(e.source,0):e)),e.effects))o.is(pt)&&(i=i&&i.setSelected(o.value,this.id));return s==this.active&&i==this.open?this:new po(s,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?pa:pl}}let pa={"aria-autocomplete":"list"},pl={};function pc(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}let ph=[];class pd{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=function(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(u1);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:16*!!e.docChanged}(e,t),s=this;for(let t of((8&n||16&n&&this.touches(e))&&(s=new pd(s.source,0)),4&n&&0==s.state&&(s=new pd(this.source,1)),s=s.updateFor(e,n),e.effects))if(t.is(u3))s=new pd(s.source,1,t.value);else if(t.is(u4))s=new pd(s.source,0);else if(t.is(pp))for(let e of t.value)e.source==s.source&&(s=e);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(uJ(e.state))}}class pu extends pd{constructor(e,t,n,s,i,r){super(e,3,t),this.limit=n,this.result=s,this.from=i,this.to=r}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let i=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),o=uJ(e.state);if(o>r||!s||2&t&&(uJ(e.startState)==this.from||o<this.limit))return new pd(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return!function(e,t,n,s){if(!e)return!1;let i=t.sliceDoc(n,s);return"function"==typeof e?e(i,n,s,t):u0(e,!0).test(i)}(s.validFor,e.state,i,r)?s.update&&(s=s.update(s,i,r,new uG(e.state,o,!1)))?new pu(this.source,this.explicit,a,s,s.from,null!=(n=s.to)?n:uJ(e.state)):new pd(this.source,1,this.explicit):new pu(this.source,this.explicit,a,s,i,r)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new pu(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new pd(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}let pp=tT.define({map:(e,t)=>e.map(e=>e.map(t))}),pf=td.define({create:()=>po.start(),update:(e,t)=>e.update(t),provide:e=>[oc.from(e,e=>e.tooltip),ry.contentAttributes.from(e,e=>e.attrs)]});function pm(e,t){let n=t.completion.apply||t.completion.label,s=e.state.field(pf).active.find(e=>e.source==t.source);return s instanceof pu&&("string"==typeof n?e.dispatch({...function(e,t,n,s){let{main:i}=e.selection,r=n-i.from,o=s-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=s&&e.sliceDoc(a.from+r,a.from+o)!=e.sliceDoc(n,s))return{range:a};let l=e.toText(t);return{changes:{from:a.from+r,to:s==i.from?a.to:a.from+o,insert:l},range:tn.cursor(a.from+r+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}(e.state,n,s.from,s.to),annotations:u1.of(t.completion)}):n(e,t.completion,s.from,s.to),!0)}let pg=e=>new ps(e,pf,pm);function px(e,t="option"){return n=>{let s=n.state.field(pf,!1);if(!s||!s.open||s.open.disabled||Date.now()-s.open.timestamp<n.state.facet(u9).interactionDelay)return!1;let i=1,r;"page"==t&&(r=of(n,s.open.tooltip))&&(i=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=s.open.options,a=s.open.selected>-1?s.open.selected+i*(e?1:-1):e?0:o-1;return a<0?a="page"==t?0:o-1:a>=o&&(a="page"==t?o-1:0),n.dispatch({effects:pt.of(a)}),!0}}"object"==typeof navigator&&navigator.platform;let pb=ry.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class pv{constructor(e,t,n,s){this.field=e,this.line=t,this.from=n,this.to=s}}class py{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,e2.TrackDel),n=e.mapPos(this.to,1,e2.TrackDel);return null==t||null==n?null:new py(this.field,t,n)}}class pw{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],s=[t],i=e.doc.lineAt(t),r=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=r,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(a1);s.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new py(e.field,s[e.line]+e.from,s[e.line]+e.to))}}static parse(e){let t=[],n=[],s=[],i;for(let r of e.split(/\r\n?|\n/)){for(;i=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(r);){let e=i[1]?+i[1]:null,o=i[2]||i[3]||"",a=-1,l=o.replace(/\\[{}]/g,e=>e[1]);for(let n=0;n<t.length;n++)(null!=e?t[n].seq==e:l&&t[n].name==l)&&(a=n);if(a<0){let n=0;for(;n<t.length&&(null==e||null!=t[n].seq&&t[n].seq<e);)n++;for(let i of(t.splice(n,0,{seq:e,name:l}),a=n,s))i.field>=a&&i.field++}for(let e of s)if(e.line==n.length&&e.from>i.index){let t=i[2]?3+(i[1]||"").length:2;e.from-=t,e.to-=t}s.push(new pv(a,n.length,i.index,i.index+l.length)),r=r.slice(0,i.index)+o+r.slice(i.index+i[0].length)}r=r.replace(/\\([{}])/g,(e,t,i)=>{for(let e of s)e.line==n.length&&e.from>i&&(e.from--,e.to--);return t}),n.push(r)}return new pw(n,s)}}let pO=nS.widget({widget:new class extends nj{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),pk=nS.mark({class:"cm-snippetField"});class pj{constructor(e,t){this.ranges=e,this.active=t,this.deco=nS.set(e.map(e=>(e.from==e.to?pO:pk).range(e.from,e.to)),!0)}map(e){let t=[];for(let n of this.ranges){let s=n.map(e);if(!s)return null;t.push(s)}return new pj(t,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}}let pN=tT.define({map:(e,t)=>e&&e.map(t)}),pS=tT.define(),pz=td.define({create:()=>null,update(e,t){for(let n of t.effects){if(n.is(pN))return n.value;if(n.is(pS)&&e)return new pj(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>ry.decorations.from(e,e=>e?e.deco:nS.none)});function pC(e,t){return tn.create(e.filter(e=>e.field==t).map(e=>tn.range(e.from,e.to)))}function p_(e){return({state:t,dispatch:n})=>{let s=t.field(pz,!1);if(!s||e<0&&0==s.active)return!1;let i=s.active+e,r=e>0&&!s.ranges.some(t=>t.field==i+e);return n(t.update({selection:pC(s.ranges,i),effects:pN.of(r?null:new pj(s.ranges,i)),scrollIntoView:!0})),!0}}let pT=[{key:"Tab",run:p_(1),shift:p_(-1)},{key:"Escape",run:({state:e,dispatch:t})=>!!e.field(pz,!1)&&(t(e.update({effects:pN.of(null)})),!0)}],pA=tr.define({combine:e=>e.length?e[0]:pT}),pM=tp.highest(rC.compute([pA],e=>e.facet(pA)));function pP(e,t){let n;return{...t,apply:(n=pw.parse(e),(e,t,s,i)=>{let{text:r,ranges:o}=n.instantiate(e.state,s),{main:a}=e.state.selection,l={changes:{from:s,to:i==a.from?a.to:i,insert:eB.of(r)},scrollIntoView:!0,annotations:t?[u1.of(t),tA.userEvent.of("input.complete")]:void 0};if(o.length&&(l.selection=pC(o,0)),o.some(e=>e.field>0)){let t=new pj(o,0),n=l.effects=[pN.of(t)];void 0===e.state.field(pz,!1)&&n.push(tT.appendConfig.of([pz,pM,pE,pb]))}e.dispatch(e.state.update(l))})}}let pE=ry.domEventHandlers({mousedown(e,t){let n=t.state.field(pz,!1),s;if(!n||null==(s=t.posAtCoords({x:e.clientX,y:e.clientY})))return!1;let i=n.ranges.find(e=>e.from<=s&&e.to>=s);return!!i&&i.field!=n.active&&(t.dispatch({selection:pC(n.ranges,i.field),effects:pN.of(n.ranges.some(e=>e.field>i.field)?new pj(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),pR={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},pD=tT.define({map(e,t){let n=t.mapPos(e,-1,e2.TrackAfter);return null==n?void 0:n}}),p$=new class extends tL{};p$.startSide=1,p$.endSide=-1;"object"==typeof navigator&&navigator.userAgent;let pQ=new class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof an?this.setBuffer(e.context.buffer,e.index,t):e instanceof o9&&this.map.set(e.tree,t)}get(e){return e instanceof an?this.getBuffer(e.context.buffer,e.index):e instanceof o9?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},pI=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function pL(e){return(t,n,s)=>{if(s)return!1;let i=t.node.getChild("VariableName");return i&&n(i,e),!0}}let pq={FunctionDefinition:pL("function"),ClassDefinition:pL("class"),ForStatement(e,t,n){if(n){for(let n=e.node.firstChild;n;n=n.nextSibling)if("VariableName"==n.name)t(n,"variable");else if("in"==n.name)break}},ImportStatement(e,t){var n,s;let{node:i}=e,r=(null==(n=i.firstChild)?void 0:n.name)=="from";for(let e=i.getChild("import");e;e=e.nextSibling)"VariableName"==e.name&&(null==(s=e.nextSibling)?void 0:s.name)!="as"&&t(e,r?"variable":"namespace")},AssignStatement(e,t){for(let n=e.node.firstChild;n;n=n.nextSibling)if("VariableName"==n.name)t(n,"variable");else if(":"==n.name||"AssignOp"==n.name)break},ParamList(e,t){for(let n=null,s=e.node.firstChild;s;s=s.nextSibling)"VariableName"!=s.name||n&&/\*|AssignOp/.test(n.name)||t(s,"variable"),n=s},CapturePattern:pL("variable"),AsPattern:pL("variable"),__proto__:null},pB=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,pW=["String","FormatString","Comment","PropertyName"];function pV(e){let t=aW(e.state).resolveInner(e.pos,-1);if(pW.indexOf(t.name)>-1)return null;let n="VariableName"==t.name||t.to-t.from<20&&pB.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let s=[];for(let n=t;n;n=n.parent)pI.has(n.name)&&(s=s.concat(function e(t,n){let s=pQ.get(n);if(s)return s;let i=[],r=!0;function o(e,n){let s=t.sliceString(e.from,e.to);i.push({label:s,type:n})}return n.cursor(mX.IncludeAnonymous).iterate(n=>{if(n.name){let e=pq[n.name];if(e&&e(n,o,r)||!r&&pI.has(n.name))return!1;r=!1}else if(n.to-n.from>8192){for(let s of e(t,n.node))i.push(s);return!1}}),pQ.set(n,i),i}(e.state.doc,n)));return{options:s,from:n?t.from:e.pos,validFor:pB}}let pF=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(e=>({label:e,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(e=>({label:e,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(e=>({label:e,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(e=>({label:e,type:"function"}))),pH=[pP("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),pP("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),pP("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),pP("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),pP("if ${}:\n \n",{label:"if",detail:"block",type:"keyword"}),pP("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),pP("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),pP("import ${module}",{label:"import",detail:"statement",type:"keyword"}),pP("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],pX=(mH=uY(pF.concat(pH)),e=>{for(let t=aW(e.state).resolveInner(e.pos,-1);t;t=t.parent){if(pW.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return mH(e)});function pU(e){let{node:t,pos:n}=e,s=e.lineIndent(n,-1),i=null;for(;;){let r=t.childBefore(n);if(r)if("Comment"==r.name)n=r.from;else if("Body"==r.name||"MatchBody"==r.name)e.baseIndentFor(r)+e.unit<=s&&(i=r),t=r;else if("MatchClause"==r.name)t=r;else if(r.type.is("Statement"))t=r;else break;else break}return i}function pG(e,t){let n=e.baseIndentFor(t),s=e.lineAt(e.pos,-1),i=s.from+s.text.length;return/^\s*($|#)/.test(s.text)&&e.node.to<i+100&&!/\S/.test(e.state.sliceDoc(i,e.node.to))&&e.lineIndent(e.pos,-1)<=n||/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(e.textAfter)&&e.lineIndent(e.pos,-1)>n?null:n+e.unit}let pZ=aB.define({name:"python",parser:uU.configure({props:[a8.add({Body:e=>{var t;let n=/^\s*(#|$)/.test(e.textAfter)&&pU(e)||e.node;return null!=(t=pG(e,n))?t:e.continue()},MatchBody:e=>{var t;let n=pU(e);return null!=(t=pG(e,n||e.node))?t:e.continue()},IfStatement:e=>/^\s*(else:|elif )/.test(e.textAfter)?e.baseIndent:e.continue(),"ForStatement WhileStatement":e=>/^\s*else:/.test(e.textAfter)?e.baseIndent:e.continue(),TryStatement:e=>/^\s*(except[ :]|finally:|else:)/.test(e.textAfter)?e.baseIndent:e.continue(),MatchStatement:e=>/^\s*case /.test(e.textAfter)?e.baseIndent+e.unit:e.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":le({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":le({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":le({closing:"]"}),MemberExpression:e=>e.baseIndent+e.unit,"String FormatString":()=>null,Script:e=>{var t;let n=pU(e);return null!=(t=n&&pG(e,n))?t:e.continue()}}),ls.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null},Body:(e,t)=>({from:e.from+1,to:e.to-(e.to!=t.doc.length)}),"String FormatString":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function pY(){return new aJ(pZ,[pZ.data.of({autocomplete:pV}),pZ.data.of({autocomplete:pX})])}let pK="#abb2bf",pJ="#2c313a",p0="#282c34",p1="#353a42",p2="#528bff",p5=ry.theme({"&":{color:pK,backgroundColor:p0},".cm-content":{caretColor:p2},".cm-cursor, .cm-dropCursor":{borderLeftColor:p2},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:pK},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:p0,color:"#7d8799",border:"none"},".cm-activeLineGutter":{backgroundColor:pJ},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:p1},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:p1,borderBottomColor:p1},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:pJ,color:pK}}},{dark:!0});a$.keyword,a$.name,a$.deleted,a$.character,a$.propertyName,a$.macroName,a$.variableName,a$.labelName,a$.color,a$.name,a$.name,a$.name,a$.separator,a$.typeName,a$.className,a$.number,a$.changed,a$.annotation,a$.modifier,a$.self,a$.namespace,a$.operator,a$.operatorKeyword,a$.url,a$.escape,a$.regexp,a$.link,a$.string,a$.meta,a$.comment,a$.strong,a$.emphasis,a$.strikethrough,a$.link,a$.heading,a$.atom,a$.bool,a$.variableName,a$.processingInstruction,a$.string,a$.inserted,a$.invalid;let p3=lC(lj.define([{tag:a$.keyword,color:"#c792ea",fontWeight:"bold"},{tag:a$.definitionKeyword,color:"#c792ea",fontWeight:"bold"},{tag:a$.self,color:"#f78c6c",fontStyle:"italic"},{tag:a$.bool,color:"#ff9cac"},{tag:a$.null,color:"#ff9cac"},{tag:a$.definition(a$.function(a$.variableName)),color:"#82aaff",fontWeight:"bold"},{tag:a$.function(a$.variableName),color:"#82aaff"},{tag:a$.definition(a$.className),color:"#ffcb6b",fontWeight:"bold"},{tag:a$.className,color:"#ffcb6b"},{tag:a$.meta,color:"#ffa759",fontStyle:"italic"},{tag:a$.variableName,color:"#eeffff"},{tag:a$.propertyName,color:"#89ddff"},{tag:a$.string,color:"#c3e88d"},{tag:a$.special(a$.string),color:"#c3e88d"},{tag:a$.number,color:"#f78c6c"},{tag:a$.operator,color:"#89ddff"},{tag:a$.punctuation,color:"#89ddff"},{tag:a$.bracket,color:"#ffcb6b"},{tag:a$.comment,color:"#546e7a",fontStyle:"italic"},{tag:a$.special(a$.variableName),color:"#80cbc4"},{tag:a$.typeName,color:"#ffcb6b"},{tag:a$.moduleKeyword,color:"#c792ea",fontWeight:"bold"},{tag:a$.escape,color:"#f78c6c"}])),p4=["pandas","numpy","scipy","scikit-learn","matplotlib","seaborn","requests","httpx","beautifulsoup4","lxml","openpyxl","xlsxwriter","pyyaml","tabulate","jinja2","jsonschema","pillow","sympy"],p8=`# _args contains all tool arguments as a Python dict
|
|
13
|
+
# Use print() — stdout becomes the tool result
|
|
14
|
+
# JSON output is recommended: the agent can parse it
|
|
15
|
+
import json
|
|
16
|
+
|
|
17
|
+
query = _args.get("query", "")
|
|
18
|
+
|
|
19
|
+
# Your logic here
|
|
20
|
+
result = {"output": f"Processed: {query}"}
|
|
21
|
+
|
|
22
|
+
print(json.dumps(result))
|
|
23
|
+
`;function p6(e){let t=[],n=e.split("\n");return n.forEach((e,s)=>{let i=s+1,r=(e.match(/(?<!\\)'/g)||[]).filter(t=>!e.includes("'''")).length,o=(e.match(/(?<!\\)"/g)||[]).filter(t=>!e.includes('"""')).length;(r%2!=0||o%2!=0)&&t.push({line:i,message:"Possible unmatched quote",severity:"warning"}),/\barguments\b/.test(e)&&!/\b_args\b/.test(n.join("\n"))&&t.push({line:i,message:"Did you mean `_args` instead of `arguments`?",severity:"warning"}),/^\s*print\s+[^(]/.test(e)&&t.push({line:i,message:"Python 2 print statement — use print() instead",severity:"error"})}),t}function p9({draft:e,onChange:t}){let n=(0,O.useRef)(null),s=(0,O.useRef)(null),[i,r]=(0,O.useState)(!1),[o,a]=(0,O.useState)("{}"),[l,c]=(0,O.useState)(null),[h,d]=(0,O.useState)(!1),[u,p]=(0,O.useState)(null),[f,m]=(0,O.useState)([]),g=(0,O.useCallback)(n=>{m(p6(n)),t({...e,code:n})},[e,t]);(0,O.useEffect)(()=>{if(!n.current||s.current)return;let t=tQ.create({doc:e.code||p8,extensions:[ul,pY(),p5,p3,ry.updateListener.of(e=>{e.docChanged&&g(e.state.doc.toString())}),ry.theme({"&":{backgroundColor:"#09090b",height:"100%",borderRadius:"0"},".cm-scroller":{overflow:"auto",fontFamily:"monospace",fontSize:"13px"},".cm-content":{padding:"12px 0"},".cm-line":{padding:"0 16px"},"&.cm-focused .cm-cursor":{borderLeftColor:"#a855f7"},".cm-selectionBackground":{backgroundColor:"#3f3f46"},"&.cm-focused .cm-selectionBackground":{backgroundColor:"#4f46e5"}})]});return s.current=new ry({state:t,parent:n.current}),m(p6(e.code||p8)),()=>{s.current?.destroy(),s.current=null}},[]);let[x,b]=(0,O.useState)(()=>JSON.stringify(e.inputSchema||{type:"object",properties:{input:{type:"string"}}},null,2)),[v,y]=(0,O.useState)(null),k=async()=>{if(!e.code.trim())return;d(!0),c(null),p(null);let t={};try{t=JSON.parse(o||"{}")}catch{p("Test Args must be valid JSON"),d(!1);return}try{let n=await fetch("/api/tools/python/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e.code,args:t,timeout:30})});if(!n.ok){let e=await n.json();p(e.detail||"Test run failed");return}let s=await n.json();c(s)}catch(e){p(e.message||"Network error")}finally{d(!1)}};return(0,w.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,w.jsxs)("div",{className:"bg-zinc-950 border border-violet-900/40 rounded-sm p-3 space-y-2",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 text-xs font-bold text-violet-400 uppercase tracking-wider",children:[(0,w.jsx)(eM,{className:"h-3.5 w-3.5"}),"Python Sandbox"]}),(0,w.jsxs)("button",{onClick:()=>r(e=>!e),className:"text-[10px] text-zinc-500 hover:text-zinc-300 flex items-center gap-1",children:[i?(0,w.jsx)(eT,{className:"h-3 w-3"}):(0,w.jsx)(ei.ChevronDown,{className:"h-3 w-3"}),i?"Hide":"Show"," packages"]})]}),(0,w.jsxs)("p",{className:"text-[11px] text-zinc-500 leading-relaxed",children:["Code runs in a ",(0,w.jsx)("span",{className:"text-violet-400 font-mono",children:"Docker sandbox"})," (512MB RAM, 1 CPU, no network). Vault files are mounted at ",(0,w.jsx)("span",{className:"font-mono text-violet-300",children:"/data/"}),". Arguments are injected as ",(0,w.jsx)("span",{className:"font-mono text-violet-300",children:"_args"})," (dict).",(0,w.jsx)("span",{className:"font-mono text-zinc-400",children:" print()"})," stdout becomes the tool result."]}),i&&(0,w.jsx)("div",{className:"flex flex-wrap gap-1.5 pt-1 border-t border-zinc-800",children:p4.map(e=>(0,w.jsx)("span",{className:"text-[10px] font-mono bg-zinc-900 border border-zinc-700 text-zinc-400 px-1.5 py-0.5 rounded",children:e},e))})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Python Code"}),f.length>0&&(0,w.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-amber-400",children:[(0,w.jsx)(X,{className:"h-3 w-3"}),f.length," warning",f.length>1?"s":""]})]}),(0,w.jsx)("div",{ref:n,className:"min-h-[280px] h-[280px] overflow-hidden border border-zinc-800 focus-within:border-violet-600 transition-colors rounded-sm"}),f.length>0&&(0,w.jsx)("div",{className:"space-y-1 pt-1",children:f.map((e,t)=>(0,w.jsxs)("div",{className:`flex items-start gap-2 text-[10px] font-mono ${"error"===e.severity?"text-red-400":"text-amber-400"}`,children:[(0,w.jsx)(X,{className:"h-3 w-3 mt-0.5 shrink-0"}),(0,w.jsxs)("span",{children:["Line ",e.line,": ",e.message]})]},t))})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Input Schema (JSON)"}),(0,w.jsx)("textarea",{value:x,onChange:n=>(n=>{b(n);try{let s=JSON.parse(n);y(null),t({...e,inputSchema:s})}catch{y("Invalid JSON")}})(n.target.value),className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-[10px] font-mono text-zinc-300 focus:border-violet-600 focus:outline-none resize-none min-h-[140px]",placeholder:'{"type": "object", "properties": {"query": {"type": "string", "description": "The input query"}}}'}),v&&(0,w.jsxs)("p",{className:"text-[10px] text-red-400 flex items-center gap-1",children:[(0,w.jsx)(X,{className:"h-3 w-3 shrink-0"})," ",v]})]}),(0,w.jsxs)("div",{className:"space-y-2 border-t border-zinc-800 pt-4",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsxs)("label",{className:"text-[10px] uppercase font-bold text-zinc-500 flex items-center gap-2",children:[(0,w.jsx)(eA.Terminal,{className:"h-3.5 w-3.5"}),"Test Run"]}),(0,w.jsx)("span",{className:"text-[10px] text-zinc-600",children:"Runs in Docker sandbox"})]}),(0,w.jsxs)("div",{className:"flex gap-2 items-start",children:[(0,w.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,w.jsx)("label",{className:"text-[9px] text-zinc-600 uppercase tracking-wider",children:"Test Arguments (JSON)"}),(0,w.jsx)("textarea",{value:o,onChange:e=>a(e.target.value),rows:2,className:"w-full bg-zinc-950 border border-zinc-800 p-2 text-xs font-mono text-zinc-300 focus:border-violet-600 focus:outline-none resize-none",placeholder:'{"query": "hello world"}'})]}),(0,w.jsx)("button",{onClick:k,disabled:h||!e.code.trim(),className:"flex items-center gap-2 px-4 py-2 bg-violet-700 hover:bg-violet-600 disabled:bg-zinc-800 disabled:text-zinc-600 text-white text-xs font-bold transition-colors mt-4 shrink-0",children:h?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Running..."]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(e_,{className:"h-3.5 w-3.5"})," Run"]})})]}),u&&(0,w.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-red-950/40 border border-red-800 text-red-400 text-[11px]",children:[(0,w.jsx)(X,{className:"h-4 w-4 shrink-0"}),u]}),l&&(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[0===l.exit_code?(0,w.jsx)(U,{className:"h-4 w-4 text-green-500"}):(0,w.jsx)(X,{className:"h-4 w-4 text-red-500"}),(0,w.jsxs)("span",{className:`text-[11px] font-bold ${0===l.exit_code?"text-green-400":"text-red-400"}`,children:["Exit code: ",l.exit_code]})]}),l.stdout&&(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("p",{className:"text-[9px] uppercase tracking-wider text-zinc-500",children:"stdout"}),(0,w.jsx)("pre",{className:"p-3 bg-zinc-950 border border-zinc-800 text-[11px] font-mono text-green-300 overflow-auto max-h-48 whitespace-pre-wrap",children:l.stdout})]}),l.stderr&&(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("p",{className:"text-[9px] uppercase tracking-wider text-zinc-500",children:"stderr"}),(0,w.jsx)("pre",{className:"p-3 bg-zinc-950 border border-red-900/40 text-[11px] font-mono text-red-300 overflow-auto max-h-32 whitespace-pre-wrap",children:l.stderr})]})]})]})]})}let p7=({customTools:e,draftTool:t,setDraftTool:n,toolBuilderMode:s,setToolBuilderMode:i,headerRows:r,setHeaderRows:o,n8nWorkflows:a,n8nWorkflowsLoading:l,n8nWorkflowId:c,setN8nWorkflowId:h,getN8nBaseUrl:d,onSaveTool:u,onDeleteTool:p,n8nIntegrated:f})=>{let[m,g]=(0,O.useState)(null),[x,b]=(0,O.useState)(!1),[v,y]=(0,O.useState)(!1),[k,N]=(0,O.useState)(null),S=(0,O.useCallback)(async()=>{b(!0);try{let e=await fetch("/api/tools/docker/status");e.ok&&g(await e.json())}finally{b(!1)}},[]),z=async()=>{y(!0),N(null);try{let e=await fetch("/api/tools/docker/build",{method:"POST"});if(e.ok)await S();else{let t=await e.json();N(t.detail||"Build failed")}}catch(e){N(String(e))}finally{y(!1)}};return(0,O.useEffect)(()=>{S()},[S]),(0,w.jsx)("div",{className:"flex flex-col min-h-[600px]",children:t?(0,w.jsxs)("div",{className:"flex flex-col h-full",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between mb-4 pb-4 border-b border-zinc-800",children:[(0,w.jsxs)("div",{className:"flex items-center gap-4",children:[(0,w.jsx)("button",{onClick:()=>{n(null),i("config")},className:"text-zinc-500 hover:text-white",children:(0,w.jsx)(eN.X,{className:"h-5 w-5"})}),(0,w.jsx)("h3",{className:"font-bold text-white uppercase tracking-wider",children:t.name?`Editing: ${t.name}`:"New Tool Builder"})]}),(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsxs)("div",{className:"flex bg-zinc-900 border border-zinc-800 p-1 rounded gap-0.5",children:[(0,w.jsx)("button",{onClick:()=>{if("python"===t.tool_type){let e={type:"object",properties:{input:{type:"string"}}};n({...t,tool_type:"http",url:t.url||"",method:t.method||"POST",inputSchema:e,inputSchemaStr:JSON.stringify(e,null,2),outputSchemaStr:""}),o([{id:"h1",key:"",value:""}])}i("config")},className:`px-3 py-1 text-xs font-bold rounded ${"config"===s?"bg-zinc-700 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"CONFIG"}),(0,w.jsx)("button",{onClick:()=>{if("python"!==t.tool_type){let e=`# _args contains all tool arguments as a Python dict
|
|
24
|
+
# print() stdout becomes the tool result
|
|
25
|
+
import json
|
|
26
|
+
|
|
27
|
+
result = {"output": _args.get("input", "")}
|
|
28
|
+
print(json.dumps(result))
|
|
29
|
+
`;n({...t,tool_type:"python",code:t.code||e,inputSchema:{type:"object",properties:{input:{type:"string"}}},schemaParams:t.schemaParams||[{id:"p1",name:"input",type:"string",description:"The input value",required:!1}]})}i("python")},className:`px-3 py-1 text-xs font-bold rounded ${"python"===s?"bg-violet-700 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"🐍 PYTHON"})]}),(0,w.jsx)("button",{onClick:u,className:"px-4 py-1.5 bg-white text-black text-xs font-bold hover:bg-zinc-200",children:"SAVE"})]})]}),(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"General Name"}),(0,w.jsx)("input",{type:"text",value:t.generalName||"",onChange:e=>{let s=e.target.value,i={...t,generalName:s};t.name||(i.name=s.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")),n(i)},className:"w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none placeholder:text-zinc-700",placeholder:"e.g. Process Orders"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"System Name (Snake Case)"}),(0,w.jsx)("input",{type:"text",value:t.name,onChange:e=>n({...t,name:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none font-mono placeholder:text-zinc-700",placeholder:"e.g. process_orders"})]})]}),(0,w.jsxs)("div",{className:"space-y-1 mb-5",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Description (For AI)"}),(0,w.jsx)("textarea",{value:t.description,onChange:e=>n({...t,description:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none resize-vertical min-h-[80px]",placeholder:"What does this tool do? Describe its purpose and critical rules for the AI..."})]}),"config"===s&&(0,w.jsxs)("div",{className:"space-y-5 pr-2",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Method"}),(0,w.jsxs)("select",{value:t.method,onChange:e=>n({...t,method:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none",children:[(0,w.jsx)("option",{children:"POST"}),(0,w.jsx)("option",{children:"GET"})]})]}),f&&(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"n8n Workflow"}),(0,w.jsxs)("select",{value:t.workflowId||"",onChange:async e=>{let s=e.target.value;if(n({...t,workflowId:s}),h(s||null),s)try{let e=await fetch(`/api/n8n/workflows/${s}/webhook`);if(!e.ok)return;let i=await e.json();i?.productionUrl&&n({...t,workflowId:s,url:i.productionUrl})}catch{}},className:"w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none",children:[(0,w.jsx)("option",{value:"",children:l?"Loading workflows...":"Select a workflow (optional)"}),Array.isArray(a)&&a.map(e=>(0,w.jsx)("option",{value:String(e.id),children:e.name||e.id},String(e.id)))]}),t.workflowId?(0,w.jsxs)("a",{href:`${d()}/workflow/${t.workflowId}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-[#ff6d5a] hover:text-[#ff8a78] hover:underline mt-1",children:["Open workflow in n8n ",(0,w.jsx)(eh.ExternalLink,{className:"h-3 w-3"})]}):(0,w.jsxs)("a",{href:`${d()}/workflow/new`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-zinc-500 hover:text-zinc-300 hover:underline mt-1",children:["Create new workflow in n8n ",(0,w.jsx)(eh.ExternalLink,{className:"h-3 w-3"})]})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Webhook URL"}),!f&&(0,w.jsxs)("span",{className:"text-[9px] text-zinc-600",children:["(you can also"," ",(0,w.jsx)("a",{href:"/settings/workspace",className:"text-[#ff6d5a] hover:underline",children:"integrate n8n workflows"}),")"]})]}),(0,w.jsx)("input",{type:"text",value:t.url,onChange:e=>n({...t,url:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none font-mono",placeholder:"https://example.com/webhook/..."})]}),(0,w.jsxs)("div",{className:"space-y-2 pt-2",children:[(0,w.jsxs)("div",{className:"flex justify-between items-end mb-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Headers"}),(0,w.jsx)("button",{onClick:()=>o([...r,{id:`h-${Date.now()}`,key:"",value:""}]),className:"text-[10px] text-zinc-400 hover:text-white font-bold bg-zinc-800 px-2 py-1 rounded transition-colors",children:"+ ADD HEADER"})]}),r.map((e,t)=>(0,w.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,w.jsx)("input",{type:"text",placeholder:"Key (e.g. Authorization)",value:e.key,onChange:e=>{let n=[...r];n[t].key=e.target.value,o(n)},className:"flex-1 bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none font-mono"}),(0,w.jsx)("input",{type:"text",placeholder:"Value",value:e.value,onChange:e=>{let n=[...r];n[t].value=e.target.value,o(n)},className:"flex-1 bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none font-mono"}),(0,w.jsx)("button",{onClick:()=>o(r.filter(t=>t.id!==e.id)),className:"p-2 text-zinc-600 hover:text-red-500 transition-colors",children:(0,w.jsx)(j.Trash,{className:"h-4 w-4"})})]},e.id))]}),(0,w.jsxs)("div",{className:"space-y-1 flex flex-col min-h-[280px]",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Input Schema (JSON)"}),(0,w.jsx)("textarea",{value:t.inputSchemaStr,onChange:e=>n({...t,inputSchemaStr:e.target.value}),className:"w-full flex-1 bg-zinc-950 border border-zinc-800 p-3 text-[10px] font-mono text-zinc-300 focus:border-white focus:outline-none resize-none",placeholder:'{"type": "object", "properties": {"msg": {"type": "string"}}}'})]})]}),"python"===s&&(0,w.jsxs)("div",{className:"flex flex-col gap-4",children:[x&&!m?(0,w.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-zinc-900 border border-zinc-800 rounded text-xs text-zinc-500",children:[(0,w.jsx)(ez.RefreshCw,{className:"h-3.5 w-3.5 animate-spin shrink-0"}),"Checking Docker status..."]}):m&&(m.installed&&m.running&&m.image_exists&&!k?(0,w.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-950/30 border border-green-800/40 rounded text-xs text-green-400",children:[(0,w.jsx)(U,{className:"h-3.5 w-3.5 shrink-0"}),"Docker sandbox is ready",(0,w.jsx)("button",{onClick:S,disabled:x,className:"ml-auto text-green-700 hover:text-green-400 disabled:opacity-50",children:(0,w.jsx)(ez.RefreshCw,{className:`h-3 w-3 ${x?"animate-spin":""}`})})]}):(0,w.jsxs)("div",{className:"p-3 bg-amber-950/30 border border-amber-700/50 rounded space-y-2",children:[(0,w.jsxs)("div",{className:"flex items-start gap-2",children:[(0,w.jsx)(eS,{className:"h-4 w-4 text-amber-400 shrink-0 mt-0.5"}),(0,w.jsxs)("div",{className:"flex-1 space-y-1",children:[!m.installed&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("p",{className:"text-xs font-semibold text-amber-300",children:"Docker is not installed"}),(0,w.jsx)("p",{className:"text-xs text-amber-500/80",children:"Python tools run in a Docker sandbox. Install Docker Desktop to use them."}),(0,w.jsxs)("a",{href:"https://docs.docker.com/get-docker/",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-amber-400 hover:text-amber-200 underline",children:["Install Docker Desktop ",(0,w.jsx)(eh.ExternalLink,{className:"h-3 w-3"})]})]}),m.installed&&!m.running&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("p",{className:"text-xs font-semibold text-amber-300",children:"Docker is not running"}),(0,w.jsx)("p",{className:"text-xs text-amber-500/80",children:"Start Docker Desktop, then refresh the status."})]}),m.installed&&m.running&&!m.image_exists&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("p",{className:"text-xs font-semibold text-amber-300",children:"Python sandbox image not built"}),(0,w.jsx)("p",{className:"text-xs text-amber-500/80",children:"The sandbox image needs to be built once. This downloads Python and installs packages (~2–3 min)."})]}),k&&(0,w.jsx)("p",{className:"text-xs text-red-400 font-mono whitespace-pre-wrap mt-1",children:k})]}),(0,w.jsx)("button",{onClick:S,disabled:x,className:"text-amber-700 hover:text-amber-400 shrink-0 disabled:opacity-50",children:(0,w.jsx)(ez.RefreshCw,{className:`h-3.5 w-3.5 ${x?"animate-spin":""}`})})]}),m.installed&&m.running&&!m.image_exists&&(0,w.jsxs)("button",{onClick:z,disabled:v,className:"flex items-center gap-2 px-3 py-1.5 bg-amber-700 hover:bg-amber-600 disabled:opacity-50 text-white text-xs font-bold transition-colors rounded",children:[(0,w.jsx)(eC,{className:"h-3.5 w-3.5"}),v?"Building… (this may take a few minutes)":"Build Sandbox Image"]})]})),(0,w.jsx)(p9,{draft:t,onChange:e=>n(e)})]})]}):(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"flex justify-between items-center",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:[(0,w.jsx)(T.Wrench,{className:"h-5 w-5"})," Custom Tools"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm",children:"Extend your agent with n8n webhooks, HTTP endpoints, or Python functions."})]}),(0,w.jsxs)("button",{onClick:()=>{let e={type:"object",properties:{input:{type:"string"}}};n({name:"",generalName:"",description:"",url:"",method:"POST",inputSchema:e,inputSchemaStr:JSON.stringify(e,null,2),outputSchemaStr:"",tool_type:"http"}),o([{id:"h1",key:"",value:""}]),i("config")},className:"px-3 py-2 bg-zinc-800 border border-zinc-700 text-zinc-300 font-bold text-xs uppercase flex items-center gap-2 hover:bg-zinc-700 hover:text-white transition-colors",children:[(0,w.jsx)(en.Plus,{className:"h-4 w-4"})," New Tool"]})]}),(0,w.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.map(e=>(0,w.jsxs)("div",{className:`p-4 border hover:border-zinc-600 transition-all group relative ${"python"===e.tool_type?"bg-violet-950/10 border-violet-900/30 hover:border-violet-700/50":"bg-zinc-900 border-zinc-800"}`,children:[(0,w.jsxs)("div",{className:"font-bold text-white mb-1 flex items-center gap-2 pr-10",children:[(0,w.jsx)("span",{className:"truncate",children:e.generalName||e.name}),"python"===e.tool_type?(0,w.jsx)("span",{className:"text-[9px] font-bold bg-violet-900/40 border border-violet-700 text-violet-400 px-1.5 py-0.5 rounded",children:"🐍 PYTHON"}):e.workflowId||e.url?.includes("webhook")?(0,w.jsx)("span",{className:"text-[9px] font-bold bg-orange-900/30 border border-orange-700/50 text-orange-400 px-1.5 py-0.5 rounded",children:"n8n"}):(0,w.jsx)("span",{className:"text-[9px] font-bold bg-zinc-800 border border-zinc-700 text-zinc-400 px-1.5 py-0.5 rounded",children:"HTTP"})]}),e.generalName&&(0,w.jsxs)("div",{className:"text-[9px] text-zinc-500 font-mono mb-1",children:["(",e.name,")"]}),(0,w.jsx)("div",{className:"text-xs text-zinc-500 mb-2 h-8 overflow-hidden",children:e.description}),"python"===e.tool_type?(0,w.jsx)("div",{className:"text-[10px] font-mono text-violet-600",children:"🐍 Python sandboxed function"}):(0,w.jsx)("div",{className:"text-[10px] font-mono text-zinc-600 truncate",children:e.url}),(0,w.jsx)("button",{onClick:()=>p(e.name),className:"absolute top-2 right-2 p-1 text-zinc-600 hover:text-red-500 opacity-0 group-hover:opacity-100",children:(0,w.jsx)(j.Trash,{className:"h-4 w-4"})}),(0,w.jsx)("button",{onClick:()=>{if("python"===e.tool_type)n({...e,schemaParams:e.schemaParams||[]}),i("python");else{n({...e,inputSchemaStr:JSON.stringify(e.inputSchema||{},null,2),outputSchemaStr:e.outputSchema?JSON.stringify(e.outputSchema,null,2):""});let t=Object.entries(e.headers||{}).map(([e,t],n)=>({id:`h-${n}`,key:e,value:t}));o(t.length?t:[{id:"h1",key:"",value:""}]),i("config")}},className:"absolute bottom-2 right-2 text-[10px] text-zinc-400 hover:text-white font-bold uppercase",children:"Edit"})]},e.name)),0===e.length&&(0,w.jsx)("div",{className:"col-span-full py-12 text-center text-zinc-600 italic text-sm border border-dashed border-zinc-800",children:"No custom tools yet. Create an HTTP, n8n webhook, or Python tool."})]})]})})},fe=({dlTopic:e,setDlTopic:t,dlCount:n,setDlCount:s,dlProvider:i,setDlProvider:r,dlSystemPrompt:o,setDlSystemPrompt:a,dlEdgeCases:l,setDlEdgeCases:c,dlStatus:h,dlDatasets:d,onGenerate:u})=>(0,w.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 h-full",children:[(0,w.jsx)("div",{className:"space-y-6 overflow-y-auto pr-2",children:(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Domain / Topic"}),(0,w.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none",placeholder:"e.g. Medical Assistant, Python Coding Tutor"})]}),(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Count"}),(0,w.jsx)("input",{type:"number",value:n,onChange:e=>s(parseInt(e.target.value)),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none",min:1,max:100})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Provider"}),(0,w.jsxs)("select",{value:i,onChange:e=>r(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none appearance-none",children:[(0,w.jsx)("option",{value:"openai",children:"OpenAI (GPT-4o)"}),(0,w.jsx)("option",{value:"gemini",children:"Gemini (1.5 Pro)"})]})]})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Target Persona (System Prompt)"}),(0,w.jsx)("textarea",{value:o,onChange:e=>a(e.target.value),className:"w-full h-24 bg-zinc-900 border border-zinc-800 p-3 text-xs font-mono text-zinc-300 focus:border-white focus:outline-none resize-none"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Edge Cases & Constraints"}),(0,w.jsx)("textarea",{value:l,onChange:e=>c(e.target.value),className:"w-full h-24 bg-zinc-900 border border-zinc-800 p-3 text-xs font-mono text-zinc-300 focus:border-white focus:outline-none resize-none",placeholder:"e.g. 'If user asks for illegal advice, politely refuse.' or 'Always include code comments.'"})]}),(0,w.jsx)("button",{onClick:u,disabled:h?.status==="generating",className:"w-full py-4 bg-white text-black font-bold text-sm tracking-uppercase hover:bg-zinc-200 disabled:opacity-50 disabled:cursor-not-allowed",children:h?.status==="generating"?"GENERATING...":"START GENERATION JOB"})]})}),(0,w.jsxs)("div",{className:"bg-zinc-950 border border-zinc-800 p-6 flex flex-col h-full",children:[(0,w.jsxs)("h3",{className:"text-sm font-bold text-zinc-400 mb-4 flex items-center justify-between",children:[(0,w.jsx)("span",{children:"DATASETS"}),h?.status==="generating"&&(0,w.jsxs)("span",{className:"text-green-500 text-xs animate-pulse",children:["Running: ",h.completed,"/",h.total]}),h?.status==="failed"&&(0,w.jsxs)("span",{className:"text-red-500 text-xs",children:["Failed: ",h.error]})]}),(0,w.jsx)("div",{className:"flex-1 overflow-y-auto space-y-2",children:0===d.length?(0,w.jsx)("div",{className:"text-center py-10 text-zinc-600 text-xs italic",children:"No datasets generated yet."}):d.map(e=>(0,w.jsxs)("div",{className:"p-3 bg-black border border-zinc-800 flex justify-between items-center group hover:border-zinc-600",children:[(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("div",{className:"text-xs text-white font-mono truncate mb-1",children:e.filename}),(0,w.jsxs)("div",{className:"text-[10px] text-zinc-500 flex gap-2",children:[(0,w.jsxs)("span",{children:[(e.size/1024).toFixed(1)," KB"]}),(0,w.jsx)("span",{children:"•"}),(0,w.jsx)("span",{children:new Date(e.created).toLocaleDateString()})]})]}),(0,w.jsx)(z.Database,{className:"h-4 w-4 text-zinc-600 group-hover:text-zinc-400"})]},e.filename))})]})]}),ft=(0,H.default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),fn=(0,H.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),fs=({className:e})=>(0,w.jsx)("img",{src:"/ollama-icon.svg",className:`${e} theme-adaptive-icon`,alt:"Ollama"}),fi=({className:e})=>(0,w.jsx)("img",{src:"/google-gemini-icon.svg",className:e,alt:"Google Gemini"}),fr=({className:e})=>(0,w.jsx)("img",{src:"/claude-ai-icon.svg",className:e,alt:"Anthropic Claude"}),fo=({className:e})=>(0,w.jsx)("img",{src:"/chatgpt-icon.svg",className:e,alt:"OpenAI"}),fa=({className:e})=>(0,w.jsx)(eA.Terminal,{className:e}),fl={ollama:{label:"Ollama (Local)",icon:fs,color:"#22c55e",description:"Runs locally on your machine. Private, free, no API key needed."},gemini:{label:"Google Gemini",icon:fi,color:"#4285f4",description:"Google AI models. Fast and capable, with a generous free tier.",keyPlaceholder:"AIza...",keyLink:{label:"Get a free key at Google AI Studio →",url:"https://aistudio.google.com/app/apikey"},keyNote:"Free tier available. Key starts with AIza..."},anthropic:{label:"Anthropic Claude",icon:fr,color:"#d97706",description:"Advanced reasoning and analysis via Claude models.",keyPlaceholder:"sk-ant-...",keyLink:{label:"Get your key at Anthropic Console →",url:"https://console.anthropic.com/settings/keys"},keyNote:"Key starts with sk-ant-api03-..."},openai:{label:"OpenAI",icon:fo,color:"#10b981",description:"GPT-4o and latest OpenAI models.",keyPlaceholder:"sk-...",keyLink:{label:"Get your key at OpenAI Platform →",url:"https://platform.openai.com/api-keys"},keyNote:"Key starts with sk-proj-... or sk-..."},grok:{label:"xAI Grok",icon:({className:e})=>(0,w.jsx)("img",{src:"/grok-icon.svg",className:e,alt:"Grok"}),color:"#e5e7eb",description:"Grok-3 and frontier reasoning models from Elon Musk's AI lab, xAI.",keyPlaceholder:"xai-...",keyLink:{label:"Get your key at xAI Console →",url:"https://console.x.ai/"},keyNote:"Key starts with xai-..."},deepseek:{label:"DeepSeek",icon:({className:e})=>(0,w.jsx)("img",{src:"/deepseek-logo-icon.svg",className:e,alt:"DeepSeek"}),color:"#4f6ef7",description:"DeepSeek-V3 (chat + tools) and DeepSeek-R1 (powerful chain-of-thought reasoning).",keyPlaceholder:"sk-...",keyLink:{label:"Get your key at DeepSeek Platform →",url:"https://platform.deepseek.com/api_keys"},keyNote:"Note: deepseek-reasoner (R1) does not support tool/function calling."},openai_compatible:{label:"OpenAI Compatible",icon:fo,color:"#f97316",description:"Any OpenAI v1-compatible cloud provider (OpenRouter, Together, Fireworks, etc.).",keyPlaceholder:"sk-...",keyNote:"Enter your API key, base URL, and model names below."},local_compatible:{label:"Local V1 Compatible",icon:fs,color:"#06b6d4",description:"Any local OpenAI v1-compatible server (vLLM, LM Studio, llama.cpp server, etc.).",keyNote:"Enter your base URL and model names below. API key is optional."},bedrock:{label:"AWS Bedrock",icon:({className:e})=>(0,w.jsx)("img",{src:"/aws-bedrock-icon.svg",className:e,alt:"AWS Bedrock"}),color:"#f59e0b",description:"Enterprise-grade models via AWS, including Claude, Llama, and Titan.",keyPlaceholder:"ABSK... or bedrock-api-key...",keyLink:{label:"Set up Bedrock API keys in AWS Console →",url:"https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-generate.html#api-keys-generate-console"},keyNote:"Supports long-term keys (ABSK...) and temporary keys (bedrock-api-key...). Bearer prefix is auto-normalized."},anthropic_cli:{label:"Claude (CLI)",icon:fr,color:"#d97706",description:"Use the locally installed Anthropic Claude CLI. No API key needed — uses your existing terminal session."},gemini_cli:{label:"Gemini (CLI)",icon:fi,color:"#4285f4",description:"Use the locally installed Google Gemini CLI. No API key needed — uses your existing terminal session."},codex_cli:{label:"Codex (CLI)",icon:fa,color:"#a78bfa",description:"Use the locally installed OpenAI Codex CLI agent. No API key needed — uses your existing terminal session."},github_copilot_cli:{label:"GitHub Copilot (CLI)",icon:fa,color:"#8957e5",description:"Use the locally installed GitHub Copilot CLI. No API key needed — uses your existing GitHub session."}},fc=({providers:e,selectedModel:t,setSelectedModel:n,embeddingModel:s,setEmbeddingModel:i,openaiKey:r,setOpenaiKey:o,anthropicKey:a,setAnthropicKey:l,geminiKey:c,setGeminiKey:h,grokKey:d,setGrokKey:u,deepseekKey:p,setDeepseekKey:f,bedrockApiKey:m,setBedrockApiKey:g,awsRegion:x,setAwsRegion:b,bedrockInferenceProfile:v,setBedrockInferenceProfile:y,bedrockInferenceProfiles:k,loadingInferenceProfiles:j,inferenceProfilesError:N,loadingModels:S,onExpandBedrock:z,onSave:C,isSaving:_,mode:T,setMode:A,localModels:M,cloudModels:P,filteredModels:E,openaiCompatibleKey:R,setOpenaiCompatibleKey:D,openaiCompatibleBaseUrl:$,setOpenaiCompatibleBaseUrl:Q,openaiCompatibleModels:I,setOpenaiCompatibleModels:L,openaiCompatibleEmbedModels:q,setOpenaiCompatibleEmbedModels:W,localCompatibleBaseUrl:V,setLocalCompatibleBaseUrl:F,localCompatibleKey:H,setLocalCompatibleKey:X,localCompatibleModels:U,setLocalCompatibleModels:G,localCompatibleEmbedModels:Z,setLocalCompatibleEmbedModels:Y})=>{let[K,J]=(0,O.useState)(null),ee=[];return Object.entries(e).forEach(([,e])=>{e.available&&ee.push(...e.models)}),(0,w.jsxs)("div",{className:"space-y-8",children:[(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Providers"}),(0,w.jsx)("div",{className:"space-y-3",children:Object.entries(fl).map(([t,n])=>{let s=e[t]||{available:!1,models:[]},i=K===t,O=n.icon,S=s.models.length;return(0,w.jsxs)("div",{className:`border transition-all duration-200 ${s.available?"border-zinc-700 bg-zinc-900/50":"border-zinc-800/50 bg-zinc-950"}`,children:[(0,w.jsxs)("button",{onClick:()=>{let e=i?null:t;J(e),"bedrock"===e&&z?.()},className:"w-full flex items-center justify-between p-4 text-left hover:bg-zinc-900/30 transition-colors",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("div",{className:`h-2 w-2 rounded-full ${s.available?"bg-green-500 shadow-[0_0_6px_#22c55e]":"bg-zinc-600"}`}),(0,w.jsx)(O,{className:`h-4 w-4 ${!s.available?"opacity-40 grayscale":""}`,style:{color:s.available?n.color:"#71717a"}}),(0,w.jsxs)("div",{children:[(0,w.jsx)("span",{className:`text-sm font-bold ${s.available?"text-white":"text-zinc-500"}`,children:n.label}),(0,w.jsx)("span",{className:"text-[10px] text-zinc-500 ml-2",children:s.available?`${S} model${1!==S?"s":""}`:"ollama"===t?"Not running":t.endsWith("_cli")?"Not installed":"No key configured"})]})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[s.available?(0,w.jsx)(ft,{className:"h-4 w-4 text-green-500"}):(0,w.jsx)(eN.X,{className:"h-3 w-3 text-zinc-600"}),i?(0,w.jsx)(eT,{className:"h-4 w-4 text-zinc-500"}):(0,w.jsx)(ei.ChevronDown,{className:"h-4 w-4 text-zinc-500"})]})]}),i&&(0,w.jsxs)("div",{className:"px-4 pb-4 space-y-3 border-t border-zinc-800/50 pt-3",children:[(0,w.jsx)("p",{className:"text-[10px] text-zinc-500",children:n.description}),"ollama"!==t&&"bedrock"!==t&&"openai_compatible"!==t&&"local_compatible"!==t&&!t.endsWith("_cli")&&(0,w.jsxs)("div",{className:"space-y-1.5",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"API Key"}),(0,w.jsx)("input",{type:"password",value:(e=>{switch(e){case"openai":return r;case"anthropic":return a;case"gemini":return c;case"grok":return d;case"deepseek":return p;case"bedrock":return m;case"openai_compatible":return R;case"local_compatible":return H;default:return""}})(t),onChange:e=>((e,t)=>{switch(e){case"openai":o(t);break;case"anthropic":l(t);break;case"gemini":h(t);break;case"grok":u(t);break;case"deepseek":f(t);break;case"bedrock":g(t);break;case"openai_compatible":D(t);break;case"local_compatible":X(t)}})(t,e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:n.keyPlaceholder}),n.keyNote&&(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:n.keyNote}),n.keyLink&&(0,w.jsxs)("a",{href:n.keyLink.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-blue-400 hover:text-blue-300 transition-colors",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-2.5 w-2.5"}),n.keyLink.label]})]}),"bedrock"===t&&(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("div",{className:"space-y-1.5",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Bedrock API Key"}),(0,w.jsx)("input",{type:"password",value:m,onChange:e=>g(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"ABSK... or bedrock-api-key..."}),n.keyNote&&(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:n.keyNote}),n.keyLink&&(0,w.jsxs)("a",{href:n.keyLink.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-blue-400 hover:text-blue-300 transition-colors",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-2.5 w-2.5"}),n.keyLink.label]})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"AWS Region"}),(0,w.jsx)("input",{type:"text",value:x,onChange:e=>b(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"us-east-1"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Inference Profile (Optional)"}),(0,w.jsxs)("select",{value:v,onChange:e=>y(e.target.value),className:"w-full appearance-none bg-zinc-900 border border-zinc-800 p-2.5 text-xs focus:border-white focus:outline-none transition-colors text-white cursor-pointer",children:[(0,w.jsx)("option",{value:"",children:"None (on-demand)"}),j?(0,w.jsx)("option",{value:"",disabled:!0,children:"Loading..."}):k.map(e=>{let t=(e.arn||e.id||"").toString(),n=(e.name||e.arn||e.id||"").toString();return t?(0,w.jsx)("option",{value:t,children:n},t):null})]})]}),N&&(0,w.jsxs)("div",{className:"flex items-start gap-2 p-2.5 bg-red-500/5 border border-red-500/20 text-[10px] text-red-400",children:[(0,w.jsx)(fn,{className:"w-3 h-3 mt-0.5 shrink-0"}),(0,w.jsx)("span",{className:"break-all",children:N})]}),!N&&s.available&&!v&&(0,w.jsxs)("div",{className:"flex items-start gap-2 p-2.5 bg-amber-500/5 border border-amber-500/20 text-[10px] text-amber-400",children:[(0,w.jsx)(fn,{className:"w-3 h-3 mt-0.5 shrink-0"}),(0,w.jsx)("span",{children:"No inference profile selected. Please select an inference profile above to use AWS Bedrock."})]})]}),"openai_compatible"===t&&(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("div",{className:"space-y-1.5",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"API Key"}),(0,w.jsx)("input",{type:"password",value:R,onChange:e=>D(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"sk-..."})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Base URL"}),(0,w.jsx)("input",{type:"text",value:$,onChange:e=>Q(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"https://openrouter.ai/api"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:"The /v1 path is appended automatically. Do not include /v1 in the URL."})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Model Names (comma-separated)"}),(0,w.jsx)("input",{type:"text",value:I,onChange:e=>L(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"e.g. meta-llama/llama-3-70b-instruct, google/gemma-2-27b-it"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:"If the /v1/models endpoint is available, models will be fetched automatically. Otherwise, list them here."})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Embedding Model Names (comma-separated)"}),(0,w.jsx)("input",{type:"text",value:q,onChange:e=>W(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"e.g. hf:nomic-ai/nomic-embed-text-v1.5"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:'Models listed here appear in the embedding model dropdown. Models with "embed" in the name are also auto-detected from /v1/models.'})]})]}),"local_compatible"===t&&(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("div",{className:"space-y-1.5",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"API Key (optional)"}),(0,w.jsx)("input",{type:"password",value:H,onChange:e=>X(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"Leave blank if not required"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Base URL"}),(0,w.jsx)("input",{type:"text",value:V,onChange:e=>F(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"http://localhost:8000"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:"The /v1 path is appended automatically. Do not include /v1 in the URL."})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Model Names (comma-separated)"}),(0,w.jsx)("input",{type:"text",value:U,onChange:e=>G(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"e.g. llama-3-70b, mistral-7b"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:"If the /v1/models endpoint is available, models will be fetched automatically. Otherwise, list them here."})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Embedding Model Names (comma-separated)"}),(0,w.jsx)("input",{type:"text",value:Z,onChange:e=>Y(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2.5 text-xs text-white focus:border-white focus:outline-none transition-colors",placeholder:"e.g. bge-m3"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:'Models listed here appear in the embedding model dropdown. Models with "embed" in the name are also auto-detected from /v1/models.'})]})]}),"ollama"===t&&(0,w.jsxs)("div",{className:"space-y-1.5",children:[(0,w.jsx)("div",{className:"text-[10px] text-zinc-500",children:s.available?`Detected ${S} local model${1!==S?"s":""}: ${s.models.slice(0,5).join(", ")}${S>5?"...":""}`:"Ollama is not running. Start it to use local models."}),(0,w.jsxs)("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-blue-400 hover:text-blue-300 transition-colors",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-2.5 w-2.5"}),"Download Ollama →"]})]}),t.endsWith("_cli")&&(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("div",{className:"text-[10px] text-zinc-500",children:s.available?`Detected ${S} CLI session${1!==S?"s":""}: ${s.models.join(", ")}`:`No CLI binary found in PATH for ${n.label}.`}),(0,w.jsxs)("div",{className:"p-2.5 bg-violet-500/5 border border-violet-500/20 text-[10px] text-violet-300 leading-relaxed",children:[(0,w.jsx)("strong",{children:"No API key needed"})," — uses your existing CLI session. Run the CLI manually first to authenticate."]}),(0,w.jsxs)("div",{className:"flex flex-col gap-1",children:["anthropic_cli"===t&&(0,w.jsxs)("a",{href:"https://claude.ai/download",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-blue-400 hover:text-blue-300 transition-colors",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-2.5 w-2.5"})," Install Claude CLI →"]}),"gemini_cli"===t&&(0,w.jsxs)("a",{href:"https://ai.google.dev/gemini-api/docs/gemini-cli",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-blue-400 hover:text-blue-300 transition-colors",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-2.5 w-2.5"})," Install Gemini CLI →"]}),"codex_cli"===t&&(0,w.jsxs)("a",{href:"https://github.com/openai/codex",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-blue-400 hover:text-blue-300 transition-colors",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-2.5 w-2.5"})," Install OpenAI Codex CLI →"]}),"github_copilot_cli"===t&&(0,w.jsxs)("a",{href:"https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-blue-400 hover:text-blue-300 transition-colors",children:[(0,w.jsx)(eh.ExternalLink,{className:"h-2.5 w-2.5"})," Install GitHub Copilot CLI →"]})]})]}),s.available&&s.models.length>0&&"ollama"!==t&&(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-600",children:"Available Models"}),(0,w.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.models.map(e=>(0,w.jsx)("span",{className:"text-[10px] px-2 py-0.5 bg-zinc-800 text-zinc-400 border border-zinc-700/50 rounded-sm",children:e},e))})]})]})]},t)})})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Default Model"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600 -mt-1",children:"Used for system prompt generation and agents without a specific model assigned."}),(0,w.jsx)("select",{value:t,onChange:e=>n(e.target.value),className:"w-full appearance-none bg-zinc-900 border border-zinc-800 p-2.5 text-sm focus:border-white focus:outline-none transition-colors text-white cursor-pointer",children:S?(0,w.jsx)("option",{children:"Loading models..."}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("option",{value:"",disabled:!0,children:"Select default model..."}),Object.entries(e).map(([e,t])=>{if(!t.available||0===t.models.length)return null;let n=fl[e]?.label||e;return(0,w.jsx)("optgroup",{label:n,children:t.models.map(e=>(0,w.jsx)("option",{value:e,children:e},e))},e)})]})})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Embedding Model"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600 -mt-1",children:"Used for code indexing and repository search. Requires compatible providers like Gemini, OpenAI, or Ollama."}),(0,w.jsx)("select",{value:s,onChange:e=>i(e.target.value),className:"w-full appearance-none bg-zinc-900 border border-zinc-800 p-2.5 text-sm focus:border-white focus:outline-none transition-colors text-white cursor-pointer",children:S?(0,w.jsx)("option",{children:"Loading models..."}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("option",{value:"",children:"Select default embedding model..."}),Object.entries(e).map(([e,t])=>{if(!t.available||!t.embedding_models||0===t.embedding_models.length)return null;let n=fl[e]?.label||e;return(0,w.jsx)("optgroup",{label:n,children:t.embedding_models.map(e=>(0,w.jsx)("option",{value:e,children:e},e))},e)})]})})]}),(0,w.jsx)("div",{className:"p-3 bg-amber-900/20 border border-amber-900/50 rounded-sm",children:(0,w.jsx)("p",{className:"text-[10px] text-amber-500 leading-relaxed uppercase font-bold tracking-tight",children:"⚠ Warning: Changing the global embedding model will affect new repository indexals. Existing repositories will NOT be automatically migrated. Use individual repo settings to re-index manually if needed."})})]}),(0,w.jsx)("div",{className:"pt-4 flex justify-end",children:(0,w.jsxs)("button",{onClick:C,disabled:_,className:"flex items-center gap-2 px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg disabled:opacity-50 disabled:cursor-not-allowed",children:[_&&(0,w.jsx)(B.Loader2,{className:"w-4 h-4 animate-spin"}),_?"Saving…":"Save Changes"]})})]})};var fh=e.i(84614);let fd=({n8nUrl:e,setN8nUrl:t,n8nApiKey:n,setN8nApiKey:s,onSave:i})=>{let[r,o]=(0,O.useState)(null),[a,l]=(0,O.useState)(!0),[c,h]=(0,O.useState)(!1),[d,u]=(0,O.useState)(!1),[p,f]=(0,O.useState)("idle"),m=(0,O.useCallback)(async()=>{l(!0);try{let e=await fetch("/api/config"),t=await e.json();o(t)}catch{o({has_credentials:!1,is_connected:!1})}finally{l(!1)}},[]);(0,O.useEffect)(()=>{m()},[m]),(0,O.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get("google_auth");"success"===t?(m(),window.history.replaceState({},"",window.location.pathname)):"error"===t&&(console.error("Google OAuth error:",e.get("reason")||"Unknown error"),window.history.replaceState({},"",window.location.pathname))},[m]);let g=async e=>{try{JSON.parse(e)}catch{return}f("saving");try{(await fetch("/api/setup/google-credentials",{method:"POST",body:e,headers:{"Content-Type":"application/json"}})).ok?(f("saved"),setTimeout(async()=>{await m(),f("idle"),h(!1)},1200)):(f("error"),setTimeout(()=>f("idle"),2e3))}catch{f("error"),setTimeout(()=>f("idle"),2e3)}},x=async e=>{try{JSON.parse(e)}catch{return}try{(await fetch("/api/setup/google-token",{method:"POST",body:e,headers:{"Content-Type":"application/json"}})).ok&&(await m(),u(!1))}catch{}},b=r?.has_credentials,v=r?.is_connected,y=r?.user_email;return(0,w.jsxs)("div",{className:"space-y-8",children:[(0,w.jsxs)("div",{className:"bg-zinc-900 border border-zinc-800 overflow-hidden",children:[(0,w.jsxs)("div",{className:"p-4 border-b border-zinc-800 bg-zinc-950 flex items-center justify-between",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("div",{className:`h-2 w-2 transition-colors ${v?"bg-green-500 shadow-[0_0_10px_rgba(34,197,94,0.5)]":"bg-red-500"}`}),(0,w.jsx)("span",{className:"text-sm font-bold text-zinc-400",children:"Connection Status"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("button",{onClick:m,disabled:a,className:"p-1 text-zinc-600 hover:text-zinc-400 transition-colors",title:"Refresh status",children:(0,w.jsx)(ez.RefreshCw,{className:`h-3 w-3 ${a?"animate-spin":""}`})}),(0,w.jsx)("span",{className:`text-xs px-2 py-1 bg-zinc-900 border border-zinc-800 ${v?"text-green-400":"text-zinc-500"}`,children:v?"CONNECTED":"DISCONNECTED"})]})]}),(0,w.jsx)("div",{className:"p-6 space-y-6",children:b?(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"bg-zinc-950 border border-zinc-800 p-4 space-y-3",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,w.jsx)(U,{className:"h-4 w-4 text-green-500"}),(0,w.jsx)("span",{className:"text-xs font-bold text-green-400 uppercase tracking-wider",children:"OAuth Credentials Configured"})]}),(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-[11px]",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-600 uppercase tracking-wider mb-0.5",children:"Client ID"}),(0,w.jsx)("p",{className:"font-mono text-zinc-300",children:r?.client_id??"—"})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-600 uppercase tracking-wider mb-0.5",children:"Project"}),(0,w.jsx)("p",{className:"font-mono text-zinc-300",children:r?.project_id||"—"})]})]}),v&&y?(0,w.jsxs)("div",{className:"mt-2 pt-2 border-t border-zinc-800 flex items-center gap-2",children:[(0,w.jsx)(fh.User,{className:"h-3.5 w-3.5 text-green-500"}),(0,w.jsx)("span",{className:"text-xs text-zinc-300",children:y}),(0,w.jsx)("span",{className:"ml-auto text-[10px] text-green-500 uppercase tracking-wider",children:"Authenticated"})]}):v?(0,w.jsxs)("div",{className:"mt-2 pt-2 border-t border-zinc-800 flex items-center gap-2",children:[(0,w.jsx)(U,{className:"h-3.5 w-3.5 text-green-500"}),(0,w.jsx)("span",{className:"text-xs text-zinc-400",children:"Token active — no email info stored"})]}):(0,w.jsxs)("div",{className:"mt-3 pt-3 border-t border-zinc-800 space-y-2",children:[(0,w.jsx)("p",{className:"text-[11px] text-zinc-500",children:"OAuth credentials are ready. Click below to authenticate your Google account."}),(0,w.jsxs)("a",{href:"/auth/login",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-white text-black text-xs font-bold uppercase tracking-wider hover:bg-zinc-200 transition-colors",children:[(0,w.jsx)(k.Shield,{className:"h-3.5 w-3.5"}),"Connect Google Account",(0,w.jsx)(eh.ExternalLink,{className:"h-3 w-3 opacity-60"})]}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:"This opens a Google sign-in page. After completing, return here and refresh."})]})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("button",{onClick:()=>h(e=>!e),className:"flex items-center gap-2 text-[11px] text-zinc-500 hover:text-zinc-300 transition-colors",children:[c?(0,w.jsx)(eT,{className:"h-3 w-3"}):(0,w.jsx)(ei.ChevronDown,{className:"h-3 w-3"}),"Replace / Re-upload credentials.json"]}),c&&(0,w.jsxs)("div",{className:"mt-2 space-y-2 animate-in fade-in slide-in-from-top-1 duration-150",children:[(0,w.jsx)("textarea",{className:`w-full h-28 bg-black border p-3 text-[10px] font-mono text-zinc-300 focus:outline-none resize-none transition-colors ${"saved"===p?"border-green-600":"error"===p?"border-red-600":"border-zinc-800 focus:border-white"}`,placeholder:'{"installed":{"client_id":"...","project_id":"..."}}',onChange:e=>g(e.target.value)}),(0,w.jsx)("p",{className:`text-[10px] ${"saved"===p?"text-green-500":"error"===p?"text-red-500":"saving"===p?"text-zinc-400":"text-zinc-700"}`,children:"saved"===p?"✓ Credentials saved — refreshing…":"error"===p?"✗ Failed to save credentials.":"saving"===p?"Saving…":"Paste valid JSON and it saves automatically."})]})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("button",{onClick:()=>u(e=>!e),className:"text-[11px] text-zinc-600 hover:text-zinc-400 underline decoration-dotted transition-colors",children:"Advanced: Import existing Token JSON (Skip OAuth)"}),d&&(0,w.jsx)("div",{className:"mt-2 animate-in fade-in slide-in-from-top-1 duration-150",children:(0,w.jsx)("textarea",{className:"w-full h-24 bg-black border border-zinc-800 p-3 font-mono text-xs text-zinc-300 focus:border-white focus:outline-none resize-none",placeholder:'{"token": "...", "refresh_token": "..."}',onChange:e=>x(e.target.value)})})]})]}):(0,w.jsxs)("div",{className:"space-y-5",children:[(0,w.jsxs)("div",{className:"text-center py-4 px-4",children:[(0,w.jsxs)("div",{className:"relative inline-block mb-3",children:[(0,w.jsx)(k.Shield,{className:"h-8 w-8 text-zinc-700 mx-auto"}),(0,w.jsx)(eu,{className:"h-4 w-4 text-red-500 absolute -bottom-1 -right-1"})]}),(0,w.jsx)("h3",{className:"text-base text-white font-bold mb-1",children:"Google Workspace Setup"}),(0,w.jsx)("p",{className:"text-xs text-zinc-500 max-w-sm mx-auto mb-4",children:"Google Workspace tools are powered by the Google Workspace MCP server. Upload your OAuth credentials below to enable it."}),(0,w.jsxs)("div",{className:"text-left text-[10px] bg-black p-4 border border-zinc-800 mb-5 max-w-md mx-auto overflow-y-auto max-h-[300px]",children:[(0,w.jsx)("p",{className:"font-bold text-zinc-300 mb-2",children:"Quick Setup Guide:"}),(0,w.jsxs)("ol",{className:"list-decimal pl-4 space-y-1.5 text-zinc-500",children:[(0,w.jsxs)("li",{children:["Go to ",(0,w.jsx)("a",{href:"https://console.cloud.google.com/",target:"_blank",rel:"noreferrer",className:"text-blue-400 hover:text-blue-300 underline",children:"Google Cloud Console"})," & create a Project."]}),(0,w.jsxs)("li",{children:["Enable ",(0,w.jsx)("em",{children:"Gmail, Drive, Calendar, Docs, Sheets, Slides, Forms, Tasks, People APIs"})," — ",(0,w.jsx)("a",{href:"https://console.cloud.google.com/flows/enableapi?apiid=gmail.googleapis.com,drive.googleapis.com,calendar-json.googleapis.com,docs.googleapis.com,sheets.googleapis.com,slides.googleapis.com,forms.googleapis.com,tasks.googleapis.com,people.googleapis.com",target:"_blank",rel:"noreferrer",className:"text-blue-400 hover:text-blue-300 underline",children:"one-click enable APIs →"})]}),(0,w.jsxs)("li",{children:["Create OAuth Client ID — use this direct link: ",(0,w.jsx)("a",{href:"https://console.cloud.google.com/auth/clients/create",target:"_blank",rel:"noreferrer",className:"text-blue-400 hover:text-blue-300 underline",children:"Create OAuth Client →"})," and choose ",(0,w.jsx)("strong",{className:"text-zinc-300",children:"Web application"}),"."]}),(0,w.jsxs)("li",{children:["Under ",(0,w.jsx)("strong",{children:"Authorized redirect URIs"}),", add ",(0,w.jsxs)("strong",{className:"text-zinc-300",children:["http://localhost:","8765","/auth/callback"]})]}),(0,w.jsx)("li",{children:"Download the JSON file, open it, copy all its content, and paste it below."})]})]})]}),(0,w.jsxs)("div",{className:"border-t border-zinc-800 pt-5 space-y-4",children:[(0,w.jsxs)("details",{className:"group appearance-none",children:[(0,w.jsx)("summary",{className:"cursor-pointer text-xs font-bold text-zinc-400 hover:text-white list-none flex items-center gap-2 p-3 bg-zinc-950 border border-zinc-800 hover:border-zinc-700 transition-colors",children:(0,w.jsx)("span",{children:"+ PASTE CREDENTIALS.JSON CONTENT"})}),(0,w.jsxs)("div",{className:"mt-2",children:[(0,w.jsx)("textarea",{className:`w-full h-32 bg-black border p-3 text-[10px] font-mono text-zinc-300 focus:outline-none resize-none transition-colors ${"saved"===p?"border-green-600":"error"===p?"border-red-600":"border-zinc-800 focus:border-white"}`,placeholder:'{"installed":{"client_id":"...","project_id":"..."}}',onChange:e=>g(e.target.value)}),(0,w.jsx)("p",{className:`mt-1 text-[10px] ${"saved"===p?"text-green-500":"error"===p?"text-red-500":"saving"===p?"text-zinc-400":"text-zinc-700"}`,children:"saved"===p?"✓ Saved — refreshing status…":"error"===p?"✗ Invalid JSON or save failed.":"saving"===p?"Saving…":"Paste valid JSON and it saves automatically."})]})]}),(0,w.jsxs)("details",{className:"group appearance-none",children:[(0,w.jsx)("summary",{className:"cursor-pointer text-xs font-bold text-zinc-500 hover:text-white mt-2 list-none flex items-center gap-2",children:(0,w.jsx)("span",{className:"underline decoration-dotted decoration-zinc-700 hover:decoration-zinc-500",children:"Advanced: Import existing Token JSON (Skip OAuth)"})}),(0,w.jsx)("div",{className:"mt-2",children:(0,w.jsx)("textarea",{className:"w-full h-24 bg-black border border-zinc-800 p-3 font-mono text-xs text-zinc-300 focus:border-white focus:outline-none resize-none",placeholder:'{"token": "...", "refresh_token": "..."}',onChange:e=>x(e.target.value)})})]})]})]})})]}),(0,w.jsxs)("div",{className:"bg-zinc-900 border border-zinc-800 overflow-hidden",children:[(0,w.jsxs)("div",{className:"p-4 border-b border-zinc-800 bg-zinc-950 flex items-center justify-between",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("div",{className:`h-2 w-2 ${n?"bg-green-500":"bg-red-500"}`}),(0,w.jsx)("span",{className:"text-sm font-bold text-zinc-400",children:"n8n"})]}),(0,w.jsx)("span",{className:`text-xs px-2 py-1 bg-zinc-900 border border-zinc-800 ${n?"text-green-400":"text-zinc-500"}`,children:n?"CONFIGURED":"NOT CONFIGURED"})]}),(0,w.jsxs)("div",{className:"p-6 space-y-6",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"n8n URL"}),(0,w.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"http://localhost:5678"}),(0,w.jsx)("p",{className:"text-xs text-zinc-600",children:"Defaults to localhost for local dev. Use your production n8n base URL in deployment."})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"n8n API Key"}),(0,w.jsx)("input",{type:"password",value:n,onChange:e=>s(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"X-N8N-API-KEY"}),(0,w.jsx)("p",{className:"text-xs text-zinc-600",children:"Used server-side to list workflows and derive webhook URLs."})]}),(0,w.jsx)("div",{className:"pt-2 flex justify-end",children:(0,w.jsx)("button",{onClick:i,className:"px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg",children:"Save Changes"})})]})]})]})},fu=(0,H.default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),fp=(0,H.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),ff=[{server_type:"stdio",name:"Git",command:"uvx",args:"mcp-server-git",label:"Git"}],fm=[{server_type:"remote",name:"Vercel",url:"https://mcp.vercel.com",label:"Vercel"},{server_type:"remote",name:"Github",url:"https://api.githubcopilot.com/mcp/",label:"GitHub Copilot",token:"GITHUB_PERSONAL_ACCESS_TOKEN"},{server_type:"remote",name:"slack",url:"https://mcp.slack.com/mcp",label:"Slack",token:"SLACK_CLIENT_ID"},{server_type:"remote",name:"notion",url:"https://mcp.notion.com/mcp",label:"Notion"},{server_type:"remote",name:"Jira",url:"https://mcp.atlassian.com/v1/mcp",label:"Jira"},{server_type:"remote",name:"Zapier",url:"https://mcp.zapier.com/api/mcp/mcp",label:"Zapier"},{server_type:"remote",name:"Figma",url:"https://mcp.figma.com/mcp",label:"Figma",token:"FIGMA_PERSONAL_ACCESS_TOKEN"},{server_type:"remote",name:"Fetch",url:"https://remote.mcpservers.org/fetch/mcp",label:"Fetch"}],fg=({status:e})=>"connecting"===e?(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] bg-blue-500/20 text-blue-400 px-1.5 py-0.5 rounded border border-blue-500/30 uppercase",children:[(0,w.jsx)(B.Loader2,{className:"h-2.5 w-2.5 animate-spin"})," Connecting"]}):"connected"===e?(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] bg-green-500/20 text-green-400 px-1.5 py-0.5 rounded border border-green-500/30 uppercase",children:[(0,w.jsx)(ed,{className:"h-2.5 w-2.5"})," Active"]}):(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] bg-yellow-500/20 text-yellow-400 px-1.5 py-0.5 rounded border border-yellow-500/30 uppercase",children:[(0,w.jsx)(eu,{className:"h-2.5 w-2.5"})," Disconnected"]}),fx=({type:e})=>"remote"===e?(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[9px] bg-violet-500/15 text-violet-400 px-1.5 py-0.5 rounded border border-violet-500/25 uppercase",children:[(0,w.jsx)(fp,{className:"h-2 w-2"}),"Remote"]}):(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[9px] bg-zinc-800 text-zinc-500 px-1.5 py-0.5 rounded border border-zinc-700 uppercase",children:[(0,w.jsx)(eA.Terminal,{className:"h-2 w-2"}),"Local"]}),fb={success:"bg-green-500/10 border-green-500/30 text-green-400",warning:"bg-yellow-500/10 border-yellow-500/30 text-yellow-300",error:"bg-red-500/10 border-red-500/30 text-red-400"},fv={success:ed,warning:X,error:eu},fy="w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none placeholder:text-zinc-700",fw=`${fy} font-mono`,fO=({mcpServers:e,loadingMcp:t,isConnecting:n,lastConnected:s,mcpToast:i,setMcpToast:r,pendingServerName:o,onPendingResolved:a,draftMcpServer:l,setDraftMcpServer:c,onAddServer:h,onDeleteServer:d,onReconnectServer:u})=>{let p,f=(0,L.useDispatch)(),m=l.server_type,g=e=>c({...l,server_type:e}),[x,b]=(0,O.useState)(!1),[v,y]=(0,O.useState)(!0),k=async(e=!1)=>{e||b(!0);try{let e=await fetch("/api/mcp/servers");if(e.ok){let t=await e.json();f((0,q.setMcpServers)(Array.isArray(t)?t:[]))}}catch{}finally{e||b(!1)}},[N,S]=(0,O.useState)(0),z=(0,O.useRef)(null),C=(0,O.useRef)(null),_=(0,O.useRef)(0),T=()=>{z.current&&(clearInterval(z.current),z.current=null),C.current&&(clearInterval(C.current),C.current=null),S(0)};(0,O.useEffect)(()=>o?(_.current=Date.now()+6e4,S(60),z.current=setInterval(async()=>{try{let e=await fetch("/api/mcp/servers");if(!e.ok)return;let t=await e.json();f((0,q.setMcpServers)(t));let n=t.find(e=>e.name===o);if(n?.status==="connected"){T(),a(),r({show:!0,message:`✓ ${o} connected!`,type:"success"}),setTimeout(()=>r(null),5e3);return}}catch{}Date.now()>=_.current&&(T(),a())},5e3),C.current=setInterval(()=>{let e=Math.max(0,Math.round((_.current-Date.now())/1e3));S(e),e<=0&&(T(),a())},1e3),T):void T(),[o]);let M=(e,t,n)=>{let s=[...l.env];s[e]={...s[e],[t]:n},c({...l,env:s})};return(0,w.jsxs)("div",{className:"space-y-8",children:[(0,w.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:[(0,w.jsx)(A.Server,{className:"h-5 w-5"})," External MCP Servers"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm mt-1",children:"Connect local and remote Model Context Protocol servers to extend agent capabilities."})]}),(0,w.jsxs)("button",{onClick:()=>k(),disabled:x,title:"Refresh server statuses",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium border border-zinc-700 text-zinc-400 hover:border-zinc-500 hover:text-white rounded transition-colors disabled:opacity-50 shrink-0 mt-1",children:[(0,w.jsx)(ez.RefreshCw,{className:`h-3.5 w-3.5 ${x?"animate-spin":""}`}),x?"Refreshing…":"Refresh"]})]}),i?.show&&(0,w.jsxs)("div",{className:`flex items-start gap-2.5 px-4 py-3 rounded border text-xs font-medium animate-in fade-in slide-in-from-top-2 duration-200 ${fb[i.type]}`,children:[(p=fv[i.type],(0,w.jsx)(p,{className:"h-4 w-4 mt-0.5 shrink-0"})),(0,w.jsx)("span",{className:"leading-relaxed",children:i.message})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("h4",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Connected Servers"}),t?(0,w.jsxs)("div",{className:"flex items-center gap-2 text-zinc-500 text-sm",children:[(0,w.jsx)(B.Loader2,{className:"h-4 w-4 animate-spin"})," Loading…"]}):0===e.length?(0,w.jsxs)("div",{className:"p-8 text-center border border-dashed border-zinc-800 rounded bg-zinc-900/30",children:[(0,w.jsx)(A.Server,{className:"h-8 w-8 mx-auto text-zinc-700 mb-2"}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm",children:"No servers added yet."}),(0,w.jsx)("p",{className:"text-zinc-700 text-xs mt-1",children:"Pick a preset or fill the form below."})]}):(0,w.jsx)("div",{className:"grid gap-3",children:e.map(e=>(0,w.jsxs)("div",{className:"flex items-center justify-between p-4 bg-zinc-900 border border-zinc-800 rounded group",children:[(0,w.jsxs)("div",{className:"flex flex-col gap-1.5 min-w-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,w.jsx)("span",{className:"font-bold text-white text-sm",children:e.label||e.name}),e.label&&e.label!==e.name&&(0,w.jsx)("span",{className:"text-[10px] text-zinc-600 font-mono",children:e.name}),(0,w.jsx)(fx,{type:e.server_type}),(0,w.jsx)(fg,{status:e.status})]}),(0,w.jsx)("code",{className:"text-[10px] text-zinc-500 font-mono truncate",children:"remote"===e.server_type?e.url:`${e.command} ${(e.args||[]).join(" ")}`})]}),(0,w.jsxs)("div",{className:"flex items-center gap-1 ml-4 shrink-0",children:["connecting"===e.status&&(0,w.jsx)("span",{className:"p-2",children:(0,w.jsx)(B.Loader2,{className:"h-3.5 w-3.5 text-blue-400 animate-spin"})}),(!e.status||"disconnected"===e.status)&&(0,w.jsx)("button",{onClick:()=>u(e.name),title:"Retry connection",className:"p-2 text-zinc-500 hover:text-blue-400 hover:bg-zinc-800 rounded transition-colors",children:(0,w.jsx)(ez.RefreshCw,{className:"h-3.5 w-3.5"})}),(0,w.jsx)("button",{onClick:()=>d(e.name),className:"p-2 text-zinc-600 hover:text-red-500 hover:bg-zinc-800 rounded transition-colors",children:(0,w.jsx)(j.Trash,{className:"h-4 w-4"})})]})]},e.name))})]}),(0,w.jsxs)("div",{className:"pt-6 border-t border-zinc-800 space-y-6",children:[(0,w.jsxs)("div",{className:"flex items-center gap-1 bg-zinc-900 border border-zinc-800 p-1 w-fit",children:[(0,w.jsxs)("button",{onClick:()=>g("stdio"),className:`flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold transition-colors ${"stdio"===m?"bg-white text-black":"text-zinc-500 hover:text-white"}`,children:[(0,w.jsx)(eA.Terminal,{className:"h-3 w-3"})," Local (stdio)"]}),(0,w.jsxs)("button",{onClick:()=>g("remote"),className:`flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold transition-colors ${"remote"===m?"bg-white text-black":"text-zinc-500 hover:text-white"}`,children:[(0,w.jsx)(fp,{className:"h-3 w-3"})," Remote (URL)"]})]}),(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)(fu,{className:"h-3.5 w-3.5 text-zinc-500"}),(0,w.jsx)("h4",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"stdio"===m?"Local Presets":"Remote Presets"})]}),(0,w.jsx)("div",{className:"flex flex-wrap gap-2",children:("stdio"===m?ff:fm).map(e=>(0,w.jsx)("button",{onClick:()=>{let t;return t=e.env?Object.entries(e.env).map(([e,t])=>({key:e,value:t})):[],void c({name:e.name,label:e.label,server_type:e.server_type,command:e.command||"",args:e.args||"",env:t,url:e.url||"",token:e.token||""})},className:"px-3 py-1.5 text-[11px] font-medium bg-zinc-900 border border-zinc-800 text-zinc-400 hover:border-zinc-600 hover:text-white rounded transition-colors",children:e.label},e.name+e.label))}),(0,w.jsxs)("p",{className:"text-[10px] text-zinc-600",children:["Find more on the"," ",(0,w.jsx)("a",{href:"https://github.com/modelcontextprotocol/servers",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 underline underline-offset-2 hover:text-white transition-colors",children:"MCP servers registry"}),".","remote"===m&&" Remote servers use native OAuth — no npx required."]})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Display Label"}),(0,w.jsx)("input",{type:"text",value:l.label,onChange:e=>c({...l,label:e.target.value}),className:fy,placeholder:"e.g. GitHub Production"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Unique ID"}),(0,w.jsx)("input",{type:"text",value:l.name,onChange:e=>c({...l,name:e.target.value}),className:fy,placeholder:"e.g. github-prod"})]})]}),"stdio"===m?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Command"}),(0,w.jsx)("input",{type:"text",value:l.command,onChange:e=>c({...l,command:e.target.value}),className:fw,placeholder:"npx, uvx, python3"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Arguments"}),(0,w.jsx)("input",{type:"text",value:l.args,onChange:e=>c({...l,args:e.target.value}),className:fw,placeholder:"-y @org/server-name"})]})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Environment Variables"}),(0,w.jsxs)("button",{onClick:()=>c({...l,env:[...l.env,{key:"",value:""}]}),className:"text-[10px] font-bold text-zinc-400 hover:text-white flex items-center gap-1",children:[(0,w.jsx)(en.Plus,{className:"h-3 w-3"})," ADD VAR"]})]}),l.env.map((e,t)=>(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("input",{type:"text",placeholder:"KEY",value:e.key,onChange:e=>M(t,"key",e.target.value),className:"flex-1 bg-zinc-900 border border-zinc-800 p-2 text-xs text-white font-mono focus:border-white focus:outline-none"}),(0,w.jsx)("input",{type:"text",placeholder:"VALUE",value:e.value,onChange:e=>M(t,"value",e.target.value),className:"flex-[2] bg-zinc-900 border border-zinc-800 p-2 text-xs text-white font-mono focus:border-white focus:outline-none"}),(0,w.jsx)("button",{onClick:()=>c({...l,env:l.env.filter((e,n)=>n!==t)}),className:"p-2 text-zinc-600 hover:text-red-500",children:(0,w.jsx)(j.Trash,{className:"h-4 w-4"})})]},t))]})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:"Server URL"}),(0,w.jsx)("input",{type:"url",value:l.url,onChange:e=>c({...l,url:e.target.value}),className:fw,placeholder:"https://mcp.example.com/mcp"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:"Leave token empty to use OAuth (browser will open). Fill token for PAT-based servers (Figma, GitHub)."})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("label",{className:"text-[10px] uppercase font-bold text-zinc-500",children:["Bearer Token / Personal Access Token ",(0,w.jsx)("span",{className:"text-zinc-600 normal-case font-normal",children:"(optional — leave empty for OAuth)"})]}),(0,w.jsxs)("div",{className:"relative",children:[(0,w.jsx)("input",{type:v?"text":"password",value:l.token,onChange:e=>c({...l,token:e.target.value}),className:`${fw} pr-10`,placeholder:"ghp_... or fig_... or leave empty"}),(0,w.jsx)("button",{type:"button",onClick:()=>y(e=>!e),title:v?"Hide token":"Show token",className:"absolute right-2 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-zinc-300 transition-colors",children:v?(0,w.jsx)(ec,{className:"h-4 w-4"}):(0,w.jsx)(el,{className:"h-4 w-4"})})]})]})]})]}),(0,w.jsx)("div",{className:"flex justify-end pt-2",children:(0,w.jsx)("button",{onClick:h,disabled:n,className:"flex items-center gap-2 px-6 py-2 bg-white text-black text-sm font-bold hover:bg-zinc-200 transition-colors disabled:opacity-60 disabled:cursor-not-allowed",children:n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(B.Loader2,{className:"h-4 w-4 animate-spin"})," Connecting…"]}):"Connect Server"})})]})]})},fk=["**/venv/**","**/.venv/**","**/env/**","**/__pycache__/**","**/site-packages/**","**/*.pyc","**/*.pyo","**/.eggs/**","**/*.egg-info/**","**/.pytest_cache/**","**/.tox/**","**/.mypy_cache/**","**/node_modules/**","**/.next/**","**/.nuxt/**","**/dist/**","**/build/**","**/.cache/**","**/.turbo/**","**/vendor/**","**/.bundle/**","**/Pods/**","**/bower_components/**","**/.git/**","**/.svn/**","**/.hg/**","**/.idea/**","**/.vscode/**","**/.vs/**","**/target/**","**/*.min.js","**/*.min.css","**/*.map","**/*.class","**/*.o","**/*.so","**/*.jar","**/coverage/**","**/htmlcov/**","**/__snapshots__/**","**/*.lock","**/*.log","**/*.tmp","**/.DS_Store"];function fj({embeddingModel:e,embedCode:t}){let[n,s]=(0,O.useState)([]),[i,r]=(0,O.useState)(!0),[o,a]=(0,O.useState)(null),[l,c]=(0,O.useState)(null),[h,d]=(0,O.useState)(new Set),[u,p]=(0,O.useState)(new Set),[f,m]=(0,O.useState)(!1),[g,x]=(0,O.useState)(""),[b,v]=(0,O.useState)(""),[y,k]=(0,O.useState)(!1),[j,N]=(0,O.useState)(!1),[S,z]=(0,O.useState)(null),C=(e,t="success")=>{z({show:!0,message:e,type:t}),setTimeout(()=>z(null),4e3)},_=(0,O.useCallback)(async()=>{try{let e=await fetch("/api/repos");if(e.ok){let t=await e.json();s(t),d(e=>{let n=new Set(e);for(let s of e){let e=t.find(e=>e.id===s);e&&"indexing"===e.status||n.delete(s)}return n}),p(e=>{let n=new Set(e);for(let s of e){let e=t.find(e=>e.id===s);e&&["indexing","stopping"].includes(e.status)||n.delete(s)}return n})}}catch(e){console.error("Failed to fetch repos",e)}finally{r(!1)}},[]);(0,O.useEffect)(()=>{o&&(x((o.excluded_patterns||[".*"]).join("\n")),v((o.included_patterns||[]).join("\n")))},[o?.id]),(0,O.useEffect)(()=>{_()},[_]),(0,O.useEffect)(()=>{let e=setInterval(_,n.some(e=>"indexing"===e.status)||h.size>0?2e3:6e3);return()=>clearInterval(e)},[n,h,_]);let T=async()=>{if(!o?.name||!o?.path)return void C("Name and Path are required","warning");N(!0);let e=e=>e.split("\n").map(e=>e.trim()).filter(Boolean),t=e(g).length?e(g):[".*"],n=e(b).length?e(b):["*.py","*.ts","*.tsx","*.js","*.jsx","*.rs","*.go","*.java","*.md","*.html","*.vue","*.css","*.scss","*.cpp","*.c"],s={id:o.id||"repo_"+Date.now(),name:o.name,path:o.path,description:o.description||"",included_patterns:n,excluded_patterns:t,status:o.status||"pending",file_count:o.file_count||0};try{(await fetch("/api/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok?(C(o.id?"Repo updated!":"Repo added!","success"),a(null),_()):C("Failed to save repo","error")}catch{C("Failed to save repo","error")}finally{N(!1)}},A=async e=>{try{(await fetch(`/api/repos/${e}`,{method:"DELETE"})).ok?_():C("Failed to delete repo","error")}catch{C("Failed to delete repo","error")}},P=async(e,t)=>{t.stopPropagation();let s=n.find(t=>t.id===e);if(!(s?.status==="indexing"||h.has(e))){d(t=>new Set(t).add(e));try{let t=await fetch(`/api/repos/${e}/reindex`,{method:"POST"});if(t.ok||409===t.status)_();else{let n=await t.json().catch(()=>({detail:t.statusText}));C(`Re-index failed: ${n?.detail??t.statusText}`,"error"),d(t=>{let n=new Set(t);return n.delete(e),n})}}catch{C("Re-index request failed","error"),d(t=>{let n=new Set(t);return n.delete(e),n})}}},E=async(e,t)=>{t.stopPropagation(),p(t=>new Set(t).add(e));try{await fetch(`/api/repos/${e}/stop-index`,{method:"POST"}),_()}catch{p(t=>{let n=new Set(t);return n.delete(e),n})}};return i?(0,w.jsx)("div",{className:"p-8 text-center text-zinc-500",children:"Loading…"}):null!==o?(0,w.jsxs)("div",{className:"space-y-8",children:[S&&(0,w.jsx)(ek,{show:S.show,message:S.message,type:S.type}),t&&!e&&(0,w.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-amber-500/5 border border-amber-500/20 text-xs text-amber-400",children:[(0,w.jsx)(fn,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),(0,w.jsxs)("span",{children:["No embedding model configured. Indexing requires an embedding model."," ",(0,w.jsx)("a",{href:"/settings/models",className:"underline hover:text-amber-300 transition-colors",children:"Go to Models settings →"})]})]}),(0,w.jsxs)("div",{className:"mb-4",children:[(0,w.jsxs)("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:[(0,w.jsx)(M.FolderGit2,{className:"h-5 w-5"}),o.id?"Edit Repo":"Add New Repo"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm mt-1",children:"Configure codebase indexing settings."})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Repo Name"}),(0,w.jsx)("input",{type:"text",value:o.name||"",onChange:e=>a({...o,name:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"e.g. Frontend App",autoComplete:"off"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Absolute Directory Path"}),(0,w.jsx)("input",{type:"text",value:o.path||"",onChange:e=>a({...o,path:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"/home/user/projects/app",autoComplete:"off"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Interconnection Description"}),(0,w.jsx)("textarea",{value:o.description||"",onChange:e=>a({...o,description:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono min-h-[80px]",placeholder:"Help the LLM understand what this repo contains…"})]}),(0,w.jsx)("div",{children:(0,w.jsxs)("button",{type:"button",onClick:()=>k(e=>!e),className:"flex items-center gap-1.5 text-xs text-zinc-500 hover:text-zinc-300 transition-colors group",children:[y?(0,w.jsx)(eT,{className:"w-3 h-3"}):(0,w.jsx)(ei.ChevronDown,{className:"w-3 h-3"}),(0,w.jsx)("span",{className:"underline underline-offset-2 decoration-dotted group-hover:decoration-solid transition-all",children:"Advanced settings"})]})}),y&&(0,w.jsxs)("div",{className:"space-y-4 pt-1 border-t border-zinc-800/60",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Extra Excluded Patterns"}),(0,w.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 bg-blue-500/10 text-blue-400 border border-blue-500/20 font-mono",children:"one per line"})]}),(0,w.jsxs)("div",{className:"flex gap-2 p-3 bg-amber-500/5 border border-amber-500/15 text-xs text-amber-300",children:[(0,w.jsx)(fn,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsxs)("p",{children:[(0,w.jsx)("span",{className:"font-mono text-white",children:"data"})," → excludes ",(0,w.jsx)("em",{children:"every"})," directory named ",(0,w.jsx)("span",{className:"font-mono",children:"data"})," (backend/data AND frontend/data)"]}),(0,w.jsxs)("p",{children:[(0,w.jsx)("span",{className:"font-mono text-white",children:"backend/data"})," → excludes ",(0,w.jsx)("em",{children:"only"})," ",(0,w.jsx)("span",{className:"font-mono",children:"backend/data"}),", leaving ",(0,w.jsx)("span",{className:"font-mono",children:"frontend/data"})," indexed"]}),(0,w.jsxs)("p",{children:[(0,w.jsx)("span",{className:"font-mono text-white",children:"*.json"})," → excludes all JSON files anywhere in the tree"]})]})]}),(0,w.jsx)("textarea",{value:g,onChange:e=>x(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono min-h-[80px]",placeholder:`.*
|
|
30
|
+
backend/data
|
|
31
|
+
fixtures`}),(0,w.jsxs)("button",{type:"button",onClick:()=>m(e=>!e),className:"flex items-center gap-1.5 text-xs text-zinc-500 hover:text-zinc-300 transition-colors",children:[f?(0,w.jsx)(eT,{className:"w-3 h-3"}):(0,w.jsx)(ei.ChevronDown,{className:"w-3 h-3"}),"Always excluded automatically (",fk.length," base patterns)"]}),f&&(0,w.jsx)("div",{className:"flex flex-wrap gap-1 p-3 bg-zinc-950 border border-zinc-800",children:fk.map(e=>(0,w.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 bg-zinc-800 text-zinc-400 font-mono",children:e},e))})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Included File Types"}),(0,w.jsx)("textarea",{value:b,onChange:e=>v(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono min-h-[60px]",placeholder:`*.py
|
|
32
|
+
*.ts
|
|
33
|
+
*.tsx
|
|
34
|
+
*.md`}),(0,w.jsx)("p",{className:"text-xs text-zinc-600",children:"Only files matching these globs will be indexed. Leave blank to use defaults."})]})]}),(0,w.jsxs)("div",{className:"flex gap-4 justify-end pt-4",children:[(0,w.jsx)("button",{onClick:()=>a(null),className:"px-6 py-2.5 text-sm font-bold text-zinc-400 hover:text-white transition-all",children:"Cancel"}),(0,w.jsxs)("button",{onClick:T,disabled:j,className:"flex items-center gap-2 px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg disabled:opacity-50 disabled:cursor-not-allowed",children:[j&&(0,w.jsx)(B.Loader2,{className:"w-4 h-4 animate-spin"}),j?"Saving…":"Save Repository"]})]})]})]}):(0,w.jsxs)("div",{className:"space-y-8",children:[S&&(0,w.jsx)(ek,{show:S.show,message:S.message,type:S.type}),(0,w.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:[(0,w.jsx)(M.FolderGit2,{className:"h-5 w-5"}),"Code Repositories"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm mt-1",children:"Manage your agent's codebases for semantic code searching."})]}),(0,w.jsxs)("button",{onClick:()=>a({}),className:"flex items-center gap-2 px-4 py-2 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg",children:[(0,w.jsx)(en.Plus,{className:"w-4 h-4"})," Add Repo"]})]}),0===n.length?(0,w.jsxs)("div",{className:"text-center py-12 border border-dashed border-zinc-800 bg-zinc-900/50",children:[(0,w.jsx)(M.FolderGit2,{className:"w-8 h-8 mx-auto text-zinc-600 mb-3"}),(0,w.jsx)("h3",{className:"text-sm font-bold text-zinc-100",children:"No repositories indexed"}),(0,w.jsx)("p",{className:"text-sm text-zinc-500 mt-1 mb-6",children:"Add a local repository path to enable code context."}),(0,w.jsxs)("button",{onClick:()=>a({}),className:"inline-flex items-center gap-2 px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg",children:[(0,w.jsx)(en.Plus,{className:"w-4 h-4"})," Add Repository"]})]}):(0,w.jsx)("div",{className:"grid grid-cols-1 gap-4",children:n.map(e=>{let n="indexing"===e.status||h.has(e.id),s="stopping"===e.status||u.has(e.id);return(0,w.jsxs)("div",{className:"p-4 border border-zinc-800 bg-zinc-900/50 hover:border-zinc-600 transition-colors cursor-pointer group",onClick:()=>a(e),children:[(0,w.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h4",{className:"font-bold text-white text-lg flex items-center gap-2",children:[e.name,(0,w.jsxs)("span",{className:`text-[10px] font-bold px-2 py-0.5 border uppercase tracking-wide inline-flex items-center gap-1 ${(e=>{switch(e){case"indexed":return"bg-emerald-500/10 text-emerald-400 border-emerald-500/20";case"indexing":return"bg-blue-500/10 text-blue-400 border-blue-500/20";case"stopping":return"bg-orange-500/10 text-orange-400 border-orange-500/20";case"stopped":return"bg-zinc-500/10 text-zinc-400 border-zinc-500/20";case"error":return"bg-red-500/10 text-red-400 border-red-500/20";default:return"bg-amber-500/10 text-amber-400 border-amber-500/20"}})(e.status)}`,children:[(n||s)&&(0,w.jsx)(B.Loader2,{className:"w-2.5 h-2.5 animate-spin"}),t||"pending"!==e.status?e.status:"not indexed"]})]}),(0,w.jsx)("p",{className:"text-xs text-zinc-500 font-mono truncate max-w-lg mt-1",children:e.path})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[t&&(n||s?(0,w.jsx)("button",{onClick:t=>E(e.id,t),title:s?"Force reset stuck status":"Stop Indexing",className:`p-2 transition-colors rounded ${s?"text-orange-400 hover:text-orange-300 hover:bg-orange-500/10":"text-red-400 hover:text-red-300 hover:bg-red-500/10"}`,children:(0,w.jsx)(ep,{className:"w-4 h-4 fill-current"})}):(0,w.jsx)("button",{onClick:t=>P(e.id,t),title:"Re-Index",className:"p-2 text-zinc-400 hover:text-white hover:bg-zinc-800 transition-colors rounded",children:(0,w.jsx)(ez.RefreshCw,{className:"w-4 h-4"})})),(0,w.jsx)("button",{onClick:t=>{t.stopPropagation(),c(e.id)},disabled:n&&!s,title:n&&!s?"Cannot delete while indexing":"Delete",className:`p-2 transition-colors rounded ${n&&!s?"text-zinc-700 cursor-not-allowed":"text-zinc-400 hover:text-red-500 hover:bg-red-500/10"}`,children:(0,w.jsx)(F.Trash2,{className:"w-4 h-4"})})]})]}),e.description&&(0,w.jsx)("p",{className:"text-sm text-zinc-400 mt-3 line-clamp-2",children:e.description}),t&&(0,w.jsxs)("div",{className:"flex gap-4 mt-4 text-xs font-bold text-zinc-600 uppercase tracking-wider",children:[(0,w.jsxs)("span",{children:[(e.file_count||0).toLocaleString()," CHUNKS",n||s?" INDEXED SO FAR…":" INDEXED"]}),e.last_indexed&&!n&&!s&&(0,w.jsxs)("span",{children:["• UPDATED ",new Date(e.last_indexed).toLocaleString()]})]})]},e.id)})}),(0,w.jsx)(K,{isOpen:!!l,title:"Delete Repository",message:"Are you sure you want to delete this repository and its index? This action cannot be undone.",onConfirm:()=>{l&&A(l),c(null)},onClose:()=>c(null)})]})}let fN=["postgres","mysql","sqlite","mssql"];function fS(){let[e,t]=(0,O.useState)([]),[n,s]=(0,O.useState)(!0),[i,r]=(0,O.useState)(null),[o,a]=(0,O.useState)(!1),[l,c]=(0,O.useState)(null),[h,d]=(0,O.useState)(null),u=(e,t="success")=>{d({show:!0,message:e,type:t}),setTimeout(()=>d(null),4e3)};(0,O.useEffect)(()=>{p()},[]);let p=async()=>{try{let e=await fetch("/api/db-configs");if(e.ok){let n=await e.json();t(n)}}catch(e){console.error("Failed to fetch DB configs",e)}finally{s(!1)}},f=async()=>{if(!i?.name||!i?.connection_string)return void u("Name and Connection String are required","warning");let e={id:i.id||"db_"+Date.now(),name:i.name,db_type:i.db_type||"postgres",connection_string:i.connection_string,description:i.description||"",schema_info:i.schema_info||"",last_tested:i.last_tested||null,status:i.status||"untested",error_message:i.error_message||null};try{(await fetch("/api/db-configs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok?(r(null),p()):u("Failed to save DB config","error")}catch(e){console.error("Save error",e),u("Failed to save DB config","error")}},m=async e=>{try{(await fetch(`/api/db-configs/${e}`,{method:"DELETE"})).ok&&p()}catch(e){u("Failed to delete DB config","error")}},g=async(e,t)=>{t.stopPropagation(),a(!0);try{let t=await fetch(`/api/db-configs/${e}/refresh-schema`,{method:"POST"});if(t.ok)p();else{let e=await t.text();u(`Schema refresh failed: ${e}`,"error")}}catch(e){u("Schema refresh failed","error")}finally{a(!1)}};return n?(0,w.jsx)("div",{className:"p-8 text-center text-zinc-500",children:"Loading..."}):null!==i?(0,w.jsxs)("div",{className:"space-y-8",children:[h&&(0,w.jsx)(ek,{show:h.show,message:h.message,type:h.type}),(0,w.jsxs)("div",{className:"mb-4",children:[(0,w.jsxs)("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:[(0,w.jsx)(z.Database,{className:"h-5 w-5"}),i.id?"Edit Database":"Add New Database"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm mt-1",children:"Configure a database connection for agent context."})]}),(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Name"}),(0,w.jsx)("input",{type:"text",value:i.name||"",onChange:e=>r({...i,name:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"e.g. Production DB",autoComplete:"off"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Database Type"}),(0,w.jsx)("select",{value:i.db_type||"postgres",onChange:e=>r({...i,db_type:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors",children:fN.map(e=>(0,w.jsx)("option",{value:e,children:e},e))})]})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Connection String"}),(0,w.jsx)("input",{type:"text",value:i.connection_string||"",onChange:e=>r({...i,connection_string:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono",placeholder:"postgresql://user:password@host:5432/dbname",autoComplete:"off"}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600",children:"e.g. postgresql://user:pass@localhost:5432/mydb — stored locally, never sent externally."})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-xs uppercase font-bold text-zinc-500 tracking-wider",children:"Description"}),(0,w.jsx)("textarea",{value:i.description||"",onChange:e=>r({...i,description:e.target.value}),className:"w-full bg-zinc-900 border border-zinc-800 p-3 text-sm text-white focus:border-white focus:outline-none transition-colors font-mono min-h-[80px]",placeholder:"Help the agent understand what this database contains and how it relates to the codebase..."})]}),(0,w.jsxs)("div",{className:"flex gap-4 justify-end pt-4",children:[(0,w.jsx)("button",{onClick:()=>r(null),className:"px-6 py-2.5 text-sm font-bold text-zinc-400 hover:text-white transition-all",children:"Cancel"}),(0,w.jsx)("button",{onClick:f,className:"px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg",children:"Save Database"})]})]})]}):(0,w.jsxs)("div",{className:"space-y-8",children:[h&&(0,w.jsx)(ek,{show:h.show,message:h.message,type:h.type}),(0,w.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:[(0,w.jsx)(z.Database,{className:"h-5 w-5"}),"Database Connections"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm mt-1",children:"Manage database configurations for agent schema context."})]}),(0,w.jsxs)("button",{onClick:()=>r({}),className:"flex items-center gap-2 px-4 py-2 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg",children:[(0,w.jsx)(en.Plus,{className:"w-4 h-4"})," Add Database"]})]}),0===e.length?(0,w.jsxs)("div",{className:"text-center py-12 border border-dashed border-zinc-800 bg-zinc-900/50",children:[(0,w.jsx)(z.Database,{className:"w-8 h-8 mx-auto text-zinc-600 mb-3"}),(0,w.jsx)("h3",{className:"text-sm font-bold text-zinc-100",children:"No databases configured"}),(0,w.jsx)("p",{className:"text-sm text-zinc-500 mt-1 mb-6",children:"Add a database connection to enable schema context for code agents."}),(0,w.jsxs)("button",{onClick:()=>r({}),className:"inline-flex items-center gap-2 px-6 py-2.5 text-sm font-bold bg-white text-black hover:bg-zinc-200 transition-all shadow-lg",children:[(0,w.jsx)(en.Plus,{className:"w-4 h-4"})," Add Database"]})]}):(0,w.jsx)("div",{className:"grid grid-cols-1 gap-4",children:e.map(e=>(0,w.jsxs)("div",{className:"p-4 border border-zinc-800 bg-zinc-900/50 hover:border-zinc-600 transition-colors cursor-pointer group",onClick:()=>r(e),children:[(0,w.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h4",{className:"font-bold text-white text-lg flex items-center gap-2",children:[e.name,(0,w.jsx)("span",{className:`text-[10px] font-bold px-2 py-0.5 border uppercase tracking-wide ${(e=>{switch(e){case"connected":return"bg-emerald-500/10 text-emerald-500 border-emerald-500/20";case"error":return"bg-red-500/10 text-red-500 border-red-500/20";default:return"bg-amber-500/10 text-amber-500 border-amber-500/20"}})(e.status)}`,children:e.status}),(0,w.jsx)("span",{className:"text-[10px] font-bold px-2 py-0.5 border border-zinc-700 text-zinc-500 uppercase",children:e.db_type})]}),(0,w.jsx)("p",{className:"text-xs text-zinc-500 font-mono truncate max-w-lg mt-1",children:e.connection_string.replace(/:\/\/[^@]+@/,"://***@")})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,w.jsx)("button",{onClick:t=>g(e.id,t),className:"p-2 text-zinc-400 hover:text-white hover:bg-zinc-800 transition-colors",title:"Refresh Schema",disabled:o,children:(0,w.jsx)(ez.RefreshCw,{className:`w-4 h-4 ${o?"animate-spin text-white":""}`})}),(0,w.jsx)("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:"p-2 text-zinc-400 hover:text-red-500 hover:bg-red-500/10 transition-colors",title:"Delete",children:(0,w.jsx)(F.Trash2,{className:"w-4 h-4"})})]})]}),e.description&&(0,w.jsx)("p",{className:"text-sm text-zinc-400 mt-3 line-clamp-2",children:e.description}),e.error_message&&(0,w.jsx)("p",{className:"text-xs text-red-400 mt-2 font-mono",children:e.error_message}),(0,w.jsxs)("div",{className:"flex gap-4 mt-4 text-xs font-bold text-zinc-600 uppercase tracking-wider",children:[e.schema_info?(0,w.jsxs)("span",{children:[e.schema_info.split("\n").length-1," TABLES CACHED"]}):(0,w.jsx)("span",{children:"SCHEMA NOT FETCHED — hover and click refresh"}),e.last_tested&&(0,w.jsxs)("span",{children:["• TESTED ",new Date(e.last_tested).toLocaleString()]})]})]},e.id))}),(0,w.jsx)(K,{isOpen:!!l,title:"Delete Database Config",message:"Are you sure you want to delete this database connection? This action cannot be undone.",onConfirm:()=>{l&&m(l),c(null)},onClose:()=>c(null)})]})}let fz=(0,H.default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),fC=(0,H.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),f_=(0,H.default)("scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]),fT=(0,H.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),fA=(0,H.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var fM=e.i(14764);let fP=(0,H.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);function fE({events:e,isLive:t}){let[n,s]=(0,O.useState)(!1),i=e.slice(0,-1),r=e[e.length-1],o=(e,t)=>{if("step_progress"===e.kind){let n="complete"===e.stepStatus;return(0,w.jsxs)("div",{className:"flex items-center gap-2 pl-1 py-0.5",children:[n?(0,w.jsx)(U,{size:12,className:"text-emerald-500 shrink-0"}):(0,w.jsx)(B.Loader2,{size:12,className:"animate-spin text-purple-400 shrink-0"}),(0,w.jsx)("span",{className:`text-[11px] font-mono truncate ${n?"text-zinc-600":"text-zinc-400"}`,children:e.stepName})]},t)}if("tool_call"===e.kind)return(0,w.jsxs)("div",{className:"flex items-start gap-2 pl-1 py-0.5",children:[(0,w.jsx)("span",{className:"text-violet-400 text-[10px] shrink-0 mt-0.5",children:"🔧"}),(0,w.jsxs)("details",{className:"flex-1 min-w-0",children:[(0,w.jsx)("summary",{className:"text-[11px] text-violet-400 cursor-pointer list-none font-mono truncate",children:e.toolName?.replace(/_/g," ")}),(0,w.jsx)("pre",{className:"bg-zinc-800/60 rounded p-1.5 mt-0.5 text-[10px] text-zinc-300 overflow-x-auto whitespace-pre-wrap max-h-28 border border-zinc-700/40",children:JSON.stringify(e.toolArgs,null,2)})]})]},t);if("tool_result"===e.kind){let n=(e.toolPreview||"").slice(0,180),s=(e.toolPreview||"").length>180;return(0,w.jsxs)("div",{className:"pl-7 text-[10px] text-zinc-600 py-0.5 font-mono truncate",children:["↳ ",n,s?"…":""]},t)}return"routing"===e.kind?e.routingDecision?(0,w.jsxs)("div",{className:"flex items-center gap-1.5 pl-1 py-0.5",children:[(0,w.jsx)("span",{className:"text-[10px] text-zinc-600",children:"→"}),(0,w.jsx)("span",{className:"text-[10px] font-mono text-amber-500",children:e.routingDecision})]},t):null:null};return(0,w.jsxs)("div",{className:"space-y-0.5",children:[(t||n)&&i.map((e,t)=>o(e,t)),!t&&i.length>0&&(0,w.jsx)("button",{onClick:()=>s(e=>!e),className:"flex items-center gap-1 pl-1 text-[10px] text-zinc-600 hover:text-zinc-400 transition-colors",children:n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(eT,{size:10})," hide"]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(ei.ChevronDown,{size:10})," ",i.length," earlier step",1!==i.length?"s":""]})}),r&&o(r,i.length)]})}let fR={code:"bg-sky-900/60 text-sky-400 border-sky-700/40",conversational:"bg-violet-900/60 text-violet-400 border-violet-700/40",orchestrator:"bg-amber-900/60 text-amber-400 border-amber-700/40",builder:"bg-purple-900/60 text-purple-400 border-purple-700/40"};function fD({content:e}){let[t,n]=(0,O.useState)(!1),s=e.length>600,i=s&&!t?e.slice(0,600)+"…":e;return(0,w.jsx)("div",{className:"flex justify-start",children:(0,w.jsxs)("div",{className:"w-full max-w-[95%] rounded-lg border border-amber-700/40 bg-zinc-900/60 overflow-hidden",children:[(0,w.jsx)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-amber-700/30 bg-amber-900/10",children:(0,w.jsx)("span",{className:"text-[9px] font-mono text-amber-500/70 uppercase tracking-widest",children:"Evaluator"})}),(0,w.jsx)("div",{className:"px-3 py-2.5 text-zinc-300 text-[12px] leading-relaxed",children:(0,ey.renderTextContent)(i)}),s&&(0,w.jsx)("button",{onClick:()=>n(e=>!e),className:"w-full text-[10px] text-zinc-500 hover:text-zinc-300 py-1.5 border-t border-zinc-800/60 transition-colors flex items-center justify-center gap-1",children:t?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(eT,{size:10})," Show less"]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(ei.ChevronDown,{size:10})," Show full plan"]})})]})})}function f$(e){let t=[...e];for(let e=t.length-1;e>=0;e--)if("step_progress"===t[e].kind&&"running"===t[e].stepStatus){t[e]={...t[e],stepStatus:"complete"};break}return t}let fQ={role:"assistant",content:'Hi! I\'m the Synapse Builder. Tell me what kind of agent or orchestration you\'d like to build, and I\'ll ask any clarifying questions before creating it.\n\nFor example:\n- *"Build a research workflow that searches the web and writes a summary to the vault"*\n- *"Create an agent that monitors my emails and drafts replies"*',kind:"text"};function fI({isOpen:e,onClose:t,agents:n,availableModels:s,currentOrchestrationId:i,onOrchestrationSaved:r,onAgentSaved:o,sessionKey:a}){let l,c,h,[d,u]=(0,O.useState)([fQ]),[p,f]=(0,O.useState)(new Set),[m,g]=(0,O.useState)(!0),[x,b]=(0,O.useState)(""),[v,y]=(0,O.useState)(""),[k,j]=(0,O.useState)(!1),[N,S]=(0,O.useState)(null),[z,C]=(0,O.useState)(!1),[T,A]=(0,O.useState)(null),M=(0,O.useRef)(null),P=(0,O.useRef)(null);(0,O.useEffect)(()=>{void 0!==a&&(u([fQ]),f(new Set),g(!0),y(""),C(!1),A(null))},[a]),(0,O.useEffect)(()=>{M.current?.scrollIntoView({behavior:"smooth"})},[d]);let E=async()=>{let e=v.trim();if(!e||k)return;let t={role:"user",content:e,kind:"text"},n=d.filter(e=>"text"===e.kind||void 0===e.kind).map(e=>({role:e.role,content:e.content}));u(e=>[...e,t]),y(""),j(!0),S("Thinking…"),T&&A(null);try{let t=T?await fetch("/api/builder/resume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({run_id:T.run_id,response:{[T.field]:e},model:x||void 0})}):await fetch("/api/builder/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,history:n,selected_agent_ids:Array.from(p),can_create_agents:m,model:x||void 0,current_orchestration_id:i})});if(!t.ok||!t.body)throw Error(`HTTP ${t.status}`);let s=t.body.getReader(),a=new TextDecoder,l="";for(;;){let{done:e,value:t}=await s.read();if(e)break;let n=(l+=a.decode(t,{stream:!0})).split("\n");for(let e of(l=n.pop()||"",n)){let t;if(e.startsWith("data: ")){try{t=JSON.parse(e.slice(6))}catch{continue}switch(t.type){case"thinking":{let e=t.message||"";if(e.startsWith("Running: ")){let t=e.replace("Running: ","");u(e=>[...f$(e),{role:"assistant",kind:"step_progress",content:"",stepName:t,stepStatus:"running"}]),S(t)}else S("Processing…");break}case"tool_call":u(e=>[...e,{role:"assistant",kind:"tool_call",content:"",toolName:t.tool_name,toolArgs:t.args||{}}]),S(`🔧 ${t.tool_name.replace(/_/g," ")}…`);break;case"tool_result":u(e=>[...e,{role:"assistant",kind:"tool_result",content:"",toolName:t.tool_name,toolPreview:t.result||t.preview||""}]),S(`✓ ${(t.tool_name??"tool").replace(/_/g," ")}`);break;case"step_complete":u(e=>f$(e));break;case"routing_decision":u(e=>[...e,{role:"assistant",kind:"routing",content:"",routingDecision:t.decision}]);break;case"orchestration_saved":r(t.orchestration),u(e=>[...f$(e),{role:"assistant",kind:"banner_orch",content:"",bannerText:t.orchestration?.name??t.orchestration?.id,orchestration:t.orchestration}]);break;case"agent_saved":o(t.agent),u(e=>[...e,{role:"assistant",kind:"banner_agent",content:"",bannerText:`✓ Agent "${t.agent?.name??t.agent?.id}" saved`}]);break;case"human_input_required":{S(null);let e=Array.isArray(t.fields)&&t.fields.length>0?t.fields[0]?.name??"answer":"answer";A({run_id:t.run_id,field:e}),u(e=>[...f$(e),{role:"assistant",kind:"human_prompt",content:t.prompt||""}]);break}case"final":S(null),u(e=>[...f$(e),{role:"assistant",kind:"text",content:t.response}]);break;case"error":S(null),u(e=>[...f$(e),{role:"assistant",kind:"text",content:`Error: ${t.message}`}])}}}}}catch(e){u(t=>[...f$(t),{role:"assistant",kind:"text",content:`Error: ${e.message}`}])}finally{u(e=>f$(e)),j(!1),S(null),P.current?.focus()}},R=n.filter(e=>"synapse_builder"!==e.id),D=R.filter(e=>p.has(e.id)).map(e=>e.name);return e?(0,w.jsxs)("div",{className:"fixed inset-y-0 right-0 z-50 w-[620px] bg-zinc-950 border-l border-zinc-800 shadow-2xl flex flex-col",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-zinc-800 shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)(ea.Sparkles,{size:15,className:"text-purple-400"}),(0,w.jsx)("span",{className:"text-sm font-semibold text-zinc-100",children:"AI Builder"})]}),(0,w.jsx)("button",{onClick:t,className:"text-zinc-500 hover:text-zinc-300 transition-colors",children:(0,w.jsx)(eN.X,{size:16})})]}),(0,w.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-3 font-sans",children:[(l=[],c=[],d.forEach((e,t)=>{"step_progress"===e.kind||"tool_call"===e.kind||"tool_result"===e.kind||"routing"===e.kind?c.push(e):(c.length>0&&(l.push({type:"activity",events:[...c]}),c=[]),l.push({type:"single",msg:e,idx:t}))}),c.length>0&&l.push({type:"activity",events:c}),h=l.length-1,l.map((e,n)=>{if("activity"===e.type){let t=k&&n===h;return(0,w.jsx)(fE,{events:e.events,isLive:t},`ag-${n}`)}let{msg:s,idx:i}=e;return"banner_orch"===s.kind?(0,w.jsxs)("div",{className:"rounded-xl border border-emerald-700/50 bg-emerald-900/20 overflow-hidden",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-emerald-700/30",children:[(0,w.jsx)(U,{size:15,className:"text-emerald-400 shrink-0"}),(0,w.jsxs)("div",{className:"min-w-0",children:[(0,w.jsx)("p",{className:"text-sm font-semibold text-emerald-300",children:"Orchestration built!"}),(0,w.jsxs)("p",{className:"text-[11px] text-emerald-600 truncate",children:["“",s.bannerText,"” is ready in the canvas"]})]})]}),(0,w.jsx)("div",{className:"px-4 py-2.5",children:(0,w.jsxs)("button",{onClick:t,className:"flex items-center gap-1.5 text-[11px] text-emerald-400 hover:text-emerald-300 transition-colors font-medium",children:["View in Canvas ",(0,w.jsx)(fP,{size:11})]})})]},i):"banner_agent"===s.kind?(0,w.jsx)("div",{className:"flex justify-center",children:(0,w.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-full bg-zinc-800/60 border border-zinc-700/40 text-zinc-500 text-[10px]",children:[(0,w.jsx)(U,{size:10,className:"text-emerald-500"}),s.bannerText]})},i):"human_prompt"===s.kind?(0,w.jsx)(fD,{content:s.content},i):"user"===s.role?(0,w.jsx)("div",{className:"flex justify-end",children:(0,w.jsx)("div",{className:"max-w-[80%] px-4 py-2.5 rounded-2xl rounded-br-sm bg-blue-600 text-white text-sm whitespace-pre-wrap",children:s.content})},i):(0,w.jsx)("div",{className:"flex justify-start",children:(0,w.jsx)("div",{className:"max-w-[88%] px-4 py-3 rounded-2xl rounded-bl-sm bg-zinc-800/80 text-zinc-200 text-sm",children:(0,ey.renderTextContent)(s.content)})},i)})),k&&N&&(0,w.jsxs)("div",{className:"flex items-center gap-2 pl-1",children:[(0,w.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500/70 animate-pulse shrink-0"}),(0,w.jsx)("span",{className:"text-[11px] text-zinc-500 font-mono",children:N})]}),(0,w.jsx)("div",{ref:M})]}),(0,w.jsxs)("div",{className:"border-t border-zinc-800 shrink-0",children:[(0,w.jsxs)("button",{className:"w-full flex items-center justify-between px-5 py-2.5 hover:bg-zinc-900/60 transition-colors",onClick:()=>C(e=>!e),children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,w.jsx)(_.Bot,{size:13,className:"text-zinc-500 shrink-0"}),0!==D.length||m?(0,w.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[D.map(e=>(0,w.jsx)("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-purple-900/50 text-purple-300 border border-purple-700/40",children:e},e)),m&&(0,w.jsxs)("span",{className:"text-[11px] px-2 py-0.5 rounded-full bg-emerald-900/50 text-emerald-400 border border-emerald-700/40 flex items-center gap-1",children:[(0,w.jsx)(en.Plus,{size:9})," new agents"]})]}):(0,w.jsx)("span",{className:"text-xs text-zinc-500",children:"Select agents to include"})]}),z?(0,w.jsx)(ei.ChevronDown,{size:13,className:"text-zinc-500 shrink-0 ml-2"}):(0,w.jsx)(eT,{size:13,className:"text-zinc-500 shrink-0 ml-2"})]}),z&&(0,w.jsxs)("div",{className:"px-4 pb-3 pt-1 max-h-56 overflow-y-auto border-t border-zinc-800/60",children:[(0,w.jsxs)("button",{onClick:()=>g(e=>!e),className:`mb-2 w-full flex items-center gap-2.5 px-3 py-2 rounded-lg border text-left transition-all ${m?"bg-emerald-900/30 border-emerald-600/60 ring-1 ring-emerald-600/30":"bg-zinc-900 border-zinc-700/60 hover:border-zinc-600 hover:bg-zinc-800/60"}`,children:[(0,w.jsx)("div",{className:`w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0 transition-colors ${m?"bg-emerald-600 border-emerald-600":"border-zinc-600"}`,children:m&&(0,w.jsx)("svg",{width:"8",height:"6",viewBox:"0 0 8 6",fill:"none",children:(0,w.jsx)("path",{d:"M1 3L3 5L7 1",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,w.jsx)("span",{className:"text-xs text-zinc-400",children:"Create new agents if needed"})]}),0===R.length?(0,w.jsx)("p",{className:"text-xs text-zinc-600 px-1",children:"No agents configured yet."}):(0,w.jsx)("div",{className:"grid grid-cols-2 gap-2",children:R.map(e=>{let t=p.has(e.id);return(0,w.jsxs)("button",{onClick:()=>{var t;return t=e.id,void f(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},className:`flex items-start gap-2.5 px-3 py-2.5 rounded-lg border text-left transition-all ${t?"bg-purple-900/30 border-purple-600/60 ring-1 ring-purple-600/30":"bg-zinc-900 border-zinc-700/60 hover:border-zinc-600 hover:bg-zinc-800/60"}`,children:[(0,w.jsx)("div",{className:`mt-0.5 w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0 transition-colors ${t?"bg-purple-600 border-purple-600":"border-zinc-600"}`,children:t&&(0,w.jsx)("svg",{width:"8",height:"6",viewBox:"0 0 8 6",fill:"none",children:(0,w.jsx)("path",{d:"M1 3L3 5L7 1",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,w.jsxs)("div",{className:"min-w-0",children:[(0,w.jsx)("p",{className:"text-xs font-medium text-zinc-200 truncate",children:e.name}),e.description?(0,w.jsx)("p",{className:"text-[10px] text-zinc-500 mt-0.5 line-clamp-2 leading-relaxed",children:e.description}):(0,w.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded border mt-0.5 inline-block ${fR[e.type||"conversational"]??"bg-zinc-800 text-zinc-400 border-zinc-700/40"}`,children:e.type||"conversational"})]})]},e.id)})})]})]}),(0,w.jsxs)("div",{className:"px-4 pb-4 pt-3 border-t border-zinc-800 shrink-0 space-y-2.5",children:[(0,w.jsxs)("div",{className:"flex items-end gap-2",children:[(0,w.jsx)("textarea",{ref:P,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),E())},placeholder:T?"Answer the question above…":"Describe what you want to build…",rows:2,disabled:k,className:"flex-1 bg-zinc-900 border border-zinc-700 rounded-xl px-3.5 py-2.5 text-sm text-zinc-200 placeholder-zinc-600 outline-none focus:border-purple-500/60 resize-none disabled:opacity-50 transition-colors font-sans"}),(0,w.jsx)("button",{onClick:E,disabled:!v.trim()||k,className:"flex items-center justify-center w-9 h-9 rounded-xl bg-purple-600 hover:bg-purple-500 disabled:opacity-40 disabled:cursor-not-allowed text-white transition-colors shrink-0",children:k?(0,w.jsx)(B.Loader2,{size:15,className:"animate-spin"}):(0,w.jsx)(fM.Send,{size:15})})]}),(0,w.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,w.jsx)("span",{className:"text-[10px] text-zinc-600 shrink-0",children:"Model"}),(0,w.jsxs)("select",{value:x,onChange:e=>b(e.target.value),className:"bg-transparent text-[10px] text-zinc-500 hover:text-zinc-300 outline-none cursor-pointer transition-colors max-w-[160px] truncate",children:[(0,w.jsx)("option",{value:"",className:"bg-zinc-900 text-zinc-300",children:"Default"}),s.map(e=>(0,w.jsx)("option",{value:e,className:"bg-zinc-900 text-zinc-300",children:e},e))]}),(0,w.jsx)("span",{className:"text-[10px] text-zinc-700 ml-auto",children:"Enter to send · Shift+Enter for newline"})]})]})]}):null}let fL={agent:{label:"Agent",color:"#3b82f6",icon:"Bot"},llm:{label:"LLM",color:"#14b8a6",icon:"Zap"},tool:{label:"Tool",color:"#a855f7",icon:"Wrench"},evaluator:{label:"Evaluator",color:"#10b981",icon:"Scale"},parallel:{label:"Parallel",color:"#8b5cf6",icon:"GitBranch"},merge:{label:"Merge",color:"#ec4899",icon:"GitMerge"},loop:{label:"Loop",color:"#f59e0b",icon:"RefreshCw"},human:{label:"Human",color:"#ef4444",icon:"User"},transform:{label:"Transform",color:"#6366f1",icon:"Code"},end:{label:"End",color:"#6b7280",icon:"Square"}};function fq(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)""!==(s=fq(e[n]))&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var fB={value:()=>{}};function fW(){for(var e,t=0,n=arguments.length,s={};t<n;++t){if(!(e=arguments[t]+"")||e in s||/[\s.]/.test(e))throw Error("illegal type: "+e);s[e]=[]}return new fV(s)}function fV(e){this._=e}function fF(e,t,n){for(var s=0,i=e.length;s<i;++s)if(e[s].name===t){e[s]=fB,e=e.slice(0,s).concat(e.slice(s+1));break}return null!=n&&e.push({name:t,value:n}),e}function fH(){}function fX(e){return null==e?fH:function(){return this.querySelector(e)}}function fU(){return[]}function fG(e){return null==e?fU:function(){return this.querySelectorAll(e)}}function fZ(e){return function(){return this.matches(e)}}function fY(e){return function(t){return t.matches(e)}}fV.prototype=fW.prototype={constructor:fV,on:function(e,t){var n,s=this._,i=(e+"").trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!s.hasOwnProperty(e))throw Error("unknown type: "+e);return{type:e,name:t}}),r=-1,o=i.length;if(arguments.length<2){for(;++r<o;)if((n=(e=i[r]).type)&&(n=function(e,t){for(var n,s=0,i=e.length;s<i;++s)if((n=e[s]).name===t)return n.value}(s[n],e.name)))return n;return}if(null!=t&&"function"!=typeof t)throw Error("invalid callback: "+t);for(;++r<o;)if(n=(e=i[r]).type)s[n]=fF(s[n],e.name,t);else if(null==t)for(n in s)s[n]=fF(s[n],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new fV(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,s,i=Array(n),r=0;r<n;++r)i[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(s=this._[e],r=0,n=s.length;r<n;++r)s[r].value.apply(t,i)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(var s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)}};var fK=Array.prototype.find;function fJ(){return this.firstElementChild}var f0=Array.prototype.filter;function f1(){return Array.from(this.children)}function f2(e){return Array(e.length)}function f5(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function f3(e,t,n,s,i,r){for(var o,a=0,l=t.length,c=r.length;a<c;++a)(o=t[a])?(o.__data__=r[a],s[a]=o):n[a]=new f5(e,r[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function f4(e,t,n,s,i,r,o){var a,l,c,h=new Map,d=t.length,u=r.length,p=Array(d);for(a=0;a<d;++a)(l=t[a])&&(p[a]=c=o.call(l,l.__data__,a,t)+"",h.has(c)?i[a]=l:h.set(c,l));for(a=0;a<u;++a)c=o.call(e,r[a],a,r)+"",(l=h.get(c))?(s[a]=l,l.__data__=r[a],h.delete(c)):n[a]=new f5(e,r[a]);for(a=0;a<d;++a)(l=t[a])&&h.get(p[a])===l&&(i[a]=l)}function f8(e){return e.__data__}function f6(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}f5.prototype={constructor:f5,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};var f9="http://www.w3.org/1999/xhtml";let f7={svg:"http://www.w3.org/2000/svg",xhtml:f9,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function me(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),f7.hasOwnProperty(t)?{space:f7[t],local:e}:e}function mt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mn(e,t){return e.style.getPropertyValue(t)||mt(e).getComputedStyle(e,null).getPropertyValue(t)}function ms(e){return e.trim().split(/^|\s+/)}function mi(e){return e.classList||new mr(e)}function mr(e){this._node=e,this._names=ms(e.getAttribute("class")||"")}function mo(e,t){for(var n=mi(e),s=-1,i=t.length;++s<i;)n.add(t[s])}function ma(e,t){for(var n=mi(e),s=-1,i=t.length;++s<i;)n.remove(t[s])}function ml(){this.textContent=""}function mc(){this.innerHTML=""}function mh(){this.nextSibling&&this.parentNode.appendChild(this)}function md(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mu(e){var t=me(e);return(t.local?function(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}:function(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===f9&&t.documentElement.namespaceURI===f9?t.createElement(e):t.createElementNS(n,e)}})(t)}function mp(){return null}function mf(){var e=this.parentNode;e&&e.removeChild(this)}function mm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function mg(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function mx(e){return function(){var t=this.__on;if(t){for(var n,s=0,i=-1,r=t.length;s<r;++s)(n=t[s],e.type&&n.type!==e.type||n.name!==e.name)?t[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?t.length=i:delete this.__on}}}function mb(e,t,n){return function(){var s,i=this.__on,r=function(e){t.call(this,e,this.__data__)};if(i){for(var o=0,a=i.length;o<a;++o)if((s=i[o]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=n),s.value=t;return}}this.addEventListener(e.type,r,n),s={type:e.type,name:e.name,value:t,listener:r,options:n},i?i.push(s):this.__on=[s]}}function mv(e,t,n){var s=mt(e),i=s.CustomEvent;"function"==typeof i?i=new i(t,n):(i=s.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}mr.prototype={add:function(e){0>this._names.indexOf(e)&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var my=[null];function mw(e,t){this._groups=e,this._parents=t}function mO(){return new mw([[document.documentElement]],my)}function mk(e){return"string"==typeof e?new mw([[document.querySelector(e)]],[document.documentElement]):new mw([[e]],my)}function mj(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,[(s=s.matrixTransform(t.getScreenCTM().inverse())).x,s.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}mw.prototype=mO.prototype={constructor:mw,select:function(e){"function"!=typeof e&&(e=fX(e));for(var t=this._groups,n=t.length,s=Array(n),i=0;i<n;++i)for(var r,o,a=t[i],l=a.length,c=s[i]=Array(l),h=0;h<l;++h)(r=a[h])&&(o=e.call(r,r.__data__,h,a))&&("__data__"in r&&(o.__data__=r.__data__),c[h]=o);return new mw(s,this._parents)},selectAll:function(e){if("function"==typeof e){var t;t=e,e=function(){var e;return e=t.apply(this,arguments),null==e?[]:Array.isArray(e)?e:Array.from(e)}}else e=fG(e);for(var n=this._groups,s=n.length,i=[],r=[],o=0;o<s;++o)for(var a,l=n[o],c=l.length,h=0;h<c;++h)(a=l[h])&&(i.push(e.call(a,a.__data__,h,l)),r.push(a));return new mw(i,r)},selectChild:function(e){var t;return this.select(null==e?fJ:(t="function"==typeof e?e:fY(e),function(){return fK.call(this.children,t)}))},selectChildren:function(e){var t;return this.selectAll(null==e?f1:(t="function"==typeof e?e:fY(e),function(){return f0.call(this.children,t)}))},filter:function(e){"function"!=typeof e&&(e=fZ(e));for(var t=this._groups,n=t.length,s=Array(n),i=0;i<n;++i)for(var r,o=t[i],a=o.length,l=s[i]=[],c=0;c<a;++c)(r=o[c])&&e.call(r,r.__data__,c,o)&&l.push(r);return new mw(s,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,f8);var n=t?f4:f3,s=this._parents,i=this._groups;"function"!=typeof e&&(b=e,e=function(){return b});for(var r=i.length,o=Array(r),a=Array(r),l=Array(r),c=0;c<r;++c){var h=s[c],d=i[c],u=d.length,p="object"==typeof(x=e.call(h,h&&h.__data__,c,s))&&"length"in x?x:Array.from(x),f=p.length,m=a[c]=Array(f),g=o[c]=Array(f);n(h,d,m,g,l[c]=Array(u),p,t);for(var x,b,v,y,w=0,O=0;w<f;++w)if(v=m[w]){for(w>=O&&(O=w+1);!(y=g[O])&&++O<f;);v._next=y||null}}return(o=new mw(o,s))._enter=a,o._exit=l,o},enter:function(){return new mw(this._enter||this._groups.map(f2),this._parents)},exit:function(){return new mw(this._exit||this._groups.map(f2),this._parents)},join:function(e,t,n){var s=this.enter(),i=this,r=this.exit();return"function"==typeof e?(s=e(s))&&(s=s.selection()):s=s.append(e+""),null!=t&&(i=t(i))&&(i=i.selection()),null==n?r.remove():n(r),s&&i?s.merge(i).order():i},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,i=n.length,r=s.length,o=Math.min(i,r),a=Array(i),l=0;l<o;++l)for(var c,h=n[l],d=s[l],u=h.length,p=a[l]=Array(u),f=0;f<u;++f)(c=h[f]||d[f])&&(p[f]=c);for(;l<i;++l)a[l]=n[l];return new mw(a,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s,i=e[t],r=i.length-1,o=i[r];--r>=0;)(s=i[r])&&(o&&4^s.compareDocumentPosition(o)&&o.parentNode.insertBefore(s,o),o=s);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=f6);for(var n=this._groups,s=n.length,i=Array(s),r=0;r<s;++r){for(var o,a=n[r],l=a.length,c=i[r]=Array(l),h=0;h<l;++h)(o=a[h])&&(c[h]=o);c.sort(t)}return new mw(i,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,r=s.length;i<r;++i){var o=s[i];if(o)return o}return null},size:function(){let e=0;for(let t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var i,r=t[n],o=0,a=r.length;o<a;++o)(i=r[o])&&e.call(i,i.__data__,o,r);return this},attr:function(e,t){var n=me(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((null==t?n.local?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}}:"function"==typeof t?n.local?function(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}:function(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}:n.local?function(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}:function(e,t){return function(){this.setAttribute(e,t)}})(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?function(e){return function(){this.style.removeProperty(e)}}:"function"==typeof t?function(e,t,n){return function(){var s=t.apply(this,arguments);null==s?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}:function(e,t,n){return function(){this.style.setProperty(e,t,n)}})(e,t,null==n?"":n)):mn(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?function(e){return function(){delete this[e]}}:"function"==typeof t?function(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}:function(e,t){return function(){this[e]=t}})(e,t)):this.node()[e]},classed:function(e,t){var n=ms(e+"");if(arguments.length<2){for(var s=mi(this.node()),i=-1,r=n.length;++i<r;)if(!s.contains(n[i]))return!1;return!0}return this.each(("function"==typeof t?function(e,t){return function(){(t.apply(this,arguments)?mo:ma)(this,e)}}:t?function(e){return function(){mo(this,e)}}:function(e){return function(){ma(this,e)}})(n,t))},text:function(e){return arguments.length?this.each(null==e?ml:("function"==typeof e?function(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}:function(e){return function(){this.textContent=e}})(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?mc:("function"==typeof e?function(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}:function(e){return function(){this.innerHTML=e}})(e)):this.node().innerHTML},raise:function(){return this.each(mh)},lower:function(){return this.each(md)},append:function(e){var t="function"==typeof e?e:mu(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})},insert:function(e,t){var n="function"==typeof e?e:mu(e),s=null==t?mp:"function"==typeof t?t:fX(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})},remove:function(){return this.each(mf)},clone:function(e){return this.select(e?mg:mm)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var s,i,r=(e+"").trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}),o=r.length;if(arguments.length<2){var a=this.node().__on;if(a){for(var l,c=0,h=a.length;c<h;++c)for(s=0,l=a[c];s<o;++s)if((i=r[s]).type===l.type&&i.name===l.name)return l.value}return}for(s=0,a=t?mb:mx;s<o;++s)this.each(a(r[s],t,n));return this},dispatch:function(e,t){return this.each(("function"==typeof t?function(e,t){return function(){return mv(this,e,t.apply(this,arguments))}}:function(e,t){return function(){return mv(this,e,t)}})(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s,i=e[t],r=0,o=i.length;r<o;++r)(s=i[r])&&(yield s)}};let mN={passive:!1},mS={capture:!0,passive:!1};function mz(e){e.stopImmediatePropagation()}function mC(e){e.preventDefault(),e.stopImmediatePropagation()}function m_(e){var t=e.document.documentElement,n=mk(e).on("dragstart.drag",mC,mS);"onselectstart"in t?n.on("selectstart.drag",mC,mS):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function mT(e,t){var n=e.document.documentElement,s=mk(e).on("dragstart.drag",null);t&&(s.on("click.drag",mC,mS),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}let mA=e=>()=>e;function mM(e,{sourceEvent:t,subject:n,target:s,identifier:i,active:r,x:o,y:a,dx:l,dy:c,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:h}})}function mP(e){return!e.ctrlKey&&!e.button}function mE(){return this.parentNode}function mR(e,t){return null==t?{x:e.x,y:e.y}:t}function mD(){return navigator.maxTouchPoints||"ontouchstart"in this}function m$(){var e,t,n,s,i=mP,r=mE,o=mR,a=mD,l={},c=fW("start","drag","end"),h=0,d=0;function u(e){e.on("mousedown.drag",p).filter(a).on("touchstart.drag",g).on("touchmove.drag",x,mN).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(o,a){if(!s&&i.call(this,o,a)){var l=v(this,r.call(this,o,a),o,a,"mouse");l&&(mk(o.view).on("mousemove.drag",f,mS).on("mouseup.drag",m,mS),m_(o.view),mz(o),n=!1,e=o.clientX,t=o.clientY,l("start",o))}}function f(s){if(mC(s),!n){var i=s.clientX-e,r=s.clientY-t;n=i*i+r*r>d}l.mouse("drag",s)}function m(e){mk(e.view).on("mousemove.drag mouseup.drag",null),mT(e.view,n),mC(e),l.mouse("end",e)}function g(e,t){if(i.call(this,e,t)){var n,s,o=e.changedTouches,a=r.call(this,e,t),l=o.length;for(n=0;n<l;++n)(s=v(this,a,e,t,o[n].identifier,o[n]))&&(mz(e),s("start",e,o[n]))}}function x(e){var t,n,s=e.changedTouches,i=s.length;for(t=0;t<i;++t)(n=l[s[t].identifier])&&(mC(e),n("drag",e,s[t]))}function b(e){var t,n,i=e.changedTouches,r=i.length;for(s&&clearTimeout(s),s=setTimeout(function(){s=null},500),t=0;t<r;++t)(n=l[i[t].identifier])&&(mz(e),n("end",e,i[t]))}function v(e,t,n,s,i,r){var a,d,p,f=c.copy(),m=mj(r||n,t);if(null!=(p=o.call(e,new mM("beforestart",{sourceEvent:n,target:u,identifier:i,active:h,x:m[0],y:m[1],dx:0,dy:0,dispatch:f}),s)))return a=p.x-m[0]||0,d=p.y-m[1]||0,function n(r,o,c){var g,x=m;switch(r){case"start":l[i]=n,g=h++;break;case"end":delete l[i],--h;case"drag":m=mj(c||o,t),g=h}f.call(r,e,new mM(r,{sourceEvent:o,subject:p,target:u,identifier:i,active:g,x:m[0]+a,y:m[1]+d,dx:m[0]-x[0],dy:m[1]-x[1],dispatch:f}),s)}}return u.filter=function(e){return arguments.length?(i="function"==typeof e?e:mA(!!e),u):i},u.container=function(e){return arguments.length?(r="function"==typeof e?e:mA(e),u):r},u.subject=function(e){return arguments.length?(o="function"==typeof e?e:mA(e),u):o},u.touchable=function(e){return arguments.length?(a="function"==typeof e?e:mA(!!e),u):a},u.on=function(){var e=c.on.apply(c,arguments);return e===c?u:e},u.clickDistance=function(e){return arguments.length?(d=(e*=1)*e,u):Math.sqrt(d)},u}function mQ(e){return((e=Math.exp(e))+1/e)/2}mM.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};let mI=function e(t,n,s){function i(e,i){var r,o,a=e[0],l=e[1],c=e[2],h=i[0],d=i[1],u=i[2],p=h-a,f=d-l,m=p*p+f*f;if(m<1e-12)o=Math.log(u/c)/t,r=function(e){return[a+e*p,l+e*f,c*Math.exp(t*e*o)]};else{var g=Math.sqrt(m),x=(u*u-c*c+s*m)/(2*c*n*g),b=(u*u-c*c-s*m)/(2*u*n*g),v=Math.log(Math.sqrt(x*x+1)-x);o=(Math.log(Math.sqrt(b*b+1)-b)-v)/t,r=function(e){var s,i,r=e*o,h=mQ(v),d=c/(n*g)*(h*(((s=Math.exp(2*(s=t*r+v)))-1)/(s+1))-((i=Math.exp(i=v))-1/i)/2);return[a+d*p,l+d*f,c*h/mQ(t*r+v)]}}return r.duration=1e3*o*t/Math.SQRT2,r}return i.rho=function(t){var n=Math.max(.001,+t),s=n*n;return e(n,s,s*s)},i}(Math.SQRT2,2,4);var mL,mq,mB,mW,mV,mF,mH,mX,mU,mG,mZ,mY=0,mK=0,mJ=0,m0=0,m1=0,m2=0,m5="object"==typeof performance&&performance.now?performance:Date,m3="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function m4(){return m1||(m3(m8),m1=m5.now()+m2)}function m8(){m1=0}function m6(){this._call=this._time=this._next=null}function m9(e,t,n){var s=new m6;return s.restart(e,t,n),s}function m7(){m1=(m0=m5.now())+m2,mY=mK=0;try{m4(),++mY;for(var e,t=mG;t;)(e=m1-t._time)>=0&&t._call.call(void 0,e),t=t._next;--mY}finally{mY=0,function(){for(var e,t,n=mG,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:mG=t);mZ=e,gt(s)}(),m1=0}}function ge(){var e=m5.now(),t=e-m0;t>1e3&&(m2-=t,m0=e)}function gt(e){!mY&&(mK&&(mK=clearTimeout(mK)),e-m1>24?(e<1/0&&(mK=setTimeout(m7,e-m5.now()-m2)),mJ&&(mJ=clearInterval(mJ))):(mJ||(m0=m5.now(),mJ=setInterval(ge,1e3)),mY=1,m3(m7)))}function gn(e,t,n){var s=new m6;return t=null==t?0:+t,s.restart(n=>{s.stop(),e(n+t)},t,n),s}m6.prototype=m9.prototype={constructor:m6,restart:function(e,t,n){if("function"!=typeof e)throw TypeError("callback is not a function");n=(null==n?m4():+n)+(null==t?0:+t),this._next||mZ===this||(mZ?mZ._next=this:mG=this,mZ=this),this._call=e,this._time=n,gt()},stop:function(){this._call&&(this._call=null,this._time=1/0,gt())}};var gs=fW("start","end","cancel","interrupt"),gi=[];function gr(e,t,n,s,i,r){var o=e.__transition;if(o){if(n in o)return}else e.__transition={};!function(e,t,n){var s,i=e.__transition;function r(l){var c,h,d,u;if(1!==n.state)return a();for(c in i)if((u=i[c]).name===n.name){if(3===u.state)return gn(r);4===u.state?(u.state=6,u.timer.stop(),u.on.call("interrupt",e,e.__data__,u.index,u.group),delete i[c]):+c<t&&(u.state=6,u.timer.stop(),u.on.call("cancel",e,e.__data__,u.index,u.group),delete i[c])}if(gn(function(){3===n.state&&(n.state=4,n.timer.restart(o,n.delay,n.time),o(l))}),n.state=2,n.on.call("start",e,e.__data__,n.index,n.group),2===n.state){for(c=0,n.state=3,s=Array(d=n.tween.length),h=-1;c<d;++c)(u=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(s[++h]=u);s.length=h+1}}function o(t){for(var i=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(a),n.state=5,1),r=-1,o=s.length;++r<o;)s[r].call(e,i);5===n.state&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){for(var s in n.state=6,n.timer.stop(),delete i[t],i)return;delete e.__transition}i[t]=n,n.timer=m9(function(e){n.state=1,n.timer.restart(r,n.delay,n.time),n.delay<=e&&r(e-n.delay)},0,n.time)}(e,n,{name:t,index:s,group:i,on:gs,tween:gi,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:0})}function go(e,t){var n=gl(e,t);if(n.state>0)throw Error("too late; already scheduled");return n}function ga(e,t){var n=gl(e,t);if(n.state>3)throw Error("too late; already running");return n}function gl(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error("transition not found");return n}function gc(e,t){var n,s,i,r=e.__transition,o=!0;if(r){for(i in t=null==t?null:t+"",r){if((n=r[i]).name!==t){o=!1;continue}s=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(s?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete r[i]}o&&delete e.__transition}}function gh(e,t){return e*=1,t*=1,function(n){return e*(1-n)+t*n}}var gd=180/Math.PI,gu={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gp(e,t,n,s,i,r){var o,a,l;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(l=e*n+t*s)&&(n-=e*l,s-=t*l),(a=Math.sqrt(n*n+s*s))&&(n/=a,s/=a,l/=a),e*s<t*n&&(e=-e,t=-t,l=-l,o=-o),{translateX:i,translateY:r,rotate:Math.atan2(t,e)*gd,skewX:Math.atan(l)*gd,scaleX:o,scaleY:a}}function gf(e,t,n,s){function i(e){return e.length?e.pop()+" ":""}return function(r,o){var a,l,c,h,d=[],u=[];return r=e(r),o=e(o),!function(e,s,i,r,o,a){if(e!==i||s!==r){var l=o.push("translate(",null,t,null,n);a.push({i:l-4,x:gh(e,i)},{i:l-2,x:gh(s,r)})}else(i||r)&&o.push("translate("+i+t+r+n)}(r.translateX,r.translateY,o.translateX,o.translateY,d,u),a=r.rotate,l=o.rotate,a!==l?(a-l>180?l+=360:l-a>180&&(a+=360),u.push({i:d.push(i(d)+"rotate(",null,s)-2,x:gh(a,l)})):l&&d.push(i(d)+"rotate("+l+s),c=r.skewX,h=o.skewX,c!==h?u.push({i:d.push(i(d)+"skewX(",null,s)-2,x:gh(c,h)}):h&&d.push(i(d)+"skewX("+h+s),!function(e,t,n,s,r,o){if(e!==n||t!==s){var a=r.push(i(r)+"scale(",null,",",null,")");o.push({i:a-4,x:gh(e,n)},{i:a-2,x:gh(t,s)})}else(1!==n||1!==s)&&r.push(i(r)+"scale("+n+","+s+")")}(r.scaleX,r.scaleY,o.scaleX,o.scaleY,d,u),r=o=null,function(e){for(var t,n=-1,s=u.length;++n<s;)d[(t=u[n]).i]=t.x(e);return d.join("")}}}var gm=gf(function(e){let t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?gu:gp(t.a,t.b,t.c,t.d,t.e,t.f)},"px, ","px)","deg)"),gg=gf(function(e){return null==e?gu:(u||(u=document.createElementNS("http://www.w3.org/2000/svg","g")),u.setAttribute("transform",e),e=u.transform.baseVal.consolidate())?gp((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):gu},", ",")",")");function gx(e,t,n){var s=e._id;return e.each(function(){var e=ga(this,s);(e.value||(e.value={}))[t]=n.apply(this,arguments)}),function(e){return gl(e,s).value[t]}}function gb(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function gv(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function gy(){}var gw="\\s*([+-]?\\d+)\\s*",gO="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",gk="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gj=/^#([0-9a-f]{3,8})$/,gN=RegExp(`^rgb\\(${gw},${gw},${gw}\\)$`),gS=RegExp(`^rgb\\(${gk},${gk},${gk}\\)$`),gz=RegExp(`^rgba\\(${gw},${gw},${gw},${gO}\\)$`),gC=RegExp(`^rgba\\(${gk},${gk},${gk},${gO}\\)$`),g_=RegExp(`^hsl\\(${gO},${gk},${gk}\\)$`),gT=RegExp(`^hsla\\(${gO},${gk},${gk},${gO}\\)$`),gA={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32};function gM(){return this.rgb().formatHex()}function gP(){return this.rgb().formatRgb()}function gE(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=gj.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?gR(t):3===n?new gQ(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?gD(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?gD(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=gN.exec(e))?new gQ(t[1],t[2],t[3],1):(t=gS.exec(e))?new gQ(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=gz.exec(e))?gD(t[1],t[2],t[3],t[4]):(t=gC.exec(e))?gD(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=g_.exec(e))?gV(t[1],t[2]/100,t[3]/100,1):(t=gT.exec(e))?gV(t[1],t[2]/100,t[3]/100,t[4]):gA.hasOwnProperty(e)?gR(gA[e]):"transparent"===e?new gQ(NaN,NaN,NaN,0):null}function gR(e){return new gQ(e>>16&255,e>>8&255,255&e,1)}function gD(e,t,n,s){return s<=0&&(e=t=n=NaN),new gQ(e,t,n,s)}function g$(e,t,n,s){var i;return 1==arguments.length?((i=e)instanceof gy||(i=gE(i)),i)?new gQ((i=i.rgb()).r,i.g,i.b,i.opacity):new gQ:new gQ(e,t,n,null==s?1:s)}function gQ(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}function gI(){return`#${gW(this.r)}${gW(this.g)}${gW(this.b)}`}function gL(){let e=gq(this.opacity);return`${1===e?"rgb(":"rgba("}${gB(this.r)}, ${gB(this.g)}, ${gB(this.b)}${1===e?")":`, ${e})`}`}function gq(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gB(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function gW(e){return((e=gB(e))<16?"0":"")+e.toString(16)}function gV(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new gH(e,t,n,s)}function gF(e){if(e instanceof gH)return new gH(e.h,e.s,e.l,e.opacity);if(e instanceof gy||(e=gE(e)),!e)return new gH;if(e instanceof gH)return e;var t=(e=e.rgb()).r/255,n=e.g/255,s=e.b/255,i=Math.min(t,n,s),r=Math.max(t,n,s),o=NaN,a=r-i,l=(r+i)/2;return a?(o=t===r?(n-s)/a+(n<s)*6:n===r?(s-t)/a+2:(t-n)/a+4,a/=l<.5?r+i:2-r-i,o*=60):a=l>0&&l<1?0:o,new gH(o,a,l,e.opacity)}function gH(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}function gX(e){return(e=(e||0)%360)<0?e+360:e}function gU(e){return Math.max(0,Math.min(1,e||0))}function gG(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}function gZ(e,t,n,s,i){var r=e*e,o=r*e;return((1-3*e+3*r-o)*t+(4-6*r+3*o)*n+(1+3*e+3*r-3*o)*s+o*i)/6}gb(gy,gE,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:gM,formatHex:gM,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return gF(this).formatHsl()},formatRgb:gP,toString:gP}),gb(gQ,g$,gv(gy,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new gQ(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new gQ(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new gQ(gB(this.r),gB(this.g),gB(this.b),gq(this.opacity))},displayable(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:gI,formatHex:gI,formatHex8:function(){return`#${gW(this.r)}${gW(this.g)}${gW(this.b)}${gW((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:gL,toString:gL})),gb(gH,function(e,t,n,s){return 1==arguments.length?gF(e):new gH(e,t,n,null==s?1:s)},gv(gy,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new gH(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new gH(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,s=n+(n<.5?n:1-n)*t,i=2*n-s;return new gQ(gG(e>=240?e-240:e+120,i,s),gG(e,i,s),gG(e<120?e+240:e-120,i,s),this.opacity)},clamp(){return new gH(gX(this.h),gU(this.s),gU(this.l),gq(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=gq(this.opacity);return`${1===e?"hsl(":"hsla("}${gX(this.h)}, ${100*gU(this.s)}%, ${100*gU(this.l)}%${1===e?")":`, ${e})`}`}}));let gY=e=>()=>e;function gK(e,t){var n=t-e;return n?function(t){return e+t*n}:gY(isNaN(e)?t:e)}let gJ=function e(t){var n,s=1==(n=+t)?gK:function(e,t){var s,i,r;return t-e?(s=e,i=t,s=Math.pow(s,r=n),i=Math.pow(i,r)-s,r=1/r,function(e){return Math.pow(s+e*i,r)}):gY(isNaN(e)?t:e)};function i(e,t){var n=s((e=g$(e)).r,(t=g$(t)).r),i=s(e.g,t.g),r=s(e.b,t.b),o=gK(e.opacity,t.opacity);return function(t){return e.r=n(t),e.g=i(t),e.b=r(t),e.opacity=o(t),e+""}}return i.gamma=e,i}(1);function g0(e){return function(t){var n,s,i=t.length,r=Array(i),o=Array(i),a=Array(i);for(n=0;n<i;++n)s=g$(t[n]),r[n]=s.r||0,o[n]=s.g||0,a[n]=s.b||0;return r=e(r),o=e(o),a=e(a),s.opacity=1,function(e){return s.r=r(e),s.g=o(e),s.b=a(e),s+""}}}g0(function(e){var t=e.length-1;return function(n){var s=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),i=e[s],r=e[s+1],o=s>0?e[s-1]:2*i-r,a=s<t-1?e[s+2]:2*r-i;return gZ((n-s/t)*t,o,i,r,a)}}),g0(function(e){var t=e.length;return function(n){var s=Math.floor(((n%=1)<0?++n:n)*t),i=e[(s+t-1)%t],r=e[s%t],o=e[(s+1)%t],a=e[(s+2)%t];return gZ((n-s/t)*t,i,r,o,a)}});var g1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,g2=RegExp(g1.source,"g");function g5(e,t){var n,s,i,r,o,a=g1.lastIndex=g2.lastIndex=0,l=-1,c=[],h=[];for(e+="",t+="";(i=g1.exec(e))&&(r=g2.exec(t));)(o=r.index)>a&&(o=t.slice(a,o),c[l]?c[l]+=o:c[++l]=o),(i=i[0])===(r=r[0])?c[l]?c[l]+=r:c[++l]=r:(c[++l]=null,h.push({i:l,x:gh(i,r)})),a=g2.lastIndex;return a<t.length&&(o=t.slice(a),c[l]?c[l]+=o:c[++l]=o),c.length<2?h[0]?(n=h[0].x,function(e){return n(e)+""}):(s=t,function(){return s}):(t=h.length,function(e){for(var n,s=0;s<t;++s)c[(n=h[s]).i]=n.x(e);return c.join("")})}function g3(e,t){var n;return("number"==typeof t?gh:t instanceof gE?gJ:(n=gE(t))?(t=n,gJ):g5)(e,t)}var g4=mO.prototype.constructor;function g8(e){return function(){this.style.removeProperty(e)}}var g6=0;function g9(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}var g7=mO.prototype;g9.prototype=(function(e){return mO().transition(e)}).prototype={constructor:g9,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=fX(e));for(var s=this._groups,i=s.length,r=Array(i),o=0;o<i;++o)for(var a,l,c=s[o],h=c.length,d=r[o]=Array(h),u=0;u<h;++u)(a=c[u])&&(l=e.call(a,a.__data__,u,c))&&("__data__"in a&&(l.__data__=a.__data__),d[u]=l,gr(d[u],t,n,u,d,gl(a,n)));return new g9(r,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=fG(e));for(var s=this._groups,i=s.length,r=[],o=[],a=0;a<i;++a)for(var l,c=s[a],h=c.length,d=0;d<h;++d)if(l=c[d]){for(var u,p=e.call(l,l.__data__,d,c),f=gl(l,n),m=0,g=p.length;m<g;++m)(u=p[m])&&gr(u,t,n,m,p,f);r.push(p),o.push(l)}return new g9(r,o,t,n)},selectChild:g7.selectChild,selectChildren:g7.selectChildren,filter:function(e){"function"!=typeof e&&(e=fZ(e));for(var t=this._groups,n=t.length,s=Array(n),i=0;i<n;++i)for(var r,o=t[i],a=o.length,l=s[i]=[],c=0;c<a;++c)(r=o[c])&&e.call(r,r.__data__,c,o)&&l.push(r);return new g9(s,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,s=t.length,i=n.length,r=Math.min(s,i),o=Array(s),a=0;a<r;++a)for(var l,c=t[a],h=n[a],d=c.length,u=o[a]=Array(d),p=0;p<d;++p)(l=c[p]||h[p])&&(u[p]=l);for(;a<s;++a)o[a]=t[a];return new g9(o,this._parents,this._name,this._id)},selection:function(){return new g4(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=++g6,s=this._groups,i=s.length,r=0;r<i;++r)for(var o,a=s[r],l=a.length,c=0;c<l;++c)if(o=a[c]){var h=gl(o,t);gr(o,e,n,c,a,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new g9(s,this._parents,e,n)},call:g7.call,nodes:g7.nodes,node:g7.node,size:g7.size,empty:g7.empty,each:g7.each,on:function(e,t){var n,s,i,r,o,a,l=this._id;return arguments.length<2?gl(this.node(),l).on.on(e):this.each((n=l,s=e,i=t,a=(s+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e})?go:ga,function(){var e=a(this,n),t=e.on;t!==r&&(o=(r=t).copy()).on(s,i),e.on=o}))},attr:function(e,t){var n=me(e),s="transform"===n?gg:g3;return this.attrTween(e,"function"==typeof t?(n.local?function(e,t,n){var s,i,r;return function(){var o,a,l=n(this);return null==l?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local))===(a=l+"")?null:o===s&&a===i?r:(i=a,r=t(s=o,l))}}:function(e,t,n){var s,i,r;return function(){var o,a,l=n(this);return null==l?void this.removeAttribute(e):(o=this.getAttribute(e))===(a=l+"")?null:o===s&&a===i?r:(i=a,r=t(s=o,l))}})(n,s,gx(this,"attr."+e,t)):null==t?(n.local?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}})(n):(n.local?function(e,t,n){var s,i,r=n+"";return function(){var o=this.getAttributeNS(e.space,e.local);return o===r?null:o===s?i:i=t(s=o,n)}}:function(e,t,n){var s,i,r=n+"";return function(){var o=this.getAttribute(e);return o===r?null:o===s?i:i=t(s=o,n)}})(n,s,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw Error();var s=me(e);return this.tween(n,(s.local?function(e,t){var n,s;function i(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&function(t){this.setAttributeNS(e.space,e.local,i.call(this,t))}),n}return i._value=t,i}:function(e,t){var n,s;function i(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&function(t){this.setAttribute(e,i.call(this,t))}),n}return i._value=t,i})(s,t))},style:function(e,t,n){var s,i,r,o,a,l,c,h,d,u,p,f,m,g,x,b,v,y,w,O,k,j="transform"==(e+="")?gm:g3;return null==t?this.styleTween(e,(s=e,function(){var e=mn(this,s),t=(this.style.removeProperty(s),mn(this,s));return e===t?null:e===i&&t===r?o:o=j(i=e,r=t)})).on("end.style."+e,g8(e)):"function"==typeof t?this.styleTween(e,(a=e,l=gx(this,"style."+e,t),function(){var e=mn(this,a),t=l(this),n=t+"";return null==t&&(this.style.removeProperty(a),n=t=mn(this,a)),e===n?null:e===c&&n===h?d:(h=n,d=j(c=e,t))})).each((u=this._id,v="end."+(b="style."+(p=e)),function(){var e=ga(this,u),t=e.on,n=null==e.value[b]?x||(x=g8(p)):void 0;(t!==f||g!==n)&&(m=(f=t).copy()).on(v,g=n),e.on=m})):this.styleTween(e,(y=e,k=t+"",function(){var e=mn(this,y);return e===k?null:e===w?O:O=j(w=e,t)}),n).on("end.style."+e,null)},styleTween:function(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(null==t)return this.tween(s,null);if("function"!=typeof t)throw Error();return this.tween(s,function(e,t,n){var s,i;function r(){var r=t.apply(this,arguments);return r!==i&&(s=(i=r)&&function(t){this.style.setProperty(e,r.call(this,t),n)}),s}return r._value=t,r}(e,t,null==n?"":n))},text:function(e){var t,n;return this.tween("text","function"==typeof e?(t=gx(this,"text",e),function(){var e=t(this);this.textContent=null==e?"":e}):(n=null==e?"":e+"",function(){this.textContent=n}))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw Error();return this.tween(t,function(e){var t,n;function s(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&function(e){this.textContent=s.call(this,e)}),t}return s._value=e,s}(e))},remove:function(){var e;return this.on("end.remove",(e=this._id,function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s,i=gl(this.node(),n).tween,r=0,o=i.length;r<o;++r)if((s=i[r]).name===e)return s.value;return null}return this.each((null==t?function(e,t){var n,s;return function(){var i=ga(this,e),r=i.tween;if(r!==n){s=n=r;for(var o=0,a=s.length;o<a;++o)if(s[o].name===t){(s=s.slice()).splice(o,1);break}}i.tween=s}}:function(e,t,n){var s,i;if("function"!=typeof n)throw Error();return function(){var r=ga(this,e),o=r.tween;if(o!==s){i=(s=o).slice();for(var a={name:t,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=a;break}l===c&&i.push(a)}r.tween=i}})(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?function(e,t){return function(){go(this,e).delay=+t.apply(this,arguments)}}:function(e,t){return t*=1,function(){go(this,e).delay=t}})(t,e)):gl(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?function(e,t){return function(){ga(this,e).duration=+t.apply(this,arguments)}}:function(e,t){return t*=1,function(){ga(this,e).duration=t}})(t,e)):gl(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw Error();return function(){ga(this,e).ease=t}}(t,e)):gl(this.node(),t).ease},easeVarying:function(e){var t;if("function"!=typeof e)throw Error();return this.each((t=this._id,function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw Error();ga(this,t).ease=n}))},end:function(){var e,t,n=this,s=n._id,i=n.size();return new Promise(function(r,o){var a={value:o},l={value:function(){0==--i&&r()}};n.each(function(){var n=ga(this,s),i=n.on;i!==e&&((t=(e=i).copy())._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),n.on=t}),0===i&&r()})},[Symbol.iterator]:g7[Symbol.iterator]};var xe={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};mO.prototype.interrupt=function(e){return this.each(function(){gc(this,e)})},mO.prototype.transition=function(e){var t,n;e instanceof g9?(t=e._id,e=e._name):(t=++g6,(n=xe).time=m4(),e=null==e?null:e+"");for(var s=this._groups,i=s.length,r=0;r<i;++r)for(var o,a=s[r],l=a.length,c=0;c<l;++c)(o=a[c])&&gr(o,e,t,c,a,n||function(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}(o,t));return new g9(s,this._parents,e,t)};let xt=e=>()=>e;function xn(e,{sourceEvent:t,target:n,transform:s,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:i}})}function xs(e,t,n){this.k=e,this.x=t,this.y=n}xs.prototype={constructor:xs,scale:function(e){return 1===e?this:new xs(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new xs(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var xi=new xs(1,0,0);function xr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return xi;return e.__zoom}function xo(e){e.stopImmediatePropagation()}function xa(e){e.preventDefault(),e.stopImmediatePropagation()}function xl(e){return(!e.ctrlKey||"wheel"===e.type)&&!e.button}function xc(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function xh(){return this.__zoom||xi}function xd(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function xu(){return navigator.maxTouchPoints||"ontouchstart"in this}function xp(e,t,n){var s=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i),o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o))}function xf(){var e,t,n,s=xl,i=xc,r=xp,o=xd,a=xu,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,d=mI,u=fW("start","zoom","end"),p=0,f=10;function m(e){e.property("__zoom",xh).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",j).filter(a).on("touchstart.zoom",N).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new xs(t,e.x,e.y)}function x(e,t,n){var s=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return s===e.x&&i===e.y?e:new xs(e.k,s,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function v(e,t,n,s){e.on("start.zoom",function(){y(this,arguments).event(s).start()}).on("interrupt.zoom end.zoom",function(){y(this,arguments).event(s).end()}).tween("zoom",function(){var e=arguments,r=y(this,e).event(s),o=i.apply(this,e),a=null==n?b(o):"function"==typeof n?n.apply(this,e):n,l=Math.max(o[1][0]-o[0][0],o[1][1]-o[0][1]),c=this.__zoom,h="function"==typeof t?t.apply(this,e):t,u=d(c.invert(a).concat(l/c.k),h.invert(a).concat(l/h.k));return function(e){if(1===e)e=h;else{var t=u(e),n=l/t[2];e=new xs(n,a[0]-t[0]*n,a[1]-t[1]*n)}r.zoom(null,e)}})}function y(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=i.apply(e,t),this.taps=0}function O(e,...t){if(s.apply(this,arguments)){var n=y(this,t).event(e),i=this.__zoom,a=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,o.apply(this,arguments)))),h=mj(e);if(n.wheel)(n.mouse[0][0]!==h[0]||n.mouse[0][1]!==h[1])&&(n.mouse[1]=i.invert(n.mouse[0]=h)),clearTimeout(n.wheel);else{if(i.k===a)return;n.mouse=[h,i.invert(h)],gc(this),n.start()}xa(e),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",r(x(g(i,a),n.mouse[0],n.mouse[1]),n.extent,c))}}function k(e,...t){if(!n&&s.apply(this,arguments)){var i=e.currentTarget,o=y(this,t,!0).event(e),a=mk(e.view).on("mousemove.zoom",function(e){if(xa(e),!o.moved){var t=e.clientX-h,n=e.clientY-d;o.moved=t*t+n*n>p}o.event(e).zoom("mouse",r(x(o.that.__zoom,o.mouse[0]=mj(e,i),o.mouse[1]),o.extent,c))},!0).on("mouseup.zoom",function(e){a.on("mousemove.zoom mouseup.zoom",null),mT(e.view,o.moved),xa(e),o.event(e).end()},!0),l=mj(e,i),h=e.clientX,d=e.clientY;m_(e.view),xo(e),o.mouse=[l,this.__zoom.invert(l)],gc(this),o.start()}}function j(e,...t){if(s.apply(this,arguments)){var n=this.__zoom,o=mj(e.changedTouches?e.changedTouches[0]:e,this),a=n.invert(o),l=n.k*(e.shiftKey?.5:2),d=r(x(g(n,l),o,a),i.apply(this,t),c);xa(e),h>0?mk(this).transition().duration(h).call(v,d,o,e):mk(this).call(m.transform,d,o,e)}}function N(n,...i){if(s.apply(this,arguments)){var r,o,a,l,c=n.touches,h=c.length,d=y(this,i,n.changedTouches.length===h).event(n);for(xo(n),o=0;o<h;++o)l=[l=mj(a=c[o],this),this.__zoom.invert(l),a.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,r=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),r&&(d.taps<2&&(t=l[0],e=setTimeout(function(){e=null},500)),gc(this),d.start())}}function S(e,...t){if(this.__zooming){var n,s,i,o,a=y(this,t).event(e),l=e.changedTouches,h=l.length;for(xa(e),n=0;n<h;++n)i=mj(s=l[n],this),a.touch0&&a.touch0[2]===s.identifier?a.touch0[0]=i:a.touch1&&a.touch1[2]===s.identifier&&(a.touch1[0]=i);if(s=a.that.__zoom,a.touch1){var d=a.touch0[0],u=a.touch0[1],p=a.touch1[0],f=a.touch1[1],m=(m=p[0]-d[0])*m+(m=p[1]-d[1])*m,b=(b=f[0]-u[0])*b+(b=f[1]-u[1])*b;s=g(s,Math.sqrt(m/b)),i=[(d[0]+p[0])/2,(d[1]+p[1])/2],o=[(u[0]+f[0])/2,(u[1]+f[1])/2]}else{if(!a.touch0)return;i=a.touch0[0],o=a.touch0[1]}a.zoom("touch",r(x(s,i,o),a.extent,c))}}function z(e,...s){if(this.__zooming){var i,r,o=y(this,s).event(e),a=e.changedTouches,l=a.length;for(xo(e),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)r=a[i],o.touch0&&o.touch0[2]===r.identifier?delete o.touch0:o.touch1&&o.touch1[2]===r.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(r=mj(r,this),Math.hypot(t[0]-r[0],t[1]-r[1])<f)){var c=mk(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return m.transform=function(e,t,n,s){var i=e.selection?e.selection():e;i.property("__zoom",xh),e!==i?v(e,t,n,s):i.interrupt().each(function(){y(this,arguments).event(s).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()})},m.scaleBy=function(e,t,n,s){m.scaleTo(e,function(){var e=this.__zoom.k,n="function"==typeof t?t.apply(this,arguments):t;return e*n},n,s)},m.scaleTo=function(e,t,n,s){m.transform(e,function(){var e=i.apply(this,arguments),s=this.__zoom,o=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,a=s.invert(o),l="function"==typeof t?t.apply(this,arguments):t;return r(x(g(s,l),o,a),e,c)},n,s)},m.translateBy=function(e,t,n,s){m.transform(e,function(){return r(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),c)},null,s)},m.translateTo=function(e,t,n,s,o){m.transform(e,function(){var e=i.apply(this,arguments),o=this.__zoom,a=null==s?b(e):"function"==typeof s?s.apply(this,arguments):s;return r(xi.translate(a[0],a[1]).scale(o.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)},s,o)},w.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=mk(this.that).datum();u.call(e,this.that,new xn(e,{sourceEvent:this.sourceEvent,target:m,type:e,transform:this.that.__zoom,dispatch:u}),t)}},m.wheelDelta=function(e){return arguments.length?(o="function"==typeof e?e:xt(+e),m):o},m.filter=function(e){return arguments.length?(s="function"==typeof e?e:xt(!!e),m):s},m.touchable=function(e){return arguments.length?(a="function"==typeof e?e:xt(!!e),m):a},m.extent=function(e){return arguments.length?(i="function"==typeof e?e:xt([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),m):i},m.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],m):[l[0],l[1]]},m.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],m):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},m.constrain=function(e){return arguments.length?(r=e,m):r},m.duration=function(e){return arguments.length?(h=+e,m):h},m.interpolate=function(e){return arguments.length?(d=e,m):d},m.on=function(){var e=u.on.apply(u,arguments);return e===u?m:e},m.clickDistance=function(e){return arguments.length?(p=(e*=1)*e,m):Math.sqrt(p)},m.tapDistance=function(e){return arguments.length?(f=+e,m):f},m}function xm(e,t){var n,s,i=typeof t;return null==t||"boolean"===i?gY(t):("number"===i?gh:"string"===i?(s=gE(t))?(t=s,gJ):g5:t instanceof gE?gJ:t instanceof Date?function(e,t){var n=new Date;return e*=1,t*=1,function(s){return n.setTime(e*(1-s)+t*s),n}}:!ArrayBuffer.isView(n=t)||n instanceof DataView?Array.isArray(t)?function(e,t){var n,s=t?t.length:0,i=e?Math.min(s,e.length):0,r=Array(i),o=Array(s);for(n=0;n<i;++n)r[n]=xm(e[n],t[n]);for(;n<s;++n)o[n]=t[n];return function(e){for(n=0;n<i;++n)o[n]=r[n](e);return o}}:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?function(e,t){var n,s={},i={};for(n in(null===e||"object"!=typeof e)&&(e={}),(null===t||"object"!=typeof t)&&(t={}),t)n in e?s[n]=xm(e[n],t[n]):i[n]=t[n];return function(e){for(n in s)i[n]=s[n](e);return i}}:gh:function(e,t){t||(t=[]);var n,s=e?Math.min(t.length,e.length):0,i=t.slice();return function(r){for(n=0;n<s;++n)i[n]=e[n]*(1-r)+t[n]*r;return i}})(e,t)}xr.prototype=xs.prototype;let xg=[[-1/0,-1/0],[1/0,1/0]],xx=["Enter"," ","Escape"],xb={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};(i=p||(p={})).Strict="strict",i.Loose="loose",(r=f||(f={})).Free="free",r.Vertical="vertical",r.Horizontal="horizontal",(o=m||(m={})).Partial="partial",o.Full="full";let xv={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};(a=g||(g={})).Bezier="default",a.Straight="straight",a.Step="step",a.SmoothStep="smoothstep",a.SimpleBezier="simplebezier",(l=x||(x={})).Arrow="arrow",l.ArrowClosed="arrowclosed",(c=b||(b={})).Left="left",c.Top="top",c.Right="right",c.Bottom="bottom";let xy={[b.Left]:b.Right,[b.Right]:b.Left,[b.Top]:b.Bottom,[b.Bottom]:b.Top};function xw(e){return null===e?null:e?"valid":"invalid"}let xO=e=>"id"in e&&"source"in e&&"target"in e,xk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),xj=(e,t=[0,0])=>{let{width:n,height:s}=xK(e),i=e.origin??t,r=n*i[0],o=s*i[1];return{x:e.position.x-r,y:e.position.y-o}},xN=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(e=>{(void 0===t.filter||t.filter(e))&&(n=xR(n,xI(e)),s=!0)}),s?x$(n):{x:0,y:0,width:0,height:0}},xS=(e,t,[n,s,i]=[0,0,1],r=!1,o=!1)=>{let a={...xH(t,[n,s,i]),width:t.width/i,height:t.height/i},l=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:s=!1}=t;if(o&&!n||s)continue;let i=e.width??t.width??t.initialWidth??null,c=e.height??t.height??t.initialHeight??null,h=xq(a,xQ(t)),d=(i??0)*(c??0),u=r&&h>0;(!t.internals.handleBounds||u||h>=d||t.dragging)&&l.push(t)}return l};async function xz({nodes:e,width:t,height:n,panZoom:s,minZoom:i,maxZoom:r},o){let a,l;if(0===e.size)return Promise.resolve(!0);let c=xG(xN((a=new Map,l=o?.nodes?new Set(o.nodes.map(e=>e.id)):null,e.forEach(e=>{e.measured.width&&e.measured.height&&(o?.includeHiddenNodes||!e.hidden)&&(!l||l.has(e.id))&&a.set(e.id,e)}),a)),t,n,o?.minZoom??i,o?.maxZoom??r,o?.padding??.1);return await s.setViewport(c,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function xC({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:i,onError:r}){let o=n.get(e),a=o.parentId?n.get(o.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},h=o.origin??s,d=o.extent||i;if("parent"!==o.extent||o.expandParent)a&&xY(o.extent)&&(d=[[o.extent[0][0]+l,o.extent[0][1]+c],[o.extent[1][0]+l,o.extent[1][1]+c]]);else if(a){let e=a.measured.width,t=a.measured.height;e&&t&&(d=[[l,c],[l+e,c+t]])}else r?.("005","Only child nodes can use a parent extent.");let u=xY(d)?xA(t,d,o.measured):t;return(void 0===o.measured.width||void 0===o.measured.height)&&r?.("015","It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."),{position:{x:u.x-l+(o.measured.width??0)*h[0],y:u.y-c+(o.measured.height??0)*h[1]},positionAbsolute:u}}async function x_({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:i}){let r,o=new Set(e.map(e=>e.id)),a=[];for(let e of n){if(!1===e.deletable)continue;let t=o.has(e.id),n=!t&&e.parentId&&a.find(t=>t.id===e.parentId);(t||n)&&a.push(e)}let l=new Set(t.map(e=>e.id)),c=s.filter(e=>!1!==e.deletable),h=(r=new Set,a.forEach(e=>{r.add(e.id)}),c.filter(e=>r.has(e.source)||r.has(e.target)));for(let e of c)l.has(e.id)&&!h.find(t=>t.id===e.id)&&h.push(e);if(!i)return{edges:h,nodes:a};let d=await i({nodes:a,edges:h});return"boolean"==typeof d?d?{edges:h,nodes:a}:{edges:[],nodes:[]}:d}let xT=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),xA=(e={x:0,y:0},t,n)=>({x:xT(e.x,t[0][0],t[1][0]-(n?.width??0)),y:xT(e.y,t[0][1],t[1][1]-(n?.height??0))});function xM(e,t,n){let{width:s,height:i}=xK(n),{x:r,y:o}=n.internals.positionAbsolute;return xA(e,[[r,o],[r+s,o+i]],t)}let xP=(e,t,n)=>e<t?xT(Math.abs(e-t),1,t)/t:e>n?-xT(Math.abs(e-n),1,t)/t:0,xE=(e,t,n=15,s=40)=>[xP(e.x,s,t.width-s)*n,xP(e.y,s,t.height-s)*n],xR=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),xD=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),x$=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),xQ=(e,t=[0,0])=>{let{x:n,y:s}=xk(e)?e.internals.positionAbsolute:xj(e,t);return{x:n,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},xI=(e,t=[0,0])=>{let{x:n,y:s}=xk(e)?e.internals.positionAbsolute:xj(e,t);return{x:n,y:s,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},xL=(e,t)=>x$(xR(xD(e),xD(t))),xq=(e,t)=>Math.ceil(Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))),xB=e=>xW(e.width)&&xW(e.height)&&xW(e.x)&&xW(e.y),xW=e=>!isNaN(e)&&isFinite(e),xV=(e,t)=>{},xF=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),xH=({x:e,y:t},[n,s,i],r=!1,o=[1,1])=>{let a={x:(e-n)/i,y:(t-s)/i};return r?xF(a,o):a},xX=({x:e,y:t},[n,s,i])=>({x:e*i+n,y:t*i+s});function xU(e,t){if("number"==typeof e)return Math.floor((t-t/(1+e))*.5);if("string"==typeof e&&e.endsWith("px")){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if("string"==typeof e&&e.endsWith("%")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}let xG=(e,t,n,s,i,r)=>{let o=function(e,t,n){if("string"==typeof e||"number"==typeof e){let s=xU(e,n),i=xU(e,t);return{top:s,right:i,bottom:s,left:i,x:2*i,y:2*s}}if("object"==typeof e){let s=xU(e.top??e.y??0,n),i=xU(e.bottom??e.y??0,n),r=xU(e.left??e.x??0,t),o=xU(e.right??e.x??0,t);return{top:s,right:o,bottom:i,left:r,x:r+o,y:s+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}(r,t,n),a=xT(Math.min((t-o.x)/e.width,(n-o.y)/e.height),s,i),l=e.x+e.width/2,c=e.y+e.height/2,h=t/2-l*a,d=n/2-c*a,u=function(e,t,n,s,i,r){let{x:o,y:a}=xX(e,[t,n,s]),{x:l,y:c}=xX({x:e.x+e.width,y:e.y+e.height},[t,n,s]);return{left:Math.floor(o),top:Math.floor(a),right:Math.floor(i-l),bottom:Math.floor(r-c)}}(e,h,d,a,t,n),p={left:Math.min(u.left-o.left,0),top:Math.min(u.top-o.top,0),right:Math.min(u.right-o.right,0),bottom:Math.min(u.bottom-o.bottom,0)};return{x:h-p.left+p.right,y:d-p.top+p.bottom,zoom:a}},xZ=()=>"u">typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function xY(e){return null!=e&&"parent"!==e}function xK(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function xJ(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function x0(e,t={width:0,height:0},n,s,i){let r={...e},o=s.get(n);if(o){let e=o.origin||i;r.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],r.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return r}function x1(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function x2(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:i}){let{x:r,y:o}=x6(e),a=xH({x:r-(i?.left??0),y:o-(i?.top??0)},s),{x:l,y:c}=n?xF(a,t):a;return{xSnapped:l,ySnapped:c,...a}}let x5=e=>({width:e.offsetWidth,height:e.offsetHeight}),x3=e=>e?.getRootNode?.()||window?.document,x4=["INPUT","SELECT","TEXTAREA"];function x8(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1&&(x4.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey"))}let x6=(e,t)=>{let n="clientX"in e,s=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:i-(t?.top??0)}},x9=(e,t,n,s,i)=>{let r=t.querySelectorAll(`.${e}`);return r&&r.length?Array.from(r).map(t=>{let r=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:i,position:t.getAttribute("data-handlepos"),x:(r.left-n.left)/s,y:(r.top-n.top)/s,...x5(t)}}):null};function x7({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:i,sourceControlY:r,targetControlX:o,targetControlY:a}){let l=.125*e+.375*i+.375*o+.125*n,c=.125*t+.375*r+.375*a+.125*s,h=Math.abs(l-e),d=Math.abs(c-t);return[l,c,h,d]}function be(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function bt({pos:e,x1:t,y1:n,x2:s,y2:i,c:r}){switch(e){case b.Left:return[t-be(t-s,r),n];case b.Right:return[t+be(s-t,r),n];case b.Top:return[t,n-be(n-i,r)];case b.Bottom:return[t,n+be(i-n,r)]}}function bn({sourceX:e,sourceY:t,sourcePosition:n=b.Bottom,targetX:s,targetY:i,targetPosition:r=b.Top,curvature:o=.25}){let[a,l]=bt({pos:n,x1:e,y1:t,x2:s,y2:i,c:o}),[c,h]=bt({pos:r,x1:s,y1:i,x2:e,y2:t,c:o}),[d,u,p,f]=x7({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:h});return[`M${e},${t} C${a},${l} ${c},${h} ${s},${i}`,d,u,p,f]}function bs({sourceX:e,sourceY:t,targetX:n,targetY:s}){let i=Math.abs(n-e)/2,r=Math.abs(s-t)/2;return[n<e?n+i:n-i,s<t?s+r:s-r,i,r]}let bi=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,br=(e,t,n={})=>{let s,i;if(!e.source||!e.target)return xV("006","Can't create edge. An edge needs a source and a target."),t;let r=n.getEdgeId||bi;return(i=s=xO(e)?{...e}:{...e,id:r(e)},t.some(e=>e.source===i.source&&e.target===i.target&&(e.sourceHandle===i.sourceHandle||!e.sourceHandle&&!i.sourceHandle)&&(e.targetHandle===i.targetHandle||!e.targetHandle&&!i.targetHandle)))?t:(null===s.sourceHandle&&delete s.sourceHandle,null===s.targetHandle&&delete s.targetHandle,t.concat(s))};function bo({sourceX:e,sourceY:t,targetX:n,targetY:s}){let[i,r,o,a]=bs({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,i,r,o,a]}let ba={[b.Left]:{x:-1,y:0},[b.Right]:{x:1,y:0},[b.Top]:{x:0,y:-1},[b.Bottom]:{x:0,y:1}},bl=({source:e,sourcePosition:t=b.Bottom,target:n})=>t===b.Left||t===b.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},bc=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function bh({sourceX:e,sourceY:t,sourcePosition:n=b.Bottom,targetX:s,targetY:i,targetPosition:r=b.Top,borderRadius:o=5,centerX:a,centerY:l,offset:c=20,stepPosition:h=.5}){let[d,u,p,f,m]=function({source:e,sourcePosition:t=b.Bottom,target:n,targetPosition:s=b.Top,center:i,offset:r,stepPosition:o}){let a,l,c=ba[t],h=ba[s],d={x:e.x+c.x*r,y:e.y+c.y*r},u={x:n.x+h.x*r,y:n.y+h.y*r},p=bl({source:d,sourcePosition:t,target:u}),f=0!==p.x?"x":"y",m=p[f],g=[],x={x:0,y:0},v={x:0,y:0},[,,y,w]=bs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[f]*h[f]==-1){"x"===f?(a=i.x??d.x+(u.x-d.x)*o,l=i.y??(d.y+u.y)/2):(a=i.x??(d.x+u.x)/2,l=i.y??d.y+(u.y-d.y)*o);let e=[{x:a,y:d.y},{x:a,y:u.y}],t=[{x:d.x,y:l},{x:u.x,y:l}];g=c[f]===m?"x"===f?e:t:"x"===f?t:e}else{let i=[{x:d.x,y:u.y}],o=[{x:u.x,y:d.y}];if(g="x"===f?c.x===m?o:i:c.y===m?i:o,t===s){let t=Math.abs(e[f]-n[f]);if(t<=r){let s=Math.min(r-1,r-t);c[f]===m?x[f]=(d[f]>e[f]?-1:1)*s:v[f]=(u[f]>n[f]?-1:1)*s}}if(t!==s){let e="x"===f?"y":"x",t=c[f]===h[e],n=d[e]>u[e],s=d[e]<u[e];(1===c[f]&&(!t&&n||t&&s)||1!==c[f]&&(!t&&s||t&&n))&&(g="x"===f?i:o)}let p={x:d.x+x.x,y:d.y+x.y},b={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(p.x-g[0].x),Math.abs(b.x-g[0].x))>=Math.max(Math.abs(p.y-g[0].y),Math.abs(b.y-g[0].y))?(a=(p.x+b.x)/2,l=g[0].y):(a=g[0].x,l=(p.y+b.y)/2)}return[[e,{x:d.x+x.x,y:d.y+x.y},...g,{x:u.x+v.x,y:u.y+v.y},n],a,l,y,w]}({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:i},targetPosition:r,center:{x:a,y:l},offset:c,stepPosition:h});return[d.reduce((e,t,n)=>e+(n>0&&n<d.length-1?function(e,t,n,s){let i=Math.min(bc(e,t)/2,bc(t,n)/2,s),{x:r,y:o}=t;if(e.x===r&&r===n.x||e.y===o&&o===n.y)return`L${r} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,s=e.y<n.y?1:-1;return`L ${r+i*t},${o}Q ${r},${o} ${r},${o+i*s}`}let a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${r},${o+i*l}Q ${r},${o} ${r+i*a},${o}`}(d[n-1],t,d[n+1],o):`${0===n?"M":"L"}${t.x} ${t.y}`),""),u,p,f,m]}function bd(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function bu(e){if(!e)return null;let t=[],n=[];for(let s of e)s.width=s.width??1,s.height=s.height??1,"source"===s.type?t.push(s):"target"===s.type&&n.push(s);return{source:t,target:n}}function bp(e,t,n=b.Left,s=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,r=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:a}=t??xK(e);if(s)return{x:i+o/2,y:r+a/2};switch(t?.position??n){case b.Top:return{x:i+o/2,y:r};case b.Right:return{x:i+o,y:r+a/2};case b.Bottom:return{x:i+o/2,y:r+a};case b.Left:return{x:i,y:r+a/2}}}function bf(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function bm(e,t){if(!e)return"";if("string"==typeof e)return e;let n=t?`${t}__`:"";return`${n}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("&")}`}let bg={nodeOrigin:[0,0],nodeExtent:xg,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},bx={...bg,checkEquality:!0};function bb(e,t){let n={...e};for(let e in t)void 0!==t[e]&&(n[e]=t[e]);return n}function bv(e){return"manual"===e}function by(e,t,n,s={}){let i=bb(bx,s),r={i:0},o=new Map(t),a=i?.elevateNodesOnSelect&&!bv(i.zIndexMode)?1e3:0,l=e.length>0;for(let c of(t.clear(),n.clear(),e)){let e=o.get(c.id);if(i.checkEquality&&c===e?.internals.userNode)t.set(c.id,e);else{let n=xA(xj(c,i.nodeOrigin),xY(c.extent)?c.extent:i.nodeExtent,xK(c));e={...i.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:n,handleBounds:function(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],s=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};"source"===t.type?n.push(i):"target"===t.type&&s.push(i)}return{source:n,target:s}}(c,e),z:bO(c,a,i.zIndexMode),userNode:c}},t.set(c.id,e)}void 0!==e.measured&&void 0!==e.measured.width&&void 0!==e.measured.height||e.hidden||(l=!1),c.parentId&&bw(e,t,n,s,r)}return l}function bw(e,t,n,s,i){let{elevateNodesOnSelect:r,nodeOrigin:o,nodeExtent:a,zIndexMode:l}=bb(bg,s),c=e.parentId,h=t.get(c);if(!h)return void console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);!function(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}(e,n),i&&!h.parentId&&void 0===h.internals.rootParentIndex&&"auto"===l&&(h.internals.rootParentIndex=++i.i,h.internals.z=h.internals.z+10*i.i),i&&void 0!==h.internals.rootParentIndex&&(i.i=h.internals.rootParentIndex);let{x:d,y:u,z:p}=function(e,t,n,s,i,r){let{x:o,y:a}=t.internals.positionAbsolute,l=xK(e),c=xj(e,n),h=xY(e.extent)?xA(c,e.extent,l):c,d=xA({x:o+h.x,y:a+h.y},s,l);"parent"===e.extent&&(d=xM(d,l,t));let u=bO(e,i,r),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=u?p+1:u}}(e,h,o,a,r&&!bv(l)?1e3:0,l),{positionAbsolute:f}=e.internals,m=d!==f.x||u!==f.y;(m||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:d,y:u}:f,z:p}})}function bO(e,t,n){let s=xW(e.zIndex)?e.zIndex:0;return bv(n)?s:s+(e.selected?t:0)}function bk(e,t,n,s=[0,0]){let i=[],r=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let s=xL(r.get(n.parentId)?.expandedRect??xQ(e),n.rect);r.set(n.parentId,{expandedRect:s,parent:e})}return r.size>0&&r.forEach(({expandedRect:t,parent:r},o)=>{let a=r.internals.positionAbsolute,l=xK(r),c=r.origin??s,h=t.x<a.x?Math.round(Math.abs(a.x-t.x)):0,d=t.y<a.y?Math.round(Math.abs(a.y-t.y)):0,u=Math.max(l.width,Math.round(t.width)),p=Math.max(l.height,Math.round(t.height)),f=(u-l.width)*c[0],m=(p-l.height)*c[1];(h>0||d>0||f||m)&&(i.push({id:o,type:"position",position:{x:r.position.x-h+f,y:r.position.y-d+m}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:"position",position:{x:t.position.x+h,y:t.position.y+d}})})),(l.width<t.width||l.height<t.height||h||d)&&i.push({id:o,type:"dimensions",setAttributes:!0,dimensions:{width:u+(h?c[0]*h-f:0),height:p+(d?c[1]*d-m:0)}})}),i}async function bj({delta:e,panZoom:t,transform:n,translateExtent:s,width:i,height:r}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,r]],s);return Promise.resolve(!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]))}function bN(e,t,n,s,i,r){let o=i,a=s.get(o)||new Map;s.set(o,a.set(n,t)),o=`${i}-${e}`;let l=s.get(o)||new Map;if(s.set(o,l.set(n,t)),r){o=`${i}-${e}-${r}`;let a=s.get(o)||new Map;s.set(o,a.set(n,t))}}function bS(e,t,n){for(let s of(e.clear(),t.clear(),n)){let{source:n,target:i,sourceHandle:r=null,targetHandle:o=null}=s,a={edgeId:s.id,source:n,target:i,sourceHandle:r,targetHandle:o},l=`${n}-${r}--${i}-${o}`;bN("source",a,`${i}-${o}--${n}-${r}`,e,n,r),bN("target",a,l,e,i,o),t.set(s.id,s)}}function bz(e,t,n){let s=e;do{if(s?.matches?.(t))return!0;if(s===n)break;s=s?.parentElement}while(s)return!1}function bC({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){let i=[];for(let[e,r]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:r.position,dragging:s})}if(!e)return[i[0],i];let r=n.get(e)?.internals.userNode;return[r?{...r,position:t.get(e)?.position||r.position,dragging:s}:i[0],i]}function b_(e,t,n,s,i,r=!1){let o=s.get(e);if(!o)return null;let a="strict"===i?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],l=(n?a?.find(e=>e.id===n):a?.[0])??null;return l&&r?{...l,...bp(o,l,l.position,!0)}:l}function bT(e,t){return e?e:t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null}let bA=()=>!0;function bM(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:i,fromType:r,doc:o,lib:a,flowId:l,isValidConnection:c=bA,nodeLookup:h}){let d="target"===r,u=t?o.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:f,y:m}=x6(e),g=o.elementFromPoint(f,m),x=g?.classList.contains(`${a}-flow__handle`)?g:u,b={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){let e=bT(void 0,x),t=x.getAttribute("data-nodeid"),r=x.getAttribute("data-handleid"),o=x.classList.contains("connectable"),a=x.classList.contains("connectableend");if(!t||!e)return b;let l={source:d?t:s,sourceHandle:d?r:i,target:d?s:t,targetHandle:d?i:r};b.connection=l,b.isValid=o&&a&&(n===p.Strict?d&&"source"===e||!d&&"target"===e:t!==s||r!==i)&&c(l),b.toHandle=b_(t,e,r,h,n,!0)}return b}let bP=function(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:i,edgeUpdaterType:r,isTarget:o,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:h,flowId:d,panBy:u,cancelConnection:p,onConnectStart:f,onConnect:m,onConnectEnd:g,isValidConnection:x=bA,onReconnectEnd:v,updateConnection:y,getTransform:w,getFromHandle:O,autoPanSpeed:k,dragThreshold:j=1,handleDomNode:N}){let S,z=x3(e.target),C=0,{x:_,y:T}=x6(e),A=bT(r,N),M=a?.getBoundingClientRect(),P=!1;if(!M||!A)return;let E=b_(i,A,s,l,t);if(!E)return;let R=x6(e,M),D=!1,$=null,Q=!1,I=null,L={...E,nodeId:i,type:A,position:E.position},q=l.get(i),B={inProgress:!0,isValid:null,from:bp(q,L,b.Left,!0),fromHandle:L,fromPosition:L.position,fromNode:q,to:R,toHandle:null,toPosition:xy[L.position],toNode:null,pointer:R};function W(){P=!0,y(B),f?.(e,{nodeId:i,handleId:s,handleType:A})}function V(e){var r,a;let p;if(!P){let{x:t,y:n}=x6(e),s=t-_,i=n-T;if(!(s*s+i*i>j*j))return;W()}if(!O()||!L)return void F(e);let f=w();S=function(e,t,n,s){let i=[],r=1/0;for(let o of function(e,t,n){let s=[],i={x:e.x-n,y:e.y-n,width:2*n,height:2*n};for(let e of t.values())xq(i,xQ(e))>0&&s.push(e);return s}(e,n,t+250))for(let n of[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]]){if(s.nodeId===n.nodeId&&s.type===n.type&&s.id===n.id)continue;let{x:a,y:l}=bp(o,n,n.position,!0),c=Math.sqrt(Math.pow(a-e.x,2)+Math.pow(l-e.y,2));c>t||(c<r?(i=[{...n,x:a,y:l}],r=c):c===r&&i.push({...n,x:a,y:l}))}if(!i.length)return null;if(i.length>1){let e="source"===s.type?"target":"source";return i.find(t=>t.type===e)??i[0]}return i[0]}(xH(R=x6(e,M),f,!1,[1,1]),n,l,L),D||(!function e(){if(!h||!M)return;let[t,n]=xE(R,M,k);u({x:t,y:n}),C=requestAnimationFrame(e)}(),D=!0);let m=bM(e,{handle:S,connectionMode:t,fromNodeId:i,fromHandleId:s,fromType:o?"target":"source",isValidConnection:x,doc:z,lib:c,flowId:d,nodeLookup:l});I=m.handleDomNode,$=m.connection,r=!!S,a=m.isValid,p=null,a?p=!0:r&&!a&&(p=!1),Q=p;let g=l.get(i),v=g?bp(g,L,b.Left,!0):B.from,N={...B,from:v,isValid:Q,to:m.toHandle&&Q?xX({x:m.toHandle.x,y:m.toHandle.y},f):R,toHandle:m.toHandle,toPosition:Q&&m.toHandle?m.toHandle.position:xy[L.position],toNode:m.toHandle?l.get(m.toHandle.nodeId):null,pointer:R};y(N),B=N}function F(e){if(!("touches"in e)||!(e.touches.length>0)){if(P){(S||I)&&$&&Q&&m?.($);let{inProgress:t,...n}=B,s={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,s),r&&v?.(e,s)}p(),cancelAnimationFrame(C),D=!1,Q=!1,$=null,I=null,z.removeEventListener("mousemove",V),z.removeEventListener("mouseup",F),z.removeEventListener("touchmove",V),z.removeEventListener("touchend",F)}}0===j&&W(),z.addEventListener("mousemove",V),z.addEventListener("mouseup",F),z.addEventListener("touchmove",V),z.addEventListener("touchend",F)},bE=e=>({x:e.x,y:e.y,zoom:e.k}),bR=({x:e,y:t,zoom:n})=>xi.translate(e,t).scale(n),bD=(e,t)=>e.target.closest(`.${t}`),b$=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),bQ=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bI=(e,t=0,n=bQ,s=()=>{})=>{let i="number"==typeof t&&t>0;return i||s(),i?e.transition().duration(t).ease(n).on("end",s):e},bL=e=>{let t=e.ctrlKey&&xZ()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function bq(e){let t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:e.includes("left"),affectsY:e.includes("top")}}function bB(e,t){return Math.max(0,t-e)}function bW(e,t){return Math.max(0,e-t)}function bV(e,t,n){return Math.max(0,t-e,e-n)}(h=v||(v={})).Line="line",h.Handle="handle";let bF={width:0,height:0,x:0,y:0},bH={...bF,pointerX:0,pointerY:0,aspectRatio:1};var bX=e.i(30224);let bU={get url(){return`file://${e.P("node_modules/zustand/esm/vanilla.mjs")}`}},bG=e=>{let t,n=new Set,s=(e,s)=>{let i="function"==typeof e?e(t):e;if(!Object.is(i,t)){let e=t;t=(null!=s?s:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,r={setState:s,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{(bU.env?bU.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},o=t=e(s,i,r);return r},{useDebugValue:bZ}=O.default,{useSyncExternalStoreWithSelector:bY}=bX.default,bK=e=>e;function bJ(e,t=bK,n){let s=bY(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return bZ(s),s}let b0=(e,t)=>{let n=e?bG(e):bG,s=(e,s=t)=>bJ(n,e,s);return Object.assign(s,n),s};function b1(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,s]of e)if(!Object.is(s,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}let b2=(0,O.createContext)(null),b5=b2.Provider,b3="[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001";function b4(e,t){let n=(0,O.useContext)(b2);if(null===n)throw Error(b3);return bJ(n,e,t)}function b8(){let e=(0,O.useContext)(b2);if(null===e)throw Error(b3);return(0,O.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}let b6={display:"none"},b9={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},b7="react-flow__node-desc",ve="react-flow__edge-desc",vt=e=>e.ariaLiveMessage,vn=e=>e.ariaLabelConfig;function vs({rfId:e}){let t=b4(vt);return(0,w.jsx)("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:b9,children:t})}function vi({rfId:e,disableKeyboardA11y:t}){let n=b4(vn);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{id:`${b7}-${e}`,style:b6,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),(0,w.jsx)("div",{id:`${ve}-${e}`,style:b6,children:n["edge.a11yDescription.default"]}),!t&&(0,w.jsx)(vs,{rfId:e})]})}let vr=(0,O.forwardRef)(({position:e="top-left",children:t,className:n,style:s,...i},r)=>{let o=`${e}`.split("-");return(0,w.jsx)("div",{className:fq(["react-flow__panel",n,...o]),style:s,ref:r,...i,children:t})});function vo({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:(0,w.jsx)(vr,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:(0,w.jsx)("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}vr.displayName="Panel";let va=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},vl=e=>e.id;function vc(e,t){return b1(e.selectedNodes.map(vl),t.selectedNodes.map(vl))&&b1(e.selectedEdges.map(vl),t.selectedEdges.map(vl))}function vh({onSelectionChange:e}){let t=b8(),{selectedNodes:n,selectedEdges:s}=b4(va,vc);return(0,O.useEffect)(()=>{let i={nodes:n,edges:s};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,s,e]),null}let vd=e=>!!e.onSelectionChangeHandlers;function vu({onSelectionChange:e}){let t=b4(vd);return e||t?(0,w.jsx)(vh,{onSelectionChange:e}):null}let vp=[0,0],vf={x:0,y:0,zoom:1},vm=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode","rfId"],vg=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),vx={translateExtent:xg,nodeOrigin:vp,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function vb(e){let{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:i,setTranslateExtent:r,setNodeExtent:o,reset:a,setDefaultNodesAndEdges:l}=b4(vg,b1),c=b8();(0,O.useEffect)(()=>(l(e.defaultNodes,e.defaultEdges),()=>{h.current=vx,a()}),[]);let h=(0,O.useRef)(vx);return(0,O.useEffect)(()=>{for(let a of vm){let l=e[a];if(l!==h.current[a]&&void 0!==e[a])if("nodes"===a)t(l);else if("edges"===a)n(l);else if("minZoom"===a)s(l);else if("maxZoom"===a)i(l);else if("translateExtent"===a)r(l);else if("nodeExtent"===a)o(l);else if("ariaLabelConfig"===a)c.setState({ariaLabelConfig:{...xb,...l||{}}});else"fitView"===a?c.setState({fitViewQueued:l}):"fitViewOptions"===a?c.setState({fitViewOptions:l}):c.setState({[a]:l})}h.current=e},vm.map(t=>e[t])),null}function vv(){return"u"<typeof window||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}let vy="u">typeof document?document:null;function vw(e=null,t={target:vy,actInsideInputWithModifier:!0}){let[n,s]=(0,O.useState)(!1),i=(0,O.useRef)(!1),r=(0,O.useRef)(new Set([])),[o,a]=(0,O.useMemo)(()=>{if(null!==e){let t=(Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).map(e=>e.replace("+","\n").replace("\n\n","\n+").split("\n")),n=t.reduce((e,t)=>e.concat(...t),[]);return[t,n]}return[[],[]]},[e]);return(0,O.useEffect)(()=>{let n=t?.target??vy,l=t?.actInsideInputWithModifier??!0;if(null!==e){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!l)&&x8(e))return!1;let n=vk(e.code,a);if(r.current.add(e[n]),vO(o,r.current,!1)){let n=e.composedPath?.()?.[0]||e.target,r=n?.nodeName==="BUTTON"||n?.nodeName==="A";!1!==t.preventDefault&&(i.current||!r)&&e.preventDefault(),s(!0)}},c=e=>{let t=vk(e.code,a);vO(o,r.current,!0)?(s(!1),r.current.clear()):r.current.delete(e[t]),"Meta"===e.key&&r.current.clear(),i.current=!1},h=()=>{r.current.clear(),s(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",c),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",c),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,s]),n}function vO(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function vk(e,t){return t.includes(e)?"code":"key"}function vj(e,t){let n=[],s=new Map,i=[];for(let t of e)if("add"===t.type){i.push(t);continue}else if("remove"===t.type||"replace"===t.type)s.set(t.id,[t]);else{let e=s.get(t.id);e?e.push(t):s.set(t.id,[t])}for(let e of t){let t=s.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}let i={...e};for(let e of t){var r=e,o=i;switch(r.type){case"select":o.selected=r.selected;break;case"position":void 0!==r.position&&(o.position=r.position),void 0!==r.dragging&&(o.dragging=r.dragging);break;case"dimensions":void 0!==r.dimensions&&(o.measured={...r.dimensions},r.setAttributes&&((!0===r.setAttributes||"width"===r.setAttributes)&&(o.width=r.dimensions.width),(!0===r.setAttributes||"height"===r.setAttributes)&&(o.height=r.dimensions.height))),"boolean"==typeof r.resizing&&(o.resizing=r.resizing)}}n.push(i)}return i.length&&i.forEach(e=>{void 0!==e.index?n.splice(e.index,0,{...e.item}):n.push({...e.item})}),n}function vN(e,t){return{id:e,type:"select",selected:t}}function vS(e,t=new Set,n=!1){let s=[];for(let[i,r]of e){let e=t.has(i);(void 0!==r.selected||e)&&r.selected!==e&&(n&&(r.selected=e),s.push(vN(r.id,e)))}return s}function vz({items:e=[],lookup:t}){let n=[],s=new Map(e.map(e=>[e.id,e]));for(let[s,i]of e.entries()){let e=t.get(i.id),r=e?.internals?.userNode??e;void 0!==r&&r!==i&&n.push({id:i.id,item:i,type:"replace"}),void 0===r&&n.push({item:i,type:"add",index:s})}for(let[e]of t)void 0===s.get(e)&&n.push({id:e,type:"remove"});return n}function vC(e){return{id:e.id,type:"remove"}}let v_=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e);function vT(e){return(0,O.forwardRef)(e)}let vA="u">typeof window?O.useLayoutEffect:O.useEffect;function vM(e){let[t,n]=(0,O.useState)(BigInt(0)),[s]=(0,O.useState)(()=>{var e;let t;return e=()=>n(e=>e+BigInt(1)),t=[],{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}});return vA(()=>{let t=s.get();t.length&&(e(t),s.reset())},[t]),s}let vP=(0,O.createContext)(null);function vE({children:e}){let t=b8(),n=vM((0,O.useCallback)(e=>{let{nodes:n=[],setNodes:s,hasDefaultNodes:i,onNodesChange:r,nodeLookup:o,fitViewQueued:a,onNodesChangeMiddlewareMap:l}=t.getState(),c=n;for(let t of e)c="function"==typeof t?t(c):t;let h=vz({items:c,lookup:o});for(let e of l.values())h=e(h);i&&s(c),h.length>0?r?.(h):a&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:s}=t.getState();e&&s(n)})},[])),s=vM((0,O.useCallback)(e=>{let{edges:n=[],setEdges:s,hasDefaultEdges:i,onEdgesChange:r,edgeLookup:o}=t.getState(),a=n;for(let t of e)a="function"==typeof t?t(a):t;i?s(a):r&&r(vz({items:a,lookup:o}))},[])),i=(0,O.useMemo)(()=>({nodeQueue:n,edgeQueue:s}),[]);return(0,w.jsx)(vP.Provider,{value:i,children:e})}let vR=e=>!!e.panZoom;function vD(){let e,t=(e=b8(),(0,O.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:s}=e.getState();return s?s.scaleTo(t,{duration:n?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[s,i,r],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??s,y:t.y??i,zoom:t.zoom??r},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,s]=e.getState().transform;return{x:t,y:n,zoom:s}},setCenter:async(t,n,s)=>e.getState().setCenter(t,n,s),fitBounds:async(t,n)=>{let{width:s,height:i,minZoom:r,maxZoom:o,panZoom:a}=e.getState(),l=xG(t,s,i,r,o,n?.padding??.1);return a?(await a.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:s,snapGrid:i,snapToGrid:r,domNode:o}=e.getState();if(!o)return t;let{x:a,y:l}=o.getBoundingClientRect(),c={x:t.x-a,y:t.y-l},h=n.snapGrid??i;return xH(c,s,n.snapToGrid??r,h)},flowToScreenPosition:t=>{let{transform:n,domNode:s}=e.getState();if(!s)return t;let{x:i,y:r}=s.getBoundingClientRect(),o=xX(t,n);return{x:o.x+i,y:o.y+r}}}),[])),n=b8(),s=function(){let e=(0,O.useContext)(vP);if(!e)throw Error("useBatchContext must be used within a BatchProvider");return e}(),i=b4(vR),r=(0,O.useMemo)(()=>{let e=e=>n.getState().nodeLookup.get(e),t=e=>{s.nodeQueue.push(e)},i=e=>{s.edgeQueue.push(e)},r=e=>{let{nodeLookup:t,nodeOrigin:s}=n.getState(),i=v_(e)?e:t.get(e.id),r=i.parentId?x0(i.position,i.measured,i.parentId,t,s):i.position;return xQ({...i,position:r,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,n,s={replace:!1})=>{t(t=>t.map(t=>{if(t.id===e){let e="function"==typeof n?n(t):n;return s.replace&&v_(e)?e:{...t,...e}}return t}))},a=(e,t,n={replace:!1})=>{i(s=>s.map(s=>{if(s.id===e){let e="function"==typeof t?t(s):t;return n.replace&&xO(e)?e:{...s,...e}}return s}))};return{getNodes:()=>n.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=n.getState();return e.map(e=>({...e}))},getEdge:e=>n.getState().edgeLookup.get(e),setNodes:t,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];s.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];s.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:t=[],transform:s}=n.getState(),[i,r,o]=s;return{nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),viewport:{x:i,y:r,zoom:o}}},deleteElements:async({nodes:e=[],edges:t=[]})=>{let{nodes:s,edges:i,onNodesDelete:r,onEdgesDelete:o,triggerNodeChanges:a,triggerEdgeChanges:l,onDelete:c,onBeforeDelete:h}=n.getState(),{nodes:d,edges:u}=await x_({nodesToRemove:e,edgesToRemove:t,nodes:s,edges:i,onBeforeDelete:h}),p=u.length>0,f=d.length>0;if(p){let e=u.map(vC);o?.(u),l(e)}if(f){let e=d.map(vC);r?.(d),a(e)}return(f||p)&&c?.({nodes:d,edges:u}),{deletedNodes:d,deletedEdges:u}},getIntersectingNodes:(e,t=!0,s)=>{let i=xB(e),o=i?e:r(e),a=void 0!==s;return o?(s||n.getState().nodes).filter(s=>{let r=n.getState().nodeLookup.get(s.id);if(r&&!i&&(s.id===e.id||!r.internals.positionAbsolute))return!1;let l=xQ(a?s:r),c=xq(l,o);return t&&c>0||c>=l.width*l.height||c>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let s=xB(e)?e:r(e);if(!s)return!1;let i=xq(s,t);return n&&i>0||i>=t.width*t.height||i>=s.width*s.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let s="function"==typeof t?t(e):t;return n.replace?{...e,data:s}:{...e,data:{...e.data,...s}}},n)},updateEdge:a,updateEdgeData:(e,t,n={replace:!1})=>{a(e,e=>{let s="function"==typeof t?t(e):t;return n.replace?{...e,data:s}:{...e,data:{...e.data,...s}}},n)},getNodesBounds:e=>{let{nodeLookup:t,nodeOrigin:s}=n.getState();return((e,t={nodeOrigin:[0,0]})=>0===e.length?{x:0,y:0,width:0,height:0}:x$(e.reduce((e,n)=>{let s="string"==typeof n,i=t.nodeLookup||s?void 0:n;return t.nodeLookup&&(i=s?t.nodeLookup.get(n):xk(n)?n:t.nodeLookup.get(n.id)),xR(e,i?xI(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})))(e,{nodeLookup:t,nodeOrigin:s})},getHandleConnections:({type:e,id:t,nodeId:s})=>Array.from(n.getState().connectionLookup.get(`${s}-${e}${t?`-${t}`:""}`)?.values()??[]),getNodeConnections:({type:e,handleId:t,nodeId:s})=>Array.from(n.getState().connectionLookup.get(`${s}${e?t?`-${e}-${t}`:`-${e}`:""}`)?.values()??[]),fitView:async e=>{let t,i,r=n.getState().fitViewResolver??{promise:new Promise((e,n)=>{t=e,i=n}),resolve:t,reject:i};return n.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),s.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,O.useMemo)(()=>({...r,...t,viewportInitialized:i}),[i])}let v$=e=>e.selected,vQ="u">typeof window?window:void 0,vI={position:"absolute",width:"100%",height:"100%",top:0,left:0},vL=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function vq({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panOnScrollSpeed:i=.5,panOnScrollMode:r=f.Free,zoomOnDoubleClick:o=!0,panOnDrag:a=!0,defaultViewport:l,translateExtent:c,minZoom:h,maxZoom:d,zoomActivationKeyCode:u,preventScrolling:p=!0,children:m,noWheelClassName:g,noPanClassName:x,onViewportChange:b,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:k}){let j,N=b8(),S=(0,O.useRef)(null),{userSelectionActive:z,lib:C,connectionInProgress:_}=b4(vL,b1),T=vw(u),A=(0,O.useRef)();j=b8(),(0,O.useEffect)(()=>{let e=()=>{if(!S.current||!(S.current.checkVisibility?.()??!0))return!1;let e=x5(S.current);(0===e.height||0===e.width)&&j.getState().onError?.("004","The React Flow parent container needs a width and a height to render the graph."),j.setState({width:e.width||500,height:e.height||500})};if(S.current){e(),window.addEventListener("resize",e);let t=new ResizeObserver(()=>e());return t.observe(S.current),()=>{window.removeEventListener("resize",e),t&&S.current&&t.unobserve(S.current)}}},[]);let M=(0,O.useCallback)(e=>{b?.({x:e[0],y:e[1],zoom:e[2]}),v||N.setState({transform:e})},[b,v]);return(0,O.useEffect)(()=>{if(S.current){A.current=function({domNode:e,minZoom:t,maxZoom:n,translateExtent:s,viewport:i,onPanZoom:r,onPanZoomStart:o,onPanZoomEnd:a,onDraggingChange:l}){let c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),d=xf().scaleExtent([t,n]).translateExtent(s),u=mk(e).call(d);b({x:i.x,y:i.y,zoom:xT(i.zoom,t,n)},[[0,0],[h.width,h.height]],s);let p=u.on("wheel.zoom"),m=u.on("dblclick.zoom");function g(e,t){return u?new Promise(n=>{d?.interpolate(t?.interpolate==="linear"?xm:mI).transform(bI(u,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function x(){d.on("zoom",null)}async function b(e,t,n){let s=bR(e),i=d?.constrain()(s,t,n);return i&&await g(i),new Promise(e=>e(i))}return d.wheelDelta(bL),{update:function({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:s,panOnScroll:i,panOnDrag:h,panOnScrollMode:g,panOnScrollSpeed:b,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:w,zoomOnDoubleClick:O,zoomActivationKeyPressed:k,lib:j,onTransformChange:N,connectionInProgress:S,paneClickDistance:z,selectionOnDrag:C}){s&&!c.isZoomingOrPanning&&x();let _=i&&!k&&!s;d.clickDistance(C?1/0:!xW(z)||z<0?0:z);let T=_?function({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:i,panOnScrollSpeed:r,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return h=>{if(bD(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();let d=n.property("__zoom").k||1;if(h.ctrlKey&&o){let e=mj(h),t=d*Math.pow(2,bL(h));s.scaleTo(n,t,e,h);return}let u=1===h.deltaMode?20:1,p=i===f.Vertical?0:h.deltaX*u,m=i===f.Horizontal?0:h.deltaY*u;!xZ()&&h.shiftKey&&i!==f.Vertical&&(p=h.deltaY*u,m=0),s.translateBy(n,-(p/d)*r,-(m/d)*r,{internal:!0});let g=bE(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(h,g),e.panScrollTimeout=setTimeout(()=>{c?.(h,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(h,g))}}({zoomPanValues:c,noWheelClassName:e,d3Selection:u,d3Zoom:d,panOnScrollMode:g,panOnScrollSpeed:b,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:r,onPanZoomEnd:a}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,i){let r="wheel"===s.type,o=!t&&r&&!s.ctrlKey,a=bD(s,e);if(s.ctrlKey&&r&&a&&s.preventDefault(),o||a)return null;s.preventDefault(),n.call(this,s,i)}}({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(u.on("wheel.zoom",T,{passive:!1}),!s){let e=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{if(s.sourceEvent?.internal)return;let i=bE(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,s.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(s.sourceEvent,i)}}({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:o});d.on("start",e);let t=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:i}){return r=>{e.usedRightMouseButton=!!(n&&b$(t,e.mouseButton??0)),r.sourceEvent?.sync||s([r.transform.x,r.transform.y,r.transform.k]),i&&!r.sourceEvent?.internal&&i?.(r.sourceEvent,bE(r.transform))}}({zoomPanValues:c,panOnDrag:h,onPaneContextMenu:!!n,onPanZoom:r,onTransformChange:N});d.on("zoom",t);let s=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:i,onPaneContextMenu:r}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,r&&b$(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&r(o.sourceEvent),e.usedRightMouseButton=!1,s(!1),i)){let t=bE(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},150*!!n)}}}({zoomPanValues:c,panOnDrag:h,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:a,onDraggingChange:l});d.on("end",s)}let A=function({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:i,zoomOnDoubleClick:r,userSelectionActive:o,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:h}){return d=>{let u=e||t,p=n&&d.ctrlKey,f="wheel"===d.type;if(1===d.button&&"mousedown"===d.type&&(bD(d,`${c}-flow__node`)||bD(d,`${c}-flow__edge`)))return!0;if(!s&&!u&&!i&&!r&&!n||o||h&&!f||bD(d,a)&&f||bD(d,l)&&(!f||i&&f&&!e)||!n&&d.ctrlKey&&f)return!1;if(!n&&"touchstart"===d.type&&d.touches?.length>1)return d.preventDefault(),!1;if(!u&&!i&&!p&&f||!s&&("mousedown"===d.type||"touchstart"===d.type)||Array.isArray(s)&&!s.includes(d.button)&&"mousedown"===d.type)return!1;let m=Array.isArray(s)&&s.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||f)&&m}}({zoomActivationKeyPressed:k,panOnDrag:h,zoomOnScroll:w,panOnScroll:i,zoomOnDoubleClick:O,zoomOnPinch:y,userSelectionActive:s,noPanClassName:t,noWheelClassName:e,lib:j,connectionInProgress:S});d.filter(A),O?u.on("dblclick.zoom",m):u.on("dblclick.zoom",null)},destroy:x,setViewport:async function e(e,t){let n=bR(e);return await g(n,t),new Promise(e=>e(n))},setViewportConstrained:b,getViewport:function(){let e=u?xr(u.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:function(e,t){return u?new Promise(n=>{d?.interpolate(t?.interpolate==="linear"?xm:mI).scaleTo(bI(u,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)},scaleBy:function(e,t){return u?new Promise(n=>{d?.interpolate(t?.interpolate==="linear"?xm:mI).scaleBy(bI(u,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)},setScaleExtent:function(e){d?.scaleExtent(e)},setTranslateExtent:function(e){d?.translateExtent(e)},syncViewport:function(e){if(u){let t=bR(e),n=u.property("__zoom");(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(u,t,null,{sync:!0})}},setClickDistance:function(e){let t=!xW(e)||e<0?0:e;d?.clickDistance(t)}}}({domNode:S.current,minZoom:h,maxZoom:d,translateExtent:c,viewport:l,onDraggingChange:e=>N.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:s}=N.getState();s?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:s}=N.getState();s?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:s}=N.getState();s?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=A.current.getViewport();return N.setState({panZoom:A.current,transform:[e,t,n],domNode:S.current.closest(".react-flow")}),()=>{A.current?.destroy()}}},[]),(0,O.useEffect)(()=>{A.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panOnScrollSpeed:i,panOnScrollMode:r,zoomOnDoubleClick:o,panOnDrag:a,zoomActivationKeyPressed:T,preventScrolling:p,noPanClassName:x,userSelectionActive:z,noWheelClassName:g,lib:C,onTransformChange:M,connectionInProgress:_,selectionOnDrag:k,paneClickDistance:y})},[e,t,n,s,i,r,o,a,T,p,x,z,g,C,M,_,k,y]),(0,w.jsx)("div",{className:"react-flow__renderer",ref:S,style:vI,children:m})}let vB=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function vW(){let{userSelectionActive:e,userSelectionRect:t}=b4(vB,b1);return e&&t?(0,w.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}let vV=(e,t)=>n=>{n.target===t.current&&e?.(n)},vF=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function vH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=m.Full,panOnDrag:s,paneClickDistance:i,selectionOnDrag:r,onSelectionStart:o,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:h,onPaneMouseEnter:d,onPaneMouseMove:u,onPaneMouseLeave:p,children:f}){let g=b8(),{userSelectionActive:x,elementsSelectable:b,dragging:v,connectionInProgress:y}=b4(vF,b1),k=b&&(e||x),j=(0,O.useRef)(null),N=(0,O.useRef)(),S=(0,O.useRef)(new Set),z=(0,O.useRef)(new Set),C=(0,O.useRef)(!1),_=e=>{if(C.current||y){C.current=!1;return}l?.(e),g.getState().resetSelectedElements(),g.setState({nodesSelectionActive:!1})},T=!0===s||Array.isArray(s)&&s.includes(0);return(0,w.jsxs)("div",{className:fq(["react-flow__pane",{draggable:T,dragging:v,selection:e}]),onClick:k?void 0:vV(_,j),onContextMenu:vV(e=>{Array.isArray(s)&&s?.includes(2)?e.preventDefault():c?.(e)},j),onWheel:vV(h?e=>h(e):void 0,j),onPointerEnter:k?void 0:d,onPointerMove:k?e=>{let{userSelectionRect:s,transform:r,nodeLookup:a,edgeLookup:l,connectionLookup:c,triggerNodeChanges:h,triggerEdgeChanges:d,defaultEdgeOptions:u,resetSelectedElements:p}=g.getState();if(!N.current||!s)return;let{x:f,y:x}=x6(e.nativeEvent,N.current),{startX:b,startY:v}=s;if(!C.current){if(Math.hypot(f-b,x-v)<=(t?0:i))return;p(),o?.(e)}C.current=!0;let y={startX:b,startY:v,x:f<b?f:b,y:x<v?x:v,width:Math.abs(f-b),height:Math.abs(x-v)},w=S.current,O=z.current;S.current=new Set(xS(a,y,r,n===m.Partial,!0).map(e=>e.id)),z.current=new Set;let k=u?.selectable??!0;for(let e of S.current){let t=c.get(e);if(t)for(let{edgeId:e}of t.values()){let t=l.get(e);t&&(t.selectable??k)&&z.current.add(e)}}x1(w,S.current)||h(vS(a,S.current,!0)),x1(O,z.current)||d(vS(l,z.current)),g.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:u,onPointerUp:k?e=>{0===e.button&&(e.target?.releasePointerCapture?.(e.pointerId),!x&&e.target===j.current&&g.getState().userSelectionRect&&_?.(e),g.setState({userSelectionActive:!1,userSelectionRect:null}),C.current&&(a?.(e),g.setState({nodesSelectionActive:S.current.size>0})))}:void 0,onPointerDownCapture:k?n=>{let{domNode:s}=g.getState();if(N.current=s?.getBoundingClientRect(),!N.current)return;let i=n.target===j.current;if(!i&&n.target.closest(".nokey")||!e||!(r&&i||t)||0!==n.button||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),C.current=!1;let{x:o,y:a}=x6(n.nativeEvent,N.current);g.setState({userSelectionRect:{width:0,height:0,startX:o,startY:a,x:o,y:a}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:k?e=>{C.current&&(e.stopPropagation(),C.current=!1)}:void 0,onPointerLeave:p,ref:j,style:vI,children:[f,(0,w.jsx)(vW,{})]})}function vX({id:e,store:t,unselect:n=!1,nodeRef:s}){let i,{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),h=l.get(e);h?(t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&a)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):r([e])):c?.("012",(i=e,`Node with id "${i}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`))}function vU({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:i,isSelectable:r,nodeClickDistance:o}){let a=b8(),[l,c]=(0,O.useState)(!1),h=(0,O.useRef)();return(0,O.useEffect)(()=>{h.current=function({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:i}){let r={x:null,y:null},o=0,a=new Map,l=!1,c={x:0,y:0},h=null,d=!1,u=null,p=!1,f=!1,m=null;return{update:function({noDragClassName:g,handleSelector:x,domNode:b,isSelectable:v,nodeId:y,nodeClickDistance:w=0}){function O({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:l,snapToGrid:c,nodeOrigin:h,onNodeDrag:d,onSelectionDrag:u,onError:p,updateNodePositions:g}=t();r={x:e,y:n};let x=!1,b=a.size>1,v=b&&o?xD(xN(a)):null,w=b&&c?function({dragItems:e,snapGrid:t,x:n,y:s}){let i=e.values().next().value;if(!i)return null;let r={x:n-i.distance.x,y:s-i.distance.y},o=xF(r,t);return{x:o.x-r.x,y:o.y-r.y}}({dragItems:a,snapGrid:l,x:e,y:n}):null;for(let[t,s]of a){if(!i.has(t))continue;let r={x:e-s.distance.x,y:n-s.distance.y};c&&(r=w?{x:Math.round(r.x+w.x),y:Math.round(r.y+w.y)}:xF(r,l));let a=null;if(b&&o&&!s.extent&&v){let{positionAbsolute:e}=s.internals,t=e.x-v.x+o[0][0],n=e.x+s.measured.width-v.x2+o[1][0];a=[[t,e.y-v.y+o[0][1]],[n,e.y+s.measured.height-v.y2+o[1][1]]]}let{position:d,positionAbsolute:u}=xC({nodeId:t,nextPosition:r,nodeLookup:i,nodeExtent:a||o,nodeOrigin:h,onError:p});x=x||s.position.x!==d.x||s.position.y!==d.y,s.position=d,s.internals.positionAbsolute=u}if(f=f||x,x&&(g(a,!0),m&&(s||d||!y&&u))){let[e,t]=bC({nodeId:y,dragItems:a,nodeLookup:i});s?.(m,a,e,t),d?.(m,e,t),y||u?.(m,t)}}async function k(){if(!h)return;let{transform:e,panBy:n,autoPanSpeed:s,autoPanOnNodeDrag:i}=t();if(!i){l=!1,cancelAnimationFrame(o);return}let[a,d]=xE(c,h,s);(0!==a||0!==d)&&(r.x=(r.x??0)-a/e[2],r.y=(r.y??0)-d/e[2],await n({x:a,y:d})&&O(r)),o=requestAnimationFrame(k)}function j(s){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:l,transform:c,snapGrid:u,snapToGrid:p,selectNodesOnDrag:f,onNodeDragStart:m,onSelectionDragStart:g,unselectNodesAndEdges:x}=t();d=!0,f&&v||o||!y||i.get(y)?.selected||x(),v&&f&&y&&e?.(y);let b=x2(s.sourceEvent,{transform:c,snapGrid:u,snapToGrid:p,containerBounds:h});if(r=b,(a=function(e,t,n,s){let i=new Map;for(let[r,o]of e)if((o.selected||o.id===s)&&(!o.parentId||!function e(t,n){if(!t.parentId)return!1;let s=n.get(t.parentId);return!!s&&(!!s.selected||e(s,n))}(o,e))&&(o.draggable||t&&void 0===o.draggable)){let t=e.get(r);t&&i.set(r,{id:r,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}(i,l,b,y)).size>0&&(n||m||!y&&g)){let[e,t]=bC({nodeId:y,dragItems:a,nodeLookup:i});n?.(s.sourceEvent,a,e,t),m?.(s.sourceEvent,e,t),y||g?.(s.sourceEvent,t)}}u=mk(b);let N=m$().clickDistance(w).on("start",e=>{let{domNode:n,nodeDragThreshold:s,transform:i,snapGrid:o,snapToGrid:a}=t();h=n?.getBoundingClientRect()||null,p=!1,f=!1,m=e.sourceEvent,0===s&&j(e),r=x2(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:a,containerBounds:h}),c=x6(e.sourceEvent,h)}).on("drag",e=>{let{autoPanOnNodeDrag:n,transform:s,snapGrid:i,snapToGrid:o,nodeDragThreshold:u,nodeLookup:f}=t(),g=x2(e.sourceEvent,{transform:s,snapGrid:i,snapToGrid:o,containerBounds:h});if(m=e.sourceEvent,("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1||y&&!f.has(y))&&(p=!0),!p){if(!l&&n&&d&&(l=!0,k()),!d){let t=x6(e.sourceEvent,h),n=t.x-c.x,s=t.y-c.y;Math.sqrt(n*n+s*s)>u&&j(e)}(r.x!==g.xSnapped||r.y!==g.ySnapped)&&a&&d&&(c=x6(e.sourceEvent,h),O(g))}}).on("end",e=>{if(d&&!p&&(l=!1,d=!1,cancelAnimationFrame(o),a.size>0)){let{nodeLookup:n,updateNodePositions:s,onNodeDragStop:r,onSelectionDragStop:o}=t();if(f&&(s(a,!1),f=!1),i||r||!y&&o){let[t,s]=bC({nodeId:y,dragItems:a,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,a,t,s),r?.(e.sourceEvent,t,s),y||o?.(e.sourceEvent,s)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!bz(t,`.${g}`,b))&&(!x||bz(t,x,b))});u.call(N)},destroy:function(){u?.on(".drag",null)}}}({getStoreItems:()=>a.getState(),onNodeMouseDown:t=>{vX({id:t,store:a,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),(0,O.useEffect)(()=>{if(!t&&e.current&&h.current)return h.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:r,nodeId:i,nodeClickDistance:o}),()=>{h.current?.destroy()}},[n,s,t,r,e,i,o]),l}function vG(){let e=b8();return(0,O.useCallback)(t=>{let{nodeExtent:n,snapToGrid:s,snapGrid:i,nodesDraggable:r,onError:o,updateNodePositions:a,nodeLookup:l,nodeOrigin:c}=e.getState(),h=new Map,d=e=>e.selected&&(e.draggable||r&&void 0===e.draggable),u=s?i[0]:5,p=s?i[1]:5,f=t.direction.x*u*t.factor,m=t.direction.y*p*t.factor;for(let[,e]of l){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+f,y:e.internals.positionAbsolute.y+m};s&&(t=xF(t,i));let{position:r,positionAbsolute:a}=xC({nodeId:e.id,nextPosition:t,nodeLookup:l,nodeExtent:n,nodeOrigin:c,onError:o});e.position=r,e.internals.positionAbsolute=a,h.set(e.id,e)}a(h)},[])}let vZ=(0,O.createContext)(null),vY=vZ.Provider;vZ.Consumer;let vK=()=>(0,O.useContext)(vZ),vJ=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),v0=(0,O.memo)(vT(function({type:e="source",position:t=b.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:i=!0,isConnectableEnd:r=!0,id:o,onConnect:a,children:l,className:c,onMouseDown:h,onTouchStart:d,...u},f){let m=o||null,g="target"===e,x=b8(),v=vK(),{connectOnClick:y,noPanClassName:O,rfId:k}=b4(vJ,b1),{connectingFrom:j,connectingTo:N,clickConnecting:S,isPossibleEndHandle:z,connectionInProcess:C,clickConnectionInProcess:_,valid:T}=b4(t=>{let{connectionClickStartHandle:n,connectionMode:s,connection:i}=t,{fromHandle:r,toHandle:o,isValid:a}=i,l=o?.nodeId===v&&o?.id===m&&o?.type===e;return{connectingFrom:r?.nodeId===v&&r?.id===m&&r?.type===e,connectingTo:l,clickConnecting:n?.nodeId===v&&n?.id===m&&n?.type===e,isPossibleEndHandle:s===p.Strict?r?.type!==e:v!==r?.nodeId||m!==r?.id,connectionInProcess:!!r,clickConnectionInProcess:!!n,valid:l&&a}},b1);v||x.getState().onError?.("010","Handle: No node id found. Make sure to only use a Handle inside a custom Node.");let A=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:s}=x.getState(),i={...t,...e};if(s){let{edges:e,setEdges:t}=x.getState();t(br(i,e))}n?.(i),a?.(i)},M=e=>{if(!v)return;let t="clientX"in e.nativeEvent;if(i&&(t&&0===e.button||!t)){let t=x.getState();bP(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:g,handleId:m,nodeId:v,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>x.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:A,isValidConnection:n||((...e)=>x.getState().isValidConnection?.(...e)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?h?.(e):d?.(e)};return(0,w.jsx)("div",{"data-handleid":m,"data-nodeid":v,"data-handlepos":t,"data-id":`${k}-${v}-${m}-${e}`,className:fq(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",O,c,{source:!g,target:g,connectable:s,connectablestart:i,connectableend:r,clickconnecting:S,connectingfrom:j,connectingto:N,valid:T,connectionindicator:s&&(!C||z)&&(C||_?r:i)}]),onMouseDown:M,onTouchStart:M,onClick:y?t=>{let{onClickConnectStart:s,onClickConnectEnd:r,connectionClickStartHandle:o,connectionMode:a,isValidConnection:l,lib:c,rfId:h,nodeLookup:d,connection:u}=x.getState();if(!v||!o&&!i)return;if(!o){s?.(t.nativeEvent,{nodeId:v,handleId:m,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:v,type:e,id:m}});return}let p=x3(t.target),f=n||l,{connection:g,isValid:b}=bM(t.nativeEvent,{handle:{nodeId:v,id:m,type:e},connectionMode:a,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:f,flowId:h,doc:p,lib:c,nodeLookup:d});b&&g&&A(g);let y=structuredClone(u);delete y.inProgress,y.toPosition=y.toHandle?y.toHandle.position:null,r?.(t,y),x.setState({connectionClickStartHandle:null})}:void 0,ref:f,...u,children:l})})),v1={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},v2={input:function({data:e,isConnectable:t,sourcePosition:n=b.Bottom}){return(0,w.jsxs)(w.Fragment,{children:[e?.label,(0,w.jsx)(v0,{type:"source",position:n,isConnectable:t})]})},default:function({data:e,isConnectable:t,targetPosition:n=b.Top,sourcePosition:s=b.Bottom}){return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(v0,{type:"target",position:n,isConnectable:t}),e?.label,(0,w.jsx)(v0,{type:"source",position:s,isConnectable:t})]})},output:function({data:e,isConnectable:t,targetPosition:n=b.Top}){return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(v0,{type:"target",position:n,isConnectable:t}),e?.label]})},group:function(){return null}},v5=e=>{let{width:t,height:n,x:s,y:i}=xN(e.nodeLookup,{filter:e=>!!e.selected});return{width:xW(t)?t:null,height:xW(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${i}px)`}};function v3({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let s=b8(),{width:i,height:r,transformString:o,userSelectionActive:a}=b4(v5,b1),l=vG(),c=(0,O.useRef)(null);(0,O.useEffect)(()=>{n||c.current?.focus({preventScroll:!0})},[n]);let h=!a&&null!==i&&null!==r;if(vU({nodeRef:c,disabled:!h}),!h)return null;let d=e?t=>{e(t,s.getState().nodes.filter(e=>e.selected))}:void 0;return(0,w.jsx)("div",{className:fq(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:(0,w.jsx)("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(v1,e.key)&&(e.preventDefault(),l({direction:v1[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:r}})})}let v4="u">typeof window?window:void 0,v8=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function v6({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:r,onPaneScroll:o,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:c,selectionOnDrag:h,selectionMode:d,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:f,panActivationKeyCode:m,zoomActivationKeyCode:g,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:v,panOnScroll:y,panOnScrollSpeed:k,panOnScrollMode:j,zoomOnDoubleClick:N,panOnDrag:S,defaultViewport:z,translateExtent:C,minZoom:_,maxZoom:T,preventScrolling:A,onSelectionContextMenu:M,noWheelClassName:P,noPanClassName:E,disableKeyboardA11y:R,onViewportChange:D,isControlledViewport:$}){let{nodesSelectionActive:Q,userSelectionActive:I}=b4(v8,b1),L=vw(c,{target:v4}),q=vw(m,{target:v4}),B=q||S,W=q||y,V=h&&!0!==B,F=L||I||V;return!function({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=b8(),{deleteElements:s}=vD(),i=vw(e,{actInsideInputWithModifier:!1}),r=vw(t,{target:vQ});(0,O.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();s({nodes:t.filter(v$),edges:e.filter(v$)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,O.useEffect)(()=>{n.setState({multiSelectionActive:r})},[r])}({deleteKeyCode:l,multiSelectionKeyCode:f}),(0,w.jsx)(vq,{onPaneContextMenu:r,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:v,panOnScroll:W,panOnScrollSpeed:k,panOnScrollMode:j,zoomOnDoubleClick:N,panOnDrag:!L&&B,defaultViewport:z,translateExtent:C,minZoom:_,maxZoom:T,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:P,noPanClassName:E,onViewportChange:D,isControlledViewport:$,paneClickDistance:a,selectionOnDrag:V,children:(0,w.jsxs)(vH,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:r,onPaneScroll:o,panOnDrag:B,isSelecting:!!F,selectionMode:d,selectionKeyPressed:L,paneClickDistance:a,selectionOnDrag:V,children:[e,Q&&(0,w.jsx)(v3,{onSelectionContextMenu:M,noPanClassName:E,disableKeyboardA11y:R})]})})}v6.displayName="FlowRenderer";let v9=(0,O.memo)(v6),v7=e=>e.updateNodeInternals;var ye=(0,O.memo)(function({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:i,onContextMenu:r,onDoubleClick:o,nodesDraggable:a,elementsSelectable:l,nodesConnectable:c,nodesFocusable:h,resizeObserver:d,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:f,rfId:m,nodeTypes:g,nodeClickDistance:x,onError:b}){let v,{node:y,internals:k,isParent:j}=b4(t=>{let n=t.nodeLookup.get(e),s=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:s}},b1),N=y.type||"default",S=g?.[N]||v2[N];void 0===S&&(b?.("003",(v=N,`Node type "${v}" not found. Using fallback type "default".`)),N="default",S=g?.default||v2.default);let z=!!(y.draggable||a&&void 0===y.draggable),C=!!(y.selectable||l&&void 0===y.selectable),_=!!(y.connectable||c&&void 0===y.connectable),T=!!(y.focusable||h&&void 0===y.focusable),A=b8(),M=xJ(y),P=function({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){let i=b8(),r=(0,O.useRef)(null),o=(0,O.useRef)(null),a=(0,O.useRef)(e.sourcePosition),l=(0,O.useRef)(e.targetPosition),c=(0,O.useRef)(t),h=n&&!!e.internals.handleBounds;return(0,O.useEffect)(()=>{!r.current||e.hidden||h&&o.current===r.current||(o.current&&s?.unobserve(o.current),s?.observe(r.current),o.current=r.current)},[h,e.hidden]),(0,O.useEffect)(()=>()=>{o.current&&(s?.unobserve(o.current),o.current=null)},[]),(0,O.useEffect)(()=>{if(r.current){let n=c.current!==t,s=a.current!==e.sourcePosition,o=l.current!==e.targetPosition;(n||s||o)&&(c.current=t,a.current=e.sourcePosition,l.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:r.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),r}({node:y,nodeType:N,hasDimensions:M,resizeObserver:d}),E=vU({nodeRef:P,disabled:y.hidden||!z,noDragClassName:u,handleSelector:y.dragHandle,nodeId:e,isSelectable:C,nodeClickDistance:x}),R=vG();if(y.hidden)return null;let D=xK(y),$=void 0===y.internals.handleBounds?{width:y.width??y.initialWidth??y.style?.width,height:y.height??y.initialHeight??y.style?.height}:{width:y.width??y.style?.width,height:y.height??y.style?.height},Q=C||z||t||n||s||i,I=n?e=>n(e,{...k.userNode}):void 0,L=s?e=>s(e,{...k.userNode}):void 0,q=i?e=>i(e,{...k.userNode}):void 0,B=r?e=>r(e,{...k.userNode}):void 0,W=o?e=>o(e,{...k.userNode}):void 0;return(0,w.jsx)("div",{className:fq(["react-flow__node",`react-flow__node-${N}`,{[p]:z},y.className,{selected:y.selected,selectable:C,parent:j,draggable:z,dragging:E}]),ref:P,style:{zIndex:k.z,transform:`translate(${k.positionAbsolute.x}px,${k.positionAbsolute.y}px)`,pointerEvents:Q?"all":"none",visibility:M?"visible":"hidden",...y.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:q,onContextMenu:B,onClick:n=>{let{selectNodesOnDrag:s,nodeDragThreshold:i}=A.getState();C&&(!s||!z||i>0)&&vX({id:e,store:A,nodeRef:P}),t&&t(n,{...k.userNode})},onDoubleClick:W,onKeyDown:T?t=>{if(!x8(t.nativeEvent)&&!f){if(xx.includes(t.key)&&C)vX({id:e,store:A,unselect:"Escape"===t.key,nodeRef:P});else if(z&&y.selected&&Object.prototype.hasOwnProperty.call(v1,t.key)){t.preventDefault();let{ariaLabelConfig:e}=A.getState();A.setState({ariaLiveMessage:e["node.a11yDescription.ariaLiveMessage"]({direction:t.key.replace("Arrow","").toLowerCase(),x:~~k.positionAbsolute.x,y:~~k.positionAbsolute.y})}),R({direction:v1[t.key],factor:t.shiftKey?4:1})}}}:void 0,tabIndex:T?0:void 0,onFocus:T?()=>{if(f||!P.current?.matches(":focus-visible"))return;let{transform:t,width:n,height:s,autoPanOnNodeFocus:i,setCenter:r}=A.getState();!i||xS(new Map([[e,y]]),{x:0,y:0,width:n,height:s},t,!0).length>0||r(y.position.x+D.width/2,y.position.y+D.height/2,{zoom:t[2]})}:void 0,role:y.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":f?void 0:`${b7}-${m}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,w.jsx)(vY,{value:e,children:(0,w.jsx)(S,{id:e,data:y.data,type:N,positionAbsoluteX:k.positionAbsolute.x,positionAbsoluteY:k.positionAbsolute.y,selected:y.selected??!1,selectable:C,draggable:z,deletable:y.deletable??!0,isConnectable:_,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:E,dragHandle:y.dragHandle,zIndex:k.z,parentId:y.parentId,...D})})})});let yt=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function yn(e){var t;let{nodesDraggable:n,nodesConnectable:s,nodesFocusable:i,elementsSelectable:r,onError:o}=b4(yt,b1),a=(t=e.onlyRenderVisibleElements,b4((0,O.useCallback)(e=>t?xS(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(e=>e.id):Array.from(e.nodeLookup.keys()),[t]),b1)),l=function(){let e=b4(v7),[t]=(0,O.useState)(()=>"u"<typeof ResizeObserver?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,O.useEffect)(()=>()=>{t?.disconnect()},[t]),t}();return(0,w.jsx)("div",{className:"react-flow__nodes",style:vI,children:a.map(t=>(0,w.jsx)(ye,{id:t,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:n,nodesConnectable:s,nodesFocusable:i,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},t))})}yn.displayName="NodeRenderer";let ys=(0,O.memo)(yn),yi={[x.Arrow]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,w.jsx)("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},[x.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,w.jsx)("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})}},yr=({id:e,type:t,color:n,width:s=12.5,height:i=12.5,markerUnits:r="strokeWidth",strokeWidth:o,orient:a="auto-start-reverse"})=>{let l,c=(l=b8(),(0,O.useMemo)(()=>{let e;return Object.prototype.hasOwnProperty.call(yi,t)?yi[t]:(l.getState().onError?.("009",(e=t,`Marker type "${e}" doesn't exist.`)),null)},[t]));return c?(0,w.jsx)("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:r,orient:a,refX:"0",refY:"0",children:(0,w.jsx)(c,{color:n,strokeWidth:o})}):null},yo=({defaultColor:e,rfId:t})=>{let n=b4(e=>e.edges),s=b4(e=>e.defaultEdgeOptions),i=(0,O.useMemo)(()=>(function(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:i}){let r=new Set;return e.reduce((e,o)=>([o.markerStart||s,o.markerEnd||i].forEach(s=>{if(s&&"object"==typeof s){let i=bm(s,t);r.has(i)||(e.push({id:i,color:s.color||n,...s}),r.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))})(n,{id:t,defaultColor:e,defaultMarkerStart:s?.markerStart,defaultMarkerEnd:s?.markerEnd}),[n,s,t,e]);return i.length?(0,w.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,w.jsx)("defs",{children:i.map(e=>(0,w.jsx)(yr,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};yo.displayName="MarkerDefinitions";var ya=(0,O.memo)(yo);function yl({x:e,y:t,label:n,labelStyle:s,labelShowBg:i=!0,labelBgStyle:r,labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...h}){let[d,u]=(0,O.useState)({x:1,y:0,width:0,height:0}),p=fq(["react-flow__edge-textwrapper",c]),f=(0,O.useRef)(null);return((0,O.useEffect)(()=>{if(f.current){let e=f.current.getBBox();u({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n)?(0,w.jsxs)("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?"visible":"hidden",...h,children:[i&&(0,w.jsx)("rect",{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:"react-flow__edge-textbg",style:r,rx:a,ry:a}),(0,w.jsx)("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:f,style:s,children:n}),l]}):null}yl.displayName="EdgeText";let yc=(0,O.memo)(yl);function yh({path:e,labelX:t,labelY:n,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:c=20,...h}){return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("path",{...h,d:e,fill:"none",className:fq(["react-flow__edge-path",h.className])}),c?(0,w.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,s&&xW(t)&&xW(n)?(0,w.jsx)(yc,{x:t,y:n,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function yd({pos:e,x1:t,y1:n,x2:s,y2:i}){return e===b.Left||e===b.Right?[.5*(t+s),n]:[t,.5*(n+i)]}function yu({sourceX:e,sourceY:t,sourcePosition:n=b.Bottom,targetX:s,targetY:i,targetPosition:r=b.Top}){let[o,a]=yd({pos:n,x1:e,y1:t,x2:s,y2:i}),[l,c]=yd({pos:r,x1:s,y1:i,x2:e,y2:t}),[h,d,u,p]=x7({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:o,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${e},${t} C${o},${a} ${l},${c} ${s},${i}`,h,d,u,p]}function yp(e){return(0,O.memo)(({id:t,sourceX:n,sourceY:s,targetX:i,targetY:r,sourcePosition:o,targetPosition:a,label:l,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:g,interactionWidth:x})=>{let[b,v,y]=yu({sourceX:n,sourceY:s,sourcePosition:o,targetX:i,targetY:r,targetPosition:a}),O=e.isInternal?void 0:t;return(0,w.jsx)(yh,{id:O,path:b,labelX:v,labelY:y,label:l,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:g,interactionWidth:x})})}let yf=yp({isInternal:!1}),ym=yp({isInternal:!0});function yg(e){return(0,O.memo)(({id:t,sourceX:n,sourceY:s,targetX:i,targetY:r,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:d,style:u,sourcePosition:p=b.Bottom,targetPosition:f=b.Top,markerEnd:m,markerStart:g,pathOptions:x,interactionWidth:v})=>{let[y,O,k]=bh({sourceX:n,sourceY:s,sourcePosition:p,targetX:i,targetY:r,targetPosition:f,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),j=e.isInternal?void 0:t;return(0,w.jsx)(yh,{id:j,path:y,labelX:O,labelY:k,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:m,markerStart:g,interactionWidth:v})})}yf.displayName="SimpleBezierEdge",ym.displayName="SimpleBezierEdgeInternal";let yx=yg({isInternal:!1}),yb=yg({isInternal:!0});function yv(e){return(0,O.memo)(({id:t,...n})=>{let s=e.isInternal?void 0:t;return(0,w.jsx)(yx,{...n,id:s,pathOptions:(0,O.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}yx.displayName="SmoothStepEdge",yb.displayName="SmoothStepEdgeInternal";let yy=yv({isInternal:!1}),yw=yv({isInternal:!0});function yO(e){return(0,O.memo)(({id:t,sourceX:n,sourceY:s,targetX:i,targetY:r,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:f,interactionWidth:m})=>{let[g,x,b]=bo({sourceX:n,sourceY:s,targetX:i,targetY:r}),v=e.isInternal?void 0:t;return(0,w.jsx)(yh,{id:v,path:g,labelX:x,labelY:b,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:f,interactionWidth:m})})}yy.displayName="StepEdge",yw.displayName="StepEdgeInternal";let yk=yO({isInternal:!1}),yj=yO({isInternal:!0});function yN(e){return(0,O.memo)(({id:t,sourceX:n,sourceY:s,targetX:i,targetY:r,sourcePosition:o=b.Bottom,targetPosition:a=b.Top,label:l,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:g,pathOptions:x,interactionWidth:v})=>{let[y,O,k]=bn({sourceX:n,sourceY:s,sourcePosition:o,targetX:i,targetY:r,targetPosition:a,curvature:x?.curvature}),j=e.isInternal?void 0:t;return(0,w.jsx)(yh,{id:j,path:y,labelX:O,labelY:k,label:l,labelStyle:c,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:g,interactionWidth:v})})}yk.displayName="StraightEdge",yj.displayName="StraightEdgeInternal";let yS=yN({isInternal:!1}),yz=yN({isInternal:!0});yS.displayName="BezierEdge",yz.displayName="BezierEdgeInternal";let yC={default:yz,straight:yj,step:yw,smoothstep:yb,simplebezier:ym},y_={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},yT="react-flow__edgeupdater";function yA({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:i,onMouseEnter:r,onMouseOut:o,type:a}){return(0,w.jsx)("circle",{onMouseDown:i,onMouseEnter:r,onMouseOut:o,className:fq([yT,`${yT}-${a}`]),cx:e===b.Left?t-s:e===b.Right?t+s:t,cy:e===b.Top?n-s:e===b.Bottom?n+s:n,r:s,stroke:"transparent",fill:"transparent"})}function yM({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:i,targetX:r,targetY:o,sourcePosition:a,targetPosition:l,onReconnect:c,onReconnectStart:h,onReconnectEnd:d,setReconnecting:u,setUpdateHover:p}){let f=b8(),m=(e,t)=>{if(0!==e.button)return;let{autoPanOnConnect:s,domNode:i,connectionMode:r,connectionRadius:o,lib:a,onConnectStart:l,cancelConnection:p,nodeLookup:m,rfId:g,panBy:x,updateConnection:b}=f.getState(),v="target"===t.type;bP(e.nativeEvent,{autoPanOnConnect:s,connectionMode:r,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:m,isTarget:v,edgeUpdaterType:t.type,lib:a,flowId:g,cancelConnection:p,panBy:x,isValidConnection:(...e)=>f.getState().isValidConnection?.(...e)??!0,onConnect:e=>c?.(n,e),onConnectStart:(s,i)=>{u(!0),h?.(e,n,t.type),l?.(s,i)},onConnectEnd:(...e)=>f.getState().onConnectEnd?.(...e),onReconnectEnd:(e,s)=>{u(!1),d?.(e,n,t.type,s)},updateConnection:b,getTransform:()=>f.getState().transform,getFromHandle:()=>f.getState().connection.fromHandle,dragThreshold:f.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=()=>p(!0),x=()=>p(!1);return(0,w.jsxs)(w.Fragment,{children:[(!0===e||"source"===e)&&(0,w.jsx)(yA,{position:a,centerX:s,centerY:i,radius:t,onMouseDown:e=>m(e,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),onMouseEnter:g,onMouseOut:x,type:"source"}),(!0===e||"target"===e)&&(0,w.jsx)(yA,{position:l,centerX:r,centerY:o,radius:t,onMouseDown:e=>m(e,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),onMouseEnter:g,onMouseOut:x,type:"target"})]})}var yP=(0,O.memo)(function({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:i,onDoubleClick:r,onContextMenu:o,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:f,rfId:m,edgeTypes:g,noPanClassName:x,onError:v,disableKeyboardA11y:y}){let k,j=b4(t=>t.edgeLookup.get(e)),N=b4(e=>e.defaultEdgeOptions),S=(j=N?{...N,...j}:j).type||"default",z=g?.[S]||yC[S];void 0===z&&(v?.("011",(k=S,`Edge type "${k}" not found. Using fallback type "default".`)),S="default",z=g?.default||yC.default);let C=!!(j.focusable||t&&void 0===j.focusable),_=void 0!==d&&(j.reconnectable||n&&void 0===j.reconnectable),T=!!(j.selectable||s&&void 0===j.selectable),A=(0,O.useRef)(null),[M,P]=(0,O.useState)(!1),[E,R]=(0,O.useState)(!1),D=b8(),{zIndex:$,sourceX:Q,sourceY:I,targetX:L,targetY:q,sourcePosition:B,targetPosition:W}=b4((0,O.useCallback)(t=>{let n=t.nodeLookup.get(j.source),s=t.nodeLookup.get(j.target);if(!n||!s)return{zIndex:j.zIndex,...y_};let i=function(e){let{sourceNode:t,targetNode:n}=e;if(!bd(t)||!bd(n))return null;let s=t.internals.handleBounds||bu(t.handles),i=n.internals.handleBounds||bu(n.handles),r=bf(s?.source??[],e.sourceHandle),o=bf(e.connectionMode===p.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!r||!o)return e.onError?.("008",((e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${"source"===e?n:s}", edge id: ${t}.`)(!r?"source":"target",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let a=r?.position||b.Bottom,l=o?.position||b.Top,c=bp(t,r,a),h=bp(n,o,l);return{sourceX:c.x,sourceY:c.y,targetX:h.x,targetY:h.y,sourcePosition:a,targetPosition:l}}({id:e,sourceNode:n,targetNode:s,sourceHandle:j.sourceHandle||null,targetHandle:j.targetHandle||null,connectionMode:t.connectionMode,onError:v});return{zIndex:function({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:i=!1,zIndexMode:r="basic"}){if("manual"===r)return s;let o=Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0);return(i&&n?s+1e3:s)+o}({selected:j.selected,zIndex:j.zIndex,sourceNode:n,targetNode:s,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||y_}},[j.source,j.target,j.sourceHandle,j.targetHandle,j.selected,j.zIndex]),b1),V=(0,O.useMemo)(()=>j.markerStart?`url('#${bm(j.markerStart,m)}')`:void 0,[j.markerStart,m]),F=(0,O.useMemo)(()=>j.markerEnd?`url('#${bm(j.markerEnd,m)}')`:void 0,[j.markerEnd,m]);if(j.hidden||null===Q||null===I||null===L||null===q)return null;let H=r?e=>{r(e,{...j})}:void 0,X=o?e=>{o(e,{...j})}:void 0,U=a?e=>{a(e,{...j})}:void 0,G=l?e=>{l(e,{...j})}:void 0,Z=c?e=>{c(e,{...j})}:void 0;return(0,w.jsx)("svg",{style:{zIndex:$},children:(0,w.jsxs)("g",{className:fq(["react-flow__edge",`react-flow__edge-${S}`,j.className,x,{selected:j.selected,animated:j.animated,inactive:!T&&!i,updating:M,selectable:T}]),onClick:t=>{let{addSelectedEdges:n,unselectNodesAndEdges:s,multiSelectionActive:r}=D.getState();T&&(D.setState({nodesSelectionActive:!1}),j.selected&&r?(s({nodes:[],edges:[j]}),A.current?.blur()):n([e])),i&&i(t,j)},onDoubleClick:H,onContextMenu:X,onMouseEnter:U,onMouseMove:G,onMouseLeave:Z,onKeyDown:C?t=>{if(!y&&xx.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:s}=D.getState();"Escape"===t.key?(A.current?.blur(),n({edges:[j]})):s([e])}}:void 0,tabIndex:C?0:void 0,role:j.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":null===j.ariaLabel?void 0:j.ariaLabel||`Edge from ${j.source} to ${j.target}`,"aria-describedby":C?`${ve}-${m}`:void 0,ref:A,...j.domAttributes,children:[!E&&(0,w.jsx)(z,{id:e,source:j.source,target:j.target,type:j.type,selected:j.selected,animated:j.animated,selectable:T,deletable:j.deletable??!0,label:j.label,labelStyle:j.labelStyle,labelShowBg:j.labelShowBg,labelBgStyle:j.labelBgStyle,labelBgPadding:j.labelBgPadding,labelBgBorderRadius:j.labelBgBorderRadius,sourceX:Q,sourceY:I,targetX:L,targetY:q,sourcePosition:B,targetPosition:W,data:j.data,style:j.style,sourceHandleId:j.sourceHandle,targetHandleId:j.targetHandle,markerStart:V,markerEnd:F,pathOptions:"pathOptions"in j?j.pathOptions:void 0,interactionWidth:j.interactionWidth}),_&&(0,w.jsx)(yM,{edge:j,isReconnectable:_,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:f,sourceX:Q,sourceY:I,targetX:L,targetY:q,sourcePosition:B,targetPosition:W,setUpdateHover:P,setReconnecting:R})]})})});let yE=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function yR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:s,noPanClassName:i,onReconnect:r,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:h,reconnectRadius:d,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:f,disableKeyboardA11y:m}){let{edgesFocusable:g,edgesReconnectable:x,elementsSelectable:b,onError:v}=b4(yE,b1),y=b4((0,O.useCallback)(e=>{if(!t)return e.edges.map(e=>e.id);let n=[];if(e.width&&e.height)for(let t of e.edges){let s=e.nodeLookup.get(t.source),i=e.nodeLookup.get(t.target);s&&i&&function({sourceNode:e,targetNode:t,width:n,height:s,transform:i}){let r=xR(xI(e),xI(t));return r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1),xq({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:s/i[2]},x$(r))>0}({sourceNode:s,targetNode:i,width:e.width,height:e.height,transform:e.transform})&&n.push(t.id)}return n},[t]),b1);return(0,w.jsxs)("div",{className:"react-flow__edges",children:[(0,w.jsx)(ya,{defaultColor:e,rfId:n}),y.map(e=>(0,w.jsx)(yP,{id:e,edgesFocusable:g,edgesReconnectable:x,elementsSelectable:b,noPanClassName:i,onReconnect:r,onContextMenu:o,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:h,reconnectRadius:d,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:f,rfId:n,onError:v,edgeTypes:s,disableKeyboardA11y:m},e))]})}yR.displayName="EdgeRenderer";let yD=(0,O.memo)(yR),y$=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function yQ({children:e}){let t=b4(y$);return(0,w.jsx)("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}let yI=e=>e.panZoom?.syncViewport;function yL(e){return e.connection.inProgress?{...e.connection,to:xH(e.connection.to,e.transform)}:{...e.connection}}let yq=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function yB({containerStyle:e,style:t,type:n,component:s}){let{nodesConnectable:i,width:r,height:o,isValid:a,inProgress:l}=b4(yq,b1);return r&&i&&l?(0,w.jsx)("svg",{style:e,width:r,height:o,className:"react-flow__connectionline react-flow__container",children:(0,w.jsx)("g",{className:fq(["react-flow__connection",xw(a)]),children:(0,w.jsx)(yW,{style:t,type:n,CustomComponent:s,isValid:a})})}):null}let yW=({style:e,type:t=g.Bezier,CustomComponent:n,isValid:s})=>{let{inProgress:i,from:r,fromNode:o,fromHandle:a,fromPosition:l,to:c,toNode:h,toHandle:d,toPosition:u,pointer:p}=b4(yL,b1);if(!i)return;if(n)return(0,w.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:a,fromX:r.x,fromY:r.y,toX:c.x,toY:c.y,fromPosition:l,toPosition:u,connectionStatus:xw(s),toNode:h,toHandle:d,pointer:p});let f="",m={sourceX:r.x,sourceY:r.y,sourcePosition:l,targetX:c.x,targetY:c.y,targetPosition:u};switch(t){case g.Bezier:[f]=bn(m);break;case g.SimpleBezier:[f]=yu(m);break;case g.Step:[f]=bh({...m,borderRadius:0});break;case g.SmoothStep:[f]=bh(m);break;default:[f]=bo(m)}return(0,w.jsx)("path",{d:f,fill:"none",className:"react-flow__connection-path",style:e})};yW.displayName="ConnectionLine";let yV={};function yF(e=yV){(0,O.useRef)(e),b8(),(0,O.useEffect)(()=>{},[e])}function yH({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:s,onEdgeClick:i,onNodeDoubleClick:r,onEdgeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:h,onSelectionContextMenu:d,onSelectionStart:u,onSelectionEnd:p,connectionLineType:f,connectionLineStyle:m,connectionLineComponent:g,connectionLineContainerStyle:x,selectionKeyCode:b,selectionOnDrag:v,selectionMode:y,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:N,deleteKeyCode:S,onlyRenderVisibleElements:z,elementsSelectable:C,defaultViewport:_,translateExtent:T,minZoom:A,maxZoom:M,preventScrolling:P,defaultMarkerColor:E,zoomOnScroll:R,zoomOnPinch:D,panOnScroll:$,panOnScrollSpeed:Q,panOnScrollMode:I,zoomOnDoubleClick:L,panOnDrag:q,onPaneClick:B,onPaneMouseEnter:W,onPaneMouseMove:V,onPaneMouseLeave:F,onPaneScroll:H,onPaneContextMenu:X,paneClickDistance:U,nodeClickDistance:G,onEdgeContextMenu:Z,onEdgeMouseEnter:Y,onEdgeMouseMove:K,onEdgeMouseLeave:J,reconnectRadius:ee,onReconnect:et,onReconnectStart:en,onReconnectEnd:es,noDragClassName:ei,noWheelClassName:er,noPanClassName:eo,disableKeyboardA11y:ea,nodeExtent:el,rfId:ec,viewport:eh,onViewportChange:ed}){let eu,ep,ef,em;return yF(e),yF(t),b8(),(0,O.useRef)(!1),(0,O.useEffect)(()=>{},[]),eu=vD(),ep=(0,O.useRef)(!1),(0,O.useEffect)(()=>{!ep.current&&eu.viewportInitialized&&n&&(setTimeout(()=>n(eu),1),ep.current=!0)},[n,eu.viewportInitialized]),ef=b4(yI),em=b8(),(0,O.useEffect)(()=>{eh&&(ef?.(eh),em.setState({transform:[eh.x,eh.y,eh.zoom]}))},[eh,ef]),(0,w.jsx)(v9,{onPaneClick:B,onPaneMouseEnter:W,onPaneMouseMove:V,onPaneMouseLeave:F,onPaneContextMenu:X,onPaneScroll:H,paneClickDistance:U,deleteKeyCode:S,selectionKeyCode:b,selectionOnDrag:v,selectionMode:y,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:N,elementsSelectable:C,zoomOnScroll:R,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:$,panOnScrollSpeed:Q,panOnScrollMode:I,panOnDrag:q,defaultViewport:_,translateExtent:T,minZoom:A,maxZoom:M,onSelectionContextMenu:d,preventScrolling:P,noDragClassName:ei,noWheelClassName:er,noPanClassName:eo,disableKeyboardA11y:ea,onViewportChange:ed,isControlledViewport:!!eh,children:(0,w.jsxs)(yQ,{children:[(0,w.jsx)(yD,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:et,onReconnectStart:en,onReconnectEnd:es,onlyRenderVisibleElements:z,onEdgeContextMenu:Z,onEdgeMouseEnter:Y,onEdgeMouseMove:K,onEdgeMouseLeave:J,reconnectRadius:ee,defaultMarkerColor:E,noPanClassName:eo,disableKeyboardA11y:ea,rfId:ec}),(0,w.jsx)(yB,{style:m,type:f,component:g,containerStyle:x}),(0,w.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,w.jsx)(ys,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:r,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:h,nodeClickDistance:G,onlyRenderVisibleElements:z,noPanClassName:eo,noDragClassName:ei,disableKeyboardA11y:ea,nodeExtent:el,rfId:ec}),(0,w.jsx)("div",{className:"react-flow__viewport-portal"})]})})}yH.displayName="GraphView";let yX=(0,O.memo)(yH),yU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:i,height:r,fitView:o,fitViewOptions:a,minZoom:l=.5,maxZoom:c=2,nodeOrigin:h,nodeExtent:d,zIndexMode:u="basic"}={})=>{let f=new Map,m=new Map,g=new Map,x=new Map,b=s??t??[],v=n??e??[],y=h??[0,0],w=d??xg;bS(g,x,b);let O=by(v,f,m,{nodeOrigin:y,nodeExtent:w,zIndexMode:u}),k=[0,0,1];if(o&&i&&r){let{x:e,y:t,zoom:n}=xG(xN(f,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,r,l,c,a?.padding??.1);k=[e,t,n]}return{rfId:"1",width:i??0,height:r??0,transform:k,nodes:v,nodesInitialized:O,nodeLookup:f,parentLookup:m,edges:b,edgeLookup:x,connectionLookup:g,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==n,hasDefaultEdges:void 0!==s,panZoom:null,minZoom:l,maxZoom:c,translateExtent:xg,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:p.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:a,fitViewResolver:null,connection:{...xv},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:xV,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:xb,zIndexMode:u,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}};function yG({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:s,initialWidth:i,initialHeight:r,initialMinZoom:o,initialMaxZoom:a,initialFitViewOptions:l,fitView:c,nodeOrigin:h,nodeExtent:d,zIndexMode:u,children:p}){let[f]=(0,O.useState)(()=>(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:i,height:r,fitView:o,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:h,nodeExtent:d,zIndexMode:u})=>{let p,f;return p=(p,f)=>{async function m(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:s,width:i,height:r,minZoom:o,maxZoom:a}=f();t&&(await xz({nodes:e,width:i,height:r,panZoom:t,minZoom:o,maxZoom:a},n),s?.resolve(!0),p({fitViewResolver:null}))}return{...yU({nodes:e,edges:t,width:i,height:r,fitView:o,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:h,nodeExtent:d,defaultNodes:n,defaultEdges:s,zIndexMode:u}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:s,elevateNodesOnSelect:i,fitViewQueued:r,zIndexMode:o}=f(),a=by(e,t,n,{nodeOrigin:s,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o});r&&a?(m(),p({nodes:e,nodesInitialized:a,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:e,nodesInitialized:a})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=f();bS(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=f();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=f();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:s,domNode:i,nodeOrigin:r,nodeExtent:o,debug:a,fitViewQueued:l,zIndexMode:c}=f(),{changes:h,updatedInternals:d}=function(e,t,n,s,i,r,o){let a=s?.querySelector(".xyflow__viewport"),l=!1;if(!a)return{changes:[],updatedInternals:l};let c=[],h=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(h.transform),u=[];for(let s of e.values()){let e=t.get(s.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),l=!0;continue}let a=x5(s.nodeElement),h=e.measured.width!==a.width||e.measured.height!==a.height;if(a.width&&a.height&&(h||!e.internals.handleBounds||s.force)){let p=s.nodeElement.getBoundingClientRect(),f=xY(e.extent)?e.extent:r,{positionAbsolute:m}=e.internals;e.parentId&&"parent"===e.extent?m=xM(m,a,t.get(e.parentId)):f&&(m=xA(m,f,a));let g={...e,measured:a,internals:{...e.internals,positionAbsolute:m,handleBounds:{source:x9("source",s.nodeElement,p,d,e.id),target:x9("target",s.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&bw(g,t,n,{nodeOrigin:i,zIndexMode:o}),l=!0,h&&(c.push({id:e.id,type:"dimensions",dimensions:a}),e.expandParent&&e.parentId&&u.push({id:e.id,parentId:e.parentId,rect:xQ(g,i)}))}}if(u.length>0){let e=bk(u,t,n,i);c.push(...e)}return{changes:c,updatedInternals:l}}(e,n,s,i,r,o,c);d&&(!function(e,t,n){let s=bb(bg,n);for(let n of e.values())if(n.parentId)bw(n,e,t,s);else{let e=xA(xj(n,s.nodeOrigin),xY(n.extent)?n.extent:s.nodeExtent,xK(n));n.internals.positionAbsolute=e}}(n,s,{nodeOrigin:r,nodeExtent:o,zIndexMode:c}),l?(m(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),h?.length>0&&(a&&console.log("React Flow: trigger node changes",h),t?.(h)))},updateNodePositions:(e,t=!1)=>{let n=[],s=[],{nodeLookup:i,triggerNodeChanges:r,connection:o,updateConnection:a,onNodesChangeMiddlewareMap:l}=f();for(let[r,l]of e){let e=i.get(r),c=!!(e?.expandParent&&e?.parentId&&l?.position),h={id:r,type:"position",position:c?{x:Math.max(0,l.position.x),y:Math.max(0,l.position.y)}:l.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=bp(e,o.fromHandle,b.Left,!0);a({...o,from:t})}c&&e.parentId&&n.push({id:r,parentId:e.parentId,rect:{...l.internals.positionAbsolute,width:l.measured.width??0,height:l.measured.height??0}}),s.push(h)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=f(),r=bk(n,i,e,t);s.push(...r)}for(let e of l.values())s=e(s);r(s)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:s,hasDefaultNodes:i,debug:r}=f();e?.length&&(i&&n(vj(e,s)),r&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:s,hasDefaultEdges:i,debug:r}=f();e?.length&&(i&&n(vj(e,s)),r&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:s,triggerNodeChanges:i,triggerEdgeChanges:r}=f();t?i(e.map(e=>vN(e,!0))):(i(vS(s,new Set([...e]),!0)),r(vS(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:s,triggerNodeChanges:i,triggerEdgeChanges:r}=f();t?r(e.map(e=>vN(e,!0))):(r(vS(n,new Set([...e]))),i(vS(s,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:s,nodeLookup:i,triggerNodeChanges:r,triggerEdgeChanges:o}=f(),a=[];for(let t of e||s){if(!t.selected)continue;let e=i.get(t.id);e&&(e.selected=!1),a.push(vN(t.id,!1))}let l=[];for(let e of t||n)e.selected&&l.push(vN(e.id,!1));r(a),o(l)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=f();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=f();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{f().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:s,elementsSelectable:i}=f();if(!i)return;let r=t.reduce((e,t)=>t.selected?[...e,vN(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,vN(t.id,!1)]:e,[]);n(r),s(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:s,nodeOrigin:i,elevateNodesOnSelect:r,nodeExtent:o,zIndexMode:a}=f();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(by(t,n,s,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:r,checkEquality:!1,zIndexMode:a}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:s,panZoom:i,translateExtent:r}=f();return bj({delta:e,panZoom:i,transform:t,translateExtent:r,width:n,height:s})},setCenter:async(e,t,n)=>{let{width:s,height:i,maxZoom:r,panZoom:o}=f();if(!o)return Promise.resolve(!1);let a=void 0!==n?.zoom?n.zoom:r;return await o.setViewport({x:s/2-e*a,y:i/2-t*a,zoom:a},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...xv}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...yU()})}},f=Object.is,p?b0(p,f):b0})({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:i,height:r,fitView:c,minZoom:o,maxZoom:a,fitViewOptions:l,nodeOrigin:h,nodeExtent:d,zIndexMode:u}));return(0,w.jsx)(b5,{value:f,children:(0,w.jsx)(vE,{children:p})})}function yZ({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p}){return(0,O.useContext)(b2)?(0,w.jsx)(w.Fragment,{children:e}):(0,w.jsx)(yG,{initialNodes:t,initialEdges:n,defaultNodes:s,defaultEdges:i,initialWidth:r,initialHeight:o,fitView:a,initialFitViewOptions:l,initialMinZoom:c,initialMaxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p,children:e})}let yY={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var yK=vT(function({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:i,nodeTypes:r,edgeTypes:o,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:h,onMoveStart:d,onMoveEnd:u,onConnect:p,onConnectStart:x,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:k,onNodeMouseMove:j,onNodeMouseLeave:N,onNodeContextMenu:S,onNodeDoubleClick:z,onNodeDragStart:C,onNodeDrag:_,onNodeDragStop:T,onNodesDelete:A,onEdgesDelete:M,onDelete:P,onSelectionChange:E,onSelectionDragStart:R,onSelectionDrag:D,onSelectionDragStop:$,onSelectionContextMenu:Q,onSelectionStart:I,onSelectionEnd:L,onBeforeDelete:q,connectionMode:B,connectionLineType:W=g.Bezier,connectionLineStyle:V,connectionLineComponent:F,connectionLineContainerStyle:H,deleteKeyCode:X="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:G=!1,selectionMode:Z=m.Full,panActivationKeyCode:Y="Space",multiSelectionKeyCode:K=xZ()?"Meta":"Control",zoomActivationKeyCode:J=xZ()?"Meta":"Control",snapToGrid:ee,snapGrid:et,onlyRenderVisibleElements:en=!1,selectNodesOnDrag:es,nodesDraggable:ei,autoPanOnNodeFocus:er,nodesConnectable:eo,nodesFocusable:ea,nodeOrigin:el=vp,edgesFocusable:ec,edgesReconnectable:eh,elementsSelectable:ed=!0,defaultViewport:eu=vf,minZoom:ep=.5,maxZoom:ef=2,translateExtent:em=xg,preventScrolling:eg=!0,nodeExtent:ex,defaultMarkerColor:eb="#b1b1b7",zoomOnScroll:ev=!0,zoomOnPinch:ey=!0,panOnScroll:ew=!1,panOnScrollSpeed:eO=.5,panOnScrollMode:ek=f.Free,zoomOnDoubleClick:ej=!0,panOnDrag:eN=!0,onPaneClick:eS,onPaneMouseEnter:ez,onPaneMouseMove:eC,onPaneMouseLeave:e_,onPaneScroll:eT,onPaneContextMenu:eA,paneClickDistance:eM=1,nodeClickDistance:eP=0,children:eE,onReconnect:eR,onReconnectStart:eD,onReconnectEnd:e$,onEdgeContextMenu:eQ,onEdgeDoubleClick:eI,onEdgeMouseEnter:eL,onEdgeMouseMove:eq,onEdgeMouseLeave:eB,reconnectRadius:eW=10,onNodesChange:eV,onEdgesChange:eF,noDragClassName:eH="nodrag",noWheelClassName:eX="nowheel",noPanClassName:eU="nopan",fitView:eG,fitViewOptions:eZ,connectOnClick:eY,attributionPosition:eK,proOptions:eJ,defaultEdgeOptions:e0,elevateNodesOnSelect:e1=!0,elevateEdgesOnSelect:e2=!1,disableKeyboardA11y:e5=!1,autoPanOnConnect:e3,autoPanOnNodeDrag:e4,autoPanSpeed:e8,connectionRadius:e6,isValidConnection:e9,onError:e7,style:te,id:tt,nodeDragThreshold:tn,connectionDragThreshold:ts,viewport:ti,onViewportChange:tr,width:to,height:ta,colorMode:tl="light",debug:tc,onScroll:th,ariaLabelConfig:td,zIndexMode:tu="basic",...tp},tf){let tm=tt||"1",tg=function(e){let[t,n]=(0,O.useState)("system"===e?null:e);return(0,O.useEffect)(()=>{if("system"!==e)return void n(e);let t=vv(),s=()=>n(t?.matches?"dark":"light");return s(),t?.addEventListener("change",s),()=>{t?.removeEventListener("change",s)}},[e]),null!==t?t:vv()?.matches?"dark":"light"}(tl),tx=(0,O.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),th?.(e)},[th]);return(0,w.jsx)("div",{"data-testid":"rf__wrapper",...tp,onScroll:tx,style:{...te,...yY},ref:tf,className:fq(["react-flow",i,tg]),id:tt,role:"application",children:(0,w.jsxs)(yZ,{nodes:e,edges:t,width:to,height:ta,fitView:eG,fitViewOptions:eZ,minZoom:ep,maxZoom:ef,nodeOrigin:el,nodeExtent:ex,zIndexMode:tu,children:[(0,w.jsx)(yX,{onInit:c,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:k,onNodeMouseMove:j,onNodeMouseLeave:N,onNodeContextMenu:S,onNodeDoubleClick:z,nodeTypes:r,edgeTypes:o,connectionLineType:W,connectionLineStyle:V,connectionLineComponent:F,connectionLineContainerStyle:H,selectionKeyCode:U,selectionOnDrag:G,selectionMode:Z,deleteKeyCode:X,multiSelectionKeyCode:K,panActivationKeyCode:Y,zoomActivationKeyCode:J,onlyRenderVisibleElements:en,defaultViewport:eu,translateExtent:em,minZoom:ep,maxZoom:ef,preventScrolling:eg,zoomOnScroll:ev,zoomOnPinch:ey,zoomOnDoubleClick:ej,panOnScroll:ew,panOnScrollSpeed:eO,panOnScrollMode:ek,panOnDrag:eN,onPaneClick:eS,onPaneMouseEnter:ez,onPaneMouseMove:eC,onPaneMouseLeave:e_,onPaneScroll:eT,onPaneContextMenu:eA,paneClickDistance:eM,nodeClickDistance:eP,onSelectionContextMenu:Q,onSelectionStart:I,onSelectionEnd:L,onReconnect:eR,onReconnectStart:eD,onReconnectEnd:e$,onEdgeContextMenu:eQ,onEdgeDoubleClick:eI,onEdgeMouseEnter:eL,onEdgeMouseMove:eq,onEdgeMouseLeave:eB,reconnectRadius:eW,defaultMarkerColor:eb,noDragClassName:eH,noWheelClassName:eX,noPanClassName:eU,rfId:tm,disableKeyboardA11y:e5,nodeExtent:ex,viewport:ti,onViewportChange:tr}),(0,w.jsx)(vb,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:x,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:ei,autoPanOnNodeFocus:er,nodesConnectable:eo,nodesFocusable:ea,edgesFocusable:ec,edgesReconnectable:eh,elementsSelectable:ed,elevateNodesOnSelect:e1,elevateEdgesOnSelect:e2,minZoom:ep,maxZoom:ef,nodeExtent:ex,onNodesChange:eV,onEdgesChange:eF,snapToGrid:ee,snapGrid:et,connectionMode:B,translateExtent:em,connectOnClick:eY,defaultEdgeOptions:e0,fitView:eG,fitViewOptions:eZ,onNodesDelete:A,onEdgesDelete:M,onDelete:P,onNodeDragStart:C,onNodeDrag:_,onNodeDragStop:T,onSelectionDrag:D,onSelectionDragStart:R,onSelectionDragStop:$,onMove:h,onMoveStart:d,onMoveEnd:u,noPanClassName:eU,nodeOrigin:el,rfId:tm,autoPanOnConnect:e3,autoPanOnNodeDrag:e4,autoPanSpeed:e8,onError:e7,connectionRadius:e6,isValidConnection:e9,selectNodesOnDrag:es,nodeDragThreshold:tn,connectionDragThreshold:ts,onBeforeDelete:q,debug:tc,ariaLabelConfig:td,zIndexMode:tu}),(0,w.jsx)(vu,{onSelectionChange:E}),eE,(0,w.jsx)(vo,{proOptions:eJ,position:eK}),(0,w.jsx)(vi,{rfId:tm,disableKeyboardA11y:e5})]})})});function yJ({dimensions:e,lineWidth:t,variant:n,className:s}){return(0,w.jsx)("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:fq(["react-flow__background-pattern",n,s])})}function y0({radius:e,className:t}){return(0,w.jsx)("circle",{cx:e,cy:e,r:e,className:fq(["react-flow__background-pattern","dots",t])})}(d=y||(y={})).Lines="lines",d.Dots="dots",d.Cross="cross";let y1={[y.Dots]:1,[y.Lines]:1,[y.Cross]:6},y2=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function y5({id:e,variant:t=y.Dots,gap:n=20,size:s,lineWidth:i=1,offset:r=0,color:o,bgColor:a,style:l,className:c,patternClassName:h}){let d=(0,O.useRef)(null),{transform:u,patternId:p}=b4(y2,b1),f=s||y1[t],m=t===y.Dots,g=t===y.Cross,x=Array.isArray(n)?n:[n,n],b=[x[0]*u[2]||1,x[1]*u[2]||1],v=f*u[2],k=Array.isArray(r)?r:[r,r],j=g?[v,v]:b,N=[k[0]*u[2]||1+j[0]/2,k[1]*u[2]||1+j[1]/2],S=`${p}${e||""}`;return(0,w.jsxs)("svg",{className:fq(["react-flow__background",c]),style:{...l,...vI,"--xy-background-color-props":a,"--xy-background-pattern-color-props":o},ref:d,"data-testid":"rf__background",children:[(0,w.jsx)("pattern",{id:S,x:u[0]%b[0],y:u[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:m?(0,w.jsx)(y0,{radius:v/2,className:h}):(0,w.jsx)(yJ,{dimensions:j,lineWidth:i,variant:t,className:h})}),(0,w.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}y5.displayName="Background";let y3=(0,O.memo)(y5);function y4(){return(0,w.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,w.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function y8(){return(0,w.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,w.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function y6(){return(0,w.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,w.jsx)("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function y9(){return(0,w.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,w.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function y7(){return(0,w.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,w.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function we({children:e,className:t,...n}){return(0,w.jsx)("button",{type:"button",className:fq(["react-flow__controls-button",t]),...n,children:e})}let wt=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function wn({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:i,onZoomIn:r,onZoomOut:o,onFitView:a,onInteractiveChange:l,className:c,children:h,position:d="bottom-left",orientation:u="vertical","aria-label":p}){let f=b8(),{isInteractive:m,minZoomReached:g,maxZoomReached:x,ariaLabelConfig:b}=b4(wt,b1),{zoomIn:v,zoomOut:y,fitView:O}=vD();return(0,w.jsxs)(vr,{className:fq(["react-flow__controls","horizontal"===u?"horizontal":"vertical",c]),position:d,style:e,"data-testid":"rf__controls","aria-label":p??b["controls.ariaLabel"],children:[t&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(we,{onClick:()=>{v(),r?.()},className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:x,children:(0,w.jsx)(y4,{})}),(0,w.jsx)(we,{onClick:()=>{y(),o?.()},className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:g,children:(0,w.jsx)(y8,{})})]}),n&&(0,w.jsx)(we,{className:"react-flow__controls-fitview",onClick:()=>{O(i),a?.()},title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:(0,w.jsx)(y6,{})}),s&&(0,w.jsx)(we,{className:"react-flow__controls-interactive",onClick:()=>{f.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),l?.(!m)},title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:m?(0,w.jsx)(y7,{}):(0,w.jsx)(y9,{})}),h]})}wn.displayName="Controls";let ws=(0,O.memo)(wn),wi=(0,O.memo)(function({id:e,x:t,y:n,width:s,height:i,style:r,color:o,strokeColor:a,strokeWidth:l,className:c,borderRadius:h,shapeRendering:d,selected:u,onClick:p}){let{background:f,backgroundColor:m}=r||{};return(0,w.jsx)("rect",{className:fq(["react-flow__minimap-node",{selected:u},c]),x:t,y:n,rx:h,ry:h,width:s,height:i,style:{fill:o||f||m,stroke:a,strokeWidth:l},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}),wr=e=>e.nodes.map(e=>e.id),wo=e=>e instanceof Function?e:()=>e,wa=(0,O.memo)(function({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:i,nodeStrokeWidth:r,shapeRendering:o,NodeComponent:a,onClick:l}){let{node:c,x:h,y:d,width:u,height:p}=b4(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let s=n.internals.userNode,{x:i,y:r}=n.internals.positionAbsolute,{width:o,height:a}=xK(s);return{node:s,x:i,y:r,width:o,height:a}},b1);return c&&!c.hidden&&xJ(c)?(0,w.jsx)(a,{x:h,y:d,width:u,height:p,style:c.style,selected:!!c.selected,className:s(c),color:t(c),borderRadius:i,strokeColor:n(c),strokeWidth:r,shapeRendering:o,onClick:l,id:c.id}):null});var wl=(0,O.memo)(function({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:r=wi,onClick:o}){let a=b4(wr,b1),l=wo(t),c=wo(e),h=wo(n),d="u"<typeof window||window.chrome?"crispEdges":"geometricPrecision";return(0,w.jsx)(w.Fragment,{children:a.map(e=>(0,w.jsx)(wa,{id:e,nodeColorFunc:l,nodeStrokeColorFunc:c,nodeClassNameFunc:h,nodeBorderRadius:s,nodeStrokeWidth:i,NodeComponent:r,onClick:o,shapeRendering:d},e))})});let wc=e=>!e.hidden,wh=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?xL(xN(e.nodeLookup,{filter:wc}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}};function wd({style:e,className:t,nodeStrokeColor:n,nodeColor:s,nodeClassName:i="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:a,bgColor:l,maskColor:c,maskStrokeColor:h,maskStrokeWidth:d,position:u="bottom-right",onClick:p,onNodeClick:f,pannable:m=!1,zoomable:g=!1,ariaLabel:x,inversePan:b,zoomStep:v=1,offsetScale:y=5}){let k=b8(),j=(0,O.useRef)(null),{boundingRect:N,viewBB:S,rfId:z,panZoom:C,translateExtent:_,flowWidth:T,flowHeight:A,ariaLabelConfig:M}=b4(wh,b1),P=e?.width??200,E=e?.height??150,R=Math.max(N.width/P,N.height/E),D=R*P,$=R*E,Q=y*R,I=N.x-(D-N.width)/2-Q,L=N.y-($-N.height)/2-Q,q=D+2*Q,B=$+2*Q,W=`react-flow__minimap-desc-${z}`,V=(0,O.useRef)(0),F=(0,O.useRef)();V.current=R,(0,O.useEffect)(()=>{if(j.current&&C)return F.current=function({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){let i=mk(e);return{update:function({translateExtent:e,width:r,height:o,zoomStep:a=1,pannable:l=!0,zoomable:c=!0,inversePan:h=!1}){let d=[0,0],u=xf().on("start",e=>{("mousedown"===e.sourceEvent.type||"touchstart"===e.sourceEvent.type)&&(d=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on("zoom",l?i=>{let a=n();if("mousemove"!==i.sourceEvent.type&&"touchmove"!==i.sourceEvent.type||!t)return;let l=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],c=[l[0]-d[0],l[1]-d[1]];d=l;let u=s()*Math.max(a[2],Math.log(a[2]))*(h?-1:1),p={x:a[0]-c[0]*u,y:a[1]-c[1]*u};t.setViewportConstrained({x:p.x,y:p.y,zoom:a[2]},[[0,0],[r,o]],e)}:null).on("zoom.wheel",c?e=>{if("wheel"!==e.sourceEvent.type||!t)return;let s=n(),i=e.sourceEvent.ctrlKey&&xZ()?10:1,r=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*a,o=s[2]*Math.pow(2,r*i);t.scaleTo(o)}:null);i.call(u,{})},destroy:function(){i.on("zoom",null)},pointer:mj}}({domNode:j.current,panZoom:C,getTransform:()=>k.getState().transform,getViewScale:()=>V.current}),()=>{F.current?.destroy()}},[C]),(0,O.useEffect)(()=>{F.current?.update({translateExtent:_,width:T,height:A,inversePan:b,pannable:m,zoomStep:v,zoomable:g})},[m,g,b,v,_,T,A]);let H=p?e=>{let[t,n]=F.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,X=f?(0,O.useCallback)((e,t)=>{f(e,k.getState().nodeLookup.get(t).internals.userNode)},[]):void 0,U=x??M["minimap.ariaLabel"];return(0,w.jsx)(vr,{position:u,style:{...e,"--xy-minimap-background-color-props":"string"==typeof l?l:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof c?c:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof h?h:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof d?d*R:void 0,"--xy-minimap-node-background-color-props":"string"==typeof s?s:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof n?n:void 0,"--xy-minimap-node-stroke-width-props":"number"==typeof o?o:void 0},className:fq(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:(0,w.jsxs)("svg",{width:P,height:E,viewBox:`${I} ${L} ${q} ${B}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":W,ref:j,onClick:H,children:[U&&(0,w.jsx)("title",{id:W,children:U}),(0,w.jsx)(wl,{onClick:X,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:r,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:a}),(0,w.jsx)("path",{className:"react-flow__minimap-mask",d:`M${I-Q},${L-Q}h${q+2*Q}v${B+2*Q}h${-q-2*Q}z
|
|
35
|
+
M${S.x},${S.y}h${S.width}v${S.height}h${-S.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}wd.displayName="MiniMap";let wu=(0,O.memo)(wd),wp={[v.Line]:"right",[v.Handle]:"bottom-right"};(0,O.memo)(function({nodeId:e,position:t,variant:n=v.Handle,className:s,style:i,children:r,color:o,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:u,autoScale:p=!0,shouldResize:f,onResizeStart:m,onResize:g,onResizeEnd:x}){let b,y=vK(),k="string"==typeof e?e:y,j=b8(),N=(0,O.useRef)(null),S=n===v.Handle,z=b4((0,O.useCallback)((b=S&&p,e=>b?`${Math.max(1/e.transform[2],1)}`:void 0),[S,p]),b1),C=(0,O.useRef)(null),_=t??wp[n];(0,O.useEffect)(()=>{if(N.current&&k)return C.current||(C.current=function({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:i}){let r=mk(e),o={controlDirection:bq("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:e,boundaries:a,keepAspectRatio:l,resizeDirection:c,onResizeStart:h,onResize:d,onResizeEnd:u,shouldResize:p}){let f,m,g,x,b={...bF},v={...bH};o={boundaries:a,resizeDirection:c,keepAspectRatio:l,controlDirection:bq(e)};let y=null,w=[],O=!1,k=m$().on("start",e=>{let{nodeLookup:s,transform:i,snapGrid:r,snapToGrid:o,nodeOrigin:a,paneDomNode:l}=n();if(!(f=s.get(t)))return;y=l?.getBoundingClientRect()??null;let{xSnapped:c,ySnapped:d}=x2(e.sourceEvent,{transform:i,snapGrid:r,snapToGrid:o,containerBounds:y});if(v={...b={width:f.measured.width??0,height:f.measured.height??0,x:f.position.x??0,y:f.position.y??0},pointerX:c,pointerY:d,aspectRatio:b.width/b.height},m=void 0,f.parentId&&("parent"===f.extent||f.expandParent)){var u;g=(m=s.get(f.parentId))&&"parent"===f.extent?[[0,0],[(u=m).measured.width,u.measured.height]]:void 0}for(let[e,n]of(w=[],x=void 0,s))if(n.parentId===t&&(w.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){let e=function(e,t,n){let s=t.position.x+e.position.x,i=t.position.y+e.position.y,r=e.measured.width??0,o=e.measured.height??0,a=n[0]*r,l=n[1]*o;return[[s-a,i-l],[s+r-a,i+o-l]]}(n,f,n.origin??a);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}h?.(e,{...b})}).on("drag",e=>{let{transform:t,snapGrid:i,snapToGrid:r,nodeOrigin:a}=n(),l=x2(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:r,containerBounds:y}),c=[];if(!f)return;let{x:h,y:u,width:k,height:j}=b,N={},S=f.origin??a,{width:z,height:C,x:_,y:T}=function(e,t,n,s,i,r,o,a){var l,c,h,d;let{affectsX:u,affectsY:p}=t,{isHorizontal:f,isVertical:m}=t,g=f&&m,{xSnapped:x,ySnapped:b}=n,{minWidth:v,maxWidth:y,minHeight:w,maxHeight:O}=s,{x:k,y:j,width:N,height:S,aspectRatio:z}=e,C=Math.floor(f?x-e.pointerX:0),_=Math.floor(m?b-e.pointerY:0),T=N+(u?-C:C),A=S+(p?-_:_),M=-r[0]*N,P=-r[1]*S,E=bV(T,v,y),R=bV(A,w,O);if(o){let e=0,t=0;u&&C<0?e=bB(k+C+M,o[0][0]):!u&&C>0&&(e=bW(k+T+M,o[1][0])),p&&_<0?t=bB(j+_+P,o[0][1]):!p&&_>0&&(t=bW(j+A+P,o[1][1])),E=Math.max(E,e),R=Math.max(R,t)}if(a){let e=0,t=0;u&&C>0?e=bW(k+C,a[0][0]):!u&&C<0&&(e=bB(k+T,a[1][0])),p&&_>0?t=bW(j+_,a[0][1]):!p&&_<0&&(t=bB(j+A,a[1][1])),E=Math.max(E,e),R=Math.max(R,t)}if(i){if(f){(E=Math.max(E,bV(T/z,w,O)*z),o)&&(E=Math.max(E,(u||p)&&(!u||p||!g)?bB(j+P+(u?C:-C)/z,o[0][1])*z:bW(j+P+T/z,o[1][1])*z));a&&(E=Math.max(E,(u||p)&&(!u||p||!g)?bW(j+(u?C:-C)/z,a[0][1])*z:bB(j+T/z,a[1][1])*z))}if(m){(R=Math.max(R,bV(A*z,v,y)/z),o)&&(R=Math.max(R,(u||p)&&(!p||u||!g)?bB(k+(p?_:-_)*z+M,o[0][0])/z:bW(k+A*z+M,o[1][0])/z));a&&(R=Math.max(R,(u||p)&&(!p||u||!g)?bW(k+(p?_:-_)*z,a[0][0])/z:bB(k+A*z,a[1][0])/z))}}_+=_<0?R:-R,C+=C<0?E:-E,i&&(g?T>A*z?_=((l=u,c=p,l?!c:c)?-C:C)/z:C=((h=u,d=p,h?!d:d)?-_:_)*z:f?(_=C/z,p=u):(C=_*z,u=p));let D=u?k+C:k,$=p?j+_:j;return{width:N+(u?-C:C),height:S+(p?-_:_),x:r[0]*C*(u?-1:1)+D,y:r[1]*_*(p?-1:1)+$}}(v,o.controlDirection,l,o.boundaries,o.keepAspectRatio,S,g,x),A=z!==k,M=C!==j,P=_!==h&&A,E=T!==u&&M;if(!P&&!E&&!A&&!M)return;if((P||E||1===S[0]||1===S[1])&&(N.x=P?_:b.x,N.y=E?T:b.y,b.x=N.x,b.y=N.y,w.length>0)){let e=_-h,t=T-u;for(let n of w)n.position={x:n.position.x-e+S[0]*(z-k),y:n.position.y-t+S[1]*(C-j)},c.push(n)}if((A||M)&&(N.width=A&&(!o.resizeDirection||"horizontal"===o.resizeDirection)?z:b.width,N.height=M&&(!o.resizeDirection||"vertical"===o.resizeDirection)?C:b.height,b.width=N.width,b.height=N.height),m&&f.expandParent){let e=S[0]*(N.width??0);N.x&&N.x<e&&(b.x=e,v.x=v.x-(N.x-e));let t=S[1]*(N.height??0);N.y&&N.y<t&&(b.y=t,v.y=v.y-(N.y-t))}let R=function({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:i,affectsY:r}){let o=e-t,a=n-s,l=[o>0?1:o<0?-1:0,a>0?1:a<0?-1:0];return o&&i&&(l[0]=-1*l[0]),a&&r&&(l[1]=-1*l[1]),l}({width:b.width,prevWidth:k,height:b.height,prevHeight:j,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),D={...b,direction:R};!1!==p?.(e,D)&&(O=!0,d?.(e,D),s(N,c))}).on("end",e=>{O&&(u?.(e,{...b}),i?.({...b}),O=!1)});r.call(k)},destroy:function(){r.on(".drag",null)}}}({domNode:N.current,nodeId:k,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:s,nodeOrigin:i,domNode:r}=j.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:s,nodeOrigin:i,paneDomNode:r}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:s,parentLookup:i,nodeOrigin:r}=j.getState(),o=[],a={x:e.x,y:e.y},l=s.get(k);if(l&&l.expandParent&&l.parentId){let t=l.origin??r,n=e.width??l.measured.width??0,c=e.height??l.measured.height??0,h=bk([{id:l.id,parentId:l.parentId,rect:{width:n,height:c,...x0({x:e.x??l.position.x,y:e.y??l.position.y},{width:n,height:c},l.parentId,s,t)}}],s,i,r);o.push(...h),a.x=e.x?Math.max(t[0]*n,e.x):void 0,a.y=e.y?Math.max(t[1]*c,e.y):void 0}if(void 0!==a.x&&void 0!==a.y){let e={id:k,type:"position",position:{...a}};o.push(e)}if(void 0!==e.width&&void 0!==e.height){let t={id:k,type:"dimensions",resizing:!0,setAttributes:!u||("horizontal"===u?"width":"height"),dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:"position"};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{j.getState().triggerNodeChanges([{id:k,type:"dimensions",resizing:!1,dimensions:{width:e,height:t}}])}})),C.current.update({controlPosition:_,boundaries:{minWidth:a,minHeight:l,maxWidth:c,maxHeight:h},keepAspectRatio:d,resizeDirection:u,onResizeStart:m,onResize:g,onResizeEnd:x,shouldResize:f}),()=>{C.current?.destroy()}},[_,a,l,c,h,d,m,g,x,f]);let T=_.split("-");return(0,w.jsx)("div",{className:fq(["react-flow__resize-control","nodrag",...T,n,s]),ref:N,style:{...i,scale:z,...o&&{[S?"backgroundColor":"borderColor"]:o}},children:r})});let wf={Bot:_.Bot,Scale:f_,GitBranch:Z.GitBranch,GitMerge:fT,RefreshCw:ez.RefreshCw,User:fh.User,Code:fA,Square:ep,Zap:fu,Wrench:T.Wrench},wm=["#10b981","#3b82f6","#f59e0b","#8b5cf6","#ec4899","#06b6d4"],wg={stepNode:(0,O.memo)(function({data:e,selected:t}){let n=e.step,s=e.isEntry,i=e.runStatus,r=e.agentName,o=fL[n.type];if(!o)return null;let a=wf[o.icon]||_.Bot,l="evaluator"===n.type?Object.keys(n.route_map||{}):[],c="end"===n.type,h="loop"===n.type,d="evaluator"===n.type;return(0,w.jsxs)("div",{className:`relative bg-zinc-800 rounded-lg border-2 ${i?({pending:"border-zinc-600",running:"border-blue-400 shadow-blue-400/30 shadow-lg animate-pulse",paused:"border-amber-400 shadow-amber-400/30 shadow-lg",completed:"border-green-500",failed:"border-red-500"})[i]||"border-zinc-600":t?"border-blue-500":"border-zinc-600"} min-w-[160px] max-w-[220px] transition-all`,style:{borderColor:t?o.color:void 0},children:[(0,w.jsx)(v0,{type:"target",position:b.Left,className:"!bg-zinc-400 !w-3 !h-3 !border-2 !border-zinc-700"}),(0,w.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-zinc-700",style:{backgroundColor:o.color+"20"},children:[(0,w.jsx)("div",{style:{color:o.color},children:(0,w.jsx)(a,{size:14})}),(0,w.jsx)("span",{className:"text-xs font-medium text-zinc-300 truncate",children:n.name}),s&&(0,w.jsx)("span",{className:"text-[10px] bg-green-600 text-white px-1.5 py-0.5 rounded-full ml-auto",children:"START"})]}),(0,w.jsxs)("div",{className:"px-3 py-2 space-y-1",children:[(0,w.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:o.label}),"agent"===n.type&&r&&(0,w.jsx)("div",{className:"text-xs text-zinc-400 truncate",children:r}),"tool"===n.type&&(0,w.jsx)("div",{className:"text-[10px] text-purple-400 truncate",children:n.forced_tool?n.forced_tool:"No tool selected"}),"llm"===n.type&&(0,w.jsx)("div",{className:"text-[10px] text-teal-400 truncate",children:n.prompt_template?n.prompt_template.slice(0,40)+(n.prompt_template.length>40?"…":""):"No prompt set"}),d&&l.length>0&&(0,w.jsxs)("div",{className:"text-[10px] text-emerald-400",children:[l.length," route",1!==l.length?"s":"",": ",l.join(", ")]}),"parallel"===n.type&&(0,w.jsxs)("div",{className:"text-[10px] text-purple-400",children:[(n.parallel_branches||[]).length," branch",1!==(n.parallel_branches||[]).length?"es":""]}),"merge"===n.type&&(0,w.jsx)("div",{className:"text-[10px] text-pink-400",children:n.merge_strategy||"list"}),h&&(0,w.jsxs)("div",{className:"text-[10px] text-amber-400",children:[n.loop_count||3,"× iterations"]}),"human"===n.type&&(0,w.jsx)("div",{className:"text-[10px] text-red-400 truncate",children:n.human_prompt||"Awaiting input..."}),c&&(0,w.jsx)("div",{className:"text-[10px] text-zinc-500",children:"Terminates flow"}),n.input_keys&&n.input_keys.length>0&&(0,w.jsxs)("div",{className:"text-[10px] text-zinc-500",children:[(0,w.jsx)("span",{className:"text-zinc-600",children:"in:"})," ",n.input_keys.join(", ")]}),n.output_key&&(0,w.jsxs)("div",{className:"text-[10px] text-zinc-500",children:[(0,w.jsx)("span",{className:"text-zinc-600",children:"out:"})," ",n.output_key]}),n.max_iterations&&n.max_iterations>1&&n.max_iterations<100&&(0,w.jsxs)("div",{className:"text-[10px] text-purple-400",children:["max ",n.max_iterations,"x"]})]}),c?null:d&&l.length>0?(0,w.jsxs)(w.Fragment,{children:[l.map((e,t)=>{let n=l.length,s=wm[t%wm.length];return(0,w.jsx)(v0,{type:"source",position:b.Right,id:`route_${e}`,className:"!w-3 !h-3 !border-2 !border-zinc-700",style:{top:`${1===n?50:20+60*t/(n-1)}%`,backgroundColor:s}},`route_${e}`)}),(0,w.jsx)("div",{className:"absolute -right-1 translate-x-full text-[9px] flex flex-col gap-0.5 pointer-events-none",style:{top:"20%"},children:l.map((e,t)=>{let n=wm[t%wm.length];return(0,w.jsx)("span",{className:"leading-tight",style:{color:n},children:e},e)})})]}):h?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(v0,{type:"source",position:b.Right,id:"body",className:"!w-3 !h-3 !border-2 !border-zinc-700 !bg-amber-400",style:{top:"35%"}}),(0,w.jsx)(v0,{type:"source",position:b.Right,id:"done",className:"!w-3 !h-3 !border-2 !border-zinc-700 !bg-green-500",style:{top:"65%"}}),(0,w.jsxs)("div",{className:"absolute -right-1 translate-x-full text-[9px] flex flex-col pointer-events-none",style:{top:"25%"},children:[(0,w.jsx)("span",{className:"text-amber-400 leading-relaxed",children:"body"}),(0,w.jsx)("span",{className:"text-green-500 leading-relaxed",children:"done"})]})]}):(0,w.jsx)(v0,{type:"source",position:b.Right,className:"!bg-zinc-400 !w-3 !h-3 !border-2 !border-zinc-700"})]})})};function wx(e,t,n,s,i){return e.map(e=>{let r=n.find(t=>t.id===e.agent_id);return{id:e.id,type:"stepNode",position:{x:e.position_x??0,y:e.position_y??0},data:{step:e,isEntry:e.id===t,isSelected:e.id===s,agentName:r?.name,runStatus:i?.[e.id]},selected:e.id===s}})}let wb=["#10b981","#3b82f6","#f59e0b","#8b5cf6","#ec4899","#06b6d4"];function wv(e){let t=[];for(let n of(e.map(e=>[e.id,e]),e)){if("evaluator"===n.type&&n.route_map){let e=Object.keys(n.route_map);for(let s of e){let i=n.route_map[s];if(!i)continue;let r=wb[e.indexOf(s)%wb.length];t.push({id:`${n.id}->route_${s}->${i}`,source:n.id,sourceHandle:`route_${s}`,target:i,type:"smoothstep",label:s,labelStyle:{fill:r,fontSize:10},markerEnd:{type:x.ArrowClosed,width:16,height:16,color:r},style:{stroke:r,strokeWidth:2}})}if(e.length>0)continue}if("loop"===n.type){let e=n.loop_step_ids||[];if(e.length>0){t.push({id:`${n.id}->body->${e[0]}`,source:n.id,sourceHandle:"body",target:e[0],type:"smoothstep",style:{stroke:"#f59e0b",strokeWidth:2,strokeDasharray:"5,5"},markerEnd:{type:x.ArrowClosed,width:16,height:16,color:"#f59e0b"}});for(let s=0;s<e.length-1;s++)t.push({id:`loop_body_${n.id}_${e[s]}->${e[s+1]}`,source:e[s],target:e[s+1],type:"smoothstep",style:{stroke:"#f59e0b",strokeWidth:1.5,strokeDasharray:"4,4"},markerEnd:{type:x.ArrowClosed,width:14,height:14,color:"#f59e0b"}})}n.next_step_id&&t.push({id:`${n.id}->done->${n.next_step_id}`,source:n.id,sourceHandle:"done",target:n.next_step_id,type:"smoothstep",label:"done",labelStyle:{fill:"#22c55e",fontSize:10},markerEnd:{type:x.ArrowClosed,width:16,height:16,color:"#22c55e"},style:{stroke:"#22c55e",strokeWidth:2}});continue}if("parallel"===n.type&&n.parallel_branches){for(let e of n.parallel_branches)if(0!==e.length){t.push({id:`${n.id}->par->${e[0]}`,source:n.id,target:e[0],type:"smoothstep",style:{stroke:"#8b5cf6",strokeWidth:2,strokeDasharray:"5,5"},markerEnd:{type:x.ArrowClosed,width:16,height:16,color:"#8b5cf6"}});for(let s=0;s<e.length-1;s++)t.push({id:`par_${n.id}_${e[s]}->${e[s+1]}`,source:e[s],target:e[s+1],type:"smoothstep",style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4,4"},markerEnd:{type:x.ArrowClosed,width:14,height:14,color:"#8b5cf6"}})}n.next_step_id&&t.push({id:`${n.id}->${n.next_step_id}`,source:n.id,target:n.next_step_id,type:"smoothstep",markerEnd:{type:x.ArrowClosed,width:16,height:16,color:"#6b7280"},style:{stroke:"#6b7280",strokeWidth:2}});continue}n.next_step_id&&t.push({id:`${n.id}->${n.next_step_id}`,source:n.id,target:n.next_step_id,type:"smoothstep",markerEnd:{type:x.ArrowClosed,width:16,height:16,color:"#6b7280"},style:{stroke:"#6b7280",strokeWidth:2}})}return t}function wy({orchestration:e,agents:t,selectedStepId:n,onSelectStep:s,onUpdateOrchestration:i,runStepStatuses:r}){let o=(0,O.useMemo)(()=>wx(e.steps,e.entry_step_id,t,n,r),[e.steps,e.entry_step_id,t,n,r]),a=(0,O.useMemo)(()=>wv(e.steps),[e.steps]),[l,c,h]=function(e){let[t,n]=(0,O.useState)(e),s=(0,O.useCallback)(e=>n(t=>vj(e,t)),[]);return[t,n,s]}(o),[d,u,p]=function(e){let[t,n]=(0,O.useState)(e),s=(0,O.useCallback)(e=>n(t=>vj(e,t)),[]);return[t,n,s]}(a);(0,O.useEffect)(()=>{c(wx(e.steps,e.entry_step_id,t,n,r)),u(wv(e.steps))},[e,t,n,r,c,u]);let f=(0,O.useCallback)(t=>{u(e=>br({...t,type:"smoothstep",markerEnd:{type:x.ArrowClosed,width:16,height:16,color:"#6b7280"},style:{stroke:"#6b7280",strokeWidth:2}},e));let n=e.steps.find(e=>e.id===t.source);if(!n||!t.target)return;let s=e.steps.map(e=>{if(e.id===t.source){if("evaluator"===e.type&&t.sourceHandle?.startsWith("route_")){let n=t.sourceHandle.replace("route_",""),s={...e.route_map||{},[n]:t.target};return{...e,route_map:s}}if("loop"===e.type){if("body"===t.sourceHandle){let n=[...e.loop_step_ids||[]];return n.includes(t.target)||n.push(t.target),{...e,loop_step_ids:n}}t.sourceHandle}return{...e,next_step_id:t.target}}if(e.id===t.target&&n.output_key){let t=e.input_keys||[];if(!t.includes(n.output_key))return{...e,input_keys:[...t,n.output_key]}}return e});i({...e,steps:s})},[e,i,u]),m=(0,O.useCallback)((t,n)=>{let s=e.steps.map(e=>e.id===n.id?{...e,position_x:n.position.x,position_y:n.position.y}:e);i({...e,steps:s})},[e,i]),g=(0,O.useCallback)((e,t)=>{s(t.id)},[s]),b=(0,O.useCallback)(()=>{s(null)},[s]);return(0,w.jsx)("div",{className:"w-full h-full",children:(0,w.jsxs)(yK,{nodes:l,edges:d,onNodesChange:h,onEdgesChange:p,onConnect:f,onNodeDragStop:m,onNodeClick:g,onPaneClick:b,nodeTypes:wg,fitView:!0,proOptions:{hideAttribution:!0},className:"bg-zinc-950",defaultEdgeOptions:{type:"smoothstep"},children:[(0,w.jsx)(y3,{variant:y.Dots,gap:20,size:1,className:"!bg-zinc-950"}),(0,w.jsx)(ws,{className:"!bg-zinc-800 !border-zinc-700 !shadow-lg [&>button]:!bg-zinc-700 [&>button]:!border-zinc-600 [&>button]:!text-zinc-200 [&>button:hover]:!bg-zinc-600"}),(0,w.jsx)(wu,{className:"!bg-zinc-800 !border-zinc-700",nodeColor:e=>{let t=e.data?.step?.type;return fL[t]?.color||"#6b7280"},maskColor:"rgba(0,0,0,0.6)"})]})})}let ww=["agent","llm","tool","evaluator","parallel","merge","loop","human","transform","end"];function wO({step:e,agents:t,allStepIds:n,onUpdate:s,onDelete:i,onClose:r,isEntry:o,onSetEntry:a,availableModels:l}){let c=t=>s({...e,...t}),h=n.filter(t=>t.id!==e.id),d="w-full bg-zinc-900 border border-zinc-700 rounded px-3 py-1.5 text-sm text-zinc-200 focus:border-blue-500 outline-none",u="w-full bg-zinc-900 border border-zinc-700 rounded px-3 py-1.5 text-xs text-zinc-200 font-mono focus:border-blue-500 outline-none",p="w-full bg-zinc-900 border border-zinc-700 rounded px-3 py-2 text-xs text-zinc-200 font-mono focus:border-blue-500 outline-none resize-y min-h-[80px]",f="w-full bg-zinc-900 border border-zinc-700 rounded px-3 py-1.5 text-sm text-zinc-200 focus:border-blue-500 outline-none";return(0,w.jsxs)("div",{className:"w-80 bg-zinc-800 border-l border-zinc-700 overflow-y-auto flex flex-col",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-zinc-700",children:[(0,w.jsx)("h3",{className:"text-sm font-semibold text-zinc-200",children:"Step Config"}),(0,w.jsx)("button",{onClick:r,className:"text-zinc-400 hover:text-zinc-200",children:(0,w.jsx)(eN.X,{size:16})})]}),(0,w.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Name"}),(0,w.jsx)("input",{className:d,value:e.name,onChange:e=>c({name:e.target.value})})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Type"}),(0,w.jsx)("select",{className:f,value:e.type,onChange:e=>c({type:e.target.value}),children:ww.map(e=>(0,w.jsx)("option",{value:e,children:fL[e].label},e))})]}),!o&&(0,w.jsx)("button",{onClick:a,className:"text-xs text-green-400 hover:text-green-300 underline",children:"Set as entry point"}),o&&(0,w.jsx)("div",{className:"text-xs text-green-400",children:"This is the entry point"}),"agent"===e.type&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Agent"}),(0,w.jsxs)("select",{className:f,value:e.agent_id||"",onChange:e=>c({agent_id:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"Select agent..."}),t.map(e=>(0,w.jsxs)("option",{value:e.id,children:[e.name," (",e.type,")"]},e.id))]})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Prompt Template"}),(0,w.jsx)(eb,{className:p,rows:4,value:e.prompt_template||"",onChange:e=>c({prompt_template:e.target.value}),placeholder:"Use {state.key} to reference shared state, @ to reference vault files..."})]})]}),"tool"===e.type&&(0,w.jsx)(wj,{step:e,update:c,textareaCls:p,selectCls:f,availableModels:l}),"llm"===e.type&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"rounded bg-teal-950/40 border border-teal-800/40 px-3 py-2 text-[10px] text-teal-400 leading-relaxed",children:[(0,w.jsx)("strong",{children:"Single LLM call"})," — no agent, no tools. Great for summaries, rewrites, and lightweight reasoning between steps."]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Prompt Template"}),(0,w.jsx)(eb,{className:p,rows:5,value:e.prompt_template||"",onChange:e=>c({prompt_template:e.target.value}),placeholder:`Summarize the following in 3 bullet points:
|
|
36
|
+
|
|
37
|
+
{state.analysis_result}
|
|
38
|
+
|
|
39
|
+
Type @ to reference a vault file`}),(0,w.jsxs)("p",{className:"text-[10px] text-zinc-600 mt-0.5",children:["Use ","{state.key}}"," to embed shared state values. Type ",(0,w.jsx)("span",{className:"text-emerald-400 font-mono",children:"@"})," to reference a vault file."]})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"text-xs text-zinc-400 block mb-1",children:["Model ",(0,w.jsx)("span",{className:"text-zinc-600 normal-case",children:"(override)"})]}),(0,w.jsxs)("select",{className:f,value:e.model||"",onChange:e=>c({model:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"(Default)"}),(l||[]).map(e=>(0,w.jsx)("option",{value:e,children:e},e))]})]})]}),"evaluator"===e.type&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"text-xs text-zinc-400 block mb-1",children:["Evaluator Prompt ",(0,w.jsx)("span",{className:"text-zinc-600 normal-case",children:"(routing decision)"})]}),(0,w.jsx)("textarea",{className:p,rows:3,value:e.evaluator_prompt||"",onChange:e=>c({evaluator_prompt:e.target.value}),placeholder:"Instructions for the routing decision (e.g. If login is needed, route to human...)"})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"text-xs text-zinc-400 block mb-1",children:["Model ",(0,w.jsx)("span",{className:"text-zinc-600 normal-case",children:"(override for evaluator)"})]}),(0,w.jsxs)("select",{className:f,value:e.model||"",onChange:e=>c({model:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"(Default)"}),(l||[]).map(e=>(0,w.jsx)("option",{value:e,children:e},e))]})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"text-xs text-zinc-400 block mb-1",children:["Routes ",(0,w.jsx)("span",{className:"text-zinc-600 normal-case",children:"(LLM picks one based on context)"})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[Object.entries(e.route_map||{}).map(([t,n])=>(0,w.jsx)(wC,{label:t,targetId:n,description:(e.route_descriptions||{})[t]||"",otherSteps:h,onRename:n=>{if(n===t||!n.trim())return;let s=Object.entries(e.route_map||{}),i={};for(let[e,r]of s)i[e===t?n:e]=r;let r=Object.entries(e.route_descriptions||{}),o={};for(let[e,s]of r)o[e===t?n:e]=s;c({route_map:i,route_descriptions:o})},onChangeTarget:n=>{c({route_map:{...e.route_map||{},[t]:n}})},onChangeDescription:n=>{c({route_descriptions:{...e.route_descriptions||{},[t]:n}})},onDelete:()=>{let n={...e.route_map||{}};delete n[t];let s={...e.route_descriptions||{}};delete s[t],c({route_map:n,route_descriptions:s})}},t)),(0,w.jsxs)("button",{onClick:()=>{let t=Object.keys(e.route_map||{}),n=`route_${t.length+1}`;c({route_map:{...e.route_map||{},[n]:null}})},className:"flex items-center gap-1 text-xs text-emerald-400 hover:text-emerald-300",children:[(0,w.jsx)(en.Plus,{size:12})," Add Route"]})]})]})]}),"parallel"===e.type&&(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Branches (pick entry step per branch)"}),(0,w.jsxs)("div",{className:"space-y-2",children:[(e.parallel_branches||[]).map((t,n)=>(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsxs)("span",{className:"text-[10px] text-purple-400 font-semibold w-5",children:["B",n+1]}),(0,w.jsxs)("select",{className:"flex-1 bg-zinc-900 border border-zinc-700 rounded px-2 py-1 text-xs text-zinc-200 outline-none",value:t[0]||"",onChange:t=>{let s=[...e.parallel_branches||[]];s[n]=t.target.value?[t.target.value]:[],c({parallel_branches:s})},children:[(0,w.jsx)("option",{value:"",children:"Select entry step..."}),h.map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,w.jsx)("button",{onClick:()=>{c({parallel_branches:(e.parallel_branches||[]).filter((e,t)=>t!==n)})},className:"text-red-400 hover:text-red-300",children:(0,w.jsx)(F.Trash2,{size:10})})]},n)),(0,w.jsxs)("button",{onClick:()=>c({parallel_branches:[...e.parallel_branches||[],[]]}),className:"flex items-center gap-1 text-xs text-purple-400 hover:text-purple-300",children:[(0,w.jsx)(en.Plus,{size:12})," Add Branch"]})]}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-500 mt-1",children:"Each branch auto-follows the entry step's Next Step chain. Connect steps with edges on the canvas."})]}),"merge"===e.type&&(0,w.jsx)(w.Fragment,{children:(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Merge Strategy"}),(0,w.jsxs)("select",{className:f,value:e.merge_strategy||"list",onChange:e=>c({merge_strategy:e.target.value}),children:[(0,w.jsx)("option",{value:"list",children:"List (array of sources)"}),(0,w.jsx)("option",{value:"concat",children:"Concat (text join)"}),(0,w.jsx)("option",{value:"dict",children:"Dict (keyed by source)"})]})]})}),"loop"===e.type&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Loop Count"}),(0,w.jsx)("input",{type:"number",className:d,value:e.loop_count??3,onChange:e=>c({loop_count:parseInt(e.target.value)||3}),min:1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Body Steps (executed in order each iteration)"}),(0,w.jsxs)("div",{className:"space-y-1",children:[(e.loop_step_ids||[]).map((t,n)=>(0,w.jsxs)("div",{className:"flex items-center gap-1",children:[(0,w.jsxs)("span",{className:"text-[10px] text-amber-400 w-4",children:[n+1,"."]}),(0,w.jsxs)("select",{className:"flex-1 bg-zinc-900 border border-zinc-700 rounded px-2 py-0.5 text-xs text-zinc-200 outline-none",value:t,onChange:t=>{let s=[...e.loop_step_ids||[]];s[n]=t.target.value,c({loop_step_ids:s})},children:[(0,w.jsx)("option",{value:"",children:"Select step..."}),h.map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,w.jsx)("button",{onClick:()=>{c({loop_step_ids:(e.loop_step_ids||[]).filter((e,t)=>t!==n)})},className:"text-red-400 hover:text-red-300",children:(0,w.jsx)(F.Trash2,{size:10})})]},n)),(0,w.jsxs)("button",{onClick:()=>c({loop_step_ids:[...e.loop_step_ids||[],""]}),className:"flex items-center gap-1 text-xs text-amber-400 hover:text-amber-300",children:[(0,w.jsx)(en.Plus,{size:12})," Add Body Step"]})]}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-500 mt-1",children:'The "done" path is configured via the green output handle or Next Step below.'})]})]}),"human"===e.type&&(0,w.jsx)(wk,{step:e,update:c,textareaCls:p,inputCls:d,selectCls:f}),"transform"===e.type&&(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("div",{className:"rounded bg-amber-950/40 border border-amber-800/40 px-3 py-2 text-[10px] text-amber-400 leading-relaxed",children:[(0,w.jsx)("strong",{children:"Python sandbox"})," — runs in Docker (512MB RAM, no network). ",(0,w.jsx)("code",{children:"state"})," dict is injected. Assign to ",(0,w.jsx)("code",{children:"result"})," to write the output key."]}),(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Python Code"}),(0,w.jsx)("div",{className:"border border-zinc-700 rounded overflow-hidden h-[220px] focus-within:border-amber-600 transition-colors",children:(0,w.jsx)(wz,{value:e.transform_code||"",onChange:e=>c({transform_code:e})})})]}),"end"===e.type&&(0,w.jsx)("div",{className:"text-xs text-zinc-500",children:"This node terminates the orchestration. No configuration needed."}),(0,w.jsx)("hr",{className:"border-zinc-700"}),"end"!==e.type&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Input Keys (comma-separated)"}),(0,w.jsx)(wN,{className:u,value:(e.input_keys||[]).join(", "),onCommit:e=>c({input_keys:e.split(",").map(e=>e.trim()).filter(Boolean)}),placeholder:"portfolio_status, news_data"})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Output Key"}),(0,w.jsx)("input",{className:u,value:e.output_key||"",onChange:e=>c({output_key:e.target.value||void 0}),placeholder:"analysis_result"})]})]}),"end"!==e.type&&"evaluator"!==e.type&&"loop"!==e.type&&(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Next Step"}),(0,w.jsxs)("select",{className:f,value:e.next_step_id||"",onChange:e=>c({next_step_id:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"None (end)"}),h.map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),"loop"===e.type&&(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Done Path (after all iterations)"}),(0,w.jsxs)("select",{className:f,value:e.next_step_id||"",onChange:e=>c({next_step_id:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"None (end)"}),h.map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,w.jsx)("hr",{className:"border-zinc-700"}),"end"!==e.type&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"text-xs text-zinc-500 font-semibold uppercase tracking-wider",children:"Guardrails"}),(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Max Turns"}),(0,w.jsx)("input",{type:"number",className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1 text-sm text-zinc-200 outline-none",value:e.max_turns??"",placeholder:"15",onChange:e=>c({max_turns:""===e.target.value?void 0:parseInt(e.target.value)})})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Timeout (s)"}),(0,w.jsx)("input",{type:"number",className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1 text-sm text-zinc-200 outline-none",value:e.timeout_seconds??"",placeholder:"300",onChange:e=>c({timeout_seconds:""===e.target.value?void 0:parseInt(e.target.value)})})]})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Max Iterations (loop guard)"}),(0,w.jsx)("input",{type:"number",className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1 text-sm text-zinc-200 outline-none",value:e.max_iterations??"",placeholder:"3",onChange:e=>c({max_iterations:""===e.target.value?void 0:parseInt(e.target.value)})})]})]})]}),(0,w.jsx)("div",{className:"border-t border-zinc-700 p-3",children:(0,w.jsx)("button",{onClick:i,className:"w-full py-1.5 text-xs text-red-400 hover:text-red-300 hover:bg-red-900/20 rounded transition-colors",children:"Delete Step"})})]})}function wk({step:e,update:t,textareaCls:n,inputCls:s,selectCls:i}){let[r,o]=(0,O.useState)([]);(0,O.useEffect)(()=>{fetch("/api/messaging/channels").then(e=>e.ok?e.json():[]).then(e=>o(Array.isArray(e)?e:[])).catch(()=>{})},[]);let a={telegram:"✈️",discord:"🎮",slack:"💬",teams:"📘",whatsapp:"📱"};return(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Prompt for Human"}),(0,w.jsx)("textarea",{className:n,rows:3,value:e.human_prompt||"",onChange:e=>t({human_prompt:e.target.value}),placeholder:"What should the user decide? Use {state.key} for context."}),(0,w.jsxs)("p",{className:"text-[10px] text-zinc-600 mt-0.5",children:["Use ","{state.key}}"," to embed shared state values."]})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"text-xs text-zinc-400 flex items-center gap-1 mb-1",children:[(0,w.jsx)(R.MessageSquare,{size:11})," Notify Messaging Channel ",(0,w.jsx)("span",{className:"text-zinc-600",children:"(optional)"})]}),(0,w.jsxs)("select",{className:i,value:e.human_channel_id||"",onChange:e=>t({human_channel_id:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"Browser UI only"}),r.map(e=>(0,w.jsxs)("option",{value:e.id,children:[a[e.platform]??"🤖"," ",e.name," [",e.status??"stopped","]"]},e.id))]}),e.human_channel_id&&(0,w.jsxs)("p",{className:"text-[10px] text-amber-400 mt-1",children:["⏱ First response wins — from messaging app ",(0,w.jsx)("em",{children:"or"})," browser, whichever arrives first."]})]}),e.human_channel_id&&(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Timeout (seconds)"}),(0,w.jsx)("input",{type:"number",className:s,value:e.human_timeout_seconds??3600,onChange:e=>t({human_timeout_seconds:parseInt(e.target.value)||3600}),min:60,step:60}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-600 mt-0.5",children:"How long to wait for a reply from the messaging channel before falling back to the browser UI only."})]})]})}function wj({step:e,update:t,textareaCls:n,selectCls:s,availableModels:i}){let[r,o]=(0,O.useState)([]);(0,O.useEffect)(()=>{fetch("/api/tools/available").then(e=>e.ok?e.json():{tools:[]}).then(e=>o(Array.isArray(e.tools)?e.tools:[])).catch(()=>{})},[]);let a=r.find(t=>t.name===e.forced_tool);return(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("div",{className:"rounded bg-purple-950/40 border border-purple-800/40 px-3 py-2 text-[10px] text-purple-400 leading-relaxed",children:[(0,w.jsx)("strong",{children:"Forced tool call"})," — the LLM generates arguments for exactly one tool, then calls it. If the first attempt fails, the ReAct loop retries up to ",(0,w.jsx)("em",{children:"Max Turns"})," times."]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Tool"}),(0,w.jsxs)("select",{className:s,value:e.forced_tool||"",onChange:e=>t({forced_tool:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"Select tool..."}),r.map(e=>(0,w.jsx)("option",{value:e.name,children:e.name},e.name))]}),a?.description&&(0,w.jsx)("p",{className:"text-[10px] text-zinc-500 mt-0.5",children:a.description})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Prompt Template"}),(0,w.jsx)(eb,{className:n,rows:4,value:e.prompt_template||"",onChange:e=>t({prompt_template:e.target.value}),placeholder:`Search for relevant data about {state.user_input}
|
|
40
|
+
|
|
41
|
+
Type @ to reference a vault file`}),(0,w.jsxs)("p",{className:"text-[10px] text-zinc-600 mt-0.5",children:["Use ","{state.key}}"," to embed shared state. Type ",(0,w.jsx)("span",{className:"text-emerald-400 font-mono",children:"@"})," to reference a vault file."]})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"text-xs text-zinc-400 block mb-1",children:["Model ",(0,w.jsx)("span",{className:"text-zinc-600 normal-case",children:"(override)"})]}),(0,w.jsxs)("select",{className:s,value:e.model||"",onChange:e=>t({model:e.target.value||void 0}),children:[(0,w.jsx)("option",{value:"",children:"(Default)"}),(i||[]).map(e=>(0,w.jsx)("option",{value:e,children:e},e))]})]})]})}function wN({value:e,onCommit:t,...n}){let[s,i]=(0,O.useState)(e);return(0,O.useEffect)(()=>{i(e)},[e]),(0,w.jsx)("input",{...n,value:s,onChange:e=>i(e.target.value),onBlur:()=>t(s)})}let wS=lC(lj.define([{tag:a$.keyword,color:"#c792ea",fontWeight:"bold"},{tag:a$.definitionKeyword,color:"#c792ea",fontWeight:"bold"},{tag:a$.self,color:"#f78c6c",fontStyle:"italic"},{tag:a$.bool,color:"#ff9cac"},{tag:a$.null,color:"#ff9cac"},{tag:a$.definition(a$.function(a$.variableName)),color:"#82aaff",fontWeight:"bold"},{tag:a$.function(a$.variableName),color:"#82aaff"},{tag:a$.definition(a$.className),color:"#ffcb6b",fontWeight:"bold"},{tag:a$.className,color:"#ffcb6b"},{tag:a$.meta,color:"#ffa759",fontStyle:"italic"},{tag:a$.variableName,color:"#eeffff"},{tag:a$.propertyName,color:"#89ddff"},{tag:a$.string,color:"#c3e88d"},{tag:a$.special(a$.string),color:"#c3e88d"},{tag:a$.number,color:"#f78c6c"},{tag:a$.operator,color:"#89ddff"},{tag:a$.punctuation,color:"#89ddff"},{tag:a$.bracket,color:"#ffcb6b"},{tag:a$.comment,color:"#546e7a",fontStyle:"italic"},{tag:a$.typeName,color:"#ffcb6b"},{tag:a$.escape,color:"#f78c6c"}]));function wz({value:e,onChange:t}){let n=(0,O.useRef)(null),s=(0,O.useRef)(null),i=(0,O.useRef)(t);return i.current=t,(0,O.useEffect)(()=>{if(!n.current||s.current)return;let t=tQ.create({doc:e,extensions:[ul,pY(),p5,wS,ry.updateListener.of(e=>{e.docChanged&&i.current(e.state.doc.toString())}),ry.theme({"&":{backgroundColor:"#09090b",height:"100%"},".cm-scroller":{overflow:"auto",fontFamily:"monospace",fontSize:"12px"},".cm-content":{padding:"8px 0"},".cm-line":{padding:"0 12px"},"&.cm-focused .cm-cursor":{borderLeftColor:"#d97706"},".cm-selectionBackground":{backgroundColor:"#3f3f46"},"&.cm-focused .cm-selectionBackground":{backgroundColor:"#78350f"}})]});return s.current=new ry({state:t,parent:n.current}),()=>{s.current?.destroy(),s.current=null}},[]),(0,O.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.state.doc.toString();n!==e&&t.dispatch({changes:{from:0,to:n.length,insert:e}})},[e]),(0,w.jsx)("div",{ref:n,className:"h-full"})}function wC({label:e,targetId:t,description:n,otherSteps:s,onRename:i,onChangeTarget:r,onChangeDescription:o,onDelete:a}){let[l,c]=(0,O.useState)(e),[h,d]=(0,O.useState)(n);return(0,w.jsx)("div",{className:"bg-zinc-900 rounded p-2 space-y-2",children:(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("input",{className:"w-full bg-zinc-800 border border-zinc-700 rounded px-2 py-1 text-xs text-zinc-200 outline-none",value:l,onChange:e=>c(e.target.value),onBlur:()=>i(l),onKeyDown:e=>{"Enter"===e.key&&i(l)},placeholder:"Label"}),(0,w.jsxs)("select",{className:"w-full bg-zinc-800 border border-zinc-700 rounded px-2 py-1 text-xs text-zinc-200 outline-none",value:t??"__end__",onChange:e=>r("__end__"===e.target.value?null:e.target.value),children:[(0,w.jsx)("option",{value:"__end__",children:"End Orchestration"}),s.map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,w.jsx)("input",{className:"w-full bg-zinc-800 border border-zinc-700 rounded px-2 py-1 text-[10px] text-zinc-400 outline-none",value:h,onChange:e=>d(e.target.value),onBlur:()=>o(h),onKeyDown:e=>{"Enter"===e.key&&o(h)},placeholder:"When should this route be chosen? (helps LLM decide)"}),(0,w.jsx)("div",{className:"text-right",children:(0,w.jsxs)("button",{onClick:a,className:"w-full py-1 text-xs font-semibold text-red-400 bg-red-900/5 border border-red-700 rounded hover:bg-red-900/20 hover:text-red-300 transition-colors",title:"Delete this route",children:[(0,w.jsx)(F.Trash2,{size:12,className:"inline-block mr-1"})," Delete Route"]})})]})})}let w_=["string","number","boolean","list","dict"];function wT({schema:e,onChange:t}){let n=Object.entries(e),s=(n,s)=>{t({...e,[n]:{...e[n],...s}})};return(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("span",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"State Schema"}),(0,w.jsxs)("button",{onClick:()=>{let n=`key_${Date.now()}`;t({...e,[n]:{type:"string",default:"",description:""}})},className:"text-xs text-blue-400 hover:text-blue-300 flex items-center gap-1",children:[(0,w.jsx)(en.Plus,{size:12})," Add Key"]})]}),0===n.length&&(0,w.jsx)("div",{className:"text-xs text-zinc-600 italic",children:"No state keys defined. Steps will still work with implicit state."}),n.map(([n,i])=>(0,w.jsxs)("div",{className:"flex items-start gap-2 bg-zinc-800/50 rounded p-2",children:[(0,w.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("input",{className:"flex-1 bg-zinc-900 border border-zinc-700 rounded px-2 py-1 text-xs text-zinc-200 font-mono outline-none",value:n,onChange:s=>((n,s)=>{if(s===n)return;let i={};for(let[t,r]of Object.entries(e))i[t===n?s:t]=r;t(i)})(n,s.target.value),placeholder:"key_name"}),(0,w.jsx)("select",{className:"bg-zinc-900 border border-zinc-700 rounded px-2 py-1 text-xs text-zinc-200 outline-none",value:i.type,onChange:e=>s(n,{type:e.target.value}),children:w_.map(e=>(0,w.jsx)("option",{value:e,children:e},e))})]}),(0,w.jsx)("input",{className:"w-full bg-zinc-900 border border-zinc-700 rounded px-2 py-1 text-xs text-zinc-300 outline-none",value:i.description,onChange:e=>s(n,{description:e.target.value}),placeholder:"Description..."})]}),(0,w.jsx)("button",{onClick:()=>{let s;return s={...e},void(delete s[n],t(s))},className:"text-zinc-600 hover:text-red-400 mt-1",children:(0,w.jsx)(j.Trash,{size:12})})]},n))]})}var wA=e.i(18789),wM=e.i(42531);let wP={llm:fu,agent:_.Bot,tool:T.Wrench,evaluator:f_,parallel:Z.GitBranch,merge:fT,loop:ez.RefreshCw,human:fh.User,transform:fA,end:ep},wE={id:"",name:"New Orchestration",description:"",steps:[],entry_step_id:"",state_schema:{},max_total_turns:100,max_total_cost_usd:null,timeout_minutes:30,trigger:"manual"};function wR(){return"step_"+Math.random().toString(36).substring(2,9)}function wD(){let[e,t]=(0,O.useState)([]),[n,s]=(0,O.useState)(null),[i,r]=(0,O.useState)(null),[o,a]=(0,O.useState)([]),[l,c]=(0,O.useState)([]),[h,d]=(0,O.useState)(!1),[u,p]=(0,O.useState)(null),f=(e,t="success")=>{p({show:!0,message:e,type:t}),setTimeout(()=>p(null),4e3)},[m,g]=(0,O.useState)(null),[x,b]=(0,O.useState)("idle"),[v,y]=(0,O.useState)({}),[k,N]=(0,O.useState)(null),[S,z]=(0,O.useState)(""),[C,_]=(0,O.useState)([]),[T,A]=(0,O.useState)(null),[M,P]=(0,O.useState)(null),[E,R]=(0,O.useState)(""),D=(0,O.useRef)(null),$=(0,O.useRef)(new Map),[Q,I]=(0,O.useState)(null),[L,q]=(0,O.useState)(null),[W,V]=(0,O.useState)(!1),[F,H]=(0,O.useState)(0),[X,U]=(0,O.useState)([]),G=(0,O.useRef)(null),[Z,Y]=(0,O.useState)([]);(0,O.useEffect)(()=>{fetch("/api/orchestrations").then(e=>e.json()).then(e=>{t(Array.isArray(e)?e.filter(e=>"orch_native_builder"!==e.id):[])}).catch(()=>{}),fetch("/api/agents").then(e=>e.json()).then(e=>{a(Array.isArray(e)?e:[])}).catch(()=>{}),fetch("/api/models").then(e=>e.json()).then(e=>{c(e.all_available||[])}).catch(()=>{})},[]);let J=(0,O.useCallback)(()=>{fetch("/api/orchestrations/runs").then(e=>e.json()).then(e=>{Array.isArray(e)&&(U(e.filter(e=>"running"===e.status||"paused"===e.status)),Y(e))}).catch(()=>{})},[]);(0,O.useEffect)(()=>(J(),G.current=setInterval(J,5e3),()=>{G.current&&clearInterval(G.current)}),[J]);let ee=(0,O.useCallback)(async t=>{let n=e.find(e=>e.id===t.orchestration_id);if(s(t.orchestration_id),g(null),r(n?{...n}:null),N(t.run_id),b(t.status),_([`[Reconnected to run ${t.run_id}]`]),A(null),P(null),"paused"===t.status)try{let e=await fetch(`/api/orchestrations/runs/${t.run_id}`);if(e.ok){let t=await e.json();t.waiting_for_human&&t.human_prompt&&A(t.human_prompt)}}catch{}},[e]),et=(0,O.useCallback)(t=>{if(s(t),g(null),b("idle"),y({}),_([]),A(null),t){let n=e.find(e=>e.id===t);r(n?{...n}:null)}else r(null)},[e]),ei=()=>{let e="orch_"+Math.random().toString(36).substring(2,9);r({...wE,id:e}),s(e),g(null)},er=async()=>{if(!i)return;let e={};for(let t of i.steps)e[t.id]=wR();let n=i.steps.map(t=>{var n;return{...t,id:e[t.id],next_step_id:null==(n=t.next_step_id)?n:e[n]??n,route_map:t.route_map?Object.fromEntries(Object.entries(t.route_map).map(([t,n])=>[t,null!=n?e[n]??n:null])):void 0,parallel_branches:t.parallel_branches?.map(t=>t.map(t=>e[t]??t)),loop_step_ids:t.loop_step_ids?.map(t=>e[t]??t)}}),o="orch_"+Math.random().toString(36).substring(2,9),a={...i,id:o,name:i.name+" (Copy)",steps:n,entry_step_id:i.entry_step_id?e[i.entry_step_id]??"":"",state_schema:JSON.parse(JSON.stringify(i.state_schema??{})),created_at:void 0,updated_at:void 0};d(!0);try{let e=await fetch("/api/orchestrations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(e.ok){let n=await e.json();t(e=>[...e,n]),r(n),s(o),g(null)}}catch{}finally{d(!1)}},eo=async()=>{if(i){d(!0);try{let n=await fetch("/api/orchestrations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(n.ok){let s=await n.json(),i=e.findIndex(e=>e.id===s.id);if(i>=0){let n=[...e];n[i]=s,t(n)}else t([...e,s]);r(s)}}catch{}finally{d(!1)}}},el=async()=>{if(L)try{await fetch(`/api/orchestrations/${L}`,{method:"DELETE"}),t(e.filter(e=>e.id!==L)),i?.id===L&&(r(null),s(null))}catch{}},ec=(0,O.useCallback)(e=>{i&&r({...i,steps:i.steps.map(t=>t.id===e.id?e:t)})},[i]),eh=(0,O.useCallback)(e=>{if(!i)return;let t={...i,steps:i.steps.filter(t=>t.id!==e)};t.steps=t.steps.map(t=>{let n={...t,next_step_id:t.next_step_id===e?void 0:t.next_step_id,loop_step_ids:t.loop_step_ids?.filter(t=>t!==e),parallel_branches:t.parallel_branches?.map(t=>t.filter(t=>t!==e))};if(t.route_map){let s={};for(let[n,i]of Object.entries(t.route_map))s[n]=i===e?null:i;n.route_map=s}return n}),t.entry_step_id===e&&(t.entry_step_id=t.steps[0]?.id||""),r(t),m===e&&g(null)},[i,m]),ed=(0,O.useCallback)(e=>{i&&r({...i,entry_step_id:e})},[i]),eu=(0,O.useCallback)(e=>{r(e)},[]),ef=async(e,t)=>{let n=new AbortController;D.current=n;try{let s=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(!s.ok||!s.body){b("failed"),_(e=>[...e,`[HTTP ${s.status}]`]);return}let i=s.body.getReader(),r=new TextDecoder,o="";for(;;){let{done:e,value:t}=await i.read();if(e)break;let n=(o+=r.decode(t,{stream:!0})).split("\n");for(let e of(o=n.pop()||"",n))if(e.startsWith("data: "))try{let t=JSON.parse(e.slice(6));em(t),await new Promise(e=>setTimeout(e,0))}catch{}}}catch(e){"AbortError"!==e.name&&(b("failed"),_(e=>[...e,"[Connection lost]"]))}finally{D.current=null}},em=e=>{switch(e.type){case"orchestration_start":N(e.run_id),_(t=>[...t,`Started run ${e.run_id}`]);break;case"step_start":y(t=>({...t,[e.orch_step_id]:"running"})),_(t=>[...t,`▶ ${e.step_name} (${e.step_type})`]),"agent"===e.step_type||"llm"===e.step_type?$.current.set(e.orch_step_id,{step_name:e.step_name,step_type:e.step_type,content:""}):$.current.delete(e.orch_step_id);break;case"step_complete":{y(t=>({...t,[e.orch_step_id]:"completed"}));let t=$.current.get(e.orch_step_id);_(n=>{let s=[...n,`✓ ${e.step_name} completed (${e.duration_seconds?.toFixed(1)}s)`];return t&&t.content.trim()&&s.splice(s.length-1,0,{kind:"step_result",step_name:t.step_name,step_type:t.step_type,content:t.content.trim()}),s}),$.current.delete(e.orch_step_id);break}case"step_error":y(t=>({...t,[e.orch_step_id]:"failed"})),_(t=>[...t,`✗ Step error: ${e.error}`]),$.current.delete(e.orch_step_id);break;case"final":{let t=e.response||"",n=e.orch_step_id||"";n&&$.current.has(n)&&t&&($.current.get(n).content=t);break}case"routing_decision":_(t=>[...t,`🔀 Evaluator routed → ${e.decision} (${e.reasoning||""})`]);break;case"parallel_start":_(t=>[...t,`⫘ Parallel: running ${e.branch_count} branches`]);break;case"branch_start":_(t=>[...t,` ↳ Branch ${(e.branch_index??0)+1}/${e.branch_count}`]);break;case"parallel_complete":_(t=>[...t,`⫘ Parallel: all ${e.branch_count} branches done`]);break;case"loop_iteration":_(t=>[...t,`⟳ Loop iteration ${e.iteration}/${e.total}`]);break;case"merge_complete":_(t=>[...t,`⊕ Merged ${e.input_count} inputs (${e.strategy})`]);break;case"orchestration_end":_(e=>[...e,"■ End node reached"]);break;case"human_input_required":b("paused"),e.orch_step_id&&y(t=>({...t,[e.orch_step_id]:"paused"})),A(e.prompt||"Please provide input:"),P(e.agent_context||null),_(e=>[...e,"⏸ Waiting for human input..."]);break;case"loop_limit_reached":_(t=>[...t,`⟳ Loop limit reached for step ${e.orch_step_id} (${e.iterations} iterations)`]);break;case"orchestration_complete":b("completed"===e.status?"completed":"failed"),_(t=>[...t,`Done — status: ${e.status}`]),D.current?.abort(),D.current=null;break;case"orchestration_error":b("failed"),_(t=>[...t,`Error: ${e.error}`]),D.current?.abort(),D.current=null;break;case"tool_execution":_(t=>[...t,{kind:"tool_call",tool_name:e.tool_name,args:e.args||{},step_name:e.step_name}]);break;case"tool_result":_(t=>[...t,{kind:"tool_result",tool_name:e.tool_name,preview:e.preview||""}]);break;case"token_usage":break;default:"chunk"===e.type&&e.content&&!$.current&&_(t=>{let n=t[t.length-1];return n&&"string"==typeof n&&n.startsWith(" ")?[...t.slice(0,-1),n+e.content]:[...t," "+e.content]})}},eg=async()=>{if(D.current?.abort(),D.current=null,k)try{await fetch(`/api/orchestrations/runs/${k}/cancel`,{method:"POST"})}catch{}b("cancelled"),_(e=>[...e,"[Cancelled]"])},ex=async()=>{k&&(A(null),P(null),b("running"),y(e=>{let t={...e};for(let e in t)"paused"===t[e]&&(t[e]="running");return t}),_(e=>[...e,"Human response submitted"]),R(""),ef(`/api/orchestrations/runs/${k}/human-input`,{response:E}))},eb=async()=>{k&&(b("running"),_(e=>[...e,"[Resuming from where run stopped...]"]),ef(`/api/orchestrations/runs/${k}/resume`,{}))};(0,O.useEffect)(()=>()=>{D.current?.abort()},[]);let ev=i?.steps.find(e=>e.id===m)||null,ey=i?.steps.map(e=>({id:e.id,name:e.name}))||[],ew=async()=>{if(i)try{let e=await fetch(`/api/orchestrations/${i.id}/deploy`,{method:"POST"});if(e.ok){let t=await e.json();f(`Deployed as agent "${i.name}" (${t.agent_id})`,"success")}else{let t=await e.json();f(`Deploy failed: ${t.detail||"Unknown error"}`,"error")}}catch{f("Failed to deploy orchestration as agent","error")}};return(0,w.jsxs)("div",{className:"flex flex-col h-full relative",children:[u&&(0,w.jsx)(ek,{show:u.show,message:u.message,type:u.type}),(0,w.jsxs)("div",{className:"px-6 py-4 border-b border-zinc-800 shrink-0",children:[(0,w.jsx)("h1",{className:"text-2xl font-bold text-zinc-100",children:"Orchestrations"}),(0,w.jsx)("p",{className:"text-zinc-500 text-xs mt-0.5",children:"Design multi-agent workflows with visual canvas"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-zinc-800 shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,w.jsxs)("select",{className:"bg-zinc-900 border border-zinc-700 rounded px-3 py-1.5 text-sm text-zinc-200 outline-none max-w-[240px]",value:n||"",onChange:e=>et(e.target.value||null),children:[(0,w.jsx)("option",{value:"",children:"Select orchestration..."}),e.map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,w.jsxs)("button",{onClick:ei,className:"flex items-center gap-1 px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 text-white rounded transition-colors",children:[(0,w.jsx)(en.Plus,{size:14})," New"]}),(0,w.jsxs)("button",{onClick:()=>{n||ei(),V(!0),H(e=>e+1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-xs bg-purple-600 hover:bg-purple-500 text-white rounded-lg transition-colors",children:[(0,w.jsx)(ea.Sparkles,{size:13})," Build with AI"]})]}),i&&(0,w.jsxs)("div",{className:"flex items-center gap-2 pr-6",children:[(0,w.jsxs)("button",{onClick:eo,disabled:h,className:"flex items-center gap-1 px-3 py-1.5 text-xs bg-zinc-700 hover:bg-zinc-600 text-zinc-200 rounded transition-colors disabled:opacity-50",children:[h?(0,w.jsx)(B.Loader2,{size:14,className:"animate-spin"}):(0,w.jsx)(es,{size:14})," Save"]}),"idle"===x||"completed"===x||"failed"===x||"cancelled"===x?(0,w.jsxs)("button",{onClick:()=>{if(!i)return;let e={};i.steps.forEach(t=>{e[t.id]="pending"}),y(e),b("running"),_([]),A(null),ef(`/api/orchestrations/${i.id}/run`,{message:S})},className:"flex items-center gap-1 px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded transition-colors",children:[(0,w.jsx)(e_,{size:14})," Run"]}):(0,w.jsxs)("button",{onClick:eg,className:"flex items-center gap-1 px-3 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded transition-colors",children:[(0,w.jsx)(ep,{size:14})," Cancel"]}),(0,w.jsx)("button",{onClick:ew,className:"px-3 py-1.5 text-xs bg-purple-600 hover:bg-purple-500 text-white rounded transition-colors",children:"Deploy as Agent"}),(0,w.jsxs)("button",{onClick:er,disabled:h,className:"flex items-center gap-1 px-3 py-1.5 text-xs bg-zinc-700 hover:bg-zinc-600 text-zinc-200 rounded transition-colors disabled:opacity-50",children:[(0,w.jsx)(fz,{size:13})," Duplicate"]}),(0,w.jsx)("div",{className:"w-px h-5 bg-zinc-700 mx-1"}),(0,w.jsxs)("button",{onClick:()=>{i&&q(i.id)},className:"flex items-center gap-1 px-2 py-1.5 text-xs text-zinc-500 hover:text-red-400 hover:bg-red-900/20 rounded transition-colors",children:[(0,w.jsx)(j.Trash,{size:13})," Delete"]})]})]}),X.filter(e=>e.run_id!==k).length>0&&(0,w.jsx)("div",{className:"px-4 py-2 border-b border-zinc-800 bg-zinc-900/60 shrink-0",children:(0,w.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,w.jsxs)("span",{className:"text-xs text-zinc-500 flex items-center gap-1",children:[(0,w.jsx)(fC,{size:11,className:"text-blue-400 animate-pulse"})," Active runs:"]}),X.filter(e=>e.run_id!==k).map(t=>{let n=e.find(e=>e.id===t.orchestration_id);return(0,w.jsxs)("button",{onClick:()=>ee(t),className:"flex items-center gap-1.5 px-2.5 py-1 rounded text-xs bg-zinc-800 hover:bg-zinc-700 border border-zinc-700 transition-colors",children:[(0,w.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${"running"===t.status?"bg-blue-400 animate-pulse":"bg-yellow-400"}`}),(0,w.jsx)("span",{className:"text-zinc-300",children:n?.name??t.orchestration_id}),(0,w.jsx)("span",{className:"text-zinc-500",children:"paused"===t.status?"· waiting for input":"· running"})]},t.run_id)})]})}),i?(0,w.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-zinc-800 shrink-0",children:[(0,w.jsx)("input",{className:"bg-transparent border-b border-zinc-700 text-zinc-200 text-sm font-medium px-1 py-0.5 outline-none focus:border-blue-500 w-64",value:i.name,onChange:e=>r({...i,name:e.target.value}),placeholder:"Orchestration name"}),(0,w.jsx)("input",{className:"bg-transparent border-b border-zinc-700 text-zinc-400 text-xs px-1 py-0.5 outline-none focus:border-blue-500 flex-1 mr-6",value:i.description,onChange:e=>r({...i,description:e.target.value}),placeholder:"Description..."})]}),(0,w.jsxs)("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-zinc-800 shrink-0",children:[(0,w.jsx)("span",{className:"text-xs text-zinc-500 mr-2",children:"Add step:"}),["llm","agent","tool","evaluator","parallel","merge","loop","human","transform","end"].map(e=>{let t=fL[e],n=wP[e];return(0,w.jsxs)("button",{onClick:()=>(e=>{var t;if(!i)return;let n=i.steps.length,s=(t={x:100+n%3*250,y:80+180*Math.floor(n/3)},{id:wR(),name:e.charAt(0).toUpperCase()+e.slice(1)+" Step",type:e,position_x:t.x,position_y:t.y,max_turns:15,timeout_seconds:300,max_iterations:3}),o={...i,steps:[...i.steps,s]};o.entry_step_id||(o.entry_step_id=s.id),r(o)})(e),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded bg-zinc-800 hover:bg-zinc-700 text-zinc-300 transition-colors capitalize",children:[(0,w.jsx)(n,{size:12}),t.label]},e)})]}),(0,w.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,w.jsx)("div",{className:"flex-1 min-w-0",children:(0,w.jsx)(yG,{children:(0,w.jsx)(wy,{orchestration:i,agents:o,selectedStepId:m,onSelectStep:g,onUpdateOrchestration:eu,runStepStatuses:v})})}),ev&&(0,w.jsx)(wO,{step:ev,agents:o,allStepIds:ey,onUpdate:ec,onDelete:()=>eh(ev.id),onClose:()=>g(null),isEntry:i.entry_step_id===ev.id,onSetEntry:()=>ed(ev.id),availableModels:l})]}),(0,w.jsx)("div",{className:"border-t border-zinc-700 bg-zinc-900 shrink-0",children:(0,w.jsx)(wQ,{draft:i,setDraft:r,runStatus:x,runLog:C,runInput:S,setRunInput:z,humanPrompt:T,humanContext:M,humanResponse:E,setHumanResponse:R,onSubmitHuman:ex,onOpenResponseModal:I,runId:k,onResumeRun:eb,pastRuns:Z,onRestoreRun:ee})}),Q&&(0,w.jsx)(w$,{stepName:Q.step_name,content:Q.content,onClose:()=>I(null)})]}):(0,w.jsx)("div",{className:"flex-1 flex items-center justify-center text-zinc-600 text-sm",children:"Select an orchestration or create a new one to get started."}),(0,w.jsx)(K,{isOpen:!!L,title:"Delete Orchestration",message:"Are you sure you want to delete this orchestration? This action cannot be undone.",onConfirm:()=>{el(),q(null)},onClose:()=>q(null)}),(0,w.jsx)(fI,{isOpen:W,onClose:()=>V(!1),agents:o,availableModels:l,currentOrchestrationId:n&&e.some(e=>e.id===n)?n:null,sessionKey:F,onOrchestrationSaved:async e=>{t(t=>t.findIndex(t=>t.id===e.id)>=0?t.map(t=>t.id===e.id?e:t):[...t,e]),r(e),s(e.id);try{let n=await fetch("/api/orchestrations");if(n.ok){let s=await n.json(),i=Array.isArray(s)?s.filter(e=>"orch_native_builder"!==e.id):[];t(i);let o=i.find(t=>t.id===e.id);o&&r(o)}}catch{}},onAgentSaved:e=>{a(t=>t.findIndex(t=>t.id===e.id)>=0?t.map(t=>t.id===e.id?e:t):[...t,e])}})]})}function w$({stepName:e,content:t,onClose:n}){return(0,O.useEffect)(()=>{let e=e=>{"Escape"===e.key&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n]),(0,ef.createPortal)((0,w.jsxs)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,w.jsx)("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm"}),(0,w.jsxs)("div",{className:"relative z-10 w-full max-w-3xl max-h-[80vh] flex flex-col rounded-xl border border-zinc-700 bg-zinc-900 shadow-2xl",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-zinc-700 shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)(_.Bot,{size:14,className:"text-blue-400"}),(0,w.jsx)("span",{className:"text-sm font-semibold text-zinc-100",children:e}),(0,w.jsx)("span",{className:"text-xs text-zinc-500",children:"— full response"})]}),(0,w.jsx)("button",{onClick:n,className:"text-zinc-400 hover:text-zinc-100 transition-colors p-1 rounded hover:bg-zinc-700",children:(0,w.jsx)(eN.X,{size:15})})]}),(0,w.jsx)("div",{className:"flex-1 overflow-y-auto p-5",children:(0,w.jsx)("div",{className:"prose prose-sm prose-invert max-w-none text-zinc-300 text-sm leading-relaxed",children:(0,w.jsx)(wA.default,{remarkPlugins:[wM.default],components:{p:({children:e})=>(0,w.jsx)("p",{className:"mb-3 last:mb-0",children:e}),h1:({children:e})=>(0,w.jsx)("h1",{className:"text-lg font-bold text-zinc-100 mb-2 mt-4 first:mt-0",children:e}),h2:({children:e})=>(0,w.jsx)("h2",{className:"text-base font-semibold text-zinc-100 mb-2 mt-3",children:e}),h3:({children:e})=>(0,w.jsx)("h3",{className:"text-sm font-semibold text-zinc-200 mb-1 mt-2",children:e}),ul:({children:e})=>(0,w.jsx)("ul",{className:"list-disc pl-5 mb-3 space-y-1",children:e}),ol:({children:e})=>(0,w.jsx)("ol",{className:"list-decimal pl-5 mb-3 space-y-1",children:e}),li:({children:e})=>(0,w.jsx)("li",{className:"text-zinc-300",children:e}),code:({children:e,className:t})=>t?.includes("language-")?(0,w.jsx)("code",{className:`block bg-zinc-800 rounded px-3 py-2 text-xs font-mono text-zinc-200 overflow-x-auto ${t}`,children:e}):(0,w.jsx)("code",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-xs font-mono text-emerald-300",children:e}),pre:({children:e})=>(0,w.jsx)("pre",{className:"bg-zinc-800/60 rounded-lg p-3 mb-3 overflow-x-auto border border-zinc-700/50",children:e}),blockquote:({children:e})=>(0,w.jsx)("blockquote",{className:"border-l-2 border-zinc-600 pl-3 text-zinc-400 italic",children:e}),a:({href:e,children:t})=>(0,w.jsx)("a",{href:e,className:"text-blue-400 underline hover:text-blue-300",target:"_blank",rel:"noreferrer",children:t}),strong:({children:e})=>(0,w.jsx)("strong",{className:"font-semibold text-zinc-100",children:e}),em:({children:e})=>(0,w.jsx)("em",{className:"italic text-zinc-300",children:e}),hr:()=>(0,w.jsx)("hr",{className:"border-zinc-700 my-4"}),table:({children:e})=>(0,w.jsx)("table",{className:"w-full text-xs border-collapse mb-3",children:e}),th:({children:e})=>(0,w.jsx)("th",{className:"border border-zinc-700 px-2 py-1 text-zinc-200 font-semibold bg-zinc-800",children:e}),td:({children:e})=>(0,w.jsx)("td",{className:"border border-zinc-700 px-2 py-1 text-zinc-300",children:e})},children:t})})})]})]}),document.body)}function wQ({draft:e,setDraft:t,runStatus:n,runLog:s,runInput:i,setRunInput:r,humanPrompt:o,humanContext:a,humanResponse:l,setHumanResponse:c,onSubmitHuman:h,onOpenResponseModal:d,runId:u,onResumeRun:p,pastRuns:f,onRestoreRun:m}){let[g,x]=(0,O.useState)("run"),[b,v]=(0,O.useState)(280),[y,k]=(0,O.useState)(200),j=(0,O.useRef)(null),N=(0,O.useRef)(null),S=(0,O.useRef)(null),z=(0,O.useCallback)(e=>{e.preventDefault(),N.current={startY:e.clientY,startHeight:b};let t=e=>{if(!N.current)return;let t=N.current.startY-e.clientY;v(Math.max(120,Math.min(700,N.current.startHeight+t)))},n=()=>{N.current=null,document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)},[b]),C=(0,O.useCallback)(e=>{e.preventDefault(),S.current={startY:e.clientY,startHeight:y};let t=e=>{if(!S.current)return;let t=e.clientY-S.current.startY;k(Math.max(80,Math.min(500,S.current.startHeight+t)))},n=()=>{S.current=null,document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)},[y]);return(0,O.useEffect)(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[s]),(0,w.jsxs)("div",{style:{height:b},className:"flex flex-col",children:[(0,w.jsx)("div",{onMouseDown:z,className:"h-1.5 w-full cursor-row-resize bg-zinc-800 hover:bg-blue-500/40 transition-colors flex-shrink-0 group flex items-center justify-center",children:(0,w.jsx)("div",{className:"w-8 h-0.5 rounded bg-zinc-600 group-hover:bg-blue-400 transition-colors"})}),(0,w.jsxs)("div",{className:"flex border-b border-zinc-800 flex-shrink-0",children:[["state","guardrails","run"].map(e=>(0,w.jsxs)("button",{onClick:()=>x(e),className:`px-4 py-2 text-xs font-medium capitalize transition-colors ${g===e?"text-blue-400 border-b-2 border-blue-400":"text-zinc-500 hover:text-zinc-300"}`,children:["state"===e?"State Schema":"guardrails"===e?"Guardrails":"Run Log","run"===e&&"idle"!==n&&(0,w.jsx)("span",{className:`ml-2 inline-block w-2 h-2 rounded-full ${"running"===n?"bg-blue-400 animate-pulse":"completed"===n?"bg-green-400":"paused"===n?"bg-yellow-400":"cancelled"===n?"bg-zinc-500":"bg-red-400"}`})]},e)),(0,w.jsxs)("button",{onClick:()=>x("recent"),className:`px-4 py-2 text-xs font-medium transition-colors ${"recent"===g?"text-blue-400 border-b-2 border-blue-400":"text-zinc-500 hover:text-zinc-300"}`,children:["Recent Runs",f.length>0&&(0,w.jsx)("span",{className:"ml-1.5 text-[10px] bg-zinc-700 text-zinc-400 rounded-full px-1.5 py-0.5",children:f.length})]})]}),(0,w.jsxs)("div",{className:"p-4 flex-1 overflow-y-auto min-h-0",children:["state"===g&&(0,w.jsx)(wT,{schema:e.state_schema,onChange:n=>t({...e,state_schema:n})}),"guardrails"===g&&(0,w.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Max Total Turns"}),(0,w.jsx)("input",{type:"number",className:"w-full bg-zinc-800 border border-zinc-700 rounded px-3 py-1.5 text-sm text-zinc-200 outline-none",value:e.max_total_turns,onChange:n=>t({...e,max_total_turns:parseInt(n.target.value)||100})})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Timeout (minutes)"}),(0,w.jsx)("input",{type:"number",className:"w-full bg-zinc-800 border border-zinc-700 rounded px-3 py-1.5 text-sm text-zinc-200 outline-none",value:e.timeout_minutes,onChange:n=>t({...e,timeout_minutes:parseInt(n.target.value)||30})})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 block mb-1",children:"Max Cost (USD)"}),(0,w.jsx)("input",{type:"number",step:"0.01",className:"w-full bg-zinc-800 border border-zinc-700 rounded px-3 py-1.5 text-sm text-zinc-200 outline-none",value:e.max_total_cost_usd??"",onChange:n=>t({...e,max_total_cost_usd:n.target.value?parseFloat(n.target.value):null}),placeholder:"No limit"})]})]}),"recent"===g&&(0,w.jsx)("div",{className:"space-y-1",children:0===f.length?(0,w.jsx)("div",{className:"text-zinc-600 italic text-xs",children:"No runs yet."}):f.slice(0,20).map(e=>(0,w.jsxs)("div",{className:"flex items-center gap-2 text-[11px] py-1 px-2 rounded bg-zinc-800/50",children:[(0,w.jsx)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${"completed"===e.status?"bg-green-400":"failed"===e.status?"bg-red-400":"cancelled"===e.status?"bg-zinc-500":"paused"===e.status?"bg-yellow-400":"bg-blue-400 animate-pulse"}`}),(0,w.jsx)("span",{className:"text-zinc-400 truncate flex-1",title:e.run_id,children:e.run_id}),(0,w.jsx)("span",{className:"text-zinc-500 capitalize",children:e.status}),e.started_at&&(0,w.jsx)("span",{className:"text-zinc-600 text-[10px]",children:new Date(e.started_at).toLocaleTimeString()}),("failed"===e.status||"cancelled"===e.status)&&(0,w.jsx)("button",{onClick:()=>{m(e),x("run")},className:"px-2 py-0.5 text-[10px] bg-orange-600 hover:bg-orange-500 text-white rounded",children:"Resume"})]},e.run_id))}),"run"===g&&(0,w.jsxs)("div",{className:"space-y-2",children:[("idle"===n||"completed"===n||"failed"===n||"cancelled"===n)&&(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("input",{className:"flex-1 bg-zinc-800 border border-zinc-700 rounded px-3 py-1.5 text-xs text-zinc-200 outline-none",value:i,onChange:e=>r(e.target.value),placeholder:"Initial input for the orchestration...",onKeyDown:e=>{e.key}}),("failed"===n||"cancelled"===n)&&u&&(0,w.jsx)("button",{onClick:p,className:"px-3 py-1.5 text-xs bg-orange-600 hover:bg-orange-500 text-white rounded whitespace-nowrap",children:"Resume from failure"})]}),o&&(0,w.jsxs)("div",{className:"bg-amber-900/20 border border-amber-700/50 rounded p-3 space-y-2",children:[a&&(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"text-xs text-zinc-300 bg-zinc-800/60 rounded-t p-2 overflow-y-auto border border-zinc-700/50 border-b-0",style:{height:y},children:(0,w.jsx)(wA.default,{remarkPlugins:[wM.default],components:{p:({children:e})=>(0,w.jsx)("p",{className:"mb-1 last:mb-0",children:e}),a:({href:e,children:t})=>(0,w.jsx)("a",{href:e,className:"text-blue-400 underline",target:"_blank",rel:"noreferrer",children:t}),code:({children:e})=>(0,w.jsx)("code",{className:"bg-zinc-700 px-1 rounded",children:e}),strong:({children:e})=>(0,w.jsx)("strong",{className:"font-semibold text-zinc-100",children:e})},children:a})}),(0,w.jsx)("div",{onMouseDown:C,className:"h-1.5 w-full cursor-row-resize bg-zinc-700/60 hover:bg-blue-500/40 transition-colors rounded-b border border-zinc-700/50 flex items-center justify-center group",children:(0,w.jsx)("div",{className:"w-8 h-0.5 rounded bg-zinc-600 group-hover:bg-blue-400 transition-colors"})})]}),(0,w.jsx)("div",{className:"text-xs text-amber-300",children:(0,w.jsx)(wA.default,{remarkPlugins:[wM.default],components:{p:({children:e})=>(0,w.jsx)("p",{className:"mb-0",children:e}),a:({href:e,children:t})=>(0,w.jsx)("a",{href:e,className:"text-amber-200 underline",target:"_blank",rel:"noreferrer",children:t}),strong:({children:e})=>(0,w.jsx)("strong",{className:"font-semibold text-amber-200",children:e})},children:o})}),(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("input",{className:"flex-1 bg-zinc-800 border border-zinc-700 rounded px-3 py-1.5 text-xs text-zinc-200 outline-none",value:l,onChange:e=>c(e.target.value),placeholder:"Your response...",onKeyDown:e=>{"Enter"===e.key&&h()}}),(0,w.jsx)("button",{onClick:h,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded",children:"Submit"})]})]}),(0,w.jsx)("div",{ref:j,className:"font-mono text-[11px] text-zinc-400 space-y-0.5",children:0===s.length?(0,w.jsx)("div",{className:"text-zinc-600 italic",children:"No run output yet. Click Run to start."}):s.map((e,t)=>{if("string"!=typeof e){if("tool_call"===e.kind)return(0,w.jsx)("div",{className:"text-violet-400 pl-2",children:(0,w.jsxs)("details",{children:[(0,w.jsxs)("summary",{className:"cursor-pointer list-none",children:["🔧 ",e.tool_name,e.step_name&&(0,w.jsxs)("span",{className:"text-zinc-500 text-[10px]",children:[" · ",e.step_name]})]}),(0,w.jsx)("pre",{className:"bg-zinc-800/50 p-1 rounded mt-0.5 text-[10px] text-zinc-300 overflow-x-auto whitespace-pre-wrap",children:JSON.stringify(e.args,null,2)})]})},t);if("tool_result"===e.kind)return(0,w.jsxs)("div",{className:"text-zinc-500 pl-4 text-[10px]",children:["↳ ",e.preview.slice(0,200),e.preview.length>200?"…":""]},t);if("step_result"===e.kind){let n=e.content.slice(0,200).replace(/\n+/g," ").trim(),s=e.content.length>200,i="agent"===e.step_type;return(0,w.jsxs)("div",{className:"my-1.5",children:[(0,w.jsxs)("div",{className:"flex items-center gap-1.5 mb-1 pl-1",children:[(0,w.jsx)("div",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i?"bg-emerald-400":"bg-teal-400"}`}),(0,w.jsx)("span",{className:`text-[10px] font-semibold uppercase tracking-wider ${i?"text-emerald-400":"text-teal-400"}`,children:e.step_name}),(0,w.jsx)("span",{className:"text-[9px] text-zinc-600 uppercase tracking-wide",children:i?"agent response":"llm output"})]}),(0,w.jsxs)("div",{className:"flex items-start gap-2 bg-zinc-800/70 border border-zinc-700/50 rounded-lg px-3 py-2 group ml-3",children:[(0,w.jsxs)("div",{className:"flex-1 min-w-0 text-zinc-300 leading-relaxed",children:[n,s?"…":""]}),(0,w.jsxs)("button",{onClick:()=>d({step_name:e.step_name,content:e.content}),className:"shrink-0 flex items-center gap-1 text-[10px] text-zinc-500 hover:text-emerald-400 transition-colors opacity-0 group-hover:opacity-100 ml-1 whitespace-nowrap self-center",title:"View full response",children:[(0,w.jsx)(eh.ExternalLink,{size:10}),"View full"]})]})]},t)}return null}return(0,w.jsx)("div",{className:e.startsWith("✓")?"text-green-400":e.startsWith("✗")?"text-red-400":e.startsWith("▶")?"text-blue-400":e.startsWith("⏸")?"text-amber-400":e.startsWith("⟳")?"text-purple-400":"text-zinc-400",children:(0,w.jsx)(wA.default,{remarkPlugins:[wM.default],components:{p:({children:e})=>(0,w.jsx)("span",{children:e}),code:({children:e})=>(0,w.jsx)("code",{className:"bg-zinc-800 px-1 rounded text-[10px]",children:e}),pre:({children:e})=>(0,w.jsx)("pre",{className:"bg-zinc-800 p-1 rounded mt-0.5 overflow-x-auto",children:e}),a:({href:e,children:t})=>(0,w.jsx)("a",{href:e,className:"underline opacity-70",target:"_blank",rel:"noreferrer",children:t})},children:e})},t)})})]})]})]})}let wI=()=>{let[e,t]=(0,O.useState)("agents"),[n,s]=(0,O.useState)([]),[i,r]=(0,O.useState)(null),[o,a]=(0,O.useState)(null),[l,c]=(0,O.useState)(!1),[h,d]=(0,O.useState)(!1),[u,p]=(0,O.useState)(0),[f,m]=(0,O.useState)(!0),[g,x]=(0,O.useState)("all"),b=(0,O.useCallback)(async(t=!1)=>{c(!0),t||(r(null),a(null),p(0),m(!0));let n=t?u:0;try{let i=await fetch(`/api/logs/${e}?limit=100&offset=${n}`);if(i.ok){let e=await i.json();t?s(t=>[...t,...e]):s(e),e.length<100&&m(!1),p(n=>t?n+e.length:e.length)}}finally{c(!1)}},[e,u]);(0,O.useEffect)(()=>{b(),x("all")},[e]);let v=async t=>{r(t),d(!0),a(null);try{let n=await fetch(`/api/logs/${e}/${t}`);n.ok&&a(await n.text())}finally{d(!1)}},y=async(t,n)=>{n.stopPropagation(),(await fetch(`/api/logs/${e}/${t}`,{method:"DELETE"})).ok&&(i===t&&(r(null),a(null)),s(e=>e.filter(e=>e.run_id!==t)))},k="agents"===e?n.filter(e=>"schedule"!==e.source):n,j=Array.from(new Set(k.map(t=>"agents"===e?t.agent_name||t.run_id:"orchestrations"===e?t.orchestration_name||t.run_id:t.schedule_name||t.run_id).filter(Boolean))),N="all"===g?k:k.filter(t=>("agents"===e?t.agent_name||t.run_id:"orchestrations"===e?t.orchestration_name||t.run_id:t.schedule_name||t.run_id)===g),S={},z=[];return N.forEach(e=>{let t=e.session_id||`nosession_${e.run_id}`;S[t]||(S[t]=[],z.push(t)),S[t].push(e)}),(0,w.jsxs)("div",{className:"flex flex-col h-full overflow-hidden font-mono",children:[(0,w.jsxs)("div",{className:"px-6 py-4 border-b border-zinc-800 shrink-0 pr-14",children:[(0,w.jsx)("h1",{className:"text-2xl font-bold text-zinc-100",children:"Logs"}),(0,w.jsx)("p",{className:"text-zinc-500 text-xs mt-0.5",children:"View All logs of Agent and Orchestration"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2 px-6 py-3 border-b border-white/10 shrink-0",children:[(0,w.jsxs)("button",{onClick:()=>t("agents"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-all ${"agents"===e?"bg-white text-black":"text-zinc-400 hover:text-white hover:bg-white/5"}`,children:[(0,w.jsx)(_.Bot,{className:"h-3.5 w-3.5"}),"Agent Logs"]}),(0,w.jsxs)("button",{onClick:()=>t("orchestrations"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-all ${"orchestrations"===e?"bg-white text-black":"text-zinc-400 hover:text-white hover:bg-white/5"}`,children:[(0,w.jsx)(P.Workflow,{className:"h-3.5 w-3.5"}),"Orchestration Logs"]}),(0,w.jsxs)("button",{onClick:()=>t("schedules"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium transition-all ${"schedules"===e?"bg-white text-black":"text-zinc-400 hover:text-white hover:bg-white/5"}`,children:[(0,w.jsx)(D.Clock,{className:"h-3.5 w-3.5"}),"Schedule Logs"]}),(0,w.jsxs)("div",{className:"ml-auto flex items-center gap-3",children:[(0,w.jsxs)("span",{className:"text-xs text-zinc-600",children:[n.length," log",1!==n.length?"s":""]}),(0,w.jsx)("button",{onClick:()=>b(),className:"p-2 text-zinc-500 hover:text-white hover:bg-white/5 transition-colors",title:"Refresh",children:(0,w.jsx)(ez.RefreshCw,{className:`h-4 w-4 ${l?"animate-spin":""}`})})]})]}),j.length>1&&(0,w.jsxs)("div",{className:"flex items-center gap-3 px-6 py-2 border-b border-white/5 shrink-0 bg-zinc-900/40",children:[(0,w.jsx)("span",{className:"text-[11px] text-zinc-600 shrink-0",children:"Filter"}),(0,w.jsxs)("select",{value:g,onChange:e=>x(e.target.value),className:"bg-zinc-800/60 border border-white/8 text-zinc-300 text-[11px] px-2.5 py-1 focus:outline-none focus:border-white/20 transition-colors cursor-pointer appearance-none pr-6 max-w-[260px]",style:{backgroundImage:"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")",backgroundRepeat:"no-repeat",backgroundPosition:"right 6px center"},children:[(0,w.jsxs)("option",{value:"all",children:["All ","orchestrations"===e?"orchestrations":"agents"===e?"agents":"schedules"]}),j.map(e=>(0,w.jsx)("option",{value:e,children:e.length>40?e.slice(0,37)+"...":e},e))]})]}),(0,w.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,w.jsx)("div",{className:"w-80 border-r border-white/10 overflow-y-auto shrink-0 flex flex-col",children:l&&0===n.length?(0,w.jsx)("div",{className:"flex items-center justify-center h-32 text-zinc-600 text-xs",children:"Loading..."}):0===n.length?(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center h-40 gap-3 text-zinc-700",children:[(0,w.jsx)(E.ScrollText,{className:"h-8 w-8"}),(0,w.jsx)("p",{className:"text-xs",children:"No logs yet"})]}):(0,w.jsxs)(w.Fragment,{children:[z.map(t=>{let n=S[t],s=n.find(e=>e.user_input||e.prompt)?.user_input||n.find(e=>e.prompt)?.prompt,r=t.startsWith("nosession_")?"Individual Run":`Session: ${t.slice(-8)}`;return(0,w.jsxs)("div",{className:"border-b border-white/10 last:border-b-0",children:[(0,w.jsxs)("div",{className:"bg-white/5 px-4 py-2 border-b border-white/5 flex flex-col gap-0.5",children:[(0,w.jsx)("span",{className:"text-[10px] font-bold text-zinc-500 uppercase tracking-wider",children:r}),s&&(0,w.jsxs)("span",{className:"text-[10px] text-zinc-400 truncate italic",children:['"',s,'"']})]}),n.map(t=>{let n=i===t.run_id,s="agents"===e?t.agent_name||t.run_id:"orchestrations"===e?t.orchestration_name||t.run_id:t.schedule_name||t.run_id,r="agents"===e?t.source:"orchestrations"===e?t.orchestration_id:t.target_type;return(0,w.jsxs)("div",{onClick:()=>v(t.run_id),className:`group cursor-pointer px-4 py-3 border-b border-white/5 last:border-b-0 flex flex-col gap-1 transition-colors ${n?"bg-white/10 border-l-2 border-l-white":"hover:bg-white/5 border-l-2 border-l-transparent"}`,children:[(0,w.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,w.jsx)("span",{className:"text-xs text-white font-semibold leading-tight truncate",children:s}),(0,w.jsx)("button",{onClick:e=>y(t.run_id,e),className:"opacity-0 group-hover:opacity-100 p-0.5 text-zinc-600 hover:text-red-400 transition-all shrink-0 mt-0.5",title:"Delete log",children:(0,w.jsx)(F.Trash2,{className:"h-3 w-3"})})]}),r&&(0,w.jsx)("span",{className:"text-[10px] text-zinc-500 truncate",children:r}),(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[t.started_at&&(0,w.jsx)("span",{className:"text-[10px] text-zinc-600",children:t.started_at}),void 0!==t.file_size_kb&&(0,w.jsxs)("span",{className:"text-[10px] text-zinc-700",children:[t.file_size_kb,"KB"]})]})]},t.run_id)})]},t)}),f&&(0,w.jsx)("button",{onClick:()=>b(!0),disabled:l,className:"w-full py-4 text-xs text-zinc-500 hover:text-white hover:bg-white/5 transition-colors disabled:opacity-50",children:l?"Loading more...":"Load More"})]})}),(0,w.jsx)("div",{className:"flex-1 overflow-hidden bg-zinc-950",children:h?(0,w.jsx)("div",{className:"flex items-center justify-center h-full text-zinc-600 text-xs",children:"Loading log..."}):o?(0,w.jsx)("pre",{className:"h-full overflow-auto p-6 text-[11px] font-mono text-zinc-300 leading-relaxed whitespace-pre-wrap break-words",children:o}):(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-zinc-700",children:[(0,w.jsx)(E.ScrollText,{className:"h-10 w-10"}),(0,w.jsx)("p",{className:"text-xs",children:"Select a log to view its contents"})]})})]})]})},wL=(0,H.default)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),wq={name:"",platform:"telegram",agent_id:"",multi_agent_mode:!1,enabled:!0,credentials:{}},wB=[{id:"telegram",label:"Telegram",color:"text-sky-400 border-sky-800 bg-sky-950/40",icon:"/telegram-icon.svg"},{id:"discord",label:"Discord",color:"text-indigo-400 border-indigo-800 bg-indigo-950/40",icon:"/discord-round-color-icon.svg"},{id:"slack",label:"Slack",color:"text-green-400 border-green-800 bg-green-950/40",icon:"/slack-icon.svg"},{id:"teams",label:"Teams",color:"text-blue-400 border-blue-800 bg-blue-950/40",icon:"/teams.svg"},{id:"whatsapp",label:"WhatsApp",color:"text-emerald-400 border-emerald-800 bg-emerald-950/40",icon:"/whatsapp-color-icon.svg"}],wW={telegram:[{key:"bot_token",label:"Bot Token",placeholder:"123456:ABC-DEF...",secret:!0,note:"Get from @BotFather on Telegram"}],discord:[{key:"bot_token",label:"Bot Token",placeholder:"MTE...",secret:!0,note:"From Discord Developer Portal → Bot → Token"},{key:"channel_id",label:"Restrict to Channel ID (optional)",placeholder:"123456789012345678",note:"Leave empty to respond in all channels where the bot is mentioned"}],slack:[{key:"bot_token",label:"Bot Token (xoxb-...)",placeholder:"xoxb-...",secret:!0,note:"OAuth & Permissions → Bot Token Scopes"},{key:"app_token",label:"App-Level Token (xapp-...)",placeholder:"xapp-...",secret:!0,note:"Enable Socket Mode → generate App-Level Token with connections:write scope"}],teams:[{key:"app_id",label:"Azure App ID",placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",note:"Azure Bot resource → Configuration → Microsoft App ID"},{key:"app_password",label:"App Password / Client Secret",placeholder:"",secret:!0,note:"Azure Bot → Certificates & Secrets"}],whatsapp:[]},wV={telegram:{title:"Creating a Telegram Bot",steps:["Open Telegram and search for @BotFather","Send /newbot and follow the prompts to name your bot","Copy the bot token shown (format: 123456:ABC-DEF...)","Paste it in the Bot Token field above","Click Save & Connect — the bot will start polling immediately"]},discord:{title:"Creating a Discord Bot",steps:["Go to discord.com/developers/applications → New Application","In the Bot tab, click Add Bot → copy the Token","Enable Message Content Intent under Privileged Gateway Intents","In OAuth2 → URL Generator: select bot + applications.commands, check Read/Send Messages","Use the generated URL to invite the bot to your server","Paste the bot token above and optionally restrict to a channel ID"]},slack:{title:"Creating a Slack App with Socket Mode",steps:["Go to api.slack.com/apps → Create New App → From Scratch","In Socket Mode, enable it and generate an App-Level Token (xapp-...) with connections:write scope","In Event Subscriptions → Subscribe to bot events: message.im, app_mention","In OAuth & Permissions add scopes: app_mentions:read, chat:write, im:history, im:write, channels:history","Install to workspace and copy the Bot Token (xoxb-...)","Paste both tokens above"]},teams:{title:"Creating a Microsoft Teams Bot",steps:["Go to portal.azure.com → Create a resource → Azure Bot","Set the Messaging endpoint to: https://<your-ngrok-url>/api/messaging/teams/webhook/<channel-id>","For local dev, run: ngrok http 8765 and use the Forwarding URL","Note: only the Synapse backend needs the public URL — your frontend is unaffected","In the bot Configuration, copy the Microsoft App ID","In Certificates & Secrets, create a new client secret and copy it","Add the Teams channel in the bot's Channels tab"]},whatsapp:{title:"WhatsApp Setup",steps:["BUSINESS ACCOUNT PATH: Go to developers.facebook.com → My Apps → Create App (type: Business)","Add WhatsApp product → Phone Numbers → select a test or production number","In WhatsApp → Configuration, set Webhook URL to: https://<ngrok-url>/api/messaging/whatsapp/webhook/<channel-id>","Set your Verify Token (any string), subscribe to the messages webhook field","Copy the Phone Number ID and generate a temporary/permanent Access Token","--- OR ---","UNOFFICIAL PATH: No business account needed. Synapse will open WhatsApp Web in a browser window and you scan the QR code to authenticate. This may violate WhatsApp's Terms of Service."]}},wF=({status:e,lastError:t})=>"running"===e?(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-bold text-green-400 bg-green-950/50 border border-green-900 px-2 py-0.5",children:[(0,w.jsx)(ed,{className:"h-2.5 w-2.5"})," RUNNING"]}):"error"===e?(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-bold text-red-400 bg-red-950/50 border border-red-900 px-2 py-0.5",title:t||"",children:[(0,w.jsx)(eu,{className:"h-2.5 w-2.5"})," ERROR"]}):(0,w.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-bold text-zinc-500 bg-zinc-900 border border-zinc-800 px-2 py-0.5",children:[(0,w.jsx)(ep,{className:"h-2.5 w-2.5"})," STOPPED"]}),wH=()=>{let[e,t]=(0,O.useState)([]),[n,s]=(0,O.useState)(null),[i,r]=(0,O.useState)(null),[o,a]=(0,O.useState)([]),[l,c]=(0,O.useState)(!1),[h,d]=(0,O.useState)(!1),[u,p]=(0,O.useState)(null),[f,m]=(0,O.useState)(!1),[g,x]=(0,O.useState)(!1),[b,v]=(0,O.useState)("meta_api"),[y,k]=(0,O.useState)(!1),[N,S]=(0,O.useState)(null),z=e=>{p(e),setTimeout(()=>p(null),3e3)},C=(0,O.useCallback)(async()=>{x(!0);try{let e=await fetch("/api/messaging/channels");if(e.ok){let n=await e.json();t(Array.isArray(n)?n:[])}}catch{}finally{x(!1)}},[]);(0,O.useEffect)(()=>{C(),fetch("/api/agents").then(e=>e.json()).then(e=>a(Array.isArray(e)?e:[])).catch(()=>{})},[C]);let _=async()=>{if(i){if(!i.name.trim())return void z("Please enter a channel name");if(!i.agent_id)return void z("Please select an agent");c(!0);try{let e="whatsapp"===i.platform?{...i,credentials:{...i.credentials,whatsapp_mode:b}}:i,t=await fetch("/api/messaging/channels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error("Save failed");let n=await t.json();await fetch(`/api/messaging/channels/${n.id}/enable`,{method:"POST"}),await C(),s(n.id),r({...n}),z("✅ Channel saved and started")}catch(e){z(`❌ ${e.message}`)}finally{c(!1)}}},T=async()=>{if(n){d(!0);try{let e=await fetch(`/api/messaging/channels/${n}/test`,{method:"POST"}),t=await e.json();z("ok"===t.status?`✅ ${t.message}`:`⚠️ ${t.message}`)}catch{z("❌ Test failed")}finally{d(!1)}}},A=async e=>{if(!e.id)return;let t="running"===e.status?"disable":"enable";await fetch(`/api/messaging/channels/${e.id}/${t}`,{method:"POST"}),await C()},M=async t=>{let i=e.find(e=>e.id===t);i&&i.id&&(await fetch(`/api/messaging/channels/${i.id}`,{method:"DELETE"}),n===i.id&&(s(null),r(null)),await C())},P=(e,t)=>{i&&r({...i,credentials:{...i.credentials,[e]:t}})},E=i?.platform||"telegram",D=wB.find(e=>e.id===E),$=wV[E];return(0,w.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-10",children:[u&&(0,w.jsx)("div",{className:"fixed bottom-6 right-6 z-50 bg-zinc-900 border border-zinc-700 text-white text-xs px-4 py-3 shadow-xl animate-in slide-in-from-bottom-4",children:u}),(0,w.jsxs)("div",{className:"md:col-span-4 border-r border-zinc-800 pr-4 flex flex-col max-h-[calc(100vh-180px)] sticky top-0 self-start",children:[(0,w.jsxs)("div",{className:"mb-4 flex justify-between items-center",children:[(0,w.jsx)("h3",{className:"text-sm font-bold text-zinc-400",children:"CHANNELS"}),(0,w.jsxs)("div",{className:"flex gap-1",children:[(0,w.jsx)("button",{onClick:C,title:"Refresh",className:"p-1.5 text-zinc-500 hover:text-white hover:bg-zinc-800 transition-colors",children:(0,w.jsx)(ez.RefreshCw,{className:`h-3 w-3 ${g?"animate-spin":""}`})}),(0,w.jsx)("button",{onClick:()=>{s(null),r({...wq}),m(!1),v("meta_api"),k(!1)},className:"p-1.5 hover:bg-zinc-800 text-white transition-colors border border-dashed border-zinc-600 hover:border-white",title:"New Channel",children:(0,w.jsx)(en.Plus,{className:"h-4 w-4"})})]})]}),(0,w.jsxs)("div",{className:"space-y-2 flex-1 overflow-y-auto modern-scrollbar",children:[0===e.length&&(0,w.jsxs)("div",{className:"p-6 text-center text-zinc-600 text-xs border border-dashed border-zinc-800",children:[(0,w.jsx)(R.MessageSquare,{className:"h-8 w-8 mx-auto mb-2 opacity-20"}),"No channels configured yet.",(0,w.jsx)("br",{}),"Click + to add one."]}),e.map(e=>{let t=wB.find(t=>t.id===e.platform),i=n===e.id;return(0,w.jsx)("div",{onClick:()=>{s(e.id||null),r({...e}),m(!1),"whatsapp"===e.platform&&(v(e.credentials?.whatsapp_mode||"meta_api"),k(!1))},className:`p-3 border cursor-pointer transition-all group relative
|
|
42
|
+
${i?"bg-zinc-900 border-white":"bg-black border-zinc-800 hover:border-zinc-600"}`,children:(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("div",{className:`h-8 w-8 flex-shrink-0 flex items-center justify-center border ${t?.color??""}`,children:(0,w.jsx)("img",{src:t?.icon,alt:t?.label,className:"h-5 w-5 object-contain"})}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("div",{className:"text-xs font-bold text-white truncate",children:e.name}),(0,w.jsx)("div",{className:"text-[10px] text-zinc-500 truncate",children:o.find(t=>t.id===e.agent_id)?.name||e.agent_id})]}),(0,w.jsx)("div",{className:"group-hover:hidden flex-shrink-0",children:(0,w.jsx)(wF,{status:e.status,lastError:e.last_error})}),(0,w.jsxs)("div",{className:"hidden group-hover:flex gap-1 flex-shrink-0",children:[(0,w.jsx)("button",{onClick:t=>{t.stopPropagation(),A(e)},className:`p-1 transition-colors ${"running"===e.status?"text-orange-400 hover:text-orange-300":"text-green-400 hover:text-green-300"}`,title:"running"===e.status?"Stop":"Start",children:"running"===e.status?(0,w.jsx)(ep,{className:"h-3 w-3"}):(0,w.jsx)(e_,{className:"h-3 w-3"})}),(0,w.jsx)("button",{onClick:t=>{t.stopPropagation(),S(e.id||null)},className:"p-1 text-zinc-600 hover:text-red-400 transition-colors",children:(0,w.jsx)(j.Trash,{className:"h-3 w-3"})})]})]})},e.id)})]})]}),(0,w.jsx)("div",{className:"md:col-span-8 pl-4",children:i?(0,w.jsxs)("div",{className:"space-y-6",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsxs)("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[(0,w.jsx)("div",{className:"h-2 w-2 rounded-full bg-purple-500"}),n?`EDITING: ${i.name.toUpperCase()||"CHANNEL"}`:"NEW CHANNEL"]}),(0,w.jsxs)("div",{className:"flex gap-2",children:[n&&(0,w.jsxs)("button",{onClick:T,disabled:h,className:"flex items-center gap-1.5 px-3 py-1.5 bg-zinc-800 hover:bg-zinc-700 text-white text-xs font-bold transition-colors disabled:opacity-50",children:[h?(0,w.jsx)(B.Loader2,{className:"h-3 w-3 animate-spin"}):(0,w.jsx)(wL,{className:"h-3 w-3"}),"TEST"]}),(0,w.jsxs)("button",{onClick:_,disabled:l,className:"flex items-center gap-2 px-4 py-1.5 bg-white text-black text-xs font-bold hover:bg-zinc-200 disabled:opacity-50",children:[l?(0,w.jsx)(B.Loader2,{className:"h-3 w-3 animate-spin"}):(0,w.jsx)(es,{className:"h-3 w-3"}),"SAVE & CONNECT"]})]})]}),(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Platform"}),(0,w.jsx)("div",{className:"grid grid-cols-5 gap-2",children:wB.map(e=>(0,w.jsxs)("button",{onClick:()=>r({...wq,platform:e.id,name:i.name,agent_id:i.agent_id}),className:`flex flex-col items-center gap-1 p-3 border text-xs font-bold transition-all
|
|
43
|
+
${i.platform===e.id?`${e.color} border-current`:"bg-black border-zinc-800 text-zinc-500 hover:border-zinc-600"}`,children:[(0,w.jsx)("img",{src:e.icon,alt:e.label,className:"h-6 w-6 object-contain"}),e.label]},e.id))})]}),(0,w.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Channel Name"}),(0,w.jsx)("input",{type:"text",value:i.name,onChange:e=>r({...i,name:e.target.value}),placeholder:"e.g. Support Bot",className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none"})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Bound Agent"}),(0,w.jsxs)("select",{value:i.agent_id,onChange:e=>r({...i,agent_id:e.target.value}),className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none",children:[(0,w.jsx)("option",{value:"",children:"Select an agent…"}),o.map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]})]})]}),(0,w.jsxs)("div",{className:"flex items-start gap-4 p-3 bg-zinc-950 border border-zinc-800",children:[(0,w.jsx)("input",{id:"multi-agent-toggle",type:"checkbox",checked:i.multi_agent_mode,onChange:e=>r({...i,multi_agent_mode:e.target.checked}),className:"mt-1 accent-purple-500"}),(0,w.jsxs)("div",{className:"flex-1",children:[(0,w.jsx)("label",{htmlFor:"multi-agent-toggle",className:"text-xs font-bold text-white cursor-pointer block leading-tight",children:"Multi-Agent Mode"}),(0,w.jsxs)("p",{className:"text-[10px] text-zinc-500 mt-1.5 leading-relaxed",children:["When enabled, users can switch agents mid-chat using ",(0,w.jsx)("code",{className:"bg-zinc-800 px-1",children:"/agent <name>"})," and list them with ",(0,w.jsx)("code",{className:"bg-zinc-800 px-1",children:"/agents"}),". The channel's bound agent is the default."]})]})]}),(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:["Credentials — ",D?.label]}),"whatsapp"===i.platform?(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsx)("div",{className:"grid grid-cols-2 gap-3",children:[{v:"meta_api",label:"🏢 Business (Meta API)",desc:"Official. Requires Meta Business account + verified number."},{v:"unofficial",label:"🛠 Unofficial (Playwright)",desc:"No business account. Uses WhatsApp Web automation."}].map(e=>(0,w.jsxs)("button",{onClick:()=>{v(e.v),k(!1)},className:`p-3 border text-left text-xs transition-all
|
|
44
|
+
${b===e.v?"bg-zinc-900 border-white":"bg-black border-zinc-800 hover:border-zinc-600"}`,children:[(0,w.jsx)("div",{className:"font-bold text-white",children:e.label}),(0,w.jsx)("div",{className:"text-zinc-500 mt-1",children:e.desc})]},e.v))}),"meta_api"===b&&(0,w.jsx)("div",{className:"space-y-3",children:[{key:"phone_number_id",label:"Phone Number ID",placeholder:"123456789012345",secret:!1},{key:"access_token",label:"Access Token",placeholder:"EAA...",secret:!0},{key:"verify_token",label:"Verify Token (your choice)",placeholder:"synapse_verify",secret:!1,note:"Used to verify Meta webhook. Set the same value in your Meta App settings."}].map(e=>(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:e.label}),(0,w.jsx)("input",{type:e.secret?"password":"text",value:i.credentials[e.key]||"",onChange:t=>P(e.key,t.target.value),placeholder:e.placeholder,className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none font-mono"}),e.note&&(0,w.jsx)("p",{className:"text-[9px] text-zinc-600",children:e.note})]},e.key))}),"unofficial"===b&&(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("div",{className:"flex gap-2 p-3 bg-amber-950/30 border border-amber-800/50",children:[(0,w.jsx)(eS,{className:"h-4 w-4 text-amber-400 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("div",{className:"text-[10px] text-amber-300 space-y-1",children:[(0,w.jsx)("p",{className:"font-bold",children:"⚠️ Unofficial Approach — Use at Your Own Risk"}),(0,w.jsx)("p",{children:"This mode uses Playwright to drive WhatsApp Web in a browser window. It requires scanning a QR code. It may:"}),(0,w.jsxs)("ul",{className:"list-disc pl-4 space-y-0.5",children:[(0,w.jsx)("li",{children:"Violate WhatsApp's Terms of Service"}),(0,w.jsx)("li",{children:"Break when WhatsApp updates their web app"}),(0,w.jsx)("li",{children:"Result in your number being temporarily banned"})]}),(0,w.jsx)("p",{children:"We recommend using the official Meta Business path instead."})]})]}),(0,w.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-zinc-950 border border-zinc-800",children:[(0,w.jsx)("input",{id:"wa-risk-ack",type:"checkbox",checked:y,onChange:e=>k(e.target.checked),className:"mt-1 accent-amber-500"}),(0,w.jsx)("label",{htmlFor:"wa-risk-ack",className:"text-xs text-zinc-300 cursor-pointer leading-tight",children:"I understand the risks and accept responsibility for using the unofficial path."})]}),y&&(0,w.jsxs)("div",{className:"p-3 bg-zinc-950 border border-zinc-700 text-[10px] text-zinc-400 space-y-1",children:[(0,w.jsx)("p",{children:"After saving & connecting, Synapse will open WhatsApp Web in a Chromium browser window."}),(0,w.jsx)("p",{children:"Scan the QR code shown in the browser to authenticate. The session is saved and persists across restarts."})]})]})]}):(0,w.jsx)("div",{className:"space-y-3",children:wW[i.platform]?.map(e=>(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:e.label}),(0,w.jsx)("input",{type:e.secret?"password":"text",value:i.credentials[e.key]||"",onChange:t=>P(e.key,t.target.value),placeholder:e.placeholder,className:"w-full bg-zinc-950 border border-zinc-800 p-3 text-xs text-white focus:border-white focus:outline-none font-mono"}),e.note&&(0,w.jsxs)("p",{className:"text-[9px] text-zinc-600 flex items-center gap-1",children:[(0,w.jsx)(fn,{className:"h-2.5 w-2.5"})," ",e.note]})]},e.key))})]}),(0,w.jsxs)("div",{className:"border border-zinc-800",children:[(0,w.jsxs)("button",{onClick:()=>m(e=>!e),className:"w-full flex items-center justify-between px-4 py-3 text-xs font-bold text-zinc-400 hover:text-white hover:bg-zinc-900/50 transition-colors",children:[(0,w.jsxs)("span",{children:["📖 Setup Guide — ",$.title]}),f?(0,w.jsx)(ei.ChevronDown,{className:"h-3 w-3"}):(0,w.jsx)(er.ChevronRight,{className:"h-3 w-3"})]}),f&&(0,w.jsx)("div",{className:"px-4 pb-4 space-y-2 bg-zinc-950/50",children:(0,w.jsx)("ol",{className:"space-y-2",children:$.steps.map((e,t)=>(0,w.jsxs)("li",{className:"flex gap-2 text-[10px] text-zinc-400",children:[(0,w.jsx)("span",{className:"text-zinc-600 font-bold flex-shrink-0",children:e.startsWith("---")?"":`${t+1}.`}),(0,w.jsx)("span",{className:e.startsWith("---")?"text-zinc-700 border-t border-zinc-800 w-full pt-1":"",children:e})]},t))})})]}),i.last_error&&(0,w.jsxs)("div",{className:"flex gap-2 p-3 bg-red-950/30 border border-red-900/50",children:[(0,w.jsx)(eu,{className:"h-4 w-4 text-red-400 flex-shrink-0"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-xs font-bold text-red-400",children:"Last Error"}),(0,w.jsx)("p",{className:"text-[10px] text-red-300 mt-0.5 font-mono",children:i.last_error})]})]})]}):(0,w.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-zinc-600 space-y-4 py-20",children:[(0,w.jsx)(R.MessageSquare,{className:"h-12 w-12 opacity-20"}),(0,w.jsx)("p",{className:"text-sm",children:"Select a channel or create a new one."})]})}),(0,w.jsx)(K,{isOpen:!!N,title:"Delete Channel",message:"Are you sure you want to delete this messaging channel? This will permanently remove its configuration and stop it if it is running.",onConfirm:()=>{N&&M(N),S(null)},onClose:()=>S(null)})]})};var wX=e.i(12426);let wU=(0,H.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),wG=(0,H.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]),wZ=(0,H.default)("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]),wY=["openai","anthropic","gemini","grok","deepseek","bedrock","ollama"],wK={openai:{label:"OpenAI",color:"#10b981",dot:"#10b981",bg:"bg-emerald-950/60",text:"text-emerald-400"},anthropic:{label:"Anthropic",color:"#f59e0b",dot:"#f59e0b",bg:"bg-amber-950/60",text:"text-amber-400"},gemini:{label:"Gemini",color:"#3b82f6",dot:"#3b82f6",bg:"bg-blue-950/60",text:"text-blue-400"},grok:{label:"xAI Grok",color:"#a1a1aa",dot:"#a1a1aa",bg:"bg-zinc-800/60",text:"text-zinc-300"},deepseek:{label:"DeepSeek",color:"#8b5cf6",dot:"#8b5cf6",bg:"bg-violet-950/60",text:"text-violet-400"},bedrock:{label:"AWS Bedrock",color:"#f97316",dot:"#f97316",bg:"bg-orange-950/60",text:"text-orange-400"},ollama:{label:"Ollama (Local)",color:"#94a3b8",dot:"#94a3b8",bg:"bg-slate-800/60",text:"text-slate-400"}};function wJ(e){return 0===e?"$0.00":e<1e-6?"<$0.000001":e<.01?`$${e.toFixed(6)}`:`$${e.toFixed(4)}`}function w0(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function w1(e){let t=e/1024;return t>=1?`${t.toFixed(1)}KB`:`${e}B`}function w2(e){return e.startsWith("ollama.")?"ollama":e.startsWith("gpt")||e.startsWith("o1")||e.startsWith("o3")||e.startsWith("o4")?"openai":e.startsWith("claude")?"anthropic":e.startsWith("gemini")?"gemini":e.startsWith("grok")?"grok":e.startsWith("deepseek")?"deepseek":e.startsWith("anthropic.")||e.startsWith("amazon.")||e.startsWith("meta.")||e.startsWith("mistral.")?"bedrock":"ollama"}function w5({provider:e}){let t=wK[e]??wK.ollama;return(0,w.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs font-medium ${t.bg} ${t.text} border border-white/5`,children:[(0,w.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:t.dot}}),e||"local"]})}function w3({icon:e,label:t,value:n,sub:s,color:i}){return(0,w.jsxs)("div",{className:"relative flex flex-col gap-3 p-5 bg-zinc-900/80 border border-white/5 overflow-hidden group hover:border-white/10 transition-all duration-300",children:[(0,w.jsx)("div",{className:"absolute inset-0 opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none",style:{background:`radial-gradient(ellipse at top left, ${i}10 0%, transparent 70%)`}}),(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsx)("span",{className:"text-xs text-zinc-500 font-medium tracking-wider uppercase",children:t}),(0,w.jsx)("div",{className:"p-2",style:{background:`${i}18`},children:(0,w.jsx)(e,{className:"w-4 h-4",style:{color:i}})})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-2xl font-bold tracking-tight text-white",children:n}),s&&(0,w.jsx)("p",{className:"text-xs text-zinc-500 mt-0.5",children:s})]})]})}function w4({stat:e,maxCost:t}){let n=t>0?e.estimated_cost/t*100:0,s=wK[w2(e.model)]??wK.ollama;return(0,w.jsxs)("div",{className:"flex items-center gap-4 py-3 border-b border-white/5 last:border-0 -mx-4 px-4 hover:bg-white/2 transition-colors",children:[(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,w.jsx)("span",{className:"text-sm font-medium text-white truncate",children:e.model}),(0,w.jsx)(w5,{provider:e.provider})]}),(0,w.jsx)("div",{className:"h-1 bg-zinc-800 overflow-hidden",children:(0,w.jsx)("div",{className:"h-full transition-all duration-700",style:{width:`${n}%`,background:s.dot}})})]}),(0,w.jsxs)("div",{className:"flex gap-6 text-right shrink-0",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-xs text-zinc-500",children:"Reqs"}),(0,w.jsx)("p",{className:"text-sm font-semibold text-white",children:e.requests})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-xs text-zinc-500",children:"Tokens"}),(0,w.jsx)("p",{className:"text-sm font-semibold text-white",children:w0(e.total_tokens)})]}),(0,w.jsxs)("div",{className:"min-w-[70px]",children:[(0,w.jsx)("p",{className:"text-xs text-zinc-500",children:"Cost"}),(0,w.jsx)("p",{className:"text-sm font-semibold",style:{color:s.dot},children:wJ(e.estimated_cost)})]})]})]})}function w8({s:e}){let[t,n]=(0,O.useState)(!1),[s,i]=(0,O.useState)([]),[r,o]=(0,O.useState)(!1),a="orchestration"===e.source||e.source?.startsWith("orchestration:"),l="schedule"===e.source,c="unknown"===e.session_id&&!l,h=(0,O.useCallback)(async()=>{if(!(s.length>0)){o(!0);try{let t=(a||l)&&e.run_id?`run_id=${encodeURIComponent(e.run_id)}`:`session_id=${encodeURIComponent(e.session_id)}`,n=await fetch(`/api/usage/logs?${t}&limit=500`),s=await n.json();i(s.logs??[])}catch{}finally{o(!1)}}},[e.session_id,e.run_id,a,l,s.length]),d=(a||l)&&s.length>0?[...s].sort((e,t)=>e.timestamp.localeCompare(t.timestamp)).map((e,t)=>({...e,globalIdx:t})):[];return(0,w.jsxs)("div",{className:"border border-white/5 mb-2 hover:border-white/10 transition-colors overflow-hidden",children:[(0,w.jsxs)("button",{onClick:()=>{t||h(),n(e=>!e)},className:"w-full flex items-center gap-4 px-4 py-3 text-left hover:bg-white/3 transition-colors",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[c?(0,w.jsx)(wZ,{className:"w-3.5 h-3.5 text-fuchsia-400"}):l?(0,w.jsx)(D.Clock,{className:"w-3.5 h-3.5 text-sky-400"}):a?(0,w.jsx)(Y,{className:"w-3.5 h-3.5 text-violet-400"}):(0,w.jsx)(fu,{className:"w-3.5 h-3.5 text-emerald-400"}),(0,w.jsx)("span",{className:`text-xs px-2 py-0.5 font-medium border ${c?"border-fuchsia-800/50 text-fuchsia-400 bg-fuchsia-950/40":l?"border-sky-800/50 text-sky-400 bg-sky-950/40":a?"border-violet-800/50 text-violet-400 bg-violet-950/40":"border-emerald-800/50 text-emerald-400 bg-emerald-950/40"}`,children:c?"system":l?"schedule":a?"orch":"chat"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,w.jsx)("span",{className:"text-xs text-zinc-400 font-mono truncate",children:c?"System Prompt Generation":(a||l)&&e.run_id?e.run_id:e.session_id}),(a||l)&&(e.agents_used?.length??0)>0&&(0,w.jsxs)("span",{className:`shrink-0 text-xs px-1.5 py-0.5 border whitespace-nowrap ${l?"text-sky-400 bg-sky-950/40 border-sky-800/30":"text-violet-400 bg-violet-950/40 border-violet-800/30"}`,children:[e.agents_used.length," agent",1!==e.agents_used.length?"s":""]})]}),(0,w.jsxs)("div",{className:"flex items-center gap-5 text-right shrink-0 text-sm",children:[(0,w.jsxs)("div",{className:"hidden md:block",children:[(0,w.jsx)("p",{className:"text-xs text-zinc-500",children:"Turns"}),(0,w.jsx)("p",{className:"font-semibold text-white",children:e.requests})]}),(0,w.jsxs)("div",{className:"hidden lg:block",children:[(0,w.jsx)("p",{className:"text-xs text-zinc-500",children:"Context"}),(0,w.jsx)("p",{className:"font-semibold text-white",children:w1(e.context_chars)})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-xs text-zinc-500",children:"Tokens"}),(0,w.jsx)("p",{className:"font-semibold text-white",children:w0(e.total_tokens)})]}),(0,w.jsxs)("div",{className:"min-w-[70px]",children:[(0,w.jsx)("p",{className:"text-xs text-zinc-500",children:"Cost"}),(0,w.jsx)("p",{className:"font-semibold text-emerald-400",children:wJ(e.estimated_cost)})]})]}),t?(0,w.jsx)(eT,{className:"w-4 h-4 text-zinc-500 shrink-0"}):(0,w.jsx)(ei.ChevronDown,{className:"w-4 h-4 text-zinc-500 shrink-0"})]}),t&&(0,w.jsxs)("div",{className:"border-t border-white/5 bg-zinc-950/50",children:[(0,w.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 px-4 py-3 border-b border-white/5 text-xs",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-500 mb-1",children:(a||l)&&(e.agents_used?.length??0)>1?"Agents":"Agent"}),(a||l)&&(e.agents_used?.length??0)>1?(0,w.jsx)("div",{className:"flex flex-wrap gap-1",children:e.agents_used.map(e=>(0,w.jsxs)("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 font-mono truncate max-w-[120px] border ${l?"bg-sky-950/50 border-sky-800/30 text-sky-300":"bg-violet-950/50 border-violet-800/30 text-violet-300"}`,children:[(0,w.jsx)(N.Cpu,{className:"w-2.5 h-2.5 shrink-0"}),e]},e))}):(0,w.jsx)("p",{className:"text-zinc-300 font-mono truncate",children:e.agent_id})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-500 mb-1",children:"Models"}),(0,w.jsx)("div",{className:"flex flex-wrap gap-1",children:e.models_used.map(e=>(0,w.jsx)("span",{className:"bg-zinc-800 text-zinc-300 px-1.5 py-0.5 text-xs truncate max-w-[100px]",children:e},e))})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-500 mb-1",children:"In / Out"}),(0,w.jsxs)("p",{className:"text-zinc-300",children:[w0(e.input_tokens)," / ",w0(e.output_tokens)]})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-500 mb-1",children:"Last Active"}),(0,w.jsx)("p",{className:"text-zinc-300",children:function(e){if(!e)return"--";try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}(e.last_ts)})]})]}),(0,w.jsxs)("div",{className:"px-4 pt-3 pb-4",children:[(0,w.jsx)("p",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider mb-4",children:"Per-Turn Breakdown"}),r&&(0,w.jsxs)("div",{className:"flex items-center gap-2 py-4 text-zinc-600 text-xs",children:[(0,w.jsx)(ez.RefreshCw,{className:"w-3 h-3 animate-spin"})," Loading turns..."]}),!r&&0===s.length&&(0,w.jsx)("p",{className:"text-zinc-600 text-xs py-3",children:"No detailed logs found for this session."}),!r&&s.length>0&&(0,w.jsx)(w6,{logs:a||l?d:s.map((e,t)=>({...e,globalIdx:t})),showAgentDividers:a||l})]})]})]})}function w6({logs:e,showAgentDividers:t=!1}){let n,s=[...e].sort((e,t)=>e.timestamp.localeCompare(t.timestamp));return(0,w.jsx)("div",{className:"overflow-x-auto",children:(0,w.jsxs)("table",{className:"w-full text-xs",children:[(0,w.jsx)("thead",{children:(0,w.jsxs)("tr",{className:"border-b border-white/8",children:[(0,w.jsx)("th",{className:"text-left py-2 pr-3 pl-3 text-zinc-500 font-medium",children:"#"}),(0,w.jsx)("th",{className:"text-left py-2 pr-3 text-zinc-500 font-medium",children:"Time"}),(0,w.jsx)("th",{className:"text-left py-2 pr-3 text-zinc-500 font-medium",children:"Model"}),(0,w.jsx)("th",{className:"text-left py-2 pr-4 text-zinc-500 font-medium",children:"Tool"}),(0,w.jsx)("th",{className:"text-right py-2 pr-3 text-zinc-500 font-medium",children:"Context"}),(0,w.jsx)("th",{className:"text-right py-2 pr-3 text-zinc-500 font-medium",children:"Δ Context"}),(0,w.jsx)("th",{className:"text-right py-2 pr-3 text-zinc-500 font-medium",children:"In"}),(0,w.jsx)("th",{className:"text-right py-2 pr-3 text-zinc-500 font-medium",children:"Out"}),(0,w.jsx)("th",{className:"text-right py-2 pr-3 text-zinc-500 font-medium",children:"Latency"}),(0,w.jsx)("th",{className:"text-right py-2 pr-3 text-zinc-500 font-medium",children:"Cost"})]})}),(0,w.jsx)("tbody",{children:(n={},s.forEach(e=>{let t=e.agent_id||"";n[t]=(n[t]||0)+1}),s.map((e,i)=>{let r=i>0?s[i-1].context_chars:0,o=e.context_chars-r,a=wK[w2(e.model)]?.dot??"#71717a",l=i>0?s[i-1].agent_id||"":null,c=e.agent_id||"",h=t&&(0===i||c!==l),d=c.toLowerCase().includes("evaluator")?"#10b981":"#3b82f6",u=n[c]??0;return(0,w.jsxs)(O.default.Fragment,{children:[h&&(0,w.jsxs)("tr",{className:"border-t border-b border-white/5",children:[(0,w.jsx)("td",{colSpan:9,style:{background:`${d}10`},className:"px-3 py-2",children:(0,w.jsxs)("span",{className:"flex items-center gap-2",children:[(0,w.jsx)(N.Cpu,{className:"w-3 h-3 shrink-0",style:{color:d}}),(0,w.jsx)("span",{className:"font-mono font-semibold text-xs truncate max-w-[180px]",title:c,style:{color:d},children:c})]})}),(0,w.jsxs)("td",{style:{background:`${d}10`,color:`${d}bb`},className:"py-2 pr-3 text-right text-xs tabular-nums font-medium",children:[u," call",1!==u?"s":""]})]}),(0,w.jsxs)("tr",{className:"border-b border-white/[0.04] last:border-0 hover:bg-white/[0.02] transition-colors",children:[(0,w.jsx)("td",{className:"py-2.5 pr-3 pl-3 text-zinc-600 tabular-nums",children:i+1}),(0,w.jsx)("td",{className:"py-2.5 pr-3 text-zinc-500 whitespace-nowrap tabular-nums",children:function(e){if(!e)return"--";try{return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return e}}(e.timestamp)}),(0,w.jsx)("td",{className:"py-2.5 pr-3 font-mono max-w-[140px]",children:(0,w.jsx)("span",{className:"text-zinc-300 truncate block",title:e.model,children:e.model})}),(0,w.jsx)("td",{className:"py-2.5 pr-4 max-w-[130px]",children:e.tool_name?(0,w.jsx)("span",{className:"text-sky-400 font-mono truncate block",title:e.tool_name,children:e.tool_name}):(0,w.jsx)("span",{className:"text-zinc-700",children:"--"})}),(0,w.jsx)("td",{className:"py-2.5 pr-3 text-right text-zinc-300 tabular-nums",children:w1(e.context_chars)}),(0,w.jsx)("td",{className:"py-2.5 pr-3 text-right tabular-nums",children:(0,w.jsx)("span",{className:o>0?"text-amber-400 font-medium":"text-zinc-600",children:o>0?`+${w1(o)}`:"--"})}),(0,w.jsx)("td",{className:"py-2.5 pr-3 text-right text-zinc-400 tabular-nums",children:w0(e.input_tokens)}),(0,w.jsx)("td",{className:"py-2.5 pr-3 text-right text-zinc-400 tabular-nums",children:w0(e.output_tokens)}),(0,w.jsxs)("td",{className:"py-2.5 pr-3 text-right text-zinc-500 tabular-nums",children:[e.latency_seconds.toFixed(1),"s"]}),(0,w.jsx)("td",{className:"py-2.5 pr-3 text-right font-medium tabular-nums",style:{color:a},children:wJ(e.estimated_cost)})]})]},e.globalIdx)}))})]})})}function w9({initialPricing:e,onSaved:t}){let[n,s]=(0,O.useState)(()=>JSON.parse(JSON.stringify(e))),[i,r]=(0,O.useState)("all"),[o,a]=(0,O.useState)(!1),[l,c]=(0,O.useState)(null),[h,d]=(0,O.useState)(!1),[u,p]=(0,O.useState)({});(0,O.useEffect)(()=>{fetch("/api/models").then(e=>e.ok?e.json():null).then(e=>{if(!e?.providers)return;let t={};for(let[n,s]of Object.entries(e.providers))Array.isArray(s?.models)&&(t[n]=s.models);p(t)}).catch(()=>{})},[]);let[f,m]=(0,O.useState)(null),[g,x]=(0,O.useState)(""),[b,v]=(0,O.useState)(""),[y,k]=(0,O.useState)(""),[j,N]=(0,O.useState)(!1),S=(e,t,n)=>{let i=parseFloat(n);isNaN(i)||i<0||(s(n=>({...n,[e]:{...n[e],[t]:i}})),d(!0))},z=async()=>{a(!0),c(null);try{let e={};for(let[t,s]of Object.entries(n)){let{_editing:n,_new:i,...r}=s;e[t]=r}let s=await fetch("/api/usage/pricing",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok)throw Error(`Server error ${s.status}`);c("Saved!"),d(!1),t(e),setTimeout(()=>c(null),2e3)}catch(e){c(`Error: ${e.message}`)}finally{a(!1)}},C=wY.filter(e=>"ollama"!==e||Object.values(n).some(e=>"ollama"===e.provider));return(0,w.jsxs)("div",{className:"border border-white/5",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5 bg-zinc-900/40",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)(fn,{className:"w-4 h-4 text-zinc-400"}),(0,w.jsx)("span",{className:"text-sm font-semibold text-white",children:"Pricing Reference"}),(0,w.jsx)("span",{className:"text-xs text-zinc-500",children:"-- edit rates used for cost calculation (USD / 1M tokens)"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[l&&(0,w.jsx)("span",{className:`text-xs ${l.startsWith("Error")?"text-red-400":"text-emerald-400"}`,children:l}),h&&(0,w.jsxs)("button",{onClick:z,disabled:o,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs bg-white text-black font-semibold hover:bg-zinc-200 transition-colors disabled:opacity-50",children:[o?(0,w.jsx)(ez.RefreshCw,{className:"w-3 h-3 animate-spin"}):(0,w.jsx)(es,{className:"w-3 h-3"}),"Save Pricing"]})]})]}),(0,w.jsx)("div",{className:"flex items-center gap-0 border-b border-white/5 overflow-x-auto",children:["all",...C].map(e=>{let t=i===e,n="all"===e?null:wK[e];return(0,w.jsx)("button",{onClick:()=>r(e),className:`px-4 py-3 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${t?"border-white text-white":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:n?(0,w.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,w.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:n.dot}}),n.label]}):"All Providers"},e)})}),(0,w.jsx)("div",{children:("all"===i?C:[i]).map(e=>{let t=Object.entries(n).filter(([,t])=>"all"===e||t.provider===e);if(0===t.length&&f!==e)return null;let i=wK[e];return(0,w.jsxs)("div",{className:"border-b border-white/5 last:border-0",children:[(0,w.jsxs)("div",{className:`flex items-center justify-between px-5 py-2 ${i.bg}`,children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:i.dot}}),(0,w.jsx)("span",{className:`text-xs font-semibold uppercase tracking-wider ${i.text}`,children:i.label}),(0,w.jsxs)("span",{className:"text-xs text-zinc-600",children:["(",t.length," models)"]})]}),(0,w.jsxs)("button",{onClick:()=>{m(f===e?null:e),x(""),v(""),k(""),N(!1)},className:"flex items-center gap-1 text-xs text-zinc-500 hover:text-white transition-colors",children:[(0,w.jsx)(en.Plus,{className:"w-3 h-3"})," Add model"]})]}),t.length>0&&(0,w.jsxs)("div",{className:"grid grid-cols-[1fr_130px_130px_36px] gap-2 px-5 py-1.5 text-xs text-zinc-600 border-b border-white/3",children:[(0,w.jsx)("span",{children:"Model ID"}),(0,w.jsx)("span",{className:"text-right",children:"Input / 1M tokens"}),(0,w.jsx)("span",{className:"text-right",children:"Output / 1M tokens"}),(0,w.jsx)("span",{})]}),t.map(([e,t])=>(0,w.jsxs)("div",{className:"grid grid-cols-[1fr_130px_130px_36px] gap-2 items-center px-5 py-2.5 border-b border-white/3 last:border-0 hover:bg-white/2 transition-colors",children:[(0,w.jsxs)("span",{className:"text-xs font-mono text-zinc-300 truncate pr-2",children:[e,t._new&&(0,w.jsx)("span",{className:"ml-2 text-emerald-500 text-[10px]",children:"NEW"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-1 justify-end",children:[(0,w.jsx)("span",{className:"text-zinc-500 text-xs",children:"$"}),(0,w.jsx)("input",{type:"number",min:"0",step:"0.001",value:t.input_per_1m,onChange:t=>S(e,"input_per_1m",t.target.value),className:"w-20 bg-zinc-800 border border-white/10 text-white text-xs px-2 py-1 text-right focus:outline-none focus:border-white/30 transition-colors"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-1 justify-end",children:[(0,w.jsx)("span",{className:"text-zinc-500 text-xs",children:"$"}),(0,w.jsx)("input",{type:"number",min:"0",step:"0.001",value:t.output_per_1m,onChange:t=>S(e,"output_per_1m",t.target.value),className:"w-20 bg-zinc-800 border border-white/10 text-white text-xs px-2 py-1 text-right focus:outline-none focus:border-white/30 transition-colors"})]}),(0,w.jsx)("button",{onClick:()=>{s(t=>{let n={...t};return delete n[e],n}),d(!0)},className:"text-zinc-600 hover:text-red-400 transition-colors flex items-center justify-center",children:(0,w.jsx)(eN.X,{className:"w-3.5 h-3.5"})})]},e)),f===e&&(0,w.jsxs)("div",{className:"grid grid-cols-[1fr_130px_130px_36px] gap-2 items-center px-5 py-3 bg-zinc-900/80 border-t border-white/5",children:[j?(0,w.jsx)("input",{autoFocus:!0,placeholder:"model-id (e.g. my-custom-model)",value:g,onChange:e=>x(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(N(!1),x(""))},className:"bg-zinc-800 border border-white/20 text-white text-xs px-2 py-1.5 focus:outline-none focus:border-white/40 transition-colors placeholder:text-zinc-600"}):(0,w.jsxs)("select",{value:g,onChange:e=>{"__custom__"===e.target.value?(N(!0),x("")):x(e.target.value)},className:"bg-zinc-800 border border-white/20 text-white text-xs px-2 py-1.5 focus:outline-none focus:border-white/40 transition-colors",children:[(0,w.jsx)("option",{value:"",children:"-- select model --"}),(u[e]??[]).filter(e=>!n[e]).map(e=>(0,w.jsx)("option",{value:e,children:e},e)),(0,w.jsx)("option",{value:"__custom__",children:"Custom model ID..."})]}),(0,w.jsxs)("div",{className:"flex items-center gap-1 justify-end",children:[(0,w.jsx)("span",{className:"text-zinc-500 text-xs",children:"$"}),(0,w.jsx)("input",{placeholder:"0.000",value:b,onChange:e=>v(e.target.value),type:"number",min:"0",step:"0.001",className:"w-20 bg-zinc-800 border border-white/20 text-white text-xs px-2 py-1.5 text-right focus:outline-none focus:border-white/40 transition-colors placeholder:text-zinc-600"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-1 justify-end",children:[(0,w.jsx)("span",{className:"text-zinc-500 text-xs",children:"$"}),(0,w.jsx)("input",{placeholder:"0.000",value:y,onChange:e=>k(e.target.value),type:"number",min:"0",step:"0.001",className:"w-20 bg-zinc-800 border border-white/20 text-white text-xs px-2 py-1.5 text-right focus:outline-none focus:border-white/40 transition-colors placeholder:text-zinc-600"})]}),(0,w.jsx)("button",{onClick:()=>(e=>{if(!g.trim())return;let t=g.trim(),n=parseFloat(b)||0,i=parseFloat(y)||0;s(s=>({...s,[t]:{provider:e,input_per_1m:n,output_per_1m:i,_new:!0}})),x(""),v(""),k(""),m(null),N(!1),d(!0)})(e),className:"text-emerald-400 hover:text-emerald-300 transition-colors flex items-center justify-center",children:(0,w.jsx)(ft,{className:"w-4 h-4"})})]})]},e)})})]})}function w7(){let[e,t]=(0,O.useState)(null),[n,s]=(0,O.useState)({}),[i,r]=(0,O.useState)(!0),[o,a]=(0,O.useState)(!1),[l,c]=(0,O.useState)(null),[h,d]=(0,O.useState)(0),[u,p]=(0,O.useState)("all"),f=(0,O.useCallback)(async()=>{r(!0),c(null);try{let[e,n]=await Promise.all([fetch("/api/usage/summary"),fetch("/api/usage/pricing")]);if(!e.ok)throw Error(`Summary fetch failed: ${e.status}`);if(!n.ok)throw Error(`Pricing fetch failed: ${n.status}`);let[i,r]=await Promise.all([e.json(),n.json()]);t(i),s(r)}catch(e){c(e.message||"Failed to load usage data")}finally{r(!1)}},[]);(0,O.useEffect)(()=>{f()},[f]);let m=async()=>{if(confirm("Delete all usage logs? This cannot be undone.")){a(!0);try{await fetch("/api/usage/logs",{method:"DELETE"}),await f()}catch(e){c(e.message)}finally{a(!1)}}},g=[...e?.by_session??[],...(e?.by_schedule??[]).map(e=>({session_id:e.run_id,run_id:e.run_id,agent_id:e.agent_id,agents_used:e.agents_used,requests:e.requests,input_tokens:e.input_tokens,output_tokens:e.output_tokens,total_tokens:e.total_tokens,context_chars:0,estimated_cost:e.estimated_cost,models_used:e.models_used,first_ts:e.first_ts,last_ts:e.last_ts,source:"schedule",schedule_id:e.schedule_id}))].sort((e,t)=>(t.last_ts??"").localeCompare(e.last_ts??"")),x=g.filter(e=>"all"===u||("orchestrations"===u?"orchestration"===e.source||e.source?.startsWith("orchestration:"):"agents"===u?"orchestration"!==e.source&&!e.source?.startsWith("orchestration:")&&"unknown"!==e.session_id&&"schedule"!==e.source:"schedules"!==u||"schedule"===e.source)),b=x.slice(0,(h+1)*15),v=Math.max(...e?.by_model.map(e=>e.estimated_cost)??[0]);return(0,w.jsxs)("div",{className:"flex-1 overflow-y-auto bg-black text-white font-mono modern-scrollbar",children:[(0,w.jsx)("div",{className:"sticky top-0 z-10 border-b border-white/5 bg-black/90 backdrop-blur-sm px-6 md:px-10 py-4",children:(0,w.jsxs)("div",{className:"max-w-6xl mx-auto flex items-center justify-between gap-4",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h1",{className:"text-lg font-bold tracking-wider flex items-center gap-2",children:[(0,w.jsx)(wX.DollarSign,{className:"w-5 h-5 text-emerald-400"}),"USAGE & COSTS"]}),(0,w.jsx)("p",{className:"text-xs text-zinc-500 mt-0.5",children:"Token usage and cost tracking across all LLM calls"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsxs)("button",{onClick:f,disabled:i,className:"flex items-center gap-2 px-3 py-2 text-xs border border-white/10 text-zinc-400 hover:text-white hover:border-white/20 transition-all",children:[(0,w.jsx)(ez.RefreshCw,{className:`w-3.5 h-3.5 ${i?"animate-spin":""}`}),"Refresh"]}),(0,w.jsxs)("button",{onClick:m,disabled:o||i,className:"flex items-center gap-2 px-3 py-2 text-xs border border-red-900/50 text-red-400 hover:border-red-700 hover:text-red-300 transition-all",children:[(0,w.jsx)(F.Trash2,{className:"w-3.5 h-3.5"}),"Clear Logs"]})]})]})}),(0,w.jsxs)("div",{className:"max-w-6xl mx-auto px-6 md:px-10 py-8 space-y-8",children:[l&&(0,w.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-red-950/40 border border-red-800/40 text-red-300 text-sm",children:[(0,w.jsx)(eS,{className:"w-4 h-4 shrink-0"}),l]}),i&&!e&&(0,w.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[void 0,void 0,void 0,void 0].map((e,t)=>(0,w.jsx)("div",{className:"h-28 bg-zinc-900/80 border border-white/5 animate-pulse"},t))}),!i&&e&&0===e.total_requests&&(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-4 text-center",children:[(0,w.jsx)("div",{className:"p-4 bg-zinc-900 border border-white/5",children:(0,w.jsx)(wG,{className:"w-8 h-8 text-zinc-600"})}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-400 font-medium",children:"No usage data yet"}),(0,w.jsx)("p",{className:"text-zinc-600 text-sm mt-1",children:"Send a chat message to start tracking costs"})]})]}),e&&e.total_requests>0&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,w.jsx)(w3,{icon:wX.DollarSign,label:"Total Cost",value:wJ(e.total_cost),sub:"estimated USD",color:"#10b981"}),(0,w.jsx)(w3,{icon:wU,label:"Total Requests",value:e.total_requests.toLocaleString(),sub:"LLM calls",color:"#3b82f6"}),(0,w.jsx)(w3,{icon:fu,label:"Input Tokens",value:w0(e.total_input_tokens),sub:"prompt tokens",color:"#f59e0b"}),(0,w.jsx)(w3,{icon:N.Cpu,label:"Output Tokens",value:w0(e.total_output_tokens),sub:"completion tokens",color:"#8b5cf6"})]}),(0,w.jsxs)("div",{className:"bg-zinc-900/60 border border-white/5 p-5",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 mb-5",children:[(0,w.jsx)(wG,{className:"w-4 h-4 text-zinc-400"}),(0,w.jsx)("h2",{className:"text-sm font-semibold text-white tracking-wide",children:"Cost by Model"}),(0,w.jsx)("span",{className:"text-xs text-zinc-600",children:"sorted by spend"})]}),e.by_model.map(e=>(0,w.jsx)(w4,{stat:e,maxCost:v},e.model))]}),(0,w.jsxs)("div",{className:"bg-zinc-900/60 border border-white/5 p-5",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)(D.Clock,{className:"w-4 h-4 text-zinc-400"}),(0,w.jsx)("h2",{className:"text-sm font-semibold text-white tracking-wide",children:"Session History"}),(0,w.jsxs)("span",{className:"text-xs text-zinc-600",children:[g.length," sessions -- click to expand per-turn breakdown"]})]}),(0,w.jsxs)("div",{className:"flex items-center gap-3 text-xs text-zinc-500 flex-wrap",children:[(0,w.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,w.jsx)(fu,{className:"w-3 h-3 text-emerald-400"})," Chat"]}),(0,w.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,w.jsx)(Y,{className:"w-3 h-3 text-violet-400"})," Orchestration"]}),(0,w.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,w.jsx)(D.Clock,{className:"w-3 h-3 text-sky-400"})," Schedule"]}),(0,w.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,w.jsx)(wZ,{className:"w-3 h-3 text-fuchsia-400"})," System Prompt"]})]})]}),(0,w.jsxs)("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b border-white/5",children:[(0,w.jsx)("span",{className:"text-xs text-zinc-500 shrink-0",children:"Filter by"}),(0,w.jsxs)("select",{value:u,onChange:e=>{p(e.target.value),d(0)},className:"bg-zinc-800 border border-white/10 text-white text-xs px-2.5 py-1.5 focus:outline-none focus:border-white/30 transition-colors cursor-pointer appearance-none pr-6",style:{backgroundImage:"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")",backgroundRepeat:"no-repeat",backgroundPosition:"right 6px center"},children:[(0,w.jsx)("option",{value:"all",children:"All Sessions"}),(0,w.jsx)("option",{value:"orchestrations",children:"Orchestrations"}),(0,w.jsx)("option",{value:"agents",children:"Agents"}),(0,w.jsx)("option",{value:"schedules",children:"Schedules"})]}),(0,w.jsxs)("span",{className:"text-xs text-zinc-600 ml-auto",children:[x.length," result",1!==x.length?"s":""]})]}),b.map((e,t)=>(0,w.jsx)(w8,{s:e},`${e.session_id}-${e.run_id||""}-${t}`)),0===b.length&&(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 gap-2 text-zinc-700",children:[(0,w.jsx)(wG,{className:"w-6 h-6"}),(0,w.jsx)("p",{className:"text-xs",children:"No sessions match the selected filter"})]}),(h+1)*15<x.length&&(0,w.jsx)("div",{className:"flex justify-center mt-4 pt-4 border-t border-white/5",children:(0,w.jsxs)("button",{onClick:()=>d(e=>e+1),className:"px-4 py-2 text-xs border border-white/10 text-zinc-400 hover:text-white hover:border-white/20 transition-all",children:["Load More (",x.length-(h+1)*15," remaining)"]})})]})]}),Object.keys(n).length>0&&(0,w.jsx)(w9,{initialPricing:n,onSaved:s}),(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 bg-zinc-900/40 border border-white/5 text-xs text-zinc-500",children:[(0,w.jsx)(U,{className:"w-4 h-4 text-zinc-600 shrink-0 mt-0.5"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"font-medium text-zinc-400 mb-1",children:"About cost estimates"}),(0,w.jsxs)("p",{children:["Token counts are sourced from API response metadata for OpenAI, Anthropic, Gemini, Grok, and DeepSeek. Ollama uses its ",(0,w.jsx)("code",{children:"eval_count"})," field. AWS Bedrock does not expose token counts directly, so tokens are estimated from character length (chars / 4) -- costs for Bedrock calls may be less accurate. Edit prices above and click ",(0,w.jsx)("strong",{children:"Save Pricing"})," to update rates used for future cost calculations."]})]})]})]})]})}let Oe=(0,H.default)("pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Ot=(0,H.default)("toggle-left",[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]]),On=(0,H.default)("toggle-right",[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]]),Os=[{label:"Every day at...",buildExpr:e=>`0 ${e} * * *`},{label:"Every weekday at...",buildExpr:e=>`0 ${e} * * 1-5`},{label:"Every Monday at...",buildExpr:e=>`0 ${e} * * 1`},{label:"Every Saturday at...",buildExpr:e=>`0 ${e} * * 6`},{label:"Every Sunday at...",buildExpr:e=>`0 ${e} * * 0`},{label:"1st of every month at...",buildExpr:e=>`0 ${e} 1 * *`},{label:"Custom expression",buildExpr:()=>""}];function Oi(e){if(!e)return"";let t=e.trim().split(/\s+/);if(5!==t.length)return e;let[n,s,i,r,o]=t,a=parseInt(s),l=parseInt(n),c=isNaN(a)||isNaN(l)?`${s}:${n} UTC`:`${a.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")} UTC`,h=e=>{let t=["th","st","nd","rd"],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])},d={1:"January",2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"}[r]||"",u={0:"Sunday",7:"Sunday",1:"Monday",2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday",6:"Saturday","1-5":"weekday"}[o],p=parseInt(i);if("*"===i&&"*"===r&&"*"===o)return`Every day at ${c}`;if("*"!==i&&"*"===o&&!isNaN(p)){let e=d?` of ${d}`:" of every month";return`On the ${h(p)}${e} at ${c}`}if("*"===i&&"*"!==o&&u){let e=d?` in ${d}`:"";return`Every ${u}${e} at ${c}`}if("*"!==r&&"*"===i&&"*"===o)return`Every day in ${d} at ${c}`;if("*"!==i&&"*"!==o&&!isNaN(p)&&u){let e=d?` of ${d}`:" of every month",t=d?` in ${d}`:"";return`On the ${h(p)}${e} or every ${u}${t} at ${c}`}return e}function Or(e){if(!e)return"--";try{return new Date(e).toLocaleString()}catch{return e}}function Oo(){return{name:"",description:"",enabled:!0,target_type:"agent",target_id:"",prompt:"",schedule_type:"interval",interval_value:30,interval_unit:"minutes",cron_expression:"0 9 * * *",missed_run_policy:"skip"}}let Oa=()=>{let[e,t]=(0,O.useState)([]),[n,s]=(0,O.useState)([]),[i,r]=(0,O.useState)([]),[o,a]=(0,O.useState)(!1),[l,c]=(0,O.useState)(!1),[h,d]=(0,O.useState)(null),[u,p]=(0,O.useState)(Oo()),[f,m]=(0,O.useState)(!1),[g,x]=(0,O.useState)(new Set),[b,v]=(0,O.useState)(null),[y,k]=(0,O.useState)(0),[j,N]=(0,O.useState)(9),[S,z]=(0,O.useState)(!0),C=(e,t=!0)=>{v({msg:e,ok:t}),setTimeout(()=>v(null),3e3)},T=(0,O.useCallback)(async()=>{a(!0);try{let[e,n,i]=await Promise.all([fetch("/api/schedules"),fetch("/api/agents"),fetch("/api/orchestrations")]);e.ok&&t(await e.json()),n.ok&&s(await n.json()),i.ok&&r(await i.json())}finally{a(!1)}},[]);function A(){c(!1),d(null)}async function M(){if(!u.name.trim())return void C("Name is required",!1);if(!u.target_id)return void C("Please select a target agent or orchestration",!1);if(!u.prompt.trim())return void C("Prompt is required",!1);if("interval"===u.schedule_type&&(!u.interval_value||u.interval_value<1))return void C("Interval value must be at least 1",!1);if("cron"===u.schedule_type&&!u.cron_expression?.trim())return void C("Cron expression is required",!1);m(!0);try{let e={...u};"interval"===u.schedule_type?(delete e.cron_expression,delete e.missed_run_policy):(delete e.interval_value,delete e.interval_unit);let n=h?`/api/schedules/${h}`:"/api/schedules",s=await fetch(n,{method:h?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(s.ok){let e=await s.json();t(t=>h?t.map(t=>t.id===h?e:t):[...t,e]),A(),C(h?"Schedule updated":"Schedule created")}else{let e=await s.json().catch(()=>({}));C(e.detail||"Failed to save",!1)}}finally{m(!1)}}async function E(e){let n=await fetch(`/api/schedules/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!e.enabled})});if(n.ok){let s=await n.json();t(t=>t.map(t=>t.id===e.id?s:t))}}async function R(e){!confirm("Delete this schedule?")||(await fetch(`/api/schedules/${e}`,{method:"DELETE"})).ok&&(t(t=>t.filter(t=>t.id!==e)),C("Schedule deleted"))}async function $(e){x(t=>new Set(t).add(e));try{(await fetch(`/api/schedules/${e}/run`,{method:"POST"})).ok?C("Schedule triggered successfully"):C("Failed to trigger schedule",!1)}finally{x(t=>{let n=new Set(t);return n.delete(e),n})}}function Q(e){return"agent"===e.target_type?n.find(t=>t.id===e.target_id)?.name??e.target_id:i.find(t=>t.id===e.target_id)?.name??e.target_id}return(0,O.useEffect)(()=>{T()},[T]),(0,w.jsxs)("div",{className:"flex flex-col h-full overflow-hidden font-mono",children:[b&&(0,w.jsxs)("div",{className:`fixed bottom-6 right-6 z-50 flex items-center gap-2 px-4 py-3 text-sm shadow-lg ${b.ok?"bg-emerald-900/90 text-emerald-200 border border-emerald-700":"bg-red-900/90 text-red-200 border border-red-700"}`,children:[b.ok?(0,w.jsx)(ed,{className:"h-4 w-4"}):(0,w.jsx)(X,{className:"h-4 w-4"}),b.msg]}),(0,w.jsxs)("div",{className:"px-6 py-4 border-b border-zinc-800 shrink-0 pr-14 flex items-center justify-between",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("h1",{className:"text-2xl font-bold text-zinc-100",children:"Schedules"}),(0,w.jsx)("p",{className:"text-zinc-500 text-xs mt-0.5",children:"Automate agent and orchestration runs on a recurring schedule"})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("button",{onClick:T,className:"p-2 text-zinc-500 hover:text-white hover:bg-white/5 transition-colors",title:"Refresh",children:(0,w.jsx)(ez.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),(0,w.jsxs)("button",{onClick:function(){d(null),p(Oo()),k(0),N(9),z(!0),c(!0)},className:"flex items-center gap-2 px-4 py-2 bg-white text-black text-sm font-semibold hover:bg-zinc-200 transition-colors",children:[(0,w.jsx)(en.Plus,{className:"h-4 w-4"}),"New Schedule"]})]})]}),(0,w.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,w.jsx)("div",{className:`flex flex-col overflow-hidden transition-all ${l?"w-1/2 border-r border-zinc-800":"w-full"}`,children:(0,w.jsx)("div",{className:"flex-1 overflow-y-auto",children:o&&0===e.length?(0,w.jsx)("div",{className:"flex items-center justify-center h-32 text-zinc-600 text-xs",children:"Loading..."}):0===e.length?(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 gap-4 text-zinc-700 px-8 text-center",children:[(0,w.jsx)(D.Clock,{className:"h-10 w-10"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-sm font-semibold text-zinc-500",children:"No schedules yet"}),(0,w.jsx)("p",{className:"text-xs mt-1",children:'Click "New Schedule" to automate your first agent run'})]})]}):(0,w.jsxs)("table",{className:"w-full text-xs",children:[(0,w.jsx)("thead",{children:(0,w.jsxs)("tr",{className:"border-b border-zinc-800 text-zinc-500 text-left",children:[(0,w.jsx)("th",{className:"px-4 py-3 font-medium",children:"Name"}),(0,w.jsx)("th",{className:"px-4 py-3 font-medium",children:"Target"}),(0,w.jsx)("th",{className:"px-4 py-3 font-medium",children:"Schedule"}),(0,w.jsx)("th",{className:"px-4 py-3 font-medium",children:"Next Run"}),(0,w.jsx)("th",{className:"px-4 py-3 font-medium",children:"Last Run"}),(0,w.jsx)("th",{className:"px-4 py-3 font-medium text-right",children:"Actions"})]})}),(0,w.jsx)("tbody",{children:e.map(e=>(0,w.jsxs)("tr",{className:"border-b border-zinc-900 hover:bg-white/3 transition-colors group",children:[(0,w.jsxs)("td",{className:"px-4 py-3",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${e.enabled?"bg-emerald-400":"bg-zinc-600"}`}),(0,w.jsx)("span",{className:"font-semibold text-white truncate max-w-[140px]",title:e.name,children:e.name})]}),e.description&&(0,w.jsx)("p",{className:"text-zinc-600 truncate max-w-[160px] mt-0.5",title:e.description,children:e.description})]}),(0,w.jsx)("td",{className:"px-4 py-3",children:(0,w.jsxs)("div",{className:"flex items-center gap-1.5 text-zinc-400",children:["agent"===e.target_type?(0,w.jsx)(_.Bot,{className:"h-3 w-3 shrink-0 text-sky-400"}):(0,w.jsx)(P.Workflow,{className:"h-3 w-3 shrink-0 text-purple-400"}),(0,w.jsx)("span",{className:"truncate max-w-[100px]",title:Q(e),children:Q(e)})]})}),(0,w.jsx)("td",{className:"px-4 py-3 text-zinc-300",children:"interval"===e.schedule_type?`Every ${e.interval_value??"?"} ${e.interval_unit??"minutes"}`:Oi(e.cron_expression??"")}),(0,w.jsx)("td",{className:"px-4 py-3 text-zinc-500",children:Or(e.next_run_at)}),(0,w.jsx)("td",{className:"px-4 py-3 text-zinc-600",children:Or(e.last_run_at)}),(0,w.jsx)("td",{className:"px-4 py-3",children:(0,w.jsxs)("div",{className:"flex items-center gap-1 justify-end",children:[(0,w.jsx)("button",{onClick:()=>E(e),className:"p-1.5 text-zinc-500 hover:text-white transition-colors",title:e.enabled?"Disable":"Enable",children:e.enabled?(0,w.jsx)(On,{className:"h-4 w-4 text-emerald-400"}):(0,w.jsx)(Ot,{className:"h-4 w-4"})}),(0,w.jsx)("button",{onClick:()=>$(e.id),disabled:g.has(e.id),className:"p-1.5 text-zinc-500 hover:text-emerald-400 transition-colors disabled:opacity-40",title:"Run Now",children:(0,w.jsx)(e_,{className:`h-3.5 w-3.5 ${g.has(e.id)?"animate-pulse":""}`})}),(0,w.jsx)("button",{onClick:()=>(function(e){if(d(e.id),p({name:e.name,description:e.description??"",enabled:e.enabled,target_type:e.target_type,target_id:e.target_id,prompt:e.prompt,schedule_type:e.schedule_type,interval_value:e.interval_value??30,interval_unit:e.interval_unit??"minutes",cron_expression:e.cron_expression??"0 9 * * *",missed_run_policy:e.missed_run_policy??"skip"}),e.cron_expression){let t=e.cron_expression.split(" ");if(5===t.length){let e=parseInt(t[1]);isNaN(e)||N(e)}}k(6),z(!1),c(!0)})(e),className:"p-1.5 text-zinc-500 hover:text-white transition-colors",title:"Edit",children:(0,w.jsx)(Oe,{className:"h-3.5 w-3.5"})}),(0,w.jsx)("button",{onClick:()=>R(e.id),className:"p-1.5 text-zinc-500 hover:text-red-400 transition-colors",title:"Delete",children:(0,w.jsx)(F.Trash2,{className:"h-3.5 w-3.5"})})]})})]},e.id))})]})})}),l&&(0,w.jsxs)("div",{className:"w-1/2 flex flex-col overflow-hidden",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-zinc-800 shrink-0",children:[(0,w.jsx)("h2",{className:"text-sm font-semibold text-white",children:h?"Edit Schedule":"New Schedule"}),(0,w.jsx)("button",{onClick:A,className:"text-zinc-500 hover:text-white text-xs",children:"? Cancel"})]}),(0,w.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-5",children:[(0,w.jsxs)("div",{className:"border border-zinc-800 bg-zinc-950",children:[(0,w.jsxs)("button",{onClick:()=>z(e=>!e),className:"w-full flex items-center justify-between px-4 py-3 text-xs text-zinc-400 hover:text-white transition-colors",children:[(0,w.jsxs)("span",{className:"flex items-center gap-2",children:[(0,w.jsx)(fn,{className:"h-3.5 w-3.5 text-sky-400"}),(0,w.jsx)("span",{className:"font-semibold",children:"How to create schedules"})]}),S?(0,w.jsx)(eT,{className:"h-3.5 w-3.5"}):(0,w.jsx)(ei.ChevronDown,{className:"h-3.5 w-3.5"})]}),S&&(0,w.jsxs)("div",{className:"px-4 pb-4 text-xs text-zinc-500 space-y-3 border-t border-zinc-800",children:[(0,w.jsxs)("div",{className:"pt-3",children:[(0,w.jsx)("p",{className:"text-zinc-300 font-semibold mb-1",children:"Interval -- run every N minutes/hours/days"}),(0,w.jsxs)("ul",{className:"space-y-1 text-zinc-500",children:[(0,w.jsxs)("li",{children:["? ",(0,w.jsx)("span",{className:"text-zinc-400",children:"Every 5 minutes"})," -- monitor a feed, poll an API"]}),(0,w.jsxs)("li",{children:["? ",(0,w.jsx)("span",{className:"text-zinc-400",children:"Every 2 hours"})," -- periodic summaries or reports"]}),(0,w.jsxs)("li",{children:["? ",(0,w.jsx)("span",{className:"text-zinc-400",children:"Every 1 day"})," -- daily digest or cleanup tasks"]})]}),(0,w.jsx)("p",{className:"text-zinc-600 mt-1.5",children:"Interval restarts from the last run time. If the server was offline and the schedule is overdue, it runs immediately on restart."})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-300 font-semibold mb-1",children:"Cron / Fixed Time -- run at specific times"}),(0,w.jsxs)("ul",{className:"space-y-1 text-zinc-500",children:[(0,w.jsxs)("li",{children:["? ",(0,w.jsx)("span",{className:"text-zinc-400",children:"Every day at 9 AM"})," -- morning standup report"]}),(0,w.jsxs)("li",{children:["? ",(0,w.jsx)("span",{className:"text-zinc-400",children:"Every Monday at 6 PM"})," -- weekly digest"]}),(0,w.jsxs)("li",{children:["? ",(0,w.jsx)("span",{className:"text-zinc-400",children:"1st of month"})," -- monthly invoice summary"]})]}),(0,w.jsx)("p",{className:"text-zinc-600 mt-1.5",children:"If a run was missed while offline, choose whether to run immediately or skip to the next scheduled time."})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-300 font-semibold mb-1",children:"Prompt"}),(0,w.jsx)("p",{className:"text-zinc-500",children:"The prompt is what the agent will receive each time the schedule fires. Think of it as a standing instruction."})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-zinc-300 font-semibold mb-1",children:"Messaging notifications"}),(0,w.jsx)("p",{className:"text-zinc-500",children:"If the selected agent has a connected messaging channel (Slack, Telegram, etc.), the result is sent there automatically after each run."})]})]})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"block text-xs text-zinc-400 mb-1.5 font-semibold",children:["Name ",(0,w.jsx)("span",{className:"text-red-400",children:"*"})]}),(0,w.jsx)("input",{value:u.name,onChange:e=>p(t=>({...t,name:e.target.value})),placeholder:"e.g. Daily Sales Report",className:"w-full bg-zinc-900 border border-zinc-700 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:outline-none focus:border-zinc-500"})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"block text-xs text-zinc-400 mb-1.5 font-semibold",children:"Description"}),(0,w.jsx)("input",{value:u.description,onChange:e=>p(t=>({...t,description:e.target.value})),placeholder:"Optional short description",className:"w-full bg-zinc-900 border border-zinc-700 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:outline-none focus:border-zinc-500"})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"block text-xs text-zinc-400 mb-1.5 font-semibold",children:"Run as"}),(0,w.jsx)("div",{className:"flex gap-2",children:["agent","orchestration"].map(e=>(0,w.jsxs)("button",{onClick:()=>p(t=>({...t,target_type:e,target_id:""})),className:`flex items-center gap-2 px-4 py-2 text-xs font-medium border transition-all ${u.target_type===e?"border-white bg-white text-black":"border-zinc-700 text-zinc-400 hover:text-white hover:border-zinc-500"}`,children:["agent"===e?(0,w.jsx)(_.Bot,{className:"h-3.5 w-3.5"}):(0,w.jsx)(P.Workflow,{className:"h-3.5 w-3.5"}),"agent"===e?"Agent":"Orchestration"]},e))})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"block text-xs text-zinc-400 mb-1.5 font-semibold",children:["agent"===u.target_type?"Agent":"Orchestration"," ",(0,w.jsx)("span",{className:"text-red-400",children:"*"})]}),(0,w.jsxs)("select",{value:u.target_id,onChange:e=>p(t=>({...t,target_id:e.target.value})),className:"w-full bg-zinc-900 border border-zinc-700 px-3 py-2 text-sm text-white focus:outline-none focus:border-zinc-500",children:[(0,w.jsxs)("option",{value:"",children:["Select ","agent"===u.target_type?"an agent":"an orchestration","..."]}),("agent"===u.target_type?n:i).map(e=>(0,w.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"block text-xs text-zinc-400 mb-1.5 font-semibold",children:["Prompt ",(0,w.jsx)("span",{className:"text-red-400",children:"*"}),(0,w.jsx)("span",{className:"ml-2 font-normal text-zinc-600",children:"What should the agent do each time it runs?"})]}),(0,w.jsx)("textarea",{value:u.prompt,onChange:e=>p(t=>({...t,prompt:e.target.value})),placeholder:"e.g. Generate a daily summary of yesterday's sales data and highlight any anomalies.",rows:4,className:"w-full bg-zinc-900 border border-zinc-700 px-3 py-2 text-sm text-white placeholder-zinc-600 focus:outline-none focus:border-zinc-500 resize-none"})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"block text-xs text-zinc-400 mb-1.5 font-semibold",children:"Schedule Type"}),(0,w.jsx)("div",{className:"flex gap-2",children:["interval","cron"].map(e=>(0,w.jsxs)("button",{onClick:()=>p(t=>({...t,schedule_type:e})),className:`flex items-center gap-2 px-4 py-2 text-xs font-medium border transition-all ${u.schedule_type===e?"border-white bg-white text-black":"border-zinc-700 text-zinc-400 hover:text-white hover:border-zinc-500"}`,children:[(0,w.jsx)(D.Clock,{className:"h-3.5 w-3.5"}),"interval"===e?"Interval":"Fixed Time (Cron)"]},e))})]}),"interval"===u.schedule_type&&(0,w.jsxs)("div",{className:"bg-zinc-900/60 border border-zinc-800 p-4 space-y-3",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("span",{className:"text-xs text-zinc-400 shrink-0",children:"Run every"}),(0,w.jsx)("input",{type:"number",min:1,value:u.interval_value??30,onChange:e=>p(t=>({...t,interval_value:parseInt(e.target.value)||1})),className:"w-20 bg-zinc-800 border border-zinc-700 px-2 py-1.5 text-sm text-white text-center focus:outline-none focus:border-zinc-500"}),(0,w.jsxs)("select",{value:u.interval_unit??"minutes",onChange:e=>p(t=>({...t,interval_unit:e.target.value})),className:"bg-zinc-800 border border-zinc-700 px-2 py-1.5 text-sm text-white focus:outline-none focus:border-zinc-500",children:[(0,w.jsx)("option",{value:"minutes",children:"minutes"}),(0,w.jsx)("option",{value:"hours",children:"hours"}),(0,w.jsx)("option",{value:"days",children:"days"})]})]}),(0,w.jsxs)("p",{className:"text-xs text-zinc-600",children:["Runs every ",u.interval_value??"?"," ",u.interval_unit??"minutes"," from the last run. If overdue after a restart, it runs immediately."]})]}),"cron"===u.schedule_type&&(0,w.jsxs)("div",{className:"bg-zinc-900/60 border border-zinc-800 p-4 space-y-4",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"block text-xs text-zinc-500 mb-1.5",children:"Quick preset"}),(0,w.jsx)("select",{value:y,onChange:e=>(function(e){if(k(e),e<Os.length-1){let t=Os[e].buildExpr(j);p(e=>({...e,cron_expression:t}))}})(parseInt(e.target.value)),className:"w-full bg-zinc-800 border border-zinc-700 px-2 py-1.5 text-sm text-white focus:outline-none focus:border-zinc-500",children:Os.map((e,t)=>(0,w.jsx)("option",{value:t,children:e.label},t))})]}),y<Os.length-1&&(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("span",{className:"text-xs text-zinc-400",children:"At hour (UTC)"}),(0,w.jsx)("select",{value:j,onChange:e=>(function(e){if(N(e),y<Os.length-1){let t=Os[y].buildExpr(e);p(e=>({...e,cron_expression:t}))}})(parseInt(e.target.value)),className:"bg-zinc-800 border border-zinc-700 px-2 py-1.5 text-sm text-white focus:outline-none focus:border-zinc-500",children:Array.from({length:24},(e,t)=>(0,w.jsxs)("option",{value:t,children:[t.toString().padStart(2,"0"),":00 UTC"]},t))})]}),(0,w.jsxs)("div",{children:[(0,w.jsxs)("label",{className:"block text-xs text-zinc-500 mb-1.5",children:["Cron expression",(0,w.jsx)("span",{className:"ml-2 text-zinc-700",children:"minute hour day-of-month month day-of-week"})]}),(0,w.jsx)("input",{value:u.cron_expression??"",onChange:e=>p(t=>({...t,cron_expression:e.target.value})),placeholder:"0 9 * * *",className:"w-full bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm text-white font-mono focus:outline-none focus:border-zinc-500"}),u.cron_expression&&(0,w.jsx)("p",{className:"text-xs text-emerald-400 mt-1",children:Oi(u.cron_expression)})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"block text-xs text-zinc-500 mb-2",children:"If a run was missed while offline"}),(0,w.jsx)("div",{className:"space-y-2",children:[{value:"run_immediately",label:"Run immediately when server starts",desc:"Catches up the missed run once, then resumes normal schedule"},{value:"skip",label:"Skip and wait for the next scheduled time",desc:"Ignores the missed run, next run fires at the correct future time"}].map(e=>(0,w.jsxs)("label",{className:"flex items-start gap-3 cursor-pointer group",children:[(0,w.jsx)("input",{type:"radio",name:"missed_run_policy",value:e.value,checked:u.missed_run_policy===e.value,onChange:()=>p(t=>({...t,missed_run_policy:e.value})),className:"mt-0.5 shrink-0"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-xs text-zinc-300",children:e.label}),(0,w.jsx)("p",{className:"text-[11px] text-zinc-600",children:e.desc})]})]},e.value))})]})]}),(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("label",{className:"text-xs text-zinc-400 font-semibold",children:"Enabled"}),(0,w.jsx)("button",{onClick:()=>p(e=>({...e,enabled:!e.enabled})),className:"text-zinc-400 hover:text-white transition-colors",children:u.enabled?(0,w.jsx)(On,{className:"h-5 w-5 text-emerald-400"}):(0,w.jsx)(Ot,{className:"h-5 w-5"})}),(0,w.jsx)("span",{className:"text-xs text-zinc-600",children:u.enabled?"Schedule will run automatically":"Schedule is paused"})]}),(0,w.jsx)("div",{className:"pt-2 pb-4",children:(0,w.jsx)("button",{onClick:M,disabled:f,className:"w-full py-2.5 bg-white text-black text-sm font-semibold hover:bg-zinc-200 disabled:opacity-50 transition-colors",children:f?"Saving...":h?"Save Changes":"Create Schedule"})})]})]})]})]})},Ol=(0,H.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),Oc=(0,H.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);function Oh(e){return(e.steps||[]).map(e=>e.agent_id).filter(Boolean)}function Od(e,t){let n=e.tools||[];return t.filter(e=>n.some(t=>t.startsWith(`${e.name}__`))).map(e=>e.name)}function Ou(e,t){return t.filter(t=>(e.tools||[]).includes(t.name)).map(e=>e.name)}function Op({title:e,icon:t,items:n,selected:s,locked:i,getId:r,getLabel:o,getDesc:a,onToggle:l}){let[c,h]=(0,O.useState)(!1);if(0===n.length)return null;let d=n.filter(e=>s.has(r(e))).length;return(0,w.jsxs)("div",{className:"border border-zinc-800",children:[(0,w.jsxs)("button",{onClick:()=>h(e=>!e),className:"w-full flex items-center gap-2 px-4 py-3 bg-zinc-900 hover:bg-zinc-800 transition-colors",children:[(0,w.jsx)(t,{className:"h-4 w-4 text-zinc-400"}),(0,w.jsx)("span",{className:"text-xs font-bold uppercase tracking-wider text-zinc-400",children:e}),(0,w.jsxs)("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-zinc-600 font-mono",children:[d,"/",n.length,c?(0,w.jsx)(er.ChevronRight,{className:"h-3 w-3"}):(0,w.jsx)(ei.ChevronDown,{className:"h-3 w-3"})]})]}),!c&&(0,w.jsx)("div",{className:"divide-y divide-zinc-800/60 max-h-[400px] overflow-y-auto",children:n.map((e,t)=>{let n=r(e)??`item-${t}`,c=s.has(r(e)),h=i.has(r(e)),d=a?.(e);return(0,w.jsxs)("div",{role:"checkbox","aria-checked":c,onClick:()=>{let t=r(e);!h&&t&&l(t,!c)},className:`flex items-start gap-3 px-4 py-3 transition-colors select-none ${h?"opacity-60 cursor-not-allowed":"cursor-pointer hover:bg-zinc-900/60"} ${c?"bg-zinc-900/40":""}`,children:[(0,w.jsx)("div",{className:`mt-0.5 h-4 w-4 flex-shrink-0 flex items-center justify-center border transition-colors ${c?"bg-white border-white":"bg-zinc-950 border-zinc-700"}`,children:c&&(0,w.jsx)("svg",{className:"h-2.5 w-2.5 text-black",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,w.jsx)("polyline",{points:"2,6 5,9 10,3"})})}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,w.jsx)("span",{className:"text-sm font-bold text-zinc-200",children:o(e)}),h&&(0,w.jsx)("span",{className:"text-[9px] uppercase font-bold px-1.5 py-0.5 bg-zinc-800 border border-zinc-700 text-zinc-500 tracking-wider",children:"auto"})]}),d&&(0,w.jsx)("p",{className:"text-xs text-zinc-500 mt-0.5 line-clamp-1",children:d}),(0,w.jsx)("p",{className:"text-[10px] text-zinc-700 font-mono mt-0.5",children:r(e)})]})]},n||`fallback-${t}`)})})]})}function Of(){let[e,t]=(0,O.useState)(null),[n,s]=(0,O.useState)(!1),[i,r]=(0,O.useState)(!1),[o,a]=(0,O.useState)(null),[l,c]=(0,O.useState)(`synapse_export_${new Date().toISOString().slice(0,10)}`),[h,d]=(0,O.useState)(new Set),[u,p]=(0,O.useState)(new Set),[f,m]=(0,O.useState)(new Set),[g,x]=(0,O.useState)(new Set),[b,v]=(0,O.useState)(new Set),[y,k]=(0,O.useState)(new Set),[j,N]=(0,O.useState)(new Set),S=async()=>{s(!0),a(null);try{let e=await fetch("/api/export/data");if(!e.ok)throw Error("Failed to load export data");t(await e.json())}catch(e){a(e.message)}finally{s(!1)}},z=(0,O.useCallback)((e,t,n)=>{let s=new Set;for(let t of e){let e=n.orchestrations.find(e=>e.id===t);e&&Oh(e).forEach(e=>s.add(e))}let i=new Set([...t,...s]),r=new Set,o=new Set;for(let e of i){let t=n.agents.find(t=>t.id===e);t&&(Od(t,n.mcp_servers).forEach(e=>r.add(e)),Ou(t,n.custom_tools).forEach(e=>o.add(e)))}v(s),k(r),N(o),p(e=>new Set([...e,...s])),m(e=>new Set([...e,...r])),x(e=>new Set([...e,...o]))},[]),C=e?.custom_tools.some(e=>g.has(e.name)&&"python"===e.tool_type),M=h.size+u.size+f.size+g.size,E=async()=>{if(0!==M){r(!0);try{let e=await fetch("/api/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orchestration_ids:[...h],agent_ids:[...u],mcp_server_names:[...f],custom_tool_names:[...g]})});if(!e.ok)throw Error("Export failed");let t=new Blob([JSON.stringify(await e.json(),null,2)],{type:"application/json"}),n=Object.assign(document.createElement("a"),{href:URL.createObjectURL(t),download:`${l||"synapse_export"}.json`});n.click(),URL.revokeObjectURL(n.href)}catch(e){a(e.message)}finally{r(!1)}}};return e?(0,w.jsxs)("div",{className:"space-y-6",children:[C&&(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 border border-yellow-900/50 bg-yellow-950/10",children:[(0,w.jsx)(eS,{className:"h-4 w-4 text-yellow-500 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-yellow-400 text-xs font-bold uppercase tracking-wider",children:"Python Tool Warning"}),(0,w.jsxs)("p",{className:"text-yellow-600 text-xs mt-1 leading-relaxed",children:["One or more selected agents use a custom Python tool. Python code is exported as-is — make sure it does ",(0,w.jsx)("strong",{className:"text-yellow-500",children:"not contain hardcoded secrets, API keys, or passwords"}),"."]})]})]}),(0,w.jsxs)("div",{className:"space-y-0 border border-zinc-800 divide-y divide-zinc-800",children:[(0,w.jsx)(Op,{title:"Orchestrations",icon:P.Workflow,items:e.orchestrations,selected:h,locked:new Set,getId:e=>e.id,getLabel:e=>e.name,getDesc:e=>e.description,onToggle:(t,n)=>{let s=new Set(h);n?s.add(t):s.delete(t),d(s),e&&z(s,u,e)}}),(0,w.jsx)(Op,{title:"Agents",icon:_.Bot,items:e.agents,selected:u,locked:b,getId:e=>e.id,getLabel:e=>e.name,getDesc:e=>e.description,onToggle:(t,n)=>{if(b.has(t))return;let s=new Set(u);n?s.add(t):s.delete(t),p(s),e&&z(h,s,e)}}),(0,w.jsx)(Op,{title:"MCP Servers",icon:A.Server,items:e.mcp_servers,selected:f,locked:y,getId:e=>e.name,getLabel:e=>e.label||e.name,onToggle:(e,t)=>{if(y.has(e))return;let n=new Set(f);t?n.add(e):n.delete(e),m(n)}}),(0,w.jsx)(Op,{title:"Custom Tools",icon:T.Wrench,items:e.custom_tools,selected:g,locked:j,getId:e=>e.name,getLabel:e=>e.generalName||e.name,getDesc:e=>e.description,onToggle:(e,t)=>{if(j.has(e))return;let n=new Set(g);t?n.add(e):n.delete(e),x(n)}})]}),e.orchestrations.length+e.agents.length+e.mcp_servers.length+e.custom_tools.length===0&&(0,w.jsx)("p",{className:"text-zinc-600 text-sm text-center py-4",children:"Nothing to export yet — add orchestrations, agents, MCP servers, or tools first."}),M>0&&(0,w.jsxs)("div",{className:"border border-zinc-800 bg-zinc-900/40 p-5 space-y-4",children:[(0,w.jsx)("h4",{className:"text-[10px] uppercase font-bold tracking-wider text-zinc-500",children:"Export File"}),(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("input",{type:"text",value:l,onChange:e=>c(e.target.value),className:"w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none placeholder:text-zinc-700 flex-1",placeholder:"synapse_export"}),(0,w.jsx)("span",{className:"text-zinc-600 text-sm font-mono",children:".json"})]}),(0,w.jsxs)("div",{className:"flex items-center justify-between gap-4 pt-1",children:[(0,w.jsxs)("p",{className:"text-xs text-zinc-500",children:[(0,w.jsx)("span",{className:"text-white font-bold",children:M})," item",1!==M?"s":""," selected",h.size>0&&` \xb7 ${h.size} orchestration${1!==h.size?"s":""}`,u.size>0&&` \xb7 ${u.size} agent${1!==u.size?"s":""}`,f.size>0&&` \xb7 ${f.size} MCP server${1!==f.size?"s":""}`,g.size>0&&` \xb7 ${g.size} tool${1!==g.size?"s":""}`]}),(0,w.jsxs)("button",{onClick:E,disabled:i,className:"flex items-center gap-2 px-6 py-2 bg-white text-black text-sm font-bold hover:bg-zinc-200 transition-colors disabled:opacity-50 shrink-0",children:[i?(0,w.jsx)(B.Loader2,{className:"h-4 w-4 animate-spin"}):(0,w.jsx)(Ol,{className:"h-4 w-4"}),i?"Exporting…":"Export & Download"]})]}),o&&(0,w.jsx)("p",{className:"text-red-400 text-xs",children:o})]})]}):(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"p-8 text-center border border-dashed border-zinc-800 bg-zinc-900/30",children:[(0,w.jsx)(eM,{className:"h-8 w-8 mx-auto text-zinc-700 mb-3"}),(0,w.jsx)("p",{className:"text-zinc-400 text-sm font-bold",children:"Export your configurations"}),(0,w.jsx)("p",{className:"text-zinc-600 text-xs mt-1",children:"Select orchestrations, agents, MCP servers, and tools to export as a portable bundle"}),(0,w.jsxs)("button",{onClick:S,disabled:n,className:"mt-4 flex items-center gap-2 px-5 py-2 bg-white text-black text-sm font-bold hover:bg-zinc-200 transition-colors disabled:opacity-50 mx-auto",children:[n?(0,w.jsx)(B.Loader2,{className:"h-4 w-4 animate-spin"}):(0,w.jsx)(eM,{className:"h-4 w-4"}),n?"Loading…":"Load Export Data"]})]}),o&&(0,w.jsxs)("div",{className:"flex items-center gap-2 text-red-400 text-xs p-3 border border-red-900/50 bg-red-950/10",children:[(0,w.jsx)(eu,{className:"h-4 w-4 flex-shrink-0"})," ",o]})]})}let Om=(0,H.default)("skip-forward",[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]),Og=(0,H.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Ox="w-full bg-zinc-900 border border-zinc-800 p-2 text-sm text-white focus:border-white focus:outline-none placeholder:text-zinc-700",Ob=new Set(["start_google_auth","search_gmail_messages","get_gmail_message_content","get_gmail_messages_content_batch","get_gmail_attachment_content","send_gmail_message","draft_gmail_message","get_gmail_thread_content","get_gmail_threads_content_batch","list_gmail_labels","manage_gmail_label","list_gmail_filters","manage_gmail_filter","modify_gmail_message_labels","batch_modify_gmail_message_labels","search_drive_files","get_drive_file_content","get_drive_file_download_url","list_drive_items","create_drive_folder","create_drive_file","import_to_google_doc","get_drive_file_permissions","check_drive_file_public_access","update_drive_file","get_drive_shareable_link","manage_drive_access","copy_drive_file","set_drive_file_permissions","list_calendars","get_events","manage_event","manage_out_of_office","manage_focus_time","query_freebusy","create_calendar","search_docs","get_doc_content","list_docs_in_folder","create_doc","modify_doc_text","find_and_replace_doc","insert_doc_elements","insert_doc_image","update_doc_headers_footers","batch_update_doc","inspect_doc_structure","debug_docs_runtime_info","create_table_with_data","debug_table_structure","export_doc_to_pdf","update_paragraph_style","get_doc_as_markdown","insert_doc_tab","delete_doc_tab","update_doc_tab","list_document_comments","manage_document_comment","list_spreadsheets","get_spreadsheet_info","read_sheet_values","modify_sheet_values","format_sheet_range","manage_conditional_formatting","create_spreadsheet","create_sheet","list_sheet_tables","append_table_rows","resize_sheet_dimensions","list_spreadsheet_comments","manage_spreadsheet_comment","create_presentation","get_presentation","batch_update_presentation","get_page","get_page_thumbnail","list_presentation_comments","manage_presentation_comment","create_form","get_form","set_publish_settings","get_form_response","list_form_responses","batch_update_form","list_task_lists","get_task_list","manage_task_list","list_tasks","get_task","manage_task","list_contacts","get_contact","search_contacts","manage_contact","list_contact_groups","get_contact_group","manage_contacts_batch","manage_contact_group"]);function Ov({preloadedBundle:e,onReset:t,onImportSuccess:n,onNavigate:s}){let i=(0,O.useRef)(null),[r,o]=(0,O.useState)(!1),[a,l]=(0,O.useState)("upload"),[c,h]=(0,O.useState)(null),[d,u]=(0,O.useState)(null),[p,f]=(0,O.useState)(!1),[m,g]=(0,O.useState)(!1),[x,b]=(0,O.useState)(!1),[v,y]=(0,O.useState)(new Set),[k,j]=(0,O.useState)(new Set),[S,z]=(0,O.useState)(new Set),[C,M]=(0,O.useState)(new Set),[E,R]=(0,O.useState)(new Set),[D,$]=(0,O.useState)(new Set),[Q,I]=(0,O.useState)(new Set),[L,q]=(0,O.useState)({}),[W,V]=(0,O.useState)({}),[F,H]=(0,O.useState)({}),[G,Z]=(0,O.useState)({}),[Y,K]=(0,O.useState)(null),J=(0,O.useRef)(null);J.current=c;let ee=(0,O.useRef)(v);ee.current=v;let et=(0,O.useRef)(k);et.current=k,(0,O.useEffect)(()=>{if(e)try{if(!e.synapse_export)throw Error("Not a valid Synapse export file.");h(e),u(null);let t=new Set((e.orchestrations||[]).map(e=>e.id)),n=new Set((e.agents||[]).map(e=>e.id)),s=new Set((e.mcp_servers||[]).map(e=>e.name)),i=new Set((e.custom_tools||[]).map(e=>e.name));y(t),j(n),z(s),M(i);let r={};for(let t of e.mcp_servers||[])t.env&&Object.keys(t.env).length>0&&(r[t.name]=Object.fromEntries(Object.keys(t.env).map(e=>[e,""])));q(r);let o={};for(let t of e.custom_tools||[])t.headers&&Object.keys(t.headers).length>0&&(o[t.name]=Object.fromEntries(Object.keys(t.headers).map(e=>[e,""])));V(o),en(t,n,e),es(),l("preview")}catch(e){u(e.message)}},[e]);let en=(0,O.useCallback)((e,t,n)=>{let s=new Set;for(let t of e){let e=n.orchestrations?.find(e=>e.id===t);e&&Oh(e).forEach(e=>s.add(e))}let i=new Set([...t,...s]),r=new Set,o=new Set;for(let e of i){let t=n.agents?.find(t=>t.id===e);t&&(Od(t,n.mcp_servers||[]).forEach(e=>r.add(e)),Ou(t,n.custom_tools||[]).forEach(e=>o.add(e)))}R(s),$(r),I(o),j(e=>new Set([...e,...s])),z(e=>new Set([...e,...r])),M(e=>new Set([...e,...o]))},[]),es=async()=>{try{let e=await fetch("/api/config");e.ok&&K(await e.json())}catch{}},er=e=>{let t=new FileReader;t.onload=e=>{try{let t=JSON.parse(e.target?.result);if(!t.synapse_export)throw Error("Not a valid Synapse export file.");h(t),u(null);let n=new Set((t.orchestrations||[]).map(e=>e.id)),s=new Set((t.agents||[]).map(e=>e.id)),i=new Set((t.mcp_servers||[]).map(e=>e.name)),r=new Set((t.custom_tools||[]).map(e=>e.name));y(n),j(s),z(i),M(r);let o={};for(let e of t.mcp_servers||[])e.env&&Object.keys(e.env).length>0&&(o[e.name]=Object.fromEntries(Object.keys(e.env).map(e=>[e,""])));q(o);let a={};for(let e of t.custom_tools||[])e.headers&&Object.keys(e.headers).length>0&&(a[e.name]=Object.fromEntries(Object.keys(e.headers).map(e=>[e,""])));V(a),en(n,s,t),es(),l("preview")}catch(e){u(e.message)}},t.readAsText(e)},eo=(0,O.useCallback)(e=>{e.preventDefault(),o(!1);let t=e.dataTransfer.files[0];t&&t.name.endsWith(".json")?er(t):u("Please drop a .json file.")},[]),ea=()=>{l("upload"),h(null),u(null),Z({}),y(new Set),j(new Set),z(new Set),M(new Set),R(new Set),$(new Set),I(new Set),q({}),V({}),H({}),g(!1),b(!1),K(null),t?.()},el=c&&([...S].some(e=>{let t=c.mcp_servers.find(t=>t.name===e);return t?.env&&Object.keys(t.env).length>0||!!t?.token})||[...C].some(e=>{let t=c.custom_tools.find(t=>t.name===e);return t?.headers&&Object.keys(t.headers).length>0})),ec=async()=>{if(c){f(!0);try{let e=m?{...c,agents:(c.agents||[]).map(e=>({...e,model:null,provider:null})),orchestrations:(c.orchestrations||[]).map(e=>({...e,steps:(e.steps||[]).map(e=>({...e,model:null}))}))}:c,t=await fetch("/api/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bundle:e,mcp_secrets:L,tool_secrets:W,mcp_tokens:F,selected_orchestration_ids:[...v],selected_agent_ids:[...k],selected_mcp_server_names:[...S],selected_custom_tool_names:[...C]})}),s=await t.json();if(!t.ok)throw Error(s.detail||"Import failed");Z(s.results||{}),l("results"),n?.()}catch(e){u(e.message)}finally{f(!1)}}};if("upload"===a)return(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:eo,onClick:()=>i.current?.click(),className:`flex flex-col items-center justify-center border border-dashed py-14 px-8 cursor-pointer transition-colors ${r?"border-white bg-zinc-800":"border-zinc-700 bg-zinc-900/30 hover:border-zinc-500 hover:bg-zinc-900/60"}`,children:[(0,w.jsx)(Oc,{className:"h-8 w-8 text-zinc-600 mb-3"}),(0,w.jsx)("p",{className:"text-zinc-300 text-sm font-bold",children:"Drop your export file here"}),(0,w.jsx)("p",{className:"text-zinc-600 text-xs mt-1",children:"or click to browse · JSON files only"}),(0,w.jsx)("input",{ref:i,type:"file",accept:".json",className:"sr-only",onChange:e=>{let t=e.target.files?.[0];t&&er(t),e.target.value=""}})]}),d&&(0,w.jsxs)("div",{className:"flex items-center gap-2 text-red-400 text-xs p-3 border border-red-900/50 bg-red-950/10",children:[(0,w.jsx)(eu,{className:"h-4 w-4 flex-shrink-0"})," ",d]})]});if("preview"===a&&c){let e=v.size+k.size+S.size+C.size,t=function(e){let t=new Map,n=(e,n)=>{e&&"default"!==e.trim().toLowerCase()&&(t.has(e)||t.set(e,new Set),t.get(e).add(n))};for(let t of e.orchestrations||[])for(let e of t.steps||[])n(e.model,`${t.name} › ${e.name}`);for(let t of e.agents||[])n(t.model,`Agent: ${t.name}`);let s=[];for(let[e,n]of t.entries())s.push({model:e,usedIn:Array.from(n)});return s}(c),n=t.length>0,i=(c.agents||[]).filter(e=>k.has(e.id)&&(e.tools||[]).some(e=>Ob.has(e))).map(e=>e.name);return(0,w.jsxs)("div",{className:"space-y-5",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border border-zinc-800 bg-zinc-900",children:[(0,w.jsx)(eM,{className:"h-4 w-4 text-zinc-400 flex-shrink-0"}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("p",{className:"text-sm font-bold text-zinc-200",children:"Bundle loaded"}),(0,w.jsxs)("p",{className:"text-[10px] text-zinc-600 font-mono",children:["v",c.version||"1.0"," · ",c.exported_at?new Date(c.exported_at).toLocaleString():"unknown date"]})]}),(0,w.jsx)("button",{onClick:ea,className:"text-xs text-zinc-500 hover:text-zinc-300 transition-colors underline underline-offset-2",children:"Change file"})]}),i.length>0&&Y?.is_connected===!1&&(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 border border-orange-900/50 bg-orange-950/10",children:[(0,w.jsx)(eS,{className:"h-4 w-4 text-orange-500 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("div",{className:"space-y-1.5",children:[(0,w.jsx)("p",{className:"text-orange-400 text-xs font-bold uppercase tracking-wider",children:"Google Workspace Not Connected"}),(0,w.jsxs)("p",{className:"text-orange-600 text-xs",children:["The following agent",1!==i.length?"s":""," use Google Workspace tools (Gmail, Drive, Calendar, etc.) but Google is not connected:"]}),(0,w.jsx)("ul",{className:"space-y-0.5 pl-1",children:i.map(e=>(0,w.jsxs)("li",{className:"text-orange-400 text-xs font-mono",children:["· ",e]},e))}),(0,w.jsxs)("p",{className:"text-orange-600 text-xs pt-0.5",children:["Connect your Google account in"," ",(0,w.jsx)("button",{onClick:()=>s?.("workspace"),className:"text-orange-400 font-bold underline underline-offset-2 hover:text-orange-300 transition-colors",children:"Integrations"}),", then come back and try importing again."]})]})]}),c.has_python_tools&&(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 border border-yellow-900/50 bg-yellow-950/10",children:[(0,w.jsx)(eS,{className:"h-4 w-4 text-yellow-500 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-yellow-400 text-xs font-bold uppercase tracking-wider",children:"Python Tools Included"}),(0,w.jsx)("p",{className:"text-yellow-600 text-xs mt-1",children:"Review all Python tool code carefully for hardcoded secrets before importing."})]})]}),n?(0,w.jsxs)("div",{className:"border border-blue-900/40 bg-blue-950/10",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,w.jsx)(N.Cpu,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("p",{className:"text-blue-400 text-xs font-bold uppercase tracking-wider",children:"Models Used in This Bundle"}),(0,w.jsxs)("p",{className:"text-blue-700 text-xs mt-0.5",children:[t.length," model",1!==t.length?"s":"","found across agents & orchestration steps."]})]}),(0,w.jsx)("button",{onClick:()=>b(e=>!e),className:"flex items-center gap-1 text-[10px] text-blue-600 hover:text-blue-400 transition-colors",children:x?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(eT,{className:"h-3 w-3"}),"Hide"]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(ei.ChevronDown,{className:"h-3 w-3"}),"Show"]})})]}),x&&(0,w.jsx)("div",{className:"border-t border-blue-900/30 divide-y divide-blue-900/20",children:t.map(e=>(0,w.jsxs)("div",{className:"px-4 py-2.5 flex items-start gap-3",children:[(0,w.jsx)("span",{className:"font-mono text-xs text-blue-300 font-bold min-w-0 break-all pt-px",children:e.model}),(0,w.jsx)("div",{className:"flex-1 min-w-0",children:e.usedIn.map(e=>(0,w.jsx)("p",{className:"text-[10px] text-blue-700 truncate",children:e},e))})]},e.model))}),(0,w.jsxs)("div",{className:"border-t border-blue-900/30 px-4 py-3 flex items-center justify-between gap-4",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,w.jsx)(Og,{className:"h-3.5 w-3.5 text-blue-500 flex-shrink-0"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-xs font-bold text-blue-300",children:"Use default model for everything"}),(0,w.jsx)("p",{className:"text-[10px] text-blue-700 mt-0.5",children:"Strips all model & provider overrides from agents and orchestration steps — they will use your global default model instead."})]})]}),(0,w.jsx)("button",{onClick:()=>g(e=>!e),className:`relative flex-shrink-0 w-10 h-5 rounded-full transition-colors duration-200 focus:outline-none ${m?"bg-blue-500":"bg-zinc-700"}`,children:(0,w.jsx)("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform duration-200 ${m?"translate-x-5":"translate-x-0"}`})})]})]}):(0,w.jsxs)("div",{className:"flex items-start gap-3 p-3.5 border border-zinc-800 bg-zinc-900/40",children:[(0,w.jsx)(N.Cpu,{className:"h-3.5 w-3.5 text-zinc-500 flex-shrink-0 mt-0.5"}),(0,w.jsx)("p",{className:"text-zinc-500 text-xs leading-relaxed",children:"No explicit model overrides found — agents & orchestration steps will use your global default model."})]}),(0,w.jsxs)("div",{className:"border border-zinc-800 divide-y divide-zinc-800",children:[(0,w.jsx)(Op,{title:"Orchestrations",icon:P.Workflow,items:c.orchestrations||[],selected:v,locked:new Set,getId:e=>e.id,getLabel:e=>e.name,getDesc:e=>e.description,onToggle:(e,t)=>{let n=new Set(ee.current);t?n.add(e):n.delete(e),y(n),J.current&&en(n,et.current,J.current)}}),(0,w.jsx)(Op,{title:"Agents",icon:_.Bot,items:c.agents||[],selected:k,locked:E,getId:e=>e.id,getLabel:e=>e.name,getDesc:e=>e.description,onToggle:(e,t)=>{if(E.has(e))return;let n=new Set(et.current);t?n.add(e):n.delete(e),j(n),J.current&&en(ee.current,n,J.current)}}),(0,w.jsx)(Op,{title:"MCP Servers",icon:A.Server,items:c.mcp_servers||[],selected:S,locked:D,getId:e=>e.name,getLabel:e=>e.label||e.name,onToggle:(e,t)=>{D.has(e)||z(n=>{let s=new Set(n);return t?s.add(e):s.delete(e),s})}}),(0,w.jsx)(Op,{title:"Custom Tools",icon:T.Wrench,items:c.custom_tools||[],selected:C,locked:Q,getId:e=>e.name,getLabel:e=>e.generalName||e.name,getDesc:e=>e.description,onToggle:(e,t)=>{Q.has(e)||M(n=>{let s=new Set(n);return t?s.add(e):s.delete(e),s})}})]}),m&&n&&(0,w.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-blue-800/50 bg-blue-950/20",children:[(0,w.jsx)(Og,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),(0,w.jsxs)("p",{className:"text-blue-400 text-xs",children:[(0,w.jsx)("span",{className:"font-bold",children:"Default model active"})," — ",t.length," model override",1!==t.length?"s":""," will be stripped on import."]})]}),(0,w.jsxs)("div",{className:"flex items-center justify-between gap-4 pt-2",children:[(0,w.jsx)("button",{onClick:ea,className:"px-4 py-2 text-sm font-bold border border-zinc-700 text-zinc-400 hover:border-zinc-500 hover:text-white transition-colors",children:"Cancel"}),(0,w.jsx)("button",{disabled:0===e,onClick:()=>el?l("secrets"):ec(),className:"flex items-center gap-2 px-6 py-2 bg-white text-black text-sm font-bold hover:bg-zinc-200 transition-colors disabled:opacity-40",children:el?"Configure Secrets →":(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Oc,{className:"h-4 w-4"})," Import Now"]})})]}),d&&(0,w.jsx)("p",{className:"text-red-400 text-xs",children:d})]})}if("secrets"===a&&c){let e=c.mcp_servers.filter(e=>S.has(e.name)&&e.env&&Object.keys(e.env).length>0),t=c.mcp_servers.filter(e=>S.has(e.name)&&!!e.token),n=c.custom_tools.filter(e=>C.has(e.name)&&"python"!==e.tool_type&&e.headers&&Object.keys(e.headers).length>0);return(0,w.jsxs)("div",{className:"space-y-6",children:[(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 border border-blue-900/50 bg-blue-950/10",children:[(0,w.jsx)(X,{className:"h-4 w-4 text-blue-400 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-blue-400 text-xs font-bold uppercase tracking-wider",children:"Secret Values Required"}),(0,w.jsx)("p",{className:"text-blue-600 text-xs mt-1",children:"MCP server env vars and custom tool headers were redacted during export. Enter the actual values before importing."})]})]}),t.length>0&&(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("h4",{className:"text-[10px] uppercase font-bold tracking-wider text-zinc-500 flex items-center gap-2",children:[(0,w.jsx)(A.Server,{className:"h-3 w-3"})," Remote MCP Server Tokens"]}),t.map(e=>(0,w.jsxs)("div",{className:"border border-zinc-800",children:[(0,w.jsxs)("div",{className:"px-4 py-2.5 bg-zinc-900 flex items-center gap-2",children:[(0,w.jsx)("span",{className:"text-sm font-bold text-zinc-200",children:e.label||e.name}),(0,w.jsx)("span",{className:"text-[10px] text-zinc-600 font-mono",children:e.url})]}),(0,w.jsx)("div",{className:"p-4",children:(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-600 font-mono w-36 flex-shrink-0 truncate",children:"Bearer Token"}),(0,w.jsx)("input",{type:"password",value:F[e.name]||"",onChange:t=>H(n=>({...n,[e.name]:t.target.value})),placeholder:"Paste your token here",className:`${Ox} flex-1 font-mono`})]})})]},e.name))]}),e.length>0&&(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("h4",{className:"text-[10px] uppercase font-bold tracking-wider text-zinc-500 flex items-center gap-2",children:[(0,w.jsx)(A.Server,{className:"h-3 w-3"})," MCP Server Environment Variables"]}),e.map(e=>(0,w.jsxs)("div",{className:"border border-zinc-800",children:[(0,w.jsxs)("div",{className:"px-4 py-2.5 bg-zinc-900 flex items-center gap-2",children:[(0,w.jsx)("span",{className:"text-sm font-bold text-zinc-200",children:e.label||e.name}),(0,w.jsx)("span",{className:"text-[10px] text-zinc-600 font-mono",children:e.name})]}),(0,w.jsx)("div",{className:"p-4 space-y-3",children:Object.keys(e.env||{}).map(t=>(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-600 font-mono w-36 flex-shrink-0 truncate",children:t}),(0,w.jsx)("input",{type:"password",value:L[e.name]?.[t]||"",onChange:n=>q(s=>({...s,[e.name]:{...s[e.name]||{},[t]:n.target.value}})),placeholder:`Value for ${t}`,className:`${Ox} flex-1 font-mono`})]},t))})]},e.name))]}),n.length>0&&(0,w.jsxs)("div",{className:"space-y-3",children:[(0,w.jsxs)("h4",{className:"text-[10px] uppercase font-bold tracking-wider text-zinc-500 flex items-center gap-2",children:[(0,w.jsx)(T.Wrench,{className:"h-3 w-3"})," Custom Tool Headers"]}),n.map(e=>(0,w.jsxs)("div",{className:"border border-zinc-800",children:[(0,w.jsxs)("div",{className:"px-4 py-2.5 bg-zinc-900 flex items-center gap-2",children:[(0,w.jsx)("span",{className:"text-sm font-bold text-zinc-200",children:e.generalName||e.name}),(0,w.jsx)("span",{className:"text-[10px] text-zinc-600 font-mono",children:e.name})]}),(0,w.jsx)("div",{className:"p-4 space-y-3",children:Object.keys(e.headers||{}).map(t=>(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsx)("label",{className:"text-[10px] uppercase font-bold text-zinc-600 font-mono w-36 flex-shrink-0 truncate",children:t}),(0,w.jsx)("input",{type:"password",value:W[e.name]?.[t]||"",onChange:n=>V(s=>({...s,[e.name]:{...s[e.name]||{},[t]:n.target.value}})),placeholder:`Value for ${t}`,className:`${Ox} flex-1 font-mono`})]},t))})]},e.name))]}),(0,w.jsxs)("div",{className:"flex items-center justify-between gap-4 pt-2",children:[(0,w.jsx)("button",{onClick:()=>l("preview"),className:"px-4 py-2 text-sm font-bold border border-zinc-700 text-zinc-400 hover:border-zinc-500 hover:text-white transition-colors",children:"← Back"}),(0,w.jsxs)("button",{disabled:p,onClick:ec,className:"flex items-center gap-2 px-6 py-2 bg-white text-black text-sm font-bold hover:bg-zinc-200 transition-colors disabled:opacity-50",children:[p?(0,w.jsx)(B.Loader2,{className:"h-4 w-4 animate-spin"}):(0,w.jsx)(Oc,{className:"h-4 w-4"}),p?"Importing…":"Start Import"]})]}),d&&(0,w.jsx)("p",{className:"text-red-400 text-xs",children:d})]})}if("results"===a){let e=Object.values(G).flat(),t=e.filter(e=>"imported"===e.status||"connected"===e.status).length,n=[{key:"orchestrations",label:"Orchestrations",icon:P.Workflow},{key:"agents",label:"Agents",icon:_.Bot},{key:"mcp_servers",label:"MCP Servers",icon:A.Server},{key:"custom_tools",label:"Custom Tools",icon:T.Wrench}];return(0,w.jsxs)("div",{className:"space-y-5",children:[(0,w.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border border-green-900/50 bg-green-950/10",children:[(0,w.jsx)(U,{className:"h-4 w-4 text-green-400 flex-shrink-0"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-green-400 text-xs font-bold uppercase tracking-wider",children:"Import Complete"}),(0,w.jsxs)("p",{className:"text-green-700 text-xs mt-0.5",children:[t," item",1!==t?"s":""," imported.",e.some(e=>"skipped_existing"===e.status)&&" Some MCP servers were skipped (already exist).",m&&" · All model overrides were reset to default."]})]})]}),(0,w.jsx)("div",{className:"border border-zinc-800 divide-y divide-zinc-800",children:n.map(({key:e,label:t,icon:n})=>{let s=G[e]||[];return s.length?(0,w.jsxs)("div",{children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-zinc-900",children:[(0,w.jsx)(n,{className:"h-3.5 w-3.5 text-zinc-500"}),(0,w.jsx)("span",{className:"text-[10px] uppercase font-bold tracking-wider text-zinc-500",children:t})]}),s.map((e,t)=>{let n=e.status,s="imported"===n||"connected"===n?U:"skipped_existing"===n?Om:"disconnected"===n?eS:"oauth_pending"===n?X:eu,i="imported"===n||"connected"===n?"text-green-400":"skipped_existing"===n||"disconnected"===n?"text-yellow-400":"oauth_pending"===n?"text-blue-400":"text-red-400",r="connected"===n?"Connected":"imported"===n?"Imported":"skipped_existing"===n?"Skipped — already exists":"disconnected"===n?"Saved — needs Retry":"oauth_pending"===n?"Needs authorization":"Error";return(0,w.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-t border-zinc-800/60",children:[(0,w.jsx)(s,{className:`h-4 w-4 ${i} flex-shrink-0`}),(0,w.jsx)("span",{className:"flex-1 text-sm text-zinc-200 font-bold",children:e.name||e.label}),"oauth_pending"===n&&e.auth_url&&(0,w.jsx)("a",{href:e.auth_url,target:"_blank",rel:"noreferrer",className:"text-xs font-bold text-blue-400 border border-blue-700 px-2 py-0.5 hover:bg-blue-900/30 transition-colors mr-2",children:"Authorize ↗"}),(0,w.jsx)("span",{className:`text-xs font-mono ${i}`,children:r})]},t)})]},e):null})}),G.mcp_servers?.some(e=>"disconnected"===e.status)&&(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 border border-zinc-800 bg-zinc-900/40",children:[(0,w.jsx)(eS,{className:"h-4 w-4 text-yellow-500 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("p",{className:"text-zinc-500 text-xs leading-relaxed",children:["Some MCP servers could not connect automatically. Go to the"," ",(0,w.jsx)("span",{className:"text-zinc-300 font-bold",children:"MCP Servers"})," tab and click"," ",(0,w.jsx)("span",{className:"text-zinc-300 font-bold",children:"Retry"})," to connect them."]})]}),G.mcp_servers?.some(e=>"oauth_pending"===e.status)&&(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 border border-blue-900/40 bg-blue-950/10",children:[(0,w.jsx)(X,{className:"h-4 w-4 text-blue-400 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("p",{className:"text-zinc-400 text-xs leading-relaxed",children:["Some servers require OAuth authorization. Click the"," ",(0,w.jsx)("span",{className:"text-blue-400 font-bold",children:"Authorize ↗"})," button next to each server above. Once you complete authorization in the browser, the server will connect automatically."]})]}),(0,w.jsx)("div",{className:"flex justify-end",children:(0,w.jsxs)("button",{onClick:ea,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold border border-zinc-700 text-zinc-400 hover:border-zinc-500 hover:text-white transition-colors",children:[(0,w.jsx)(Oc,{className:"h-4 w-4"})," Import Another File"]})})]})}return null}let Oy=(0,H.default)("package-open",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]),Ow={agents:"text-violet-400 bg-violet-950/60 border-violet-800/50",orchestrations:"text-emerald-400 bg-emerald-950/60 border-emerald-800/50",mcp_servers:"text-amber-400 bg-amber-950/60 border-amber-800/50",custom_tools:"text-sky-400 bg-sky-950/60 border-sky-800/50"},OO={agents:"Agents",orchestrations:"Orchestrations",mcp_servers:"MCP Servers",custom_tools:"Custom Tools"};function Ok({icon:e,count:t,label:n,color:s}){return 0===t?null:(0,w.jsxs)("div",{className:`flex items-center gap-1 text-[11px] font-mono ${s}`,children:[(0,w.jsx)(e,{className:"h-3 w-3"}),(0,w.jsxs)("span",{children:[t," ",n,1!==t?"s":""]})]})}function Oj({onLoadBundle:e}){let[t,n]=(0,O.useState)([]),[s,i]=(0,O.useState)(!0),[r,o]=(0,O.useState)(null),[a,l]=(0,O.useState)(null);(0,O.useEffect)(()=>{fetch("/api/examples").then(e=>{if(!e.ok)throw Error("Failed to fetch examples");return e.json()}).then(e=>{n(e),i(!1)}).catch(e=>{o(e.message),i(!1)})},[]);let c=async t=>{l(t.id);try{let n=await fetch(`/api/examples/${t.id}`);if(!n.ok)throw Error("Failed to load example pack");let s=await n.json();e(s)}catch(e){o(e.message)}finally{l(null)}};return s?(0,w.jsxs)("div",{className:"flex items-center justify-center py-20",children:[(0,w.jsx)(B.Loader2,{className:"h-6 w-6 text-zinc-500 animate-spin"}),(0,w.jsx)("span",{className:"ml-3 text-sm text-zinc-500",children:"Loading example packs…"})]}):r?(0,w.jsxs)("div",{className:"flex items-start gap-3 p-4 border border-red-900/50 bg-red-950/10",children:[(0,w.jsx)(X,{className:"h-4 w-4 text-red-400 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-red-400 text-xs font-bold uppercase tracking-wider",children:"Failed to load examples"}),(0,w.jsx)("p",{className:"text-red-600 text-xs mt-1",children:r})]})]}):(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border border-zinc-800 bg-zinc-900/60",children:[(0,w.jsx)(ea.Sparkles,{className:"h-4 w-4 text-violet-400 flex-shrink-0 mt-0.5"}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"text-sm font-bold text-zinc-200",children:"Example Packs"}),(0,w.jsx)("p",{className:"text-[11px] text-zinc-500 mt-0.5 leading-relaxed",children:"Curated collections of agents, orchestrations, and MCP servers. Select a pack to preview what will be imported before committing."})]})]}),(0,w.jsx)("div",{className:"grid gap-3",children:t.map(e=>{let t=a===e.id;return(0,w.jsx)("div",{className:"group flex flex-col border border-zinc-800 bg-zinc-900/30 hover:bg-zinc-900/70 hover:border-zinc-700 transition-all duration-200",children:(0,w.jsxs)("div",{className:"flex items-start justify-between gap-4 p-4",children:[(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2",children:e.tags.map(e=>(0,w.jsx)("span",{className:`text-[9px] font-mono uppercase tracking-widest px-1.5 py-0.5 border ${Ow[e]||"text-zinc-400 bg-zinc-900 border-zinc-700"}`,children:OO[e]||e},e))}),(0,w.jsx)("p",{className:"text-sm font-bold text-zinc-100 mb-1",children:e.name}),(0,w.jsx)("p",{className:"text-[12px] text-zinc-400 leading-relaxed",children:e.description}),(0,w.jsxs)("div",{className:"flex flex-wrap gap-3 mt-2.5",children:[(0,w.jsx)(Ok,{icon:_.Bot,count:e.agent_count,label:"Agent",color:"text-violet-400"}),(0,w.jsx)(Ok,{icon:P.Workflow,count:e.orchestration_count,label:"Orchestration",color:"text-emerald-400"}),(0,w.jsx)(Ok,{icon:A.Server,count:e.mcp_count,label:"MCP Server",color:"text-amber-400"}),(0,w.jsx)(Ok,{icon:T.Wrench,count:e.tool_count,label:"Tool",color:"text-sky-400"})]})]}),(0,w.jsx)("button",{onClick:()=>c(e),disabled:!!a,className:"flex items-center gap-1.5 shrink-0 px-3 py-2 bg-zinc-800 border border-zinc-700 text-zinc-300 hover:bg-white hover:text-black hover:border-white text-xs font-bold transition-all duration-150 disabled:opacity-50 group-hover:border-zinc-500",children:t?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Loading…"]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ol,{className:"h-3.5 w-3.5"}),"Preview & Import",(0,w.jsx)(er.ChevronRight,{className:"h-3 w-3 ml-0.5"})]})})]})},e.id)})}),0===t.length&&(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center py-16",children:[(0,w.jsx)(Oy,{className:"h-10 w-10 text-zinc-700 mb-3"}),(0,w.jsx)("p",{className:"text-sm text-zinc-500",children:"No example packs available."})]})]})}function ON({defaultView:e,onImportSuccess:t,onNavigate:n}){let[s,i]=(0,O.useState)(e??"export"),[r,o]=(0,O.useState)(null);(0,O.useEffect)(()=>{e&&i(e)},[e]);let a=(0,O.useCallback)(e=>{o(e),i("import")},[]),l=(0,O.useCallback)(()=>{o(null)},[]);return(0,w.jsxs)("div",{className:"space-y-8",children:[(0,w.jsxs)("div",{className:"flex items-center gap-1 bg-zinc-900 border border-zinc-800 p-1 w-fit",children:[(0,w.jsxs)("button",{onClick:()=>i("export"),className:`flex items-center gap-1.5 px-5 py-2 text-xs font-bold transition-colors ${"export"===s?"bg-white text-black":"text-zinc-500 hover:text-white"}`,children:[(0,w.jsx)(Ol,{className:"h-3.5 w-3.5"})," Export"]}),(0,w.jsxs)("button",{onClick:()=>{i("import"),o(null)},className:`flex items-center gap-1.5 px-5 py-2 text-xs font-bold transition-colors ${"import"===s?"bg-white text-black":"text-zinc-500 hover:text-white"}`,children:[(0,w.jsx)(Oc,{className:"h-3.5 w-3.5"})," Import"]}),(0,w.jsxs)("button",{onClick:()=>i("examples"),className:`flex items-center gap-1.5 px-5 py-2 text-xs font-bold transition-colors ${"examples"===s?"bg-white text-black":"text-zinc-500 hover:text-white"}`,children:[(0,w.jsx)(ea.Sparkles,{className:"h-3.5 w-3.5"})," Examples"]})]}),"export"===s&&(0,w.jsx)(Of,{}),"examples"===s&&(0,w.jsx)(Oj,{onLoadBundle:a}),"import"===s&&(0,w.jsx)(Ov,{preloadedBundle:r,onReset:l,onImportSuccess:t,onNavigate:n})]})}let OS=(0,H.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),Oz=(0,H.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),OC=(0,H.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),O_=(0,H.default)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);function OT({node:e,selectedPath:t,onSelect:n,onDelete:s,onCreateInFolder:i,depth:r=0}){let[o,a]=(0,O.useState)(0===r),l=t===e.path,c="folder"===e.type;return(0,w.jsxs)("div",{children:[(0,w.jsxs)("div",{className:`group flex items-center gap-1.5 px-2 py-1 cursor-pointer transition-colors rounded text-xs
|
|
45
|
+
${l?"bg-zinc-800 text-white":"text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800/50"}`,style:{paddingLeft:`${8+16*r}px`},onClick:()=>{c?a(e=>!e):n(e)},children:[c?(0,w.jsx)("span",{className:"text-zinc-500 flex-shrink-0",children:o?(0,w.jsx)(ei.ChevronDown,{className:"h-3 w-3"}):(0,w.jsx)(er.ChevronRight,{className:"h-3 w-3"})}):(0,w.jsx)("span",{className:"w-3 flex-shrink-0"}),c?o?(0,w.jsx)(OS,{className:"h-3.5 w-3.5 text-amber-400 flex-shrink-0"}):(0,w.jsx)(Oz,{className:"h-3.5 w-3.5 text-amber-400 flex-shrink-0"}):".json"===e.ext?(0,w.jsx)(eg,{className:"h-3.5 w-3.5 text-amber-300 flex-shrink-0"}):".txt"===e.ext?(0,w.jsx)(ex,{className:"h-3.5 w-3.5 text-zinc-400 flex-shrink-0"}):(0,w.jsx)(em,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),(0,w.jsx)("span",{className:"flex-1 truncate font-mono",children:e.name}),c&&(0,w.jsx)("button",{onClick:t=>{t.stopPropagation(),i(e.path)},className:"opacity-0 group-hover:opacity-100 text-zinc-500 hover:text-emerald-400 transition-all p-0.5 flex-shrink-0",title:`New file in ${e.name}`,children:(0,w.jsx)(O_,{className:"h-3 w-3"})}),(0,w.jsx)("button",{onClick:t=>{t.stopPropagation(),s(e)},className:"opacity-0 group-hover:opacity-100 text-zinc-600 hover:text-red-500 transition-opacity p-0.5 flex-shrink-0",title:`Delete ${e.name}`,children:(0,w.jsx)(F.Trash2,{className:"h-3 w-3"})})]}),c&&o&&e.children&&e.children.length>0&&(0,w.jsx)("div",{children:e.children.map(e=>(0,w.jsx)(OT,{node:e,selectedPath:t,onSelect:n,onDelete:s,onCreateInFolder:i,depth:r+1},e.path))}),c&&o&&(!e.children||0===e.children.length)&&(0,w.jsx)("div",{className:"text-[10px] text-zinc-600 italic",style:{paddingLeft:`${8+(r+2)*16}px`,paddingTop:"4px",paddingBottom:"4px"},children:"Empty folder"})]})}function OA({type:e,parentPath:t,onClose:n,onCreate:s}){let[i,r]=(0,O.useState)(""),[o,a]=(0,O.useState)("md");return(0,w.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/70 backdrop-blur-sm",children:(0,w.jsxs)("div",{className:"bg-zinc-950 border border-zinc-800 w-80 shadow-2xl",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-zinc-800",children:[(0,w.jsx)("h3",{className:"text-sm font-bold text-white",children:"file"===e?"New File":"New Folder"}),(0,w.jsx)("button",{onClick:n,className:"text-zinc-500 hover:text-white",children:(0,w.jsx)(eN.X,{className:"h-4 w-4"})})]}),(0,w.jsxs)("form",{onSubmit:t=>{t.preventDefault(),i.trim()&&("file"===e?s(i.trim().endsWith(`.${o}`)?i.trim():`${i.trim()}.${o}`,`.${o}`):s(i.trim()))},className:"p-4 space-y-4",children:[t&&(0,w.jsxs)("p",{className:"text-[10px] text-zinc-500 font-mono",children:["Location: ",(0,w.jsxs)("span",{className:"text-zinc-400",children:["/",t]})]}),"file"===e&&(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsxs)("button",{type:"button",onClick:()=>a("md"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 text-xs font-bold border transition-colors ${"md"===o?"border-blue-500 bg-blue-950/40 text-blue-400":"border-zinc-700 text-zinc-500 hover:border-zinc-600"}`,children:[(0,w.jsx)(em,{className:"h-3.5 w-3.5"})," Markdown"]}),(0,w.jsxs)("button",{type:"button",onClick:()=>a("json"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 text-xs font-bold border transition-colors ${"json"===o?"border-amber-500 bg-amber-950/40 text-amber-400":"border-zinc-700 text-zinc-500 hover:border-zinc-600"}`,children:[(0,w.jsx)(eg,{className:"h-3.5 w-3.5"})," JSON"]}),(0,w.jsxs)("button",{type:"button",onClick:()=>a("txt"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 text-xs font-bold border transition-colors ${"txt"===o?"border-zinc-400 bg-zinc-800/60 text-zinc-200":"border-zinc-700 text-zinc-500 hover:border-zinc-600"}`,children:[(0,w.jsx)(ex,{className:"h-3.5 w-3.5"})," Text"]})]}),(0,w.jsxs)("div",{className:"space-y-1",children:[(0,w.jsx)("label",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"file"===e?"File Name":"Folder Name"}),(0,w.jsx)("input",{autoFocus:!0,type:"text",value:i,onChange:e=>r(e.target.value),placeholder:"file"===e?`my-document.${o}`:"my-folder",className:"w-full bg-zinc-900 border border-zinc-700 px-3 py-2 text-xs text-white font-mono focus:border-white focus:outline-none"}),"file"===e&&(0,w.jsxs)("p",{className:"text-[9px] text-zinc-600",children:["Extension ",(0,w.jsxs)("span",{className:"text-zinc-400",children:[".",o]})," will be appended automatically if not included."]})]}),(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("button",{type:"button",onClick:n,className:"flex-1 py-2 text-xs text-zinc-500 hover:text-white border border-zinc-700 hover:border-zinc-500 transition-colors",children:"Cancel"}),(0,w.jsx)("button",{type:"submit",disabled:!i.trim(),className:"flex-1 py-2 text-xs font-bold bg-white text-black hover:bg-zinc-200 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Create"})]})]})]})})}function OM({node:e,onConfirm:t,onCancel:n}){return(0,w.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/70 backdrop-blur-sm",children:(0,w.jsxs)("div",{className:"bg-zinc-950 border border-zinc-800 w-80 shadow-2xl p-6 space-y-4",children:[(0,w.jsx)("h3",{className:"text-sm font-bold text-white",children:"Confirm Delete"}),(0,w.jsx)("p",{className:"text-xs text-zinc-400",children:"folder"===e.type?(0,w.jsxs)(w.Fragment,{children:["Are you sure you want to delete folder ",(0,w.jsx)("span",{className:"font-mono text-red-400",children:e.name})," and all its contents? This cannot be undone."]}):(0,w.jsxs)(w.Fragment,{children:["Are you sure you want to delete ",(0,w.jsx)("span",{className:"font-mono text-red-400",children:e.name}),"? This cannot be undone."]})}),(0,w.jsxs)("div",{className:"flex gap-2",children:[(0,w.jsx)("button",{onClick:n,className:"flex-1 py-2 text-xs text-zinc-500 hover:text-white border border-zinc-700 hover:border-zinc-500 transition-colors",children:"Cancel"}),(0,w.jsx)("button",{onClick:t,className:"flex-1 py-2 text-xs font-bold bg-red-600 text-white hover:bg-red-500 transition-colors",children:"Delete"})]})]})})}function OP({value:e,onChange:t}){let[n,s]=(0,O.useState)(null);return(0,w.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,w.jsx)("textarea",{value:e,onChange:e=>{let n=e.target.value;t(n);try{JSON.parse(n),s(null)}catch(e){s(e.message)}},spellCheck:!1,className:`flex-1 min-h-0 w-full bg-zinc-950 p-4 text-xs font-mono text-zinc-200 focus:outline-none resize-none leading-relaxed border-0 ${n?"border-b-2 border-red-600/60":""}`,style:{fontFamily:"monospace"}}),n&&(0,w.jsxs)("div",{className:"px-4 py-1.5 text-[10px] text-red-400 font-mono bg-red-950/30 border-t border-red-900/50 flex-shrink-0",children:["⚠ ",n]})]})}function OE({value:e,onChange:t}){let[n,s]=(0,O.useState)(!1);return(0,w.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-zinc-800 flex-shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,w.jsx)(em,{className:"h-3.5 w-3.5 text-blue-400"}),(0,w.jsx)("span",{className:"text-[10px] font-bold text-zinc-400 uppercase",children:"Markdown"})]}),(0,w.jsxs)("button",{onClick:()=>s(e=>!e),className:"flex items-center gap-1.5 text-[10px] font-bold text-zinc-500 hover:text-white transition-colors px-2 py-1",children:[n?(0,w.jsx)(ec,{className:"h-3 w-3"}):(0,w.jsx)(el,{className:"h-3 w-3"}),n?"EDIT":"PREVIEW"]})]}),n?(0,w.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 text-sm text-zinc-300 leading-relaxed modern-scrollbar",children:(0,ey.renderTextContent)(e||"*Empty file*")}):(0,w.jsx)("textarea",{value:e,onChange:e=>t(e.target.value),spellCheck:!1,className:"flex-1 min-h-0 w-full bg-zinc-950 p-4 text-xs font-mono text-zinc-200 focus:outline-none resize-none leading-relaxed border-0",style:{fontFamily:"monospace"},placeholder:"# Title Start writing..."})]})}function OR({value:e,onChange:t}){return(0,w.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-zinc-800 flex-shrink-0",children:[(0,w.jsx)(ex,{className:"h-3.5 w-3.5 text-zinc-400"}),(0,w.jsx)("span",{className:"text-[10px] font-bold text-zinc-400 uppercase",children:"Plain Text"})]}),(0,w.jsx)("textarea",{value:e,onChange:e=>t(e.target.value),spellCheck:!1,className:"flex-1 min-h-0 w-full bg-zinc-950 p-4 text-xs font-mono text-zinc-200 focus:outline-none resize-none leading-relaxed border-0",style:{fontFamily:"monospace"},placeholder:"Start typing..."})]})}function OD(){let[e,t]=(0,O.useState)([]),[n,s]=(0,O.useState)(!0),[i,r]=(0,O.useState)(null),[o,a]=(0,O.useState)(""),[l,c]=(0,O.useState)(""),[h,d]=(0,O.useState)(!1),[u,p]=(0,O.useState)(!1),[f,m]=(0,O.useState)("idle"),[g,x]=(0,O.useState)(null),[b,v]=(0,O.useState)(null),[y,k]=(0,O.useState)(""),j=(0,O.useCallback)(async()=>{s(!0);try{let e=await fetch("/api/vault/tree");if(e.ok){let n=await e.json();t(n.tree||[])}}catch(e){console.error("Failed to load vault tree",e)}finally{s(!1)}},[]);(0,O.useEffect)(()=>{j()},[j]),(0,O.useEffect)(()=>{i&&"file"===i.type&&(d(!0),m("idle"),fetch(`/api/vault/file?path=${encodeURIComponent(i.path)}`).then(e=>e.ok?e.json():null).then(e=>{let t=e?.content??"";a(t),c(t)}).catch(()=>{a(""),c("")}).finally(()=>d(!1)))},[i]);let N=async()=>{if(i&&"file"===i.type){p(!0),m("idle");try{(await fetch("/api/vault/file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:i.path,content:o})})).ok?(c(o),m("saved"),setTimeout(()=>m("idle"),2e3)):m("error")}catch{m("error")}finally{p(!1)}}},S=async e=>{if(!g)return;let t="file"===g.type?"/api/vault/file":"/api/vault/folder";try{let n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:y,name:e})});if(n.ok){let e=await n.json();x(null),await j(),"file"===g.type&&r({name:e.name,path:e.path,type:"file",ext:e.ext})}}catch(e){console.error("Failed to create",e)}},z=async()=>{if(b)try{(await fetch("/api/vault/item",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b.path})})).ok&&((i?.path===b.path||"folder"===b.type&&i?.path.startsWith(b.path+"/"))&&(r(null),a(""),c("")),await j())}catch(e){console.error("Failed to delete",e)}finally{v(null)}},C=o!==l;return(0,w.jsxs)("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[(0,w.jsxs)("div",{className:"w-64 flex-shrink-0 border-r border-zinc-800 flex flex-col bg-zinc-950",children:[(0,w.jsxs)("div",{className:"flex items-center gap-1 px-3 py-2.5 border-b border-zinc-800",children:[(0,w.jsx)("span",{className:"text-[10px] font-bold text-zinc-500 uppercase flex-1",children:"Vault Files"}),(0,w.jsx)("button",{onClick:()=>{k(""),x({type:"folder",parentPath:""})},title:"New Folder",className:"p-1 text-zinc-500 hover:text-white hover:bg-zinc-800 transition-colors",children:(0,w.jsx)(OC,{className:"h-3.5 w-3.5"})}),(0,w.jsx)("button",{onClick:()=>{k(""),x({type:"file",parentPath:""})},title:"New File",className:"p-1 text-zinc-500 hover:text-white hover:bg-zinc-800 transition-colors",children:(0,w.jsx)(O_,{className:"h-3.5 w-3.5"})}),(0,w.jsx)("button",{onClick:j,title:"Refresh",className:"p-1 text-zinc-500 hover:text-white hover:bg-zinc-800 transition-colors",children:(0,w.jsx)(ez.RefreshCw,{className:"h-3 w-3"})})]}),(0,w.jsx)("div",{className:"flex-1 overflow-y-auto modern-scrollbar py-1",children:n?(0,w.jsxs)("div",{className:"flex items-center gap-2 px-4 py-4 text-zinc-600 text-xs",children:[(0,w.jsx)(B.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Loading…"]}):0===e.length?(0,w.jsxs)("div",{className:"px-4 py-6 text-center",children:[(0,w.jsx)("div",{className:"text-zinc-600 text-xs mb-3",children:"Vault is empty"}),(0,w.jsx)("button",{onClick:()=>{k(""),x({type:"file",parentPath:""})},className:"text-[10px] text-zinc-400 hover:text-white underline",children:"Create your first file →"})]}):e.map(e=>(0,w.jsx)(OT,{node:e,selectedPath:i?.path??null,onSelect:e=>{r(e),"folder"===e.type?k(e.path):k(e.path.split("/").slice(0,-1).join("/"))},onDelete:v,onCreateInFolder:e=>{k(e),x({type:"file",parentPath:e})}},e.path))}),(0,w.jsx)("div",{className:"px-3 py-2 border-t border-zinc-800",children:(0,w.jsxs)("p",{className:"text-[9px] text-zinc-600 leading-relaxed",children:["Files here can be referenced in agent prompts using ",(0,w.jsx)("span",{className:"font-mono text-zinc-500",children:"@[path]"})]})})]}),(0,w.jsx)("div",{className:"flex-1 flex flex-col min-h-0 bg-zinc-950",children:i&&"file"===i.type?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-zinc-800 flex-shrink-0",children:[".json"===i.ext?(0,w.jsx)(eg,{className:"h-4 w-4 text-amber-400 flex-shrink-0"}):".txt"===i.ext?(0,w.jsx)(ex,{className:"h-4 w-4 text-zinc-400 flex-shrink-0"}):(0,w.jsx)(em,{className:"h-4 w-4 text-blue-400 flex-shrink-0"}),(0,w.jsx)("span",{className:"text-xs font-mono text-zinc-300 flex-1 truncate",children:i.path}),C&&(0,w.jsx)("span",{className:"text-[10px] text-amber-400",children:"unsaved changes"}),(0,w.jsxs)("button",{onClick:N,disabled:u||!C,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold transition-colors disabled:opacity-40 disabled:cursor-not-allowed
|
|
46
|
+
${"saved"===f?"bg-emerald-600 text-white":"error"===f?"bg-red-600 text-white":"bg-white text-black hover:bg-zinc-200"}`,children:[u?(0,w.jsx)(B.Loader2,{className:"h-3 w-3 animate-spin"}):(0,w.jsx)(es,{className:"h-3 w-3"}),"saved"===f?"SAVED":"error"===f?"ERROR":"SAVE"]})]}),h?(0,w.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,w.jsx)(B.Loader2,{className:"h-5 w-5 animate-spin text-zinc-600"})}):".json"===i.ext?(0,w.jsx)(OP,{value:o,onChange:a}):".txt"===i.ext?(0,w.jsx)(OR,{value:o,onChange:a}):(0,w.jsx)(OE,{value:o,onChange:a})]}):(0,w.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-6 text-center p-8",children:[(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("div",{className:"h-16 w-16 mx-auto rounded-full bg-zinc-900 border border-zinc-800 flex items-center justify-center",children:(0,w.jsx)(OS,{className:"h-7 w-7 text-zinc-600"})}),(0,w.jsx)("h3",{className:"text-sm font-bold text-zinc-400",children:"Select a file to edit"}),(0,w.jsxs)("p",{className:"text-xs text-zinc-600 max-w-xs",children:["Use the file explorer on the left to browse your vault. Create ",(0,w.jsx)("span",{className:"text-zinc-400",children:".md"}),", ",(0,w.jsx)("span",{className:"text-zinc-400",children:".json"}),", or ",(0,w.jsx)("span",{className:"text-zinc-400",children:".txt"})," files to use as context in agent prompts."]})]}),(0,w.jsxs)("div",{className:"flex gap-3",children:[(0,w.jsxs)("button",{onClick:()=>{k(""),x({type:"folder",parentPath:""})},className:"flex items-center gap-2 px-4 py-2 text-xs font-bold border border-zinc-700 text-zinc-400 hover:text-white hover:border-zinc-500 transition-colors",children:[(0,w.jsx)(OC,{className:"h-3.5 w-3.5"})," New Folder"]}),(0,w.jsxs)("button",{onClick:()=>{k(""),x({type:"file",parentPath:""})},className:"flex items-center gap-2 px-4 py-2 text-xs font-bold bg-white text-black hover:bg-zinc-200 transition-colors",children:[(0,w.jsx)(en.Plus,{className:"h-3.5 w-3.5"})," New File"]})]})]})}),g&&(0,w.jsx)(OA,{type:g.type,parentPath:y,onClose:()=>x(null),onCreate:S}),b&&(0,w.jsx)(OM,{node:b,onConfirm:z,onCancel:()=>v(null)})]})}e.s(["SettingsView",0,({initialTab:e="general",initialSubTab:t})=>{let n=(0,L.useDispatch)(),{agents:s,mcpServers:i,customTools:r,models:o,initialized:a,loading:l}=(0,L.useSelector)(e=>e.settings),[c,h]=(0,O.useState)(e),[d,u]=(0,O.useState)(""),[p,f]=(0,O.useState)(""),[m,g]=(0,O.useState)(""),[x,b]=(0,O.useState)("local"),[v,y]=(0,O.useState)([]),[B,F]=(0,O.useState)([]),[H,X]=(0,O.useState)({}),[U,G]=(0,O.useState)(!1),[Z,Y]=(0,O.useState)(!1),J=(0,I.useRouter)(),[ee,en]=(0,O.useState)(!0),[es,ei]=(0,O.useState)(1e5),[er,eo]=(0,O.useState)(!1),[ea,el]=(0,O.useState)(5e4),[ec,eh]=(0,O.useState)(!1),[ed,eu]=(0,O.useState)([]),[ep,ef]=(0,O.useState)(""),[em,eg]=(0,O.useState)(""),[ex,eb]=(0,O.useState)(""),[ev,ey]=(0,O.useState)(""),[ew,eO]=(0,O.useState)(""),[eN,eS]=(0,O.useState)(""),[ez,eC]=(0,O.useState)(""),[e_,eT]=(0,O.useState)(""),[eA,eM]=(0,O.useState)(""),[eP,eE]=(0,O.useState)(""),[eR,eD]=(0,O.useState)(""),[e$,eQ]=(0,O.useState)(""),[eI,eL]=(0,O.useState)(""),[eq,eB]=(0,O.useState)(""),[eW,eV]=(0,O.useState)("us-east-1"),[eF,eH]=(0,O.useState)(""),[eX,eU]=(0,O.useState)([]),[eG,eZ]=(0,O.useState)(!1),[eY,eK]=(0,O.useState)(null),[eJ,e0]=(0,O.useState)(""),[e1,e2]=(0,O.useState)(""),[e5,e3]=(0,O.useState)(""),[e4,e8]=(0,O.useState)(""),[e6,e9]=(0,O.useState)(""),[e7,te]=(0,O.useState)(""),[tt,tn]=(0,O.useState)(""),[ts,ti]=(0,O.useState)(""),[tr,to]=(0,O.useState)(""),[ta,tl]=(0,O.useState)(""),[tc,th]=(0,O.useState)("http://localhost:5678"),[td,tu]=(0,O.useState)(""),[tp,tf]=(0,O.useState)(null),[tm,tg]=(0,O.useState)(null),[tx,tb]=(0,O.useState)(null),[tv,ty]=(0,O.useState)("config"),[tw,tO]=(0,O.useState)([]),[tk,tj]=(0,O.useState)(null),tN=(e,t="success")=>{tj({show:!0,message:e,type:t}),setTimeout(()=>tj(null),4e3)},[tS,tz]=(0,O.useState)([]),[tC,t_]=(0,O.useState)(!1),[tT,tA]=(0,O.useState)(!1),[tM,tP]=(0,O.useState)(!1),[tE,tR]=(0,O.useState)(null),[tD,t$]=(0,O.useState)(null),[tQ,tI]=(0,O.useState)(null),[tL,tq]=(0,O.useState)({name:"",label:"",server_type:"stdio",command:"",args:"",env:[],url:"",token:""}),[tB,tW]=(0,O.useState)([]),[tV,tF]=(0,O.useState)(!0),[tH,tX]=(0,O.useState)(!1),[tU,tG]=(0,O.useState)(!1),[tZ,tY]=(0,O.useState)(!1),tK=(0,O.useCallback)(e=>{if(e.data?.type==="MCP_OAUTH_COMPLETE")if(e.data.success){let t=e.data.name;n((0,q.updateMcpServerStatus)({name:t,status:"connected"})),t$({show:!0,message:`✓ ${t} connected via OAuth!`,type:"success"}),tI(null),setTimeout(()=>t$(null),5e3)}else t$({show:!0,message:`OAuth failed: ${e.data.error}`,type:"error"}),setTimeout(()=>t$(null),6e3)},[n]);(0,O.useEffect)(()=>(window.addEventListener("message",tK),()=>window.removeEventListener("message",tK)),[tK]);let tJ=async()=>{G(!0);try{let e=await fetch("/api/bedrock/models"),t=await e.json(),n=Array.isArray(t.models)?t.models:[];n.length>0&&F(e=>[...(e||[]).filter(e=>!e.startsWith("bedrock.")),...n])}catch{}finally{G(!1)}},t0=async()=>{G(!0);try{let e=await fetch("/api/models"),t=await e.json();y(t.local||[]),F(t.cloud||[]),t.providers&&X(t.providers)}catch{}finally{G(!1)}},t1=async()=>{eZ(!0),eK(null);try{let e=await fetch("/api/bedrock/inference-profiles"),t=await e.json(),n=Array.isArray(t.profiles)?t.profiles:[];eU(n),t.error&&eK(t.error)}catch{eU([]),eK("Failed to reach the server.")}finally{eZ(!1)}},t2=async()=>{Y(!0);try{if(!(await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_name:d,model:p,embedding_model:m,mode:x,openai_key:ep,anthropic_key:em,gemini_key:ex,grok_key:ev,deepseek_key:ew,openai_compatible_key:ez,openai_compatible_base_url:e_,openai_compatible_models:eA,openai_compatible_embed_models:eP,local_compatible_base_url:eR,local_compatible_key:e$,local_compatible_models:eI,local_compatible_embed_models:eq,bedrock_api_key:eN,bedrock_inference_profile:eF,aws_region:eW,sql_connection_string:eJ,n8n_url:tc,n8n_api_key:td,vault_enabled:ee,vault_threshold:es,auto_compact_enabled:er,auto_compact_threshold:ea,allow_db_write:ec,embed_code:tZ,bash_allowed_dirs:ed})})).ok)throw Error("Failed to update settings");"bedrock"===x||eN?(await tJ(),await t1()):("models"===c||"cloud"===x)&&await t0(),tN("Configuration saved","success")}catch(e){console.error(e),tN("Failed to save settings","error")}finally{Y(!1)}},t5=async()=>{try{if(!(await fetch("/api/personal-details",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({first_name:e1,last_name:e5,email:e4,phone_number:e6,address:{address1:e7,address2:tt,city:ts,state:tr,zipcode:ta}})})).ok)throw Error("Failed to save personal details");tN("Personal details saved","success")}catch{tN("Error saving personal details","error")}},[t3,t4]=(0,O.useState)(null),[t8,t6]=(0,O.useState)(null),[t9,t7]=(0,O.useState)(""),[ne,nt]=(0,O.useState)(10),[nn,ns]=(0,O.useState)("openai"),[ni,nr]=(0,O.useState)("You are a helpful assistant."),[no,na]=(0,O.useState)(""),[nl,nc]=(0,O.useState)(null),[nh,nd]=(0,O.useState)([]);(0,O.useEffect)(()=>{if("datalab"===c){nu(),np();let e=setInterval(()=>{np(),nl?.status==="generating"&&nu()},2e3);return()=>clearInterval(e)}},[c]);let nu=()=>fetch("/api/synthetic/datasets").then(e=>e.json()).then(nd).catch(()=>{}),np=()=>fetch("/api/synthetic/status").then(e=>e.json()).then(nc).catch(()=>{}),nf=async()=>{if(!t9)return void tN("Please enter a topic","warning");if("openai"===nn&&!ep)return void tN("OpenAI Key required","warning");if("gemini"===nn&&!ex)return void tN("Gemini Key required","warning");try{let e=await fetch("/api/synthetic/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:t9,count:ne,provider:nn,api_key:"openai"===nn?ep:ex,system_prompt:ni,edge_cases:no})});if(e.ok)tN("Generation started!","success"),np();else{let t=await e.json();tN("Error: "+t.detail,"error")}}catch(e){tN("Failed to start generation","error")}},nm=async()=>{if(t8)try{"delete_mcp"===t8.type?(await fetch(`/api/mcp/servers/${t8.payload}`,{method:"DELETE"})).ok&&n((0,q.removeMcpServer)(t8.payload)):"delete_tool"===t8.type?(await fetch(`/api/tools/custom/${t8.payload}`,{method:"DELETE"}),n((0,q.removeCustomTool)(t8.payload))):"delete_agent"===t8.type&&(await fetch(`/api/agents/${t8.payload}`,{method:"DELETE"}),n((0,q.removeAgent)(t8.payload)),tp===t8.payload&&(tf(null),tg(null)))}catch(e){tN("Error running confirmation action","error")}finally{t6(null)}};(0,O.useEffect)(()=>{let e=e=>{"Escape"===e.key&&J.push("/")};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[J]),(0,O.useEffect)(()=>{a?(y(o.local||[]),F(o.cloud||[]),X(o.providers||{})):n((0,q.fetchAllSettingsData)()),fetch("/api/settings").then(e=>e.json()).then(e=>{u(e.agent_name||"Antigravity Agent"),f(e.model||"ollama.mistral"),g(e.embedding_model||""),b(e.mode||"local"),ef(e.openai_key||""),eg(e.anthropic_key||""),eb(e.gemini_key||""),ey(e.grok_key||""),eO(e.deepseek_key||""),eC(e.openai_compatible_key||""),eT(e.openai_compatible_base_url||""),eM(e.openai_compatible_models||""),eE(e.openai_compatible_embed_models||""),eD(e.local_compatible_base_url||""),eQ(e.local_compatible_key||""),eL(e.local_compatible_models||""),eB(e.local_compatible_embed_models||""),eS(e.bedrock_api_key||""),eV(e.aws_region||"us-east-1"),eH(e.bedrock_inference_profile||""),e0(e.sql_connection_string||""),th(e.n8n_url||"http://localhost:5678"),tu(e.n8n_api_key||""),en(void 0===e.vault_enabled||e.vault_enabled),ei(e.vault_threshold||1e5),eo(e.auto_compact_enabled||!1),el(e.auto_compact_threshold||5e4),eh(e.allow_db_write||!1),tY(e.embed_code||!1),eu(e.bash_allowed_dirs||[]),tX(e.messaging_enabled||!1),tG(e.coding_agent_enabled||!1),e.bedrock_api_key&&t1()}),fetch("/api/personal-details").then(e=>e.json()).then(e=>{e2(e.first_name||""),e3(e.last_name||""),e8(e.email||""),e9(e.phone_number||"");let t=e.address||{};te(t.address1||""),tn(t.address2||""),ti(t.city||""),to(t.state||""),tl(t.zipcode||"")}).catch(()=>{}),t0(),tF(!0),fetch("/api/tools/available").then(e=>e.json()).then(e=>{let t=e.tools||[],n={};t.forEach(e=>{if("custom_http"===e.source){let t=e.name;n[t]||(n[t]={id:t,label:e.label||e.name,description:e.description,tools:[e.name],toolDetails:[{name:e.name,description:e.description||""}],toolType:"custom"})}else{let t=e.source||"unknown";n[t]||(n[t]={id:t,label:e.source_label||t.charAt(0).toUpperCase()+t.slice(1).replace(/_/g," "),description:`Tools from ${t}`,tools:[],toolDetails:[],toolType:"mcp_external"===e.type?"mcp":"mcp_native"===e.type?"native":"custom"}),n[t].tools.push(e.name),n[t].toolDetails.push({name:e.name,description:e.description||""})}}),tW(Object.values(n))}).finally(()=>tF(!1))},[a,o,n]),(0,O.useEffect)(()=>{"bedrock"===x&&(tJ(),t1())},[x]),(0,O.useEffect)(()=>{"custom_tools"!==c||!tx||"config"!==tv||tS.length>0||ny()},[c,tx,tv]),(0,O.useEffect)(()=>{"mcp_servers"!==c||a||n((0,q.fetchAllSettingsData)())},[c,n,a]);let ng=async()=>{if(!tL.name){t$({show:!0,message:"Server name is required.",type:"error"}),setTimeout(()=>t$(null),4e3);return}if("stdio"===tL.server_type&&!tL.command){t$({show:!0,message:"Command is required for local servers.",type:"error"}),setTimeout(()=>t$(null),4e3);return}if("remote"===tL.server_type&&!tL.url){t$({show:!0,message:"URL is required for remote servers.",type:"error"}),setTimeout(()=>t$(null),4e3);return}let e=tL.args.match(/(?:[^\s"]+|"[^"]*")+/g)?.map(e=>e.replace(/^"|"$/g,""))||[],t=tL.env.reduce((e,t)=>(t.key&&(e[t.key]=t.value),e),{});tP(!0);try{let s=await fetch("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:tL.name,label:tL.label,server_type:tL.server_type,command:tL.command,args:e,env:t,url:tL.url,token:tL.token})});if(s.ok){let e=await s.json();n((0,q.addMcpServer)(e.config)),tq({name:"",label:"",server_type:"stdio",command:"",args:"",env:[],url:"",token:""}),"oauth_pending"===e.status?(tR(!1),tI(tL.name),t$({show:!0,message:"🔑 OAuth required — opening browser. Return here once authorised.",type:"warning"}),e.auth_url&&window.open(e.auth_url,"_blank")):e.connected?(tR(!0),t$({show:!0,message:"✓ Server connected and saved!",type:"success"})):(tR(!1),t$({show:!0,message:"⚠ Config saved. Use Retry to reconnect.",type:"warning"})),setTimeout(()=>t$(null),7e3)}else{let e=await s.json();t$({show:!0,message:`Error: ${e.detail||"Unknown error"}`,type:"error"}),setTimeout(()=>t$(null),5e3)}}catch{t$({show:!0,message:"Failed to reach backend. Is it running?",type:"error"}),setTimeout(()=>t$(null),5e3)}finally{tP(!1)}},nx=async e=>{try{n((0,q.updateMcpServerStatus)({name:e,status:"connecting"}));let t=await fetch(`/api/mcp/servers/${e}/reconnect`,{method:"POST"});(await t.json()).connected?(n((0,q.updateMcpServerStatus)({name:e,status:"connected"})),t$({show:!0,message:`✓ ${e} reconnected!`,type:"success"})):(n((0,q.updateMcpServerStatus)({name:e,status:"disconnected"})),t$({show:!0,message:`Could not connect to ${e}. Complete OAuth first.`,type:"warning"})),setTimeout(()=>t$(null),5e3)}catch{n((0,q.updateMcpServerStatus)({name:e,status:"disconnected"})),t$({show:!0,message:"Reconnect failed.",type:"error"}),setTimeout(()=>t$(null),5e3)}},nb=async e=>{t6({type:"delete_mcp",message:`Are you sure you want to remove the MCP server '${e}'?`,payload:e})},nv=async()=>{if(!tx)return;if("python"===tx.tool_type){if(!tx.name)return void tN("System Name is required","warning");if(!tx.code||!tx.code.trim())return void tN("Python code cannot be empty","warning");try{let e={name:tx.name,generalName:tx.generalName||tx.name,description:tx.description||"",tool_type:"python",code:tx.code,inputSchema:tx.inputSchema||{type:"object",properties:{}},schemaParams:tx.schemaParams||[]},t=await fetch("/api/tools/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok){let e=await t.json(),s=e?.tool??e;n((0,q.updateCustomTool)(s)),tb(null),ty("config"),tN("Python tool saved successfully","success")}else tN("Failed to save Python tool","error")}catch{tN("Error saving Python tool","error")}return}if(!tx.name||!tx.url)return void tN("Name and URL are required","warning");let e=tx.inputSchema,t=tx.outputSchema;try{"string"==typeof tx.inputSchemaStr&&(e=JSON.parse(tx.inputSchemaStr))}catch(e){tN("Invalid Input Schema JSON","error");return}try{"string"==typeof tx.outputSchemaStr&&tx.outputSchemaStr.trim()?t=JSON.parse(tx.outputSchemaStr):tx.outputSchemaStr&&tx.outputSchemaStr.trim()||(t=void 0)}catch(e){tN("Invalid Output Schema JSON","error");return}try{let s={};tw.forEach(e=>{e.key.trim()&&(s[e.key.trim()]=e.value)});let i={...tx,inputSchema:e,outputSchema:t,headers:s};delete i.inputSchemaStr,delete i.outputSchemaStr;let r=await fetch("/api/tools/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(r.ok){let e=await r.json(),t=e?.tool??e;n((0,q.updateCustomTool)(t)),tb(null),ty("config"),tN("Tool saved successfully","success")}else tN("Failed to save tool","error")}catch(e){tN("Error saving tool","error")}},ny=async()=>{if(!tC){t_(!0);try{let e=await fetch("/api/n8n/workflows");if(!e.ok)return void tz([]);let t=await e.json();tz(Array.isArray(t)?t:[])}catch{tz([])}finally{t_(!1)}}},nw=async e=>{t6({type:"delete_tool",message:`Are you sure you want to delete the custom tool '${e}'?`,payload:e})},nO=async e=>{t6({type:"delete_agent",message:"Are you sure you want to delete this agent? This action cannot be undone.",payload:e})},nk="local"===x?v:"bedrock"===x?B.filter(e=>e.startsWith("bedrock")):B.filter(e=>!e.startsWith("bedrock")),nj=[{id:"general",label:"General",icon:C.LayoutGrid},{id:"personal_details",label:"Personal Details",icon:k.Shield},{id:"orchestrations",label:"Orchestrations",icon:P.Workflow},{id:"agents",label:"Build Agents",icon:_.Bot},{id:"mcp_servers",label:"MCP Servers",icon:A.Server},{id:"custom_tools",label:"Tool Builder",icon:T.Wrench},...tU?[{id:"repos",label:"Repos",icon:M.FolderGit2}]:[],...tU?[{id:"db_configs",label:"DB Configs",icon:z.Database}]:[],{id:"models",label:"Models",icon:N.Cpu},...tH?[{id:"messaging",label:"Messaging",icon:R.MessageSquare}]:[],{id:"workspace",label:"Integrations",icon:S.Cloud},{id:"schedules",label:"Schedules",icon:D.Clock},{id:"memory",label:"Memory",icon:j.Trash},{id:"logs",label:"Logs",icon:E.ScrollText},{id:"import_export",label:"Import / Export",icon:$.ArrowLeftRight},{id:"vault",label:"Vault",icon:Q.Vault}];return(0,w.jsxs)("div",{className:"flex-1 flex flex-col h-full overflow-hidden bg-transparent",children:["orchestrations"===c&&(0,w.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:(0,w.jsx)(wD,{})}),"logs"===c&&(0,w.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:(0,w.jsx)(wI,{})}),"messaging"===c&&(0,w.jsx)("div",{className:"flex-1 overflow-y-auto p-6 md:p-12",children:(0,w.jsxs)("div",{className:"max-w-5xl mx-auto animate-in fade-in slide-in-from-bottom-4 duration-300",children:[(0,w.jsxs)("div",{className:"mb-8",children:[(0,w.jsx)("h1",{className:"text-3xl font-bold mb-2 text-zinc-50",children:"Messaging"}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm",children:"Connect your agents to Telegram, Discord, Slack, Teams, or WhatsApp."})]}),(0,w.jsx)(wH,{})]})}),"usage"===c&&(0,w.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:(0,w.jsx)(w7,{})}),"schedules"===c&&(0,w.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:(0,w.jsx)(Oa,{})}),"import_export"===c&&(0,w.jsx)("div",{className:"flex-1 overflow-y-auto p-6 md:p-12",children:(0,w.jsxs)("div",{className:"max-w-5xl mx-auto animate-in fade-in slide-in-from-bottom-4 duration-300",children:[(0,w.jsxs)("div",{className:"mb-8",children:[(0,w.jsx)("h1",{className:"text-3xl font-bold mb-2 text-zinc-50",children:"Import / Export"}),(0,w.jsx)("p",{className:"text-zinc-500 text-sm",children:"Export your orchestrations, agents, MCP servers, and tools as a portable bundle, or import one from another Synapse instance."})]}),(0,w.jsx)(ON,{defaultView:"examples"===t?"examples":void 0,onImportSuccess:()=>n((0,q.fetchAllSettingsData)()),onNavigate:e=>h(e)})]})}),"vault"===c&&(0,w.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,w.jsxs)("div",{className:"flex-shrink-0 px-6 py-4 border-b border-zinc-800",children:[(0,w.jsxs)("h1",{className:"text-xl font-bold text-zinc-50 flex items-center gap-2",children:[(0,w.jsx)(Q.Vault,{className:"h-5 w-5 text-zinc-400"})," Vault"]}),(0,w.jsx)("p",{className:"text-zinc-500 text-xs mt-1",children:"Manage knowledge files, skills, and other files (.md, .json, .txt) that agents can reference in their prompts using @[path] syntax."})]}),(0,w.jsx)(OD,{})]}),(0,w.jsx)("div",{className:`flex-1 overflow-y-auto p-6 md:p-12 ${"orchestrations"===c||"logs"===c||"messaging"===c||"usage"===c||"schedules"===c||"import_export"===c||"vault"===c?"hidden":""}`,children:(0,w.jsxs)("div",{className:"max-w-5xl mx-auto space-y-10 animate-in fade-in slide-in-from-bottom-4 duration-300",children:[(0,w.jsxs)("div",{className:"mb-8",children:[(0,w.jsx)("h1",{className:"text-3xl font-bold mb-2 text-zinc-50",children:nj.find(e=>e.id===c)?.label}),(0,w.jsxs)("p",{className:"text-zinc-500 text-sm",children:["Manage your agent's ",c," configuration."]})]}),"general"===c&&(0,w.jsx)(W,{agentName:d,setAgentName:u,vaultEnabled:ee,setVaultEnabled:en,vaultThreshold:es,setVaultThreshold:ei,autoCompactEnabled:er,setAutoCompactEnabled:eo,autoCompactThreshold:ea,setAutoCompactThreshold:el,allowDbWrite:ec,setAllowDbWrite:eh,embedCode:tZ,setEmbedCode:tY,bashAllowedDirs:ed,setBashAllowedDirs:eu,onSave:t2,isSaving:Z}),"personal_details"===c&&(0,w.jsx)(V,{pdFirstName:e1,setPdFirstName:e2,pdLastName:e5,setPdLastName:e3,pdEmail:e4,setPdEmail:e8,pdPhone:e6,setPdPhone:e9,pdAddress1:e7,setPdAddress1:te,pdAddress2:tt,setPdAddress2:tn,pdCity:ts,setPdCity:ti,pdState:tr,setPdState:to,pdZipcode:ta,setPdZipcode:tl,onSave:t5}),"agents"===c&&(0,w.jsx)(ej,{agents:s.filter(e=>!e.id.startsWith("agent_native_builder")),selectedAgentId:tp,setSelectedAgentId:tf,draftAgent:tm,setDraftAgent:tg,availableCapabilities:tB,loadingCapabilities:tV,customTools:r,onDeleteAgent:nO,providers:H,defaultModel:p,loadingAgents:l}),"custom_tools"===c&&(0,w.jsx)(p7,{customTools:r,draftTool:tx,setDraftTool:tb,toolBuilderMode:tv,setToolBuilderMode:ty,headerRows:tw,setHeaderRows:tO,n8nWorkflows:tS,n8nWorkflowsLoading:tC,n8nWorkflowId:t3,setN8nWorkflowId:t4,getN8nBaseUrl:()=>(tc||"http://localhost:5678").replace(/\/+$/,""),onSaveTool:nv,onDeleteTool:nw,n8nIntegrated:!!(td&&td.trim())}),"datalab"===c&&(0,w.jsx)(fe,{dlTopic:t9,setDlTopic:t7,dlCount:ne,setDlCount:nt,dlProvider:nn,setDlProvider:ns,dlSystemPrompt:ni,setDlSystemPrompt:nr,dlEdgeCases:no,setDlEdgeCases:na,dlStatus:nl,dlDatasets:nh,onGenerate:nf}),"models"===c&&(0,w.jsx)(fc,{providers:H,mode:x,setMode:b,selectedModel:p,setSelectedModel:f,embeddingModel:m,setEmbeddingModel:g,localModels:v,cloudModels:B,filteredModels:nk,loadingModels:U,openaiKey:ep,setOpenaiKey:ef,anthropicKey:em,setAnthropicKey:eg,geminiKey:ex,setGeminiKey:eb,grokKey:ev,setGrokKey:ey,deepseekKey:ew,setDeepseekKey:eO,bedrockApiKey:eN,setBedrockApiKey:eS,awsRegion:eW,setAwsRegion:eV,bedrockInferenceProfile:eF,setBedrockInferenceProfile:eH,bedrockInferenceProfiles:eX,loadingInferenceProfiles:eG,inferenceProfilesError:eY,onExpandBedrock:t1,onSave:t2,isSaving:Z,openaiCompatibleKey:ez,setOpenaiCompatibleKey:eC,openaiCompatibleBaseUrl:e_,setOpenaiCompatibleBaseUrl:eT,openaiCompatibleModels:eA,setOpenaiCompatibleModels:eM,openaiCompatibleEmbedModels:eP,setOpenaiCompatibleEmbedModels:eE,localCompatibleBaseUrl:eR,setLocalCompatibleBaseUrl:eD,localCompatibleKey:e$,setLocalCompatibleKey:eQ,localCompatibleModels:eI,setLocalCompatibleModels:eL,localCompatibleEmbedModels:eq,setLocalCompatibleEmbedModels:eB}),"workspace"===c&&(0,w.jsx)(fd,{n8nUrl:tc,setN8nUrl:th,n8nApiKey:td,setN8nApiKey:tu,onSave:t2}),"mcp_servers"===c&&(0,w.jsx)(fO,{mcpServers:i,loadingMcp:tT,isConnecting:tM,lastConnected:tE,mcpToast:tD,setMcpToast:t$,pendingServerName:tQ,onPendingResolved:()=>tI(null),draftMcpServer:tL,setDraftMcpServer:tq,onAddServer:ng,onDeleteServer:nb,onReconnectServer:nx}),"memory"===c&&(0,w.jsx)(et,{}),"repos"===c&&(0,w.jsx)(fj,{embeddingModel:m,embedCode:tZ}),"db_configs"===c&&(0,w.jsx)(fS,{})]})}),tk&&(0,w.jsx)(ek,{show:tk.show,message:tk.message,type:tk.type}),(0,w.jsx)(K,{isOpen:!!t8,title:"Confirm Action",message:t8?.message||"",onConfirm:nm,onClose:()=>t6(null)})]})}],72677)}]);
|